List:Commits« Previous MessageNext Message »
From:Stewart Smith Date:February 21 2006 11:51am
Subject:bk commit into 5.2 tree (stewart:1.2110)
View as plain text  
Below is the list of changes that have just been committed into a local
5.2 repository of stewart. When stewart 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
  1.2110 06/02/21 22:51:19 stewart@stripped +7 -0
  WL#1504 Online Add Node
  
  Add preliminary mgmserv, mgmapi and mgmclient ADD NODEGROUP.
  
  This changeset doesn't include the code in dict and dih to actually add a nodegroup.

  storage/ndb/src/mgmsrv/Services.hpp
    1.19 06/02/21 22:51:15 stewart@stripped +3 -0
    Add (add|drop)_nodegroup

  storage/ndb/src/mgmsrv/Services.cpp
    1.60 06/02/21 22:51:15 stewart@stripped +64 -0
    Add add nodegroup and drop nodegroup functionality to the mgm protocol.

  storage/ndb/src/mgmsrv/MgmtSrvr.hpp
    1.42 06/02/21 22:51:15 stewart@stripped +2 -0
    addNodegroup prototype

  storage/ndb/src/mgmsrv/MgmtSrvr.cpp
    1.91 06/02/21 22:51:15 stewart@stripped +31 -0
    Add addNodegroup functionality.
    
    Sends ALTER_NODEGROUP_REQ to dict.

  storage/ndb/src/mgmclient/CommandInterpreter.cpp
    1.60 06/02/21 22:51:15 stewart@stripped +81 -0
    Add UI for Add/drop nodegroup and add/drop node to/from nodegroup.

  storage/ndb/src/mgmapi/mgmapi.cpp
    1.61 06/02/21 22:51:14 stewart@stripped +77 -0
    Add ndb_mgm_add_nodegroup call

  storage/ndb/include/mgmapi/mgmapi.h
    1.51 06/02/21 22:51:14 stewart@stripped +9 -0
    Add mgmapi calls for adding and droping nodegroups

# 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:	stewart
# Host:	willster.(none)
# Root:	/home/stewart/Documents/MySQL/5.2/wl1504-add-node

--- 1.50/storage/ndb/include/mgmapi/mgmapi.h	2006-02-14 00:20:24 +11:00
+++ 1.51/storage/ndb/include/mgmapi/mgmapi.h	2006-02-21 22:51:14 +11:00
@@ -1049,6 +1049,15 @@
   int ndb_mgm_report_event(NdbMgmHandle handle, Uint32 *data, Uint32 length);
 #endif
 
+  int ndb_mgm_add_nodegroup(NdbMgmHandle handle,
+                            char *nodes,
+                            Uint32 *ng,
+                            struct ndb_mgm_reply* mgmreply);
+
+  int ndb_mgm_drop_nodegroup(NdbMgmHandle handle,
+                             Uint32 ng,
+                             struct ndb_mgm_reply* mgmreply);
+
 #ifndef DOXYGEN_SHOULD_SKIP_DEPRECATED
   enum ndb_mgm_clusterlog_level {
      NDB_MGM_ILLEGAL_CLUSTERLOG_LEVEL = -1,

--- 1.60/storage/ndb/src/mgmapi/mgmapi.cpp	2006-02-14 00:20:24 +11:00
+++ 1.61/storage/ndb/src/mgmapi/mgmapi.cpp	2006-02-21 22:51:14 +11:00
@@ -2353,4 +2353,81 @@
   DBUG_RETURN(0);
 }
 
+int ndb_mgm_add_nodegroup(NdbMgmHandle handle,
+                          char *nodes,
+                          Uint32 *ng,
+                          struct ndb_mgm_reply* mgmreply)
+{
+  DBUG_ENTER("ndb_mgm_add_nodegroup");
+  CHECK_HANDLE(handle, -1);
+  CHECK_CONNECTED(handle, -2);
+
+  Properties args;
+  args.put("nodes", nodes);
+
+  const ParserRow<ParserDummy> reply[]= {
+    MGM_CMD("add nodegroup reply", NULL, ""),
+    MGM_ARG("ng", Int, Mandatory, "NG Id"),
+    MGM_ARG("result", String, Mandatory, "Result"),
+    MGM_END()
+  };
+
+  const Properties *prop;
+  prop = ndb_mgm_call(handle, reply, "add nodegroup", &args);
+  CHECK_REPLY(prop, -3);
+
+  int res= -1;
+  do {
+    const char * buf;
+    if(!prop->get("result", &buf) || strcmp(buf, "Ok") != 0){
+      fprintf(handle->errstream, "ERROR Message: %s\n", buf);
+      break;
+    }
+    res= 0;
+  } while(0);
+
+  if(!prop->get("ng",(Uint32*)ng)){
+    fprintf(handle->errstream, "Unable to get value\n");
+    res = -4;
+  }
+
+  delete prop;
+  DBUG_RETURN(res);
+}
+
+int ndb_mgm_drop_nodegroup(NdbMgmHandle handle,
+                           Uint32 ng,
+                           struct ndb_mgm_reply* mgmreply)
+{
+  DBUG_ENTER("ndb_mgm_drop_nodegroup");
+  CHECK_HANDLE(handle, -1);
+  CHECK_CONNECTED(handle, -2);
+
+  Properties args;
+  args.put("ng", ng);
+
+  const ParserRow<ParserDummy> reply[]= {
+    MGM_CMD("drop nodegroup reply", NULL, ""),
+    MGM_ARG("result", String, Mandatory, "Result"),
+    MGM_END()
+  };
+
+  const Properties *prop;
+  prop = ndb_mgm_call(handle, reply, "drop nodegroup", &args);
+  CHECK_REPLY(prop, -3);
+
+  int res= -1;
+  do {
+    const char * buf;
+    if(!prop->get("result", &buf) || strcmp(buf, "Ok") != 0){
+      fprintf(handle->errstream, "ERROR Message: %s\n", buf);
+      break;
+    }
+    res= 0;
+  } while(0);
+
+  delete prop;
+  DBUG_RETURN(res);
+}
+
 template class Vector<const ParserRow<ParserDummy>*>;

--- 1.59/storage/ndb/src/mgmclient/CommandInterpreter.cpp	2006-02-03 07:20:21 +11:00
+++ 1.60/storage/ndb/src/mgmclient/CommandInterpreter.cpp	2006-02-21 22:51:15 +11:00
@@ -121,6 +121,9 @@
 
   void executeCpc(char * parameters);
 
+  void executeAddNodeGroup(char* parameters);
+  void executeDropNodeGroup(char* parameters);
+
 public:
   bool connect();
   bool disconnect();
@@ -243,6 +246,10 @@
 "SHOW CONFIG                            Print configuration\n"
 "SHOW PARAMETERS                        Print configuration parameters\n"
 #endif
+"ADD NODEGROUP <id>,<id>...             Add a Nodegroup containing nodes\n"
+"DROP NODEGROUP <NG>                    Drop nodegroup with id NG\n"
+"ALTER NODEGROUP <NG> ADD NODE <id>     Add node id to nodegroup NG\n"
+"ALTER NODEGROUP <NG> DROP NODE <id>    Remove node id from nodegroup NG\n"
 "START BACKUP [NOWAIT | WAIT STARTED | WAIT COMPLETED]\n"
 "                                       Start backup (default WAIT COMPLETED)\n"
 "ABORT BACKUP <backup id>               Abort backup\n"
@@ -652,6 +659,27 @@
     executeExitSingleUser(allAfterFirstToken);
     DBUG_RETURN(true);
   }
+  else if(strcasecmp(firstToken, "ADD") == 0 &&
+	  allAfterFirstToken != NULL &&
+	  strncasecmp(allAfterFirstToken, "NODEGROUP",
+                      sizeof("NODEGROUP") - 1) == 0){
+    executeAddNodeGroup(allAfterFirstToken);
+    DBUG_RETURN(true);
+  }
+  else if(strcasecmp(firstToken, "DROP") == 0 &&
+	  allAfterFirstToken != NULL &&
+	  strncasecmp(allAfterFirstToken, "NODEGROUP",
+                      sizeof("NODEGROUP") - 1) == 0){
+    executeDropNodeGroup(allAfterFirstToken);
+    DBUG_RETURN(true);
+  }
+  else if(strcasecmp(firstToken, "ALTER") == 0 &&
+	  allAfterFirstToken != NULL &&
+	  strncasecmp(allAfterFirstToken, "NODEGROUP",
+                      sizeof("NODEGROUP") - 1) == 0){
+    // ALTER NODEGROUP
+    DBUG_RETURN(true);
+  }
   else if (strcasecmp(firstToken, "ALL") == 0) {
     analyseAfterFirstToken(-1, allAfterFirstToken);
   } else {
@@ -2018,6 +2046,59 @@
   return;
  executeAbortBackupError1:
   ndbout << "Invalid arguments: expected <BackupId>" << endl;
+  return;
+}
+
+void
+CommandInterpreter::executeAddNodeGroup(char* parameters) 
+{
+  int result;
+  Uint32 ng;
+  struct ndb_mgm_reply reply;
+  if (emptyString(parameters))
+    goto err;
+
+  result= ndb_mgm_add_nodegroup(m_mgmsrv, parameters, &ng, &reply);
+
+  if (result != 0) {
+    ndbout << "Add Node Group failed" << endl;
+    printError();
+  } else {
+    ndbout << "Nodegroup " << ng << " Added" << endl;
+  }
+
+  return;
+ err:
+  ndbout << "Invalid arguments: expected <id>,<id>..." << endl;
+  return;
+}
+
+void
+CommandInterpreter::executeDropNodeGroup(char* parameters) 
+{
+  int ng = -1;
+  struct ndb_mgm_reply reply;
+  if (emptyString(parameters))
+    goto err;
+
+  {
+    strtok(parameters, " ");
+    char* id = strtok(NULL, "\0");
+    if(id == 0 || sscanf(id, "%d", &ng) != 1)
+      goto err;
+  }
+  {
+    int result= ndb_mgm_drop_nodegroup(m_mgmsrv, ng, &reply);
+    if (result != 0) {
+      ndbout << "Drop Node Group " << ng << " failed" << endl;
+      printError();
+    } else {
+      ndbout << "Drop Node Group " << ng << " done" << endl;
+    }
+  }
+  return;
+err:
+  ndbout << "Invalid arguments: expected <NG>" << endl;
   return;
 }
 

--- 1.90/storage/ndb/src/mgmsrv/MgmtSrvr.cpp	2006-02-03 07:20:21 +11:00
+++ 1.91/storage/ndb/src/mgmsrv/MgmtSrvr.cpp	2006-02-21 22:51:15 +11:00
@@ -41,6 +41,7 @@
 #include <signaldata/NFCompleteRep.hpp>
 #include <signaldata/NodeFailRep.hpp>
 #include <signaldata/AllocNodeId.hpp>
+#include <signaldata/AlterNodegroup.hpp>
 #include <NdbSleep.h>
 #include <EventLogger.hpp>
 #include <DebuggerNames.hpp>
@@ -2692,6 +2693,36 @@
   return 0;
 }
 
+int MgmtSrvr::addNodegroup(int *nodes, int count, int *ng, BaseString &msg)
+{
+  int i;
+  SignalSender ss(theFacade);
+
+  bool next;
+  NodeId nodeId = 0;
+  while((next = getNextNodeId(&nodeId, NDB_MGM_NODE_TYPE_NDB)) == true &&
+	theFacade->get_node_alive(nodeId) == false);
+
+  if(!next){
+    return NO_CONTACT_WITH_DB_NODES;
+  }
+
+  SimpleSignal ssig;
+
+  AlterNodegroupReq* req = CAST_PTR(AlterNodegroupReq, ssig.getDataPtrSend());
+  ssig.set(ss, TestOrd::TraceAPI, DBDICT, GSN_ALTER_NODEGROUP_REQ,
+	   AlterNodegroupReq::SignalLength+count);
+
+  Uint32 *dataPtr= ssig.getDataPtrSend();
+
+  req->operation= AlterNodegroupReq::Add;
+  req->nrNodes= count;
+
+  for(i=0; i<count; i++)
+    req->nodes[i]= nodes[i];
+
+  return ss.sendSignal(nodeId, &ssig) == SEND_OK ? 0 : SEND_OR_RECEIVE_FAILED;
+}
 
 
 template class MutexVector<unsigned short>;

--- 1.41/storage/ndb/src/mgmsrv/MgmtSrvr.hpp	2006-02-03 07:20:22 +11:00
+++ 1.42/storage/ndb/src/mgmsrv/MgmtSrvr.hpp	2006-02-21 22:51:15 +11:00
@@ -470,6 +470,8 @@
 
   void transporter_connect(NDB_SOCKET_TYPE sockfd);
 
+  int addNodegroup(int *nodes, int count, int *ng, BaseString &msg);
+
   ConfigRetriever *get_config_retriever() { return m_config_retriever; };
 
   const char *get_connect_address(Uint32 node_id);

--- 1.59/storage/ndb/src/mgmsrv/Services.cpp	2006-02-14 00:20:25 +11:00
+++ 1.60/storage/ndb/src/mgmsrv/Services.cpp	2006-02-21 22:51:15 +11:00
@@ -256,6 +256,12 @@
     MGM_ARG("length", Int, Mandatory, "Length"),
     MGM_ARG("data", String, Mandatory, "Data"),
 
+  MGM_CMD("add nodegroup", &MgmApiSession::add_nodegroup, ""),
+    MGM_ARG("nodes", String, Mandatory, "Nodes"),
+
+  MGM_CMD("drop nodegroup", &MgmApiSession::drop_nodegroup, ""),
+    MGM_ARG("ng", Int, Mandatory, "Nodegroup"),
+
   MGM_END()
 };
 
@@ -1591,6 +1597,64 @@
   m_mgmsrv.eventReport(data);
   m_output->println("report event reply");
   m_output->println("result: ok");
+  m_output->println("");
+}
+
+void
+MgmApiSession::add_nodegroup(Parser_t::Context &ctx,
+                             Properties const &args)
+{
+  BaseString nodestr;
+  BaseString retval;
+  char *ns;
+  int ng = 0;
+  int nodes[4];
+  char *t=NULL;
+  char *str;
+  int ncount=0;
+  const char *result= "Ok";
+
+  args.get("nodes", nodestr);
+  ns= strdup(nodestr.c_str());
+
+  str= strtok_r(ns," ,",&t);
+  while(str)
+  {
+    nodes[ncount]= atoi(str);
+    if(nodes[ncount]>0)
+      ncount++;
+    str=strtok_r(NULL," ,",&t);
+  }
+
+  if(ncount<1)
+  {
+    result= "FAIL: Must have at least 1 node in the node group";
+    goto end;
+  }
+
+  if(m_mgmsrv.addNodegroup(nodes, ncount, &ng, retval))
+    result= retval.c_str();
+
+end:
+  m_output->println("add nodegroup reply");
+  m_output->println("ng: %d", ng);
+  m_output->println("result: %s", result);
+  m_output->println("");
+  free(ns);
+}
+
+void
+MgmApiSession::drop_nodegroup(Parser_t::Context &ctx,
+                              Properties const &args)
+{
+  BaseString ng;
+
+  args.get("ng", ng);
+
+  BaseString result;
+
+  m_output->println("drop nodegroup reply");
+  m_output->println("result: %s", "Ok");
   m_output->println("");
 }
 

--- 1.18/storage/ndb/src/mgmsrv/Services.hpp	2006-02-03 07:20:22 +11:00
+++ 1.19/storage/ndb/src/mgmsrv/Services.hpp	2006-02-21 22:51:15 +11:00
@@ -101,6 +101,9 @@
   void get_mgmd_nodeid(Parser_t::Context &ctx, Properties const &args);
 
   void report_event(Parser_t::Context &ctx, Properties const &args);
+
+  void add_nodegroup(Parser_t::Context &ctx, Properties const &args);
+  void drop_nodegroup(Parser_t::Context &ctx, Properties const &args);
 };
 
 class MgmApiService : public SocketServer::Service {
Thread
bk commit into 5.2 tree (stewart:1.2110)Stewart Smith21 Feb