commandinterpreter.cpp
来自「MySQL源码文件5.X系列, 可自已编译到服务器」· C++ 代码 · 共 1,989 行 · 第 1/5 页
CPP
1,989 行
" messages will be logged.\n\n"" <severity> can be any one of the following values:\n"" ALERT, CRITICAL, ERROR, WARNING, INFO, DEBUG.\n";static const char* helpTextClusterlogOff ="---------------------------------------------------------------------------\n"" NDB Cluster -- Management Client -- Help for CLUSTERLOG OFF command\n""---------------------------------------------------------------------------\n""CLUSTERLOG OFF Disable Cluster logging\n\n""CLUSTERLOG OFF [<severity>] ... \n"" Turn the cluster log off.\n"" It tells management server which serverity\n"" levels logging will be disabled.\n\n"" <severity> can be any one of the following values:\n"" ALERT, CRITICAL, ERROR, WARNING, INFO, DEBUG.\n";static const char* helpTextClusterlogToggle ="---------------------------------------------------------------------------\n"" NDB Cluster -- Management Client -- Help for CLUSTERLOG TOGGLE command\n""---------------------------------------------------------------------------\n""CLUSTERLOG TOGGLE Toggle severity filter on/off\n\n""CLUSTERLOG TOGGLE [<severity>] ... \n"" Toggle serverity filter on/off.\n"" If a serverity level is already enabled,then it will\n"" be disabled after you use the command,vice versa.\n\n"" <severity> can be any one of the following values:\n"" ALERT, CRITICAL, ERROR, WARNING, INFO, DEBUG.\n";static const char* helpTextClusterlogInfo ="---------------------------------------------------------------------------\n"" NDB Cluster -- Management Client -- Help for CLUSTERLOG INFO command\n""---------------------------------------------------------------------------\n""CLUSTERLOG INFO Print cluster log information\n\n""CLUSTERLOG INFO Display which severity levels have been enabled,\n"" see HELP CLUSTERLOG for list of the severity levels.\n";static const char* helpTextStart ="---------------------------------------------------------------------------\n"" NDB Cluster -- Management Client -- Help for START command\n""---------------------------------------------------------------------------\n""START Start data node (started with -n)\n\n""<id> START Start the data node identified by <id>.\n"" Only starts data nodes that have not\n"" yet joined the cluster. These are nodes\n"" launched or restarted with the -n(--nostart)\n"" option.\n\n"" It does not launch the ndbd process on a remote\n"" machine.\n";static const char* helpTextRestart ="---------------------------------------------------------------------------\n"" NDB Cluster -- Management Client -- Help for RESTART command\n""---------------------------------------------------------------------------\n""RESTART Restart data or management server node\n\n""<id> RESTART [-n] [-i] \n"" Restart the data or management node <id>(or All data nodes).\n\n"" -n (--nostart) restarts the node but does not\n"" make it join the cluster. Use '<id> START' to\n"" join the node to the cluster.\n\n"" -i (--initial) perform initial start.\n"" This cleans the file system (ndb_<id>_fs)\n"" and the node will copy data from another node\n"" in the same node group during start up.\n\n"" Consult the documentation before using -i.\n\n" " INCORRECT USE OF -i WILL CAUSE DATA LOSS!\n";static const char* helpTextStop ="---------------------------------------------------------------------------\n"" NDB Cluster -- Management Client -- Help for STOP command\n""---------------------------------------------------------------------------\n""STOP Stop data or management server node\n\n""<id> STOP Stop the data or management server node <id>.\n\n"" ALL STOP will just stop all data nodes.\n\n"" If you desire to also shut down management servers,\n"" use SHUTDOWN instead.\n" ;static const char* helpTextEnterSingleUserMode ="---------------------------------------------------------------------------\n"" NDB Cluster -- Management Client -- Help for ENTER SINGLE USER MODE command\n""---------------------------------------------------------------------------\n""ENTER SINGLE USER MODE Enter single user mode\n\n""ENTER SINGLE USER MODE <id> \n"" Enters single-user mode, whereby only the MySQL Server or NDBAPI\n" " node identified by <id> is allowed to access the database. \n";static const char* helpTextExitSingleUserMode ="---------------------------------------------------------------------------\n"" NDB Cluster -- Management Client -- Help for EXIT SINGLE USER MODE command\n""---------------------------------------------------------------------------\n""EXIT SINGLE USER MODE Exit single user mode\n\n""EXIT SINGLE USER MODE \n"" Exits single-user mode, allowing all SQL nodes \n"" (that is, all running mysqld processes) to access the database. \n" ;static const char* helpTextStatus ="---------------------------------------------------------------------------\n"" NDB Cluster -- Management Client -- Help for STATUS command\n""---------------------------------------------------------------------------\n""STATUS Print status\n\n""<id> STATUS Displays status information for the data node <id>\n"" or for All data nodes. \n\n"" e.g.\n"" ALL STATUS\n"" 1 STATUS\n\n"" When a node is starting, the start phase will be\n"" listed.\n\n"" Start Phase Meaning\n"" 1 Clear the cluster file system(ndb_<id>_fs). \n"" This stage occurs only when the --initial option \n"" has been specified.\n"" 2 This stage sets up Cluster connections, establishes \n"" inter-node communications and starts Cluster heartbeats.\n"" 3 The arbitrator node is elected.\n"" 4 Initializes a number of internal cluster variables.\n"" 5 For an initial start or initial node restart,\n"" the redo log files are created.\n"" 6 If this is an initial start, create internal system tables.\n"" 7 Update internal variables. \n"" 8 In a system restart, rebuild all indexes.\n"" 9 Update internal variables. \n"" 10 The node can be connected by APIs and can receive events.\n"" 11 At this point,event delivery is handed over to\n"" the node joining the cluster.\n""(see manual for more information)\n";static const char* helpTextClusterlog ="---------------------------------------------------------------------------\n"" NDB Cluster -- Management Client -- Help for CLUSTERLOG command\n""---------------------------------------------------------------------------\n""CLUSTERLOG Set log level for cluster log\n\n"" <id> CLUSTERLOG {<category>=<level>}+ \n"" Logs <category> events with priority less than \n"" or equal to <level> in the cluster log.\n\n"" <category> can be any one of the following values:\n"" STARTUP, SHUTDOWN, STATISTICS, CHECKPOINT, NODERESTART,\n"" CONNECTION, ERROR, INFO, CONGESTION, DEBUG, or BACKUP. \n\n"" <level> is represented by one of the numbers \n"" from 1 to 15 inclusive, where 1 indicates 'most important' \n"" and 15 'least important'.\n\n"" <severity> can be any one of the following values:\n"" ALERT, CRITICAL, ERROR, WARNING, INFO, DEBUG.\n";static const char* helpTextPurgeStaleSessions ="---------------------------------------------------------------------------\n"" NDB Cluster -- Management Client -- Help for PURGE STALE SESSIONS command\n""---------------------------------------------------------------------------\n""PURGE STALE SESSIONS Reset reserved nodeid's in the mgmt server\n\n""PURGE STALE SESSIONS \n"" Running this statement forces all reserved \n"" node IDs to be checked; any that are not \n"" being used by nodes acutally connected to \n"" the cluster are then freed.\n\n" " This command is not normally needed, but may be\n"" required in some situations where failed nodes \n"" cannot rejoin the cluster due to failing to\n"" allocate a node id.\n" ;static const char* helpTextConnect ="---------------------------------------------------------------------------\n"" NDB Cluster -- Management Client -- Help for CONNECT command\n""---------------------------------------------------------------------------\n""CONNECT Connect to management server (reconnect if already connected)\n\n""CONNECT [<connectstring>] \n"" Connect to management server.\n"" The optional parameter connectstring specifies the \n"" connect string to user.\n\n"" A connect string may be:\n"" mgm-server\n"" mgm-server:port\n"" mgm1:port,mgm2:port\n"" With multiple management servers comma separated.\n"" The management client with try to connect to the \n"" management servers in the order they are listed.\n\n"" If no connect string is specified, the default \n"" is used. \n";static const char* helpTextQuit ="---------------------------------------------------------------------------\n"" NDB Cluster -- Management Client -- Help for QUIT command\n""---------------------------------------------------------------------------\n""QUIT Quit management client\n\n""QUIT Terminates the management client. \n" ;#ifdef HAVE_GLOBAL_REPLICATIONstatic 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 ONLYstatic const char* helpTextDebug ="---------------------------------------------------------------------------\n"" NDB Cluster -- Management Client -- Help for Debugging (Internal use only)\n""---------------------------------------------------------------------------\n""SHOW PROPERTIES Print config properties object\n""<id> LOGLEVEL {<category>=<level>}+ Set log level\n"#ifdef ERROR_INSERT"<id> ERROR <errorNo> Inject error into NDB node\n"#endif"<id> LOG [BLOCK = {ALL|<block>+}] Set logging on in & out signals\n""<id> LOGIN [BLOCK = {ALL|<block>+}] Set logging on in signals\n""<id> LOGOUT [BLOCK = {ALL|<block>+}] Set logging on out signals\n""<id> LOGOFF [BLOCK = {ALL|<block>+}] Unset signal logging\n""<id> TESTON Start signal logging\n""<id> TESTOFF Stop signal logging\n""<id> SET <configParamName> <value> Update configuration variable\n""<id> DUMP <arg> Dump system state to cluster.log\n""<id> GETSTAT Print statistics\n""\n""<id> = ALL | Any database node id\n";#endifstruct st_cmd_help { const char *cmd; const char * help;}help_items[]={ {"SHOW", helpTextShow}, {"HELP", helpTextHelp}, {"BACKUP", helpTextBackup}, {"START BACKUP", helpTextStartBackup}, {"START BACKUP NOWAIT", helpTextStartBackup}, {"START BACKUP WAIT STARTED", helpTextStartBackup}, {"START BACKUP WAIT", helpTextStartBackup}, {"START BACKUP WAIT COMPLETED", helpTextStartBackup}, {"ABORT BACKUP", helpTextAbortBackup}, {"SHUTDOWN", helpTextShutdown}, {"CLUSTERLOG ON", helpTextClusterlogOn}, {"CLUSTERLOG OFF", helpTextClusterlogOff}, {"CLUSTERLOG TOGGLE", helpTextClusterlogToggle}, {"CLUSTERLOG INFO", helpTextClusterlogInfo}, {"START", helpTextStart}, {"RESTART", helpTextRestart}, {"STOP", helpTextStop}, {"ENTER SINGLE USER MODE", helpTextEnterSingleUserMode}, {"EXIT SINGLE USER MODE", helpTextExitSingleUserMode}, {"STATUS", helpTextStatus}, {"CLUSTERLOG", helpTextClusterlog}, {"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 {NULL, NULL}};static boolconvert(const char* s, int& val) { if (s == NULL) return false; if (strlen(s) == 0) return false; errno = 0; char* p; long v = strtol(s, &p, 10); if (errno != 0) return false; if (p != &s[strlen(s)]) return false; val = v; return true;}/* * Constructor */CommandInterpreter::CommandInterpreter(const char *_host,int verbose) : m_verbose(verbose){ m_constr= _host; m_connected= false; 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}/* * Destructor */CommandInterpreter::~CommandInterpreter() { disconnect(); NdbMutex_Destroy(m_print_mutex);}static bool emptyString(const char* s) { if (s == NULL) { return true; } for (unsigned int i = 0; i < strlen(s); ++i) { if (! isspace(s[i])) { return false; } } return true;}voidCommandInterpreter::printError() { ndbout_c("* %5d: %s", ndb_mgm_get_latest_error(m_mgmsrv), ndb_mgm_get_latest_error_msg(m_mgmsrv)); ndbout_c("* %s", ndb_mgm_get_latest_error_desc(m_mgmsrv)); if (ndb_mgm_check_connection(m_mgmsrv)) { disconnect(); }}//*****************************************************************************//*****************************************************************************static int do_event_thread;static void*event_thread_run(void* p){ DBUG_ENTER("event_thread_run"); struct event_thread_param param= *(struct event_thread_param*)p; NdbMgmHandle handle= *(param.m); NdbMutex* printmutex= *(param.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) { 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)))
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?