⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 commandinterpreter.cpp

📁 这是linux下运行的mysql软件包,可用于linux 下安装 php + mysql + apach 的网络配置
💻 CPP
📖 第 1 页 / 共 5 页
字号:
  if (emptyString(allAfterParameterName)) {    ndbout << "Missing parameter value." << endl;    return;  }  char* value = strtok(allAfterParameterName, " ");  char* allAfterValue = strtok(NULL, "\0");  if (! emptyString(allAfterValue)) {    ndbout << "Nothing expected after parameter value." << endl;    return;  }  bool configBackupFileUpdated;  bool configPrimaryFileUpdated;    // TODO The handling of the primary and backup config files should be   // analysed further.  // How it should be handled if only the backup is possible to write.  int result = _mgmtSrvr.updateConfigParam(processId, configParameterName, 					   value, configBackupFileUpdated, 					   configPrimaryFileUpdated);  if (result == 0) {    if (configBackupFileUpdated && configPrimaryFileUpdated) {      ndbout << "The configuration is updated." << endl;    }    else if (configBackupFileUpdated && !configPrimaryFileUpdated) {      ndbout << "The configuration is updated but it was only possible " 	     << "to update the backup configuration file, not the primary." 	     << endl;    }    else {      assert(false);    }  }  else {    ndbout << get_error_text(result) << endl;    if (configBackupFileUpdated && configPrimaryFileUpdated) {      ndbout << "The configuration files are however updated and "	     << "the value will be used next time the process is restarted." 	     << endl;    }    else if (configBackupFileUpdated && !configPrimaryFileUpdated) {      ndbout << "It was only possible to update the backup "	     << "configuration file, not the primary." << endl;    }    else if (!configBackupFileUpdated && !configPrimaryFileUpdated) {      ndbout << "The configuration files are not updated." << endl;    }    else {      // The primary is not tried to write if the write of backup file fails      abort();    }  }#endif}//*****************************************************************************//*****************************************************************************void CommandInterpreter::executeGetStat(int /*processId*/,					const char* parameters, bool /*all*/) {  if (! emptyString(parameters)) {    ndbout << "No parameters expected to this command." << endl;    return;  }#if 0  MgmtSrvr::Statistics statistics;  int result = _mgmtSrvr.getStatistics(processId, statistics);  if (result != 0) {    ndbout << get_error_text(result) << endl;    return;  }#endif  // Print statistic...  /*  ndbout << "Number of GETSTAT commands: "   << statistics._test1 << endl;  */}//*****************************************************************************//*****************************************************************************				 void CommandInterpreter::executeEventReporting(int processId,					  const char* parameters, 					  bool all) {  if (emptyString(parameters)) {    ndbout << "Expected argument" << endl;    return;  }  BaseString tmp(parameters);  Vector<BaseString> specs;  tmp.split(specs, " ");  for (int i=0; i < specs.size(); i++)  {    Vector<BaseString> spec;    specs[i].split(spec, "=");    if(spec.size() != 2){      ndbout << "Invalid loglevel specification: " << specs[i] << endl;      continue;    }    spec[0].trim().ndb_toupper();    int category = ndb_mgm_match_event_category(spec[0].c_str());    if(category == NDB_MGM_ILLEGAL_EVENT_CATEGORY){      if(!convert(spec[0].c_str(), category) ||	 category < NDB_MGM_MIN_EVENT_CATEGORY ||	 category > NDB_MGM_MAX_EVENT_CATEGORY){	ndbout << "Unknown category: \"" << spec[0].c_str() << "\"" << endl;	continue;      }    }    int level;    if (!convert(spec[1].c_str(),level))    {      ndbout << "Invalid level: " << spec[1].c_str() << endl;      continue;    }    ndbout << "Executing CLUSTERLOG " << spec[0] << "=" << spec[1]	   << " on node " << processId << flush;    struct ndb_mgm_reply reply;    int result;    result = ndb_mgm_set_loglevel_clusterlog(m_mgmsrv, 					     processId,					     (ndb_mgm_event_category)category,					     level, 					     &reply);      if (result != 0) {      ndbout_c(" failed.");       printError();    } else {      ndbout_c(" OK!");     }  }}/***************************************************************************** * Backup *****************************************************************************/intCommandInterpreter::executeStartBackup(char* parameters){  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);    for (unsigned i= 0; i < args.size(); i++)      if (args[i].length() == 0)	args.erase(i--);      else	args[i].ndb_toupper();  }  int sz= args.size();  int result;  if (sz == 2 &&      args[1] == "NOWAIT")  {    result = ndb_mgm_start_backup(m_mgmsrv, 0, &backupId, &reply);  }  else if (sz == 1 ||	   (sz == 3 &&	    args[1] == "WAIT" &&	    args[2] == "COMPLETED"))  {    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")  {    ndbout_c("Waiting for started, this may take several minutes");    result = ndb_mgm_start_backup(m_mgmsrv, 1, &backupId, &reply);  }  else  {    invalid_command(parameters);    return -1;  }  if (result != 0) {    ndbout << "Start of backup failed" << endl;    printError();#if 0    close(fd);#endif    return result;  }#if 0  ndbout_c("Waiting for completed, this may take several minutes");  char *tmp;  char buf[1024];  {    SocketInputStream in(fd);    int count = 0;    do {      tmp = in.gets(buf, 1024);      if(tmp)      {	ndbout << tmp;	unsigned int id;	if(sscanf(tmp, "%*[^:]: Backup %d ", &id) == 1 && id == backupId){	  count++;	}      }    } while(count < 2);  }  SocketInputStream in(fd, 10);  do {    tmp = in.gets(buf, 1024);    if(tmp && tmp[0] != 0)    {      ndbout << tmp;    }  } while(tmp && tmp[0] != 0);  close(fd);#endif    return 0;}voidCommandInterpreter::executeAbortBackup(char* parameters) {  int bid = -1;  struct ndb_mgm_reply reply;  if (emptyString(parameters))    goto executeAbortBackupError1;  {    strtok(parameters, " ");    char* id = strtok(NULL, "\0");    if(id == 0 || sscanf(id, "%d", &bid) != 1)      goto executeAbortBackupError1;  }  {    int result= ndb_mgm_abort_backup(m_mgmsrv, bid, &reply);    if (result != 0) {      ndbout << "Abort of backup " << bid << " failed" << endl;      printError();    } else {      ndbout << "Abort of backup " << bid << " ordered" << endl;    }  }  return; executeAbortBackupError1:  ndbout << "Invalid arguments: expected <BackupId>" << endl;  return;}#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 *****************************************************************************/voidCommandInterpreter::executeRep(char* parameters) {  if (emptyString(parameters)) {    ndbout << helpTextRep;    return;  }  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;    }        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);     else      rep_connected=true;    return;        if(!rep_connected) {      ndbout_c("Not connected to REP server");    }  }      /********   * 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;    }    int result = ndb_rep_command(m_repserver, req, &repId, &reply);        if (result != 0) {      ndbout << "Start of Global Replication failed" << endl;    } else {      ndbout << "Start of Global Replication ordered" << endl;    }    return;  }  /********   * 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;      }      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;    }    int result = ndb_rep_command(m_repserver, req, &repId, &reply, epoch);        if (result != 0) {      ndbout << "Stop command failed" << endl;    } else {      ndbout << "Stop ordered" << endl;    }    return;  }  /*********   * STATUS   *********/  if (!strcasecmp(firstToken, "STATUS")) {    struct rep_state repstate;    int result =       ndb_rep_get_status(m_repserver, &repId, &reply, &repstate);        if (r

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -