22 #include "ConfigSubscriber.hpp"
26 #include <NodeBitmask.hpp>
27 #include <ndb_version.h>
28 #include <EventLogger.hpp>
30 #include <SignalSender.hpp>
32 #define MGM_ERROR_MAX_INJECT_SESSION_ONLY 10000
42 NDB_SOCKET_TYPE m_socket;
54 void add_listener(
const Event_listener&);
55 void check_listeners();
56 void update_max_log_level(
const LogLevel&);
57 void update_log_level(
const LogLevel&);
59 void log(
int eventType,
const Uint32* theData, Uint32 len, NodeId nodeId);
63 Event_listener& operator[](
unsigned i) {
return m_clients[
i]; }
64 const Event_listener& operator[](
unsigned i)
const {
return m_clients[
i]; }
65 void lock() { m_clients.lock(); }
66 void unlock(){ m_clients.unlock(); }
87 void reserve_node(NodeId
id, NDB_TICKS timeout);
88 bool is_timed_out(NDB_TICKS tick);
89 bool is_reserved(NodeId nodeId) {
return m_reserved_nodes.
get(nodeId); }
90 bool is_reserved(
NodeBitmask mask) {
return !mask.
bitAND(m_reserved_nodes).isclear(); }
91 bool isclear() {
return m_reserved_nodes.
isclear(); }
92 NodeId get_nodeid()
const;
96 NDB_TICKS m_alloc_timeout;
114 const char* config_filename;
117 const char* bind_address;
118 int no_nodeid_checks;
119 int print_full_config;
120 const char* configdir;
122 MgmtOpts() : configdir(MYSQLCLUSTERDIR) {};
136 const char* check_configdir()
const;
151 bool start_transporter(
const Config*);
152 bool start_mgm_service(
const Config*);
153 bool connect_to_self(
void);
157 NodeId getOwnNodeId()
const {
return _ownNodeId;};
168 Uint32 * mysql_version,
170 bool * systemShutdown,
173 Uint32 * connectCount,
174 const char **address);
180 bool force,
int *stopSelf);
182 int shutdownMGM(
int *stopCount,
bool abort,
int *stopSelf);
187 int shutdownDB(
int * cnt = 0,
bool abort =
false);
205 int start(
int processId);
211 int *stopCount,
bool nostart,
212 bool initialStart,
bool abort,
bool force,
218 int restartDB(
bool nostart,
bool initialStart,
220 int * stopCount = 0);
225 int startBackup(Uint32& backupId,
int waitCompleted= 2, Uint32 input_backupId= 0, Uint32 backuppoint= 0);
226 int abortBackup(Uint32 backupId);
227 int performBackup(Uint32* backupId);
240 int setNodeLogLevelImpl(
int processId,
const SetLogLevelOrd & ll);
253 int setTraceNo(
int processId,
int traceNo);
264 int setSignalLoggingMode(
int processId,
LogMode mode,
267 int setSignalLoggingMode(
int processId,
LogMode mode,
271 return setSignalLoggingMode(processId, mode, v);
284 int startSignalTracing(
int processId);
293 int stopSignalTracing(
int processId);
304 int dumpState(
int processId,
const Uint32 args[], Uint32 argNo);
305 int dumpState(
int processId,
const char* args);
315 const struct sockaddr *client_addr,
316 SOCKET_SIZE_TYPE *client_addr_len,
332 void config_changed(NodeId,
const Config*);
333 void setClusterLog(
const Config* conf);
343 int setConnectionDbParameter(
int node1,
int node2,
int param,
int value,
345 int getConnectionDbParameter(
int node1,
int node2,
int param,
348 bool transporter_connect(NDB_SOCKET_TYPE sockfd,
BaseString& errormsg);
350 const char *get_connect_address(Uint32 node_id);
351 void get_connected_nodes(
NodeBitmask &connected_nodes)
const;
352 SocketServer *get_socket_server() {
return &m_socket_server; }
356 int createNodegroup(
int *nodes,
int count,
int *ng);
357 int dropNodegroup(
int ng);
359 int startSchemaTrans(
SignalSender& ss, NodeId & out_nodeId,
360 Uint32 transId, Uint32 & out_transKey);
362 Uint32 transId, Uint32 transKey, Uint32
flags);
367 void status_api(
int nodeId,
369 Uint32& version, Uint32& mysql_version,
370 const char **address);
371 void status_mgmd(NodeId node_id,
373 Uint32& version, Uint32& mysql_version,
374 const char **address);
376 int sendVersionReq(
int processId, Uint32 &version,
377 Uint32& mysql_version,
const char **address);
379 int sendStopMgmd(NodeId nodeId,
408 int okToSendTo(NodeId nodeId,
bool unCond =
false);
416 int getBlockNumber(
const BaseString &blockName);
418 int alloc_node_id_req(NodeId free_node_id,
422 bool is_any_node_starting(
void);
423 bool is_any_node_stopping(
void);
424 bool is_cluster_single_user(
void);
428 const MgmtOpts& m_opts;
434 NdbMutex* m_local_config_mutex;
435 const Config* m_local_config;
437 NdbMutex *m_node_id_mutex;
439 BlockReference _ownReference;
446 struct in_addr m_connect_address[MAX_NODES];
451 virtual void trp_deliver_signal(
const NdbApiSignal* signal,
453 virtual void trp_node_status(Uint32 nodeId, Uint32
event);
458 void eventReport(
const Uint32 * theData, Uint32 len);
463 int _logLevelThreadSleep;
472 NodeId m_master_node;
481 static void *logLevelThread_C(
void *);
482 void logLevelThreadRun();
492 bool get_packed_config_from_node(NodeId nodeid,
495 void print_config(
const char* section_filter = NULL,
496 NodeId nodeid_filter = 0,
497 const char* param_filter = NULL,
498 NdbOut& out = ndbout);
500 bool reload_config(
const char* config_filename,
503 void show_variables(NdbOut& out = ndbout);
511 const struct sockaddr *client_addr,
517 const struct sockaddr *client_addr, Uint32 timeout_ms);
520 const char* get_version_string(
void)
const {
521 return m_version_string.
c_str();
524 bool request_events(
NdbNodeBitmask nodes, Uint32 reports_per_node,