List:Commits« Previous MessageNext Message »
From:lzhou Date:July 30 2007 11:29am
Subject:bk commit into 5.1 tree (lzhou:1.2523)
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of zhl. When zhl does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet@stripped, 2007-07-30 09:29:04+00:00, lzhou@dev3-63.(none) +2 -0
  Merge dev3-63.(none):/home/zhl/mysql/mysql-5.0/bug23354
  into  dev3-63.(none):/home/zhl/mysql/mysql-5.1/bug23354
  MERGE: 1.1810.2963.1

  storage/ndb/src/common/debugger/EventLogger.cpp@stripped, 2007-07-30 09:28:27+00:00,
lzhou@dev3-63.(none) +0 -0
    Auto merged
    MERGE: 1.21.16.2

  storage/ndb/src/common/debugger/EventLogger.cpp@stripped, 2007-07-30 09:28:27+00:00,
lzhou@dev3-63.(none) +0 -0
    Merge rename: ndb/src/common/debugger/EventLogger.cpp ->
storage/ndb/src/common/debugger/EventLogger.cpp

  storage/ndb/src/mgmclient/CommandInterpreter.cpp@stripped, 2007-07-30 09:28:28+00:00,
lzhou@dev3-63.(none) +1 -1
    Auto merged
    MERGE: 1.49.42.2

  storage/ndb/src/mgmclient/CommandInterpreter.cpp@stripped, 2007-07-30 09:28:27+00:00,
lzhou@dev3-63.(none) +0 -0
    Merge rename: ndb/src/mgmclient/CommandInterpreter.cpp ->
storage/ndb/src/mgmclient/CommandInterpreter.cpp

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	lzhou
# Host:	dev3-63.(none)
# Root:	/home/zhl/mysql/mysql-5.1/bug23354/RESYNC

--- 1.21.16.1/ndb/src/common/debugger/EventLogger.cpp	2007-07-30 09:29:24 +00:00
+++ 1.42/storage/ndb/src/common/debugger/EventLogger.cpp	2007-07-30 09:29:24 +00:00
@@ -15,13 +15,12 @@
 
 #include <ndb_global.h>
 
-#include "EventLogger.hpp"
+#include <EventLogger.hpp>
 #include <TransporterCallback.hpp>
 
 #include <NdbConfig.h>
 #include <kernel/BlockNumbers.h>
 #include <signaldata/ArbitSignalData.hpp>
-#include <GrepEvent.hpp>
 #include <NodeState.hpp>
 #include <version.h>
 
@@ -526,6 +525,7 @@ void getTextUndoLogBlocked(QQQQ) {
 		       theData[1],
 		       theData[2]);
 }
+
 void getTextTransporterError(QQQQ) {
   struct myTransporterError{
     Uint32 errorNum;
@@ -606,21 +606,21 @@ void getTextTransporterError(QQQQ) {
   lenth = sizeof(TransporterErrorString)/sizeof(struct myTransporterError);
   for(i=0; i<lenth; i++)
   {
-    if(theData[2] == TransporterErrorString[i].errorNum)
+    if(theData[2] == (Uint32) TransporterErrorString[i].errorNum)
     {
       BaseString::snprintf(m_text, m_text_len,
-                          "Transporter to node %d reported error 0x%x: %s",
-                          theData[1],
-			  theData[2],
-                          TransporterErrorString[i].errorString);
+                           "Transporter to node %d reported error 0x%x: %s",
+                           theData[1],
+                           theData[2],
+                           TransporterErrorString[i].errorString);
       break;
     }
   }
   if(i == lenth)
     BaseString::snprintf(m_text, m_text_len,   
-                        "Transporter to node %d reported error 0x%x: unknown error",
-                          theData[1],
-			  theData[2]);
+                         "Transporter to node %d reported error 0x%x: unknown error",
+                         theData[1],
+                         theData[2]);
 }
 void getTextTransporterWarning(QQQQ) {
   getTextTransporterError(m_text, m_text_len, theData);
@@ -712,6 +712,43 @@ void getTextUNDORecordsExecuted(QQQQ) {
 void getTextInfoEvent(QQQQ) {
   BaseString::snprintf(m_text, m_text_len, (char *)&theData[1]);
 }
+const char bytes_unit[]= "B";
+const char kbytes_unit[]= "KB";
+const char mbytes_unit[]= "MB";
+static void convert_unit(unsigned &data, const char *&unit)
+{
+  if (data < 16*1024)
+  {
+    unit= bytes_unit;
+    return;
+  }
+  if (data < 16*1024*1024)
+  {
+    data= (data+1023)/1024;
+    unit= kbytes_unit;
+    return;
+  }
+  data= (data+1024*1024-1)/(1024*1024);
+  unit= mbytes_unit;  
+}
+
+void getTextEventBufferStatus(QQQQ) {
+  unsigned used= theData[1], alloc= theData[2], max_= theData[3];
+  const char *used_unit, *alloc_unit, *max_unit;
+  convert_unit(used, used_unit);
+  convert_unit(alloc, alloc_unit);
+  convert_unit(max_, max_unit);
+  BaseString::snprintf(m_text, m_text_len,
+		       "Event buffer status: used=%d%s(%d%) alloc=%d%s(%d%) "
+		       "max=%d%s apply_gci=%lld latest_gci=%lld",
+		       used, used_unit,
+		       theData[2] ? (Uint32)((((Uint64)theData[1])*100)/theData[2]) : 0,
+		       alloc, alloc_unit,
+		       theData[3] ? (Uint32)((((Uint64)theData[2])*100)/theData[3]) : 0,
+		       max_, max_unit,
+		       theData[4]+(((Uint64)theData[5])<<32),
+		       theData[6]+(((Uint64)theData[7])<<32));
+}
 void getTextWarningEvent(QQQQ) {
   BaseString::snprintf(m_text, m_text_len, (char *)&theData[1]);
 }
@@ -964,6 +1001,7 @@ const EventLoggerBase::EventRepLogLevelM
   ROW(SentHeartbeat,           LogLevel::llInfo,  12, Logger::LL_INFO ),
   ROW(CreateLogBytes,          LogLevel::llInfo,  11, Logger::LL_INFO ),
   ROW(InfoEvent,               LogLevel::llInfo,   2, Logger::LL_INFO ),
+  ROW(EventBufferStatus,       LogLevel::llInfo,   7, Logger::LL_INFO ),
 
   //Single User
   ROW(SingleUser,              LogLevel::llInfo,   7, Logger::LL_INFO ),
@@ -1058,6 +1096,7 @@ EventLogger::log(int eventType, const Ui
   Logger::LoggerLevel severity = Logger::LL_WARNING;
   LogLevel::EventCategory cat= LogLevel::llInvalid;
   EventTextFunction textF;
+  char log_text[MAX_TEXT_LENGTH];
 
   DBUG_ENTER("EventLogger::log");
   DBUG_PRINT("enter",("eventType=%d, nodeid=%d", eventType, nodeId));
@@ -1071,29 +1110,29 @@ EventLogger::log(int eventType, const Ui
     DBUG_PRINT("info",("m_logLevel.getLogLevel=%d", m_logLevel.getLogLevel(cat)));
 
   if (threshold <= set){
-    getText(m_text,sizeof(m_text),textF,theData,nodeId);
+    getText(log_text,sizeof(log_text),textF,theData,nodeId);
 
     switch (severity){
     case Logger::LL_ALERT:
-      alert(m_text);
+      alert(log_text);
       break;
     case Logger::LL_CRITICAL:
-      critical(m_text); 
+      critical(log_text); 
       break;
     case Logger::LL_WARNING:
-      warning(m_text); 
+      warning(log_text); 
       break;
     case Logger::LL_ERROR:
-      error(m_text); 
+      error(log_text); 
       break;
     case Logger::LL_INFO:
-      info(m_text); 
+      info(log_text); 
       break;
     case Logger::LL_DEBUG:
-      debug(m_text); 
+      debug(log_text); 
       break;
     default:
-      info(m_text); 
+      info(log_text); 
       break;
     }
   } // if (..
@@ -1111,7 +1150,3 @@ EventLogger::setFilterLevel(int filterLe
 {
   m_filterLevel = filterLevel;
 }
-
-//
-// PRIVATE
-//

--- 1.49.42.1/ndb/src/mgmclient/CommandInterpreter.cpp	2007-07-30 09:29:24 +00:00
+++ 1.96/storage/ndb/src/mgmclient/CommandInterpreter.cpp	2007-07-30 09:29:24 +00:00
@@ -15,16 +15,10 @@
 
 #include <ndb_global.h>
 #include <my_sys.h>
-
-//#define HAVE_GLOBAL_REPLICATION
-
 #include <Vector.hpp>
-#ifdef  HAVE_GLOBAL_REPLICATION
-#include "../rep/repapi/repapi.h"
-#endif
-
 #include <mgmapi.h>
 #include <util/BaseString.hpp>
+#include <ndbd_exit_codes.h>
 
 class MgmtSrvr;
 
@@ -125,7 +119,7 @@ public:
   int  executeStatus(int processId, const char* parameters, bool all);
   int  executeEventReporting(int processId, const char* parameters, bool all);
   int  executeDumpState(int processId, const char* parameters, bool all);
-  int  executeStartBackup(char * parameters);
+  int  executeStartBackup(char * parameters, bool interactive);
   int  executeAbortBackup(char * parameters);
   int  executeStop(Vector<BaseString> &command_list, unsigned command_pos,
                    int *node_ids, int no_of_nodes);
@@ -167,11 +161,6 @@ private:
   int m_verbose;
   int try_reconnect;
   int m_error;
-#ifdef HAVE_GLOBAL_REPLICATION  
-  NdbRepHandle m_repserver;
-  const char *rep_host;
-  bool rep_connected;
-#endif
   struct NdbThread* m_event_thread;
   NdbMutex *m_print_mutex;
 };
@@ -236,10 +225,6 @@ extern "C" {
 #include <NdbMem.h>
 #include <EventLogger.hpp>
 #include <signaldata/SetLogLevelOrd.hpp>
-#include <signaldata/GrepImpl.hpp>
-#ifdef HAVE_GLOBAL_REPLICATION
-
-#endif // HAVE_GLOBAL_REPLICATION
 #include "MgmtErrorReporter.hpp"
 #include <Parser.hpp>
 #include <SocketServer.hpp>
@@ -267,9 +252,6 @@ static const char* helpText =
 "---------------------------------------------------------------------------\n"
 "HELP                                   Print help text\n"
 "HELP COMMAND                           Print detailed help for COMMAND(e.g. SHOW)\n"
-#ifdef HAVE_GLOBAL_REPLICATION
-"HELP REPLICATION                       Help for global replication\n"
-#endif // HAVE_GLOBAL_REPLICATION
 #ifdef VM_TRACE // DEBUG ONLY
 "HELP DEBUG                             Help for debug compiled version\n"
 #endif
@@ -293,9 +275,6 @@ static const char* helpText =
 "EXIT SINGLE USER MODE                  Exit single user mode\n"
 "<id> STATUS                            Print status\n"
 "<id> CLUSTERLOG {<category>=<level>}+  Set log level for cluster
log\n"
-#ifdef HAVE_GLOBAL_REPLICATION
-"REP CONNECT <host:port>                Connect to REP server on host:port\n"
-#endif
 "PURGE STALE SESSIONS                   Reset reserved nodeid's in the mgmt server\n"
 "CONNECT [<connectstring>]              Connect to management server (reconnect if
already connected)\n"
 "QUIT                                   Quit management client\n"
@@ -595,39 +574,6 @@ static const char* helpTextQuit =
 ;
 
 
-#ifdef HAVE_GLOBAL_REPLICATION
-static const char* helpTextRep =
-"---------------------------------------------------------------------------\n"
-" NDB Cluster -- Management Client -- Help for Global Replication\n"
-"---------------------------------------------------------------------------\n"
-"Commands should be executed on the standby NDB Cluster\n"
-"These features are in an experimental release state.\n"
-"\n"
-"Simple Commands:\n"
-"REP START              Start Global Replication\n" 
-"REP START REQUESTOR    Start Global Replication Requestor\n" 
-"REP STATUS             Show Global Replication status\n" 
-"REP STOP               Stop Global Replication\n"
-"REP STOP REQUESTOR     Stop Global Replication Requestor\n"
-"\n" 
-"Advanced Commands:\n"
-"REP START <protocol>   Starts protocol\n"
-"REP STOP <protocol>    Stops protocol\n"
-"<protocol> = TRANSFER | APPLY | DELETE\n"
-"\n"
-#ifdef VM_TRACE // DEBUG ONLY
-"Debugging commands:\n"
-"REP DELETE             Removes epochs stored in primary and standy systems\n"
-"REP DROP <tableid>     Drop a table in SS identified by table id\n"
-"REP SLOWSTOP           Stop Replication (Tries to synchonize with primary)\n" 
-"REP FASTSTOP           Stop Replication (Stops in consistent state)\n" 
-"<component> = SUBSCRIPTION\n"
-"              METALOG | METASCAN | DATALOG | DATASCAN\n"
-"              REQUESTOR | TRANSFER | APPLY | DELETE\n"
-#endif
-;
-#endif // HAVE_GLOBAL_REPLICATION
-
 #ifdef VM_TRACE // DEBUG ONLY
 static const char* helpTextDebug =
 "---------------------------------------------------------------------------\n"
@@ -680,10 +626,6 @@ struct st_cmd_help {
   {"PURGE STALE SESSIONS", helpTextPurgeStaleSessions},
   {"CONNECT", helpTextConnect},
   {"QUIT", helpTextQuit},
-#ifdef HAVE_GLOBAL_REPLICATION
-  {"REPLICATION", helpTextRep},
-  {"REP", helpTextRep},
-#endif // HAVE_GLOBAL_REPLICATION
 #ifdef VM_TRACE // DEBUG ONLY
   {"DEBUG", helpTextDebug},
 #endif //VM_TRACE
@@ -723,11 +665,6 @@ CommandInterpreter::CommandInterpreter(c
   m_event_thread= NULL;
   try_reconnect = 0;
   m_print_mutex= NdbMutex_Create();
-#ifdef HAVE_GLOBAL_REPLICATION
-  rep_host = NULL;
-  m_repserver = NULL;
-  rep_connected = false;
-#endif
 }
 
 /*
@@ -768,6 +705,133 @@ CommandInterpreter::printError() 
   }
 }
 
+/*
+ * print log event from mgmsrv to console screen
+ */
+#define make_uint64(a,b) (((Uint64)(a)) + (((Uint64)(b)) << 32))
+#define Q64(a) make_uint64(event->EVENT.a ## _lo, event->EVENT.a ## _hi)
+#define R event->source_nodeid
+#define Q(a) event->EVENT.a
+#define QVERSION getMajor(Q(version)), getMinor(Q(version)), getBuild(Q(version))
+#define NDB_LE_(a) NDB_LE_ ## a
+static void
+printLogEvent(struct ndb_logevent* event)
+{
+  switch (event->type) {
+    /** 
+     * NDB_MGM_EVENT_CATEGORY_BACKUP
+     */
+#undef  EVENT
+#define EVENT BackupStarted
+  case NDB_LE_BackupStarted:
+      ndbout_c("Node %u: Backup %d started from node %d",
+               R, Q(backup_id), Q(starting_node));
+      break;
+#undef  EVENT
+#define EVENT BackupFailedToStart
+    case NDB_LE_BackupFailedToStart:
+      ndbout_c("Node %u: Backup request from %d failed to start. Error: %d",
+               R, Q(starting_node), Q(error));
+      break;
+#undef  EVENT
+#define EVENT BackupCompleted
+    case NDB_LE_BackupCompleted:
+      ndbout_c("Node %u: Backup %u started from node %u completed\n" 
+               " StartGCP: %u StopGCP: %u\n" 
+               " #Records: %u #LogRecords: %u\n" 
+               " Data: %u bytes Log: %u bytes", R,
+               Q(backup_id), Q(starting_node),
+               Q(start_gci), Q(stop_gci),
+               Q(n_records), Q(n_log_records),
+               Q(n_bytes),   Q(n_log_bytes));
+      break;
+#undef  EVENT
+#define EVENT BackupAborted
+    case NDB_LE_BackupAborted:
+      ndbout_c("Node %u: Backup %d started from %d has been aborted. Error: %d",
+               R, Q(backup_id), Q(starting_node), Q(error));
+      break;
+    /** 
+     * NDB_MGM_EVENT_CATEGORY_STARTUP
+     */ 
+#undef  EVENT
+#define EVENT NDBStartStarted
+    case NDB_LE_NDBStartStarted:
+      ndbout_c("Node %u: Start initiated (version %d.%d.%d)",
+               R, QVERSION);
+      break;
+#undef  EVENT
+#define EVENT NDBStartCompleted
+    case NDB_LE_NDBStartCompleted:
+      ndbout_c("Node %u: Started (version %d.%d.%d)",
+               R, QVERSION);
+      break;
+#undef  EVENT
+#define EVENT NDBStopStarted
+    case NDB_LE_NDBStopStarted:
+      ndbout_c("Node %u: %s shutdown initiated", R,
+               (Q(stoptype) == 1 ? "Cluster" : "Node"));
+      break;
+#undef  EVENT
+#define EVENT NDBStopCompleted
+    case NDB_LE_NDBStopCompleted:
+      {
+        BaseString action_str("");
+        BaseString signum_str("");
+        getRestartAction(Q(action), action_str);
+        if (Q(signum))
+          signum_str.appfmt(" Initiated by signal %d.", 
+                            Q(signum));
+        ndbout_c("Node %u: Node shutdown completed%s.%s", 
+                 R, action_str.c_str(), signum_str.c_str());
+      }
+      break;
+#undef  EVENT
+#define EVENT NDBStopForced
+    case NDB_LE_NDBStopForced:
+      {
+        BaseString action_str("");
+        BaseString reason_str("");
+        BaseString sphase_str("");
+        int signum = Q(signum);
+        int error = Q(error); 
+        int sphase = Q(sphase); 
+        int extra = Q(extra); 
+        getRestartAction(Q(action), action_str);
+        if (signum)
+          reason_str.appfmt(" Initiated by signal %d.", signum);
+        if (error)
+        {
+          ndbd_exit_classification cl;
+          ndbd_exit_status st;
+          const char *msg = ndbd_exit_message(error, &cl);
+          const char *cl_msg = ndbd_exit_classification_message(cl, &st);
+          const char *st_msg = ndbd_exit_status_message(st);
+          reason_str.appfmt(" Caused by error %d: \'%s(%s). %s\'.", 
+                            error, msg, cl_msg, st_msg);
+          if (extra != 0)
+            reason_str.appfmt(" (extra info %d)", extra);
+        }
+        if (sphase < 255)
+          sphase_str.appfmt(" Occured during startphase %u.", sphase);
+        ndbout_c("Node %u: Forced node shutdown completed%s.%s%s",
+                 R, action_str.c_str(), sphase_str.c_str(), 
+                 reason_str.c_str());
+      }
+      break;
+#undef  EVENT
+#define EVENT StopAborted
+    case NDB_LE_NDBStopAborted:
+      ndbout_c("Node %u: Node shutdown aborted", R);
+      break;
+    /** 
+     * default nothing to print
+     */ 
+    default:
+      break;
+  }
+}
+
 //*****************************************************************************
 //*****************************************************************************
 
@@ -784,27 +848,21 @@ event_thread_run(void* p)
   int filter[] = { 15, NDB_MGM_EVENT_CATEGORY_BACKUP,
 		   1, NDB_MGM_EVENT_CATEGORY_STARTUP,
 		   0 };
-  int fd = ndb_mgm_listen_event(handle, filter);
-  if (fd != NDB_INVALID_SOCKET)
+
+  NdbLogEventHandle log_handle= NULL;
+  struct ndb_logevent log_event;
+
+  log_handle= ndb_mgm_create_logevent_handle(handle, filter);
+  if (log_handle) 
   {
     do_event_thread= 1;
-    char *tmp= 0;
-    char buf[1024];
-    SocketInputStream in(fd,10);
     do {
-      if (tmp == 0) NdbSleep_MilliSleep(10);
-      if((tmp = in.gets(buf, 1024)))
-      {
-	const char ping_token[]= "<PING>";
-	if (memcmp(ping_token,tmp,sizeof(ping_token)-1))
-	  if(tmp && strlen(tmp))
-          {
-            Guard g(printmutex);
-            ndbout << tmp;
-          }
-      }
+      if (ndb_logevent_get_next(log_handle, &log_event, 2000) <= 0)
+        continue;
+      Guard g(printmutex);
+      printLogEvent(&log_event);
     } while(do_event_thread);
-    NDB_CLOSE_SOCKET(fd);
+    ndb_mgm_destroy_logevent_handle(&log_handle);
   }
   else
   {
@@ -1054,7 +1112,7 @@ CommandInterpreter::execute_impl(const c
   else if(strcasecmp(firstToken, "START") == 0 &&
 	  allAfterFirstToken != NULL &&
 	  strncasecmp(allAfterFirstToken, "BACKUP", sizeof("BACKUP") - 1) == 0){
-    m_error= executeStartBackup(allAfterFirstToken);
+    m_error= executeStartBackup(allAfterFirstToken, interactive);
     DBUG_RETURN(true);
   }
   else if(strcasecmp(firstToken, "ABORT") == 0 &&
@@ -1066,16 +1124,10 @@ CommandInterpreter::execute_impl(const c
   else if (strcasecmp(firstToken, "PURGE") == 0) {
     m_error = executePurge(allAfterFirstToken);
     DBUG_RETURN(true);
-  } 
-#ifdef HAVE_GLOBAL_REPLICATION
-  else if(strcasecmp(firstToken, "REPLICATION") == 0 ||
-	  strcasecmp(firstToken, "REP") == 0) {
-    m_error = executeRep(allAfterFirstToken);
-    DBUG_RETURN(true);
-  }
-#endif // HAVE_GLOBAL_REPLICATION
+  }                
   else if(strcasecmp(firstToken, "ENTER") == 0 &&
 	  allAfterFirstToken != NULL &&
+	  allAfterFirstToken != NULL &&
 	  strncasecmp(allAfterFirstToken, "SINGLE USER MODE ", 
 		  sizeof("SINGLE USER MODE") - 1) == 0){
     m_error = executeEnterSingleUser(allAfterFirstToken);
@@ -1627,8 +1679,8 @@ CommandInterpreter::executeShow(char* pa
       case NDB_MGM_NODE_TYPE_UNKNOWN:
         ndbout << "Error: Unknown Node Type" << endl;
         return -1;
-      case NDB_MGM_NODE_TYPE_REP:
-	abort();
+      case NDB_MGM_NODE_TYPE_MAX:
+        break;                                  /* purify: deadcode */
       }
     }
 
@@ -1702,7 +1754,15 @@ CommandInterpreter::executeClusterLog(ch
   char * item = strtok_r(tmpString, " ", &tmpPtr);
   int enable;
 
-  const unsigned int *enabled= ndb_mgm_get_logfilter(m_mgmsrv);
+  ndb_mgm_severity enabled[NDB_MGM_EVENT_SEVERITY_ALL] = 
+    {{NDB_MGM_EVENT_SEVERITY_ON,0},
+     {NDB_MGM_EVENT_SEVERITY_DEBUG,0},
+     {NDB_MGM_EVENT_SEVERITY_INFO,0},
+     {NDB_MGM_EVENT_SEVERITY_WARNING,0},
+     {NDB_MGM_EVENT_SEVERITY_ERROR,0},
+     {NDB_MGM_EVENT_SEVERITY_CRITICAL,0},
+     {NDB_MGM_EVENT_SEVERITY_ALERT,0}};
+  ndb_mgm_get_clusterlog_severity_filter(m_mgmsrv, &enabled[0],
NDB_MGM_EVENT_SEVERITY_ALL);
   if(enabled == NULL) {
     ndbout << "Couldn't get status" << endl;
     printError();
@@ -1715,25 +1775,25 @@ CommandInterpreter::executeClusterLog(ch
    ********************/
   if (strcasecmp(item, "INFO") == 0) {
     DBUG_PRINT("info",("INFO"));
-    if(enabled[0] == 0)
+    if(enabled[0].value == 0)
     {
       ndbout << "Cluster logging is disabled." << endl;
       m_error = 0;
       DBUG_VOID_RETURN;
     }
 #if 0 
-    for(i = 0; i<7;i++)
-      printf("enabled[%d] = %d\n", i, enabled[i]);
+    for(i = 0; i<DB_MGM_EVENT_SEVERITY_ALL;i++)
+      printf("enabled[%d] = %d\n", i, enabled[i].value);
 #endif
     ndbout << "Severities enabled: ";
     for(i = 1; i < (int)NDB_MGM_EVENT_SEVERITY_ALL; i++) {
-      const char *str= ndb_mgm_get_event_severity_string((ndb_mgm_event_severity)i);
+      const char *str= ndb_mgm_get_event_severity_string(enabled[i].category);
       if (str == 0)
       {
 	DBUG_ASSERT(false);
 	continue;
       }
-      if(enabled[i])
+      if(enabled[i].value)
 	ndbout << BaseString(str).ndb_toupper() << " ";
     }
     ndbout << endl;
@@ -2535,24 +2595,16 @@ CommandInterpreter::executeEventReportin
   return retval;
 }
 
+
 /*****************************************************************************
  * Backup
  *****************************************************************************/
 int
-CommandInterpreter::executeStartBackup(char* parameters)
+CommandInterpreter::executeStartBackup(char* parameters, bool interactive)
 {
   struct ndb_mgm_reply reply;
   unsigned int backupId;
-#if 0
-  int filter[] = { 15, NDB_MGM_EVENT_CATEGORY_BACKUP, 0 };
-  int fd = ndb_mgm_listen_event(m_mgmsrv, filter);
-  if (fd < 0)
-  {
-    ndbout << "Initializing start of backup failed" << endl;
-    printError();
-    return fd;
-  }
-#endif
+
   Vector<BaseString> args;
   {
     BaseString(parameters).split(args);
@@ -2565,25 +2617,20 @@ CommandInterpreter::executeStartBackup(c
   int sz= args.size();
 
   int result;
-  if (sz == 2 &&
-      args[1] == "NOWAIT")
+  int flags = 2;
+  if (sz == 2 && args[1] == "NOWAIT")
   {
-    result = ndb_mgm_start_backup(m_mgmsrv, 0, &backupId, &reply);
+    flags = 0;
   }
-  else if (sz == 1 ||
-	   (sz == 3 &&
-	    args[1] == "WAIT" &&
-	    args[2] == "COMPLETED"))
+  else if (sz == 1 || (sz == 3 && args[1] == "WAIT" && args[2] ==
"COMPLETED"))
   {
+    flags = 2;
     ndbout_c("Waiting for completed, this may take several minutes");
-    result = ndb_mgm_start_backup(m_mgmsrv, 2, &backupId, &reply);
   }
-  else if (sz == 3 &&
-	   args[1] == "WAIT" &&
-	   args[2] == "STARTED")
+  else if (sz == 3 && args[1] == "WAIT" && args[2] == "STARTED")
   {
     ndbout_c("Waiting for started, this may take several minutes");
-    result = ndb_mgm_start_backup(m_mgmsrv, 1, &backupId, &reply);
+    flags = 1;
   }
   else
   {
@@ -2591,45 +2638,76 @@ CommandInterpreter::executeStartBackup(c
     return -1;
   }
 
+  NdbLogEventHandle log_handle= NULL;
+  struct ndb_logevent log_event;
+  if (flags == 2 && !interactive)
+  {
+    int filter[] = { 15, NDB_MGM_EVENT_CATEGORY_BACKUP, 0, 0 };
+    log_handle = ndb_mgm_create_logevent_handle(m_mgmsrv, filter);
+    if (!log_handle)
+    {
+      ndbout << "Initializing start of backup failed" << endl;
+      printError();
+      return -1;
+    }
+  }
+  result = ndb_mgm_start_backup(m_mgmsrv, flags, &backupId, &reply);
+
   if (result != 0) {
     ndbout << "Backup failed" << endl;
     printError();
-#if 0
-    close(fd);
-#endif
+
+    if (log_handle) 
+      ndb_mgm_destroy_logevent_handle(&log_handle);
     return result;
   }
-#if 0
-  ndbout_c("Waiting for completed, this may take several minutes");
-  char *tmp;
-  char buf[1024];
+
+  /**
+   * If interactive, event listner thread is already running
+   */
+  if (log_handle && !interactive)
   {
-    SocketInputStream in(fd);
     int count = 0;
+    int retry = 0;
     do {
-      tmp = in.gets(buf, 1024);
-      if(tmp)
+      if (ndb_logevent_get_next(log_handle, &log_event, 60000) > 0)
       {
-	ndbout << tmp;
-	unsigned int id;
-	if(sscanf(tmp, "%*[^:]: Backup %d ", &id) == 1 && id == backupId){
-	  count++;
-	}
+        int print = 0;
+        switch (log_event.type) {
+          case NDB_LE_BackupStarted:
+            if (log_event.BackupStarted.backup_id == backupId)
+              print = 1;
+            break;
+          case NDB_LE_BackupCompleted:
+            if (log_event.BackupCompleted.backup_id == backupId)
+              print = 1;
+            break;
+          case NDB_LE_BackupAborted:
+            if (log_event.BackupAborted.backup_id == backupId)
+              print = 1;
+            break;
+          default:
+            break;
+        }
+        if (print)
+        {
+          Guard g(m_print_mutex);
+          printLogEvent(&log_event);
+          count++;
+        }
       }
-    } while(count < 2);
-  }
+      else
+      {
+        retry++;
+      }
+    } while(count < 2 && retry < 3);
 
-  SocketInputStream in(fd, 10);
-  do {
-    tmp = in.gets(buf, 1024);
-    if(tmp && tmp[0] != 0)
-    {
-      ndbout << tmp;
-    }
-  } while(tmp && tmp[0] != 0);
+    if (retry >= 3)
+      ndbout << "get backup event failed for " << retry << " times"
<< endl;
+
+    ndb_mgm_destroy_logevent_handle(&log_handle);
+  }
 
-  close(fd);
-#endif  
   return 0;
 }
 
@@ -2662,234 +2740,5 @@ CommandInterpreter::executeAbortBackup(c
   ndbout << "Invalid arguments: expected <BackupId>" << endl;
   return -1;
 }
-
-#ifdef HAVE_GLOBAL_REPLICATION
-/*****************************************************************************
- * Global Replication
- *
- * For information about the different commands, see
- * GrepReq::Request in file signaldata/grepImpl.cpp.
- *
- * Below are commands as of 2003-07-05 (may change!):
- * START = 0,            ///< Start Global Replication (all phases)
- * START_METALOG = 1,    ///< Start Global Replication (all phases)
- * START_METASCAN = 2,   ///< Start Global Replication (all phases)
- * START_DATALOG = 3,    ///< Start Global Replication (all phases)
- * START_DATASCAN = 4,   ///< Start Global Replication (all phases)
- * START_REQUESTOR = 5,  ///< Start Global Replication (all phases)
- * ABORT = 6,            ///< Immediate stop (removes subscription)
- * SLOW_STOP = 7,        ///< Stop after finishing applying current GCI epoch
- * FAST_STOP = 8,        ///< Stop after finishing applying all PS GCI epochs
- * START_TRANSFER = 9,   ///< Start SS-PS transfer
- * STOP_TRANSFER = 10,   ///< Stop SS-PS transfer
- * START_APPLY = 11,     ///< Start applying GCI epochs in SS
- * STOP_APPLY = 12,      ///< Stop applying GCI epochs in SS
- * STATUS = 13,           ///< Status
- * START_SUBSCR = 14,
- * REMOVE_BUFFERS = 15,
- * DROP_TABLE = 16
-
- *****************************************************************************/
-
-int
-CommandInterpreter::executeRep(char* parameters) 
-{
-  if (emptyString(parameters)) {
-    ndbout << helpTextRep;
-    return 0;
-  }
-
-  char * line = my_strdup(parameters,MYF(MY_WME));
-  My_auto_ptr<char> ap1((char*)line);
-  char * firstToken = strtok(line, " ");
-  
-  struct ndb_rep_reply  reply;
-  unsigned int          repId;
-
-
-  if (!strcasecmp(firstToken, "CONNECT")) {
-    char * host = strtok(NULL, "\0");
-    for (unsigned int i = 0; i < strlen(host); ++i) {
-      host[i] = tolower(host[i]);
-    }
-    
-    if(host == NULL)
-    {
-      ndbout_c("host:port must be specified.");
-      return -1;
-    }
-    
-    if(rep_connected) {
-      if(m_repserver != NULL) {
-	ndb_rep_disconnect(m_repserver);
-	rep_connected = false;
-      }       
-    }
-          
-    if(m_repserver == NULL)
-      m_repserver = ndb_rep_create_handle();
-    if(ndb_rep_connect(m_repserver, host) < 0){
-      ndbout_c("Failed to connect to %s", host);
-      return -1;
-    } 
-    else
-      rep_connected=true;
-    return 0;
-    
-    if(!rep_connected) {
-      ndbout_c("Not connected to REP server");
-      return -1;
-    }
-  }
-    
-  /********
-   * START 
-   ********/
-  if (!strcasecmp(firstToken, "START")) {
-    
-    unsigned int          req;
-    char *startType = strtok(NULL, "\0");
-    
-    if (startType == NULL) {                
-      req = GrepReq::START;
-    } else if (!strcasecmp(startType, "SUBSCRIPTION")) {  
-      req = GrepReq::START_SUBSCR;
-    } else if (!strcasecmp(startType, "METALOG")) { 
-      req = GrepReq::START_METALOG;
-    } else if (!strcasecmp(startType, "METASCAN")) {
-      req = GrepReq::START_METASCAN;
-    } else if (!strcasecmp(startType, "DATALOG")) {
-      req = GrepReq::START_DATALOG;
-    } else if (!strcasecmp(startType, "DATASCAN")) {
-      req = GrepReq::START_DATASCAN;
-    } else if (!strcasecmp(startType, "REQUESTOR")) {
-      req = GrepReq::START_REQUESTOR;
-    } else if (!strcasecmp(startType, "TRANSFER")) {
-      req = GrepReq::START_TRANSFER;
-    } else if (!strcasecmp(startType, "APPLY")) {
-      req = GrepReq::START_APPLY;
-    } else if (!strcasecmp(startType, "DELETE")) {
-      req = GrepReq::START_DELETE;
-    } else {
-      ndbout_c("Illegal argument to command 'REPLICATION START'");
-      return -1;
-    }
-
-    int result = ndb_rep_command(m_repserver, req, &repId, &reply);
-    
-    if (result != 0) {
-      ndbout << "Start of Global Replication failed" << endl;
-      return -1;
-    } else {
-      ndbout << "Start of Global Replication ordered" << endl;
-    }
-    return 0;
-  }
-
-  /********
-   * STOP
-   ********/
-  if (!strcasecmp(firstToken, "STOP")) {    
-    unsigned int          req;
-    char *startType = strtok(NULL, " ");
-    unsigned int epoch = 0;
-    
-    if (startType == NULL) {                 
-      /**
-       * Stop immediately
-       */
-      req = GrepReq::STOP;
-    } else if (!strcasecmp(startType, "EPOCH")) {  
-      char *strEpoch = strtok(NULL, "\0");
-      if(strEpoch == NULL) {
-	ndbout_c("Epoch expected!");
-	return -1;
-      }
-      req = GrepReq::STOP;
-      epoch=atoi(strEpoch);      
-    } else if (!strcasecmp(startType, "SUBSCRIPTION")) {  
-      req = GrepReq::STOP_SUBSCR;
-    } else if (!strcasecmp(startType, "METALOG")) { 
-      req = GrepReq::STOP_METALOG;
-    } else if (!strcasecmp(startType, "METASCAN")) {
-      req = GrepReq::STOP_METASCAN;
-    } else if (!strcasecmp(startType, "DATALOG")) {
-      req = GrepReq::STOP_DATALOG;
-    } else if (!strcasecmp(startType, "DATASCAN")) {
-      req = GrepReq::STOP_DATASCAN;
-    } else if (!strcasecmp(startType, "REQUESTOR")) {
-      req = GrepReq::STOP_REQUESTOR;
-    } else if (!strcasecmp(startType, "TRANSFER")) {
-      req = GrepReq::STOP_TRANSFER;
-    } else if (!strcasecmp(startType, "APPLY")) {
-      req = GrepReq::STOP_APPLY;
-    } else if (!strcasecmp(startType, "DELETE")) {
-      req = GrepReq::STOP_DELETE;
-    } else {
-      ndbout_c("Illegal argument to command 'REPLICATION STOP'");
-      return -1;
-    }
-    int result = ndb_rep_command(m_repserver, req, &repId, &reply, epoch);
-    
-    if (result != 0) {
-      ndbout << "Stop command failed" << endl;
-      return -1;
-    } else {
-      ndbout << "Stop ordered" << endl;
-    }
-    return 0;
-  }
-
-  /*********
-   * STATUS
-   *********/
-  if (!strcasecmp(firstToken, "STATUS")) {
-    struct rep_state repstate;
-    int result = 
-      ndb_rep_get_status(m_repserver, &repId, &reply, &repstate);
-    
-    if (result != 0) {
-      ndbout << "Status request of Global Replication failed" << endl;
-      return -1;
-    } else {
-      ndbout << "Status request of Global Replication ordered" << endl;
-      ndbout << "See printout at one of the DB nodes" << endl;
-      ndbout << "(Better status report is under development.)" << endl;
-      ndbout << " SubscriptionId " << repstate.subid 
-	     << " SubscriptionKey " << repstate.subkey << endl;
-    }
-    return 0;
-  }
-
-  /*********
-   * QUERY (see repapi.h for querable counters)
-   *********/
-  if (!strcasecmp(firstToken, "QUERY")) {
-    char *query = strtok(NULL, "\0");
-    int queryCounter=-1;
-    if(query != NULL) {
-      queryCounter = atoi(query);
-    }
-    struct rep_state repstate;
-    unsigned repId = 0;
-    int result = ndb_rep_query(m_repserver, (QueryCounter)queryCounter,
-			       &repId, &reply, &repstate);
-    
-    if (result != 0) {
-      ndbout << "Query repserver failed" << endl;
-      return -1;
-    } else {
-      ndbout << "Query repserver sucessful" << endl;
-      ndbout_c("repstate : QueryCounter %d, f=%d l=%d"
-	       " nodegroups %d" , 
-	       repstate.queryCounter,
-	       repstate.first[0], repstate.last[0],
-	       repstate.no_of_nodegroups );
-    }
-    return 0;
-  }
-  return 0;
-}
-#endif // HAVE_GLOBAL_REPLICATION
 
 template class Vector<char const*>;
Thread
bk commit into 5.1 tree (lzhou:1.2523)lzhou30 Jul