MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
mgmapi.h
1 /*
2  Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
3 
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; version 2 of the License.
7 
8  This program is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  GNU General Public License for more details.
12 
13  You should have received a copy of the GNU General Public License
14  along with this program; if not, write to the Free Software
15  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
16 */
17 
18 #ifndef MGMAPI_H
19 #define MGMAPI_H
20 
21 #include "mgmapi_config_parameters.h"
22 #include "ndb_logevent.h"
23 #include "mgmapi_error.h"
24 
25 #define MGM_LOGLEVELS CFG_MAX_LOGLEVEL - CFG_MIN_LOGLEVEL + 1
26 #define NDB_MGM_MAX_LOGLEVEL 15
27 
141 /*
142  * @page ndb_logevent.h ndb_logevent.h
143  * @include ndb_logevent.h
144  */
145 
150 #include <stdio.h>
151 #include <ndb_types.h>
152 #include "ndb_logevent.h"
153 #include "mgmapi_config_parameters.h"
154 
155 #ifdef __cplusplus
156 extern "C" {
157 #endif
158 
162  typedef struct ndb_mgm_handle * NdbMgmHandle;
163 
168  NDB_MGM_NODE_TYPE_UNKNOWN = -1
170 #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
171  = NODE_TYPE_API
172 #endif
174 #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
175  = NODE_TYPE_DB
176 #endif
178 #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
179  = NODE_TYPE_MGM
180 #endif
181 #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
182  ,NDB_MGM_NODE_TYPE_MIN = 0
183  ,NDB_MGM_NODE_TYPE_MAX = 3
184 #endif
185  };
186 
211 #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
212 
216 #endif
217  };
218 
232  int node_id;
250  int version;
259  char connect_address[
260 #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
261  sizeof("000.000.000.000")+1
262 #endif
263  ];
264 
267  };
268 
278 #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
279  1
280 #endif
281  ];
282  };
283 
287  struct ndb_mgm_reply {
291  char message[256];
292  };
293 
294 #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
295 
303  };
304 
318  };
319 #endif
320 
322  enum ndb_mgm_event_severity category;
323  unsigned int value;
324  };
325 
327  enum ndb_mgm_event_category category;
328  unsigned int value;
329  };
330 
331 
332  /***************************************************************************/
345  int ndb_mgm_get_latest_error(const NdbMgmHandle handle);
346 
353  const char * ndb_mgm_get_latest_error_msg(const NdbMgmHandle handle);
354 
364  const char * ndb_mgm_get_latest_error_desc(const NdbMgmHandle handle);
365 
366 #ifndef DOXYGEN_SHOULD_SKIP_DEPRECATED
367 
374  int ndb_mgm_get_latest_error_line(const NdbMgmHandle handle);
375 #endif
376 
380  void ndb_mgm_set_error_stream(NdbMgmHandle, FILE *);
381 
382 
395  NdbMgmHandle ndb_mgm_create_handle();
396 
402  void ndb_mgm_destroy_handle(NdbMgmHandle * handle);
403 
410  void ndb_mgm_set_name(NdbMgmHandle handle, const char *name);
411 
427  int ndb_mgm_set_ignore_sigpipe(NdbMgmHandle handle, int val);
428 
452  int ndb_mgm_set_connectstring(NdbMgmHandle handle,
453  const char *connect_string);
454 
465  int ndb_mgm_number_of_mgmd_in_connect_string(NdbMgmHandle handle);
466 
467  int ndb_mgm_set_configuration_nodeid(NdbMgmHandle handle, int nodeid);
468 
476  int ndb_mgm_set_bindaddress(NdbMgmHandle, const char * arg);
477 
491  const char *ndb_mgm_get_connectstring(NdbMgmHandle handle, char *buf, int buf_sz);
492 
500  int ndb_mgm_set_connect_timeout(NdbMgmHandle handle, unsigned int seconds);
501 
512  int ndb_mgm_set_timeout(NdbMgmHandle handle, unsigned int timeout_ms);
513 
532  int ndb_mgm_connect(NdbMgmHandle handle, int no_retries,
533  int retry_delay_in_seconds, int verbose);
540  int ndb_mgm_is_connected(NdbMgmHandle handle);
541 
548  int ndb_mgm_disconnect(NdbMgmHandle handle);
549 
558  int ndb_mgm_get_configuration_nodeid(NdbMgmHandle handle);
559 
567  int ndb_mgm_get_connected_port(NdbMgmHandle handle);
568 
576  const char *ndb_mgm_get_connected_host(NdbMgmHandle handle);
577 
585  const char *ndb_mgm_get_connected_bind_address(NdbMgmHandle handle);
586 
602  int ndb_mgm_get_version(NdbMgmHandle handle,
603  int *major, int *minor, int* build,
604  int len, char* str);
605 
606 #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
607 
620 
628 
636  const char **str);
637 
644  enum ndb_mgm_node_status ndb_mgm_match_node_status(const char * status);
645 
652  const char * ndb_mgm_get_node_status_string(enum ndb_mgm_node_status status);
653 
654  const char * ndb_mgm_get_event_severity_string(enum ndb_mgm_event_severity);
655  enum ndb_mgm_event_category ndb_mgm_match_event_category(const char *);
656  const char * ndb_mgm_get_event_category_string(enum ndb_mgm_event_category);
657 #endif
658 
674  struct ndb_mgm_cluster_state * ndb_mgm_get_status(NdbMgmHandle handle);
675 
676 
691  struct ndb_mgm_cluster_state *
692  ndb_mgm_get_status2(NdbMgmHandle handle,
693  const enum ndb_mgm_node_type types[]);
694 
695 
696 
707  int ndb_mgm_dump_state(NdbMgmHandle handle,
708  int nodeId,
709  const int * args,
710  int num_args,
711  struct ndb_mgm_reply* reply);
712 
720  struct ndb_mgm_configuration *
721  ndb_mgm_get_configuration_from_node(NdbMgmHandle handle,
722  int nodeid);
723 
724 
746  int ndb_mgm_stop(NdbMgmHandle handle, int no_of_nodes,
747  const int * node_list);
748 
763  int ndb_mgm_stop2(NdbMgmHandle handle, int no_of_nodes,
764  const int * node_list, int abort);
765 
784  int ndb_mgm_stop3(NdbMgmHandle handle, int no_of_nodes,
785  const int * node_list, int abort, int *disconnect);
786 
807  int ndb_mgm_stop4(NdbMgmHandle handle, int no_of_nodes,
808  const int * node_list, int abort, int force,
809  int *disconnect);
810 
826  int ndb_mgm_restart(NdbMgmHandle handle, int no_of_nodes,
827  const int * node_list);
828 
846  int ndb_mgm_restart2(NdbMgmHandle handle, int no_of_nodes,
847  const int * node_list, int initial,
848  int nostart, int abort);
849 
871  int ndb_mgm_restart3(NdbMgmHandle handle, int no_of_nodes,
872  const int * node_list, int initial,
873  int nostart, int abort, int *disconnect);
874 
898  int ndb_mgm_restart4(NdbMgmHandle handle, int no_of_nodes,
899  const int * node_list, int initial,
900  int nostart, int abort, int force, int *disconnect);
901 
920  int ndb_mgm_start(NdbMgmHandle handle,
921  int no_of_nodes,
922  const int * node_list);
923 
940  int ndb_mgm_set_clusterlog_severity_filter(NdbMgmHandle handle,
941  enum ndb_mgm_event_severity severity,
942  int enable,
943  struct ndb_mgm_reply* reply);
963  int ndb_mgm_get_clusterlog_severity_filter(NdbMgmHandle handle,
964  struct ndb_mgm_severity* severity,
965  unsigned int severity_size);
966 
967 #ifndef DOXYGEN_SHOULD_SKIP_DEPRECATED
968 
985  const unsigned int *ndb_mgm_get_clusterlog_severity_filter_old(NdbMgmHandle handle);
986 #endif
987 
998  int ndb_mgm_set_clusterlog_loglevel(NdbMgmHandle handle,
999  int nodeId,
1000  enum ndb_mgm_event_category category,
1001  int level,
1002  struct ndb_mgm_reply* reply);
1003 
1015  int ndb_mgm_get_clusterlog_loglevel(NdbMgmHandle handle,
1016  struct ndb_mgm_loglevel* loglevel,
1017  unsigned int loglevel_size);
1018 
1019 #ifndef DOXYGEN_SHOULD_SKIP_DEPRECATED
1020 
1028  const unsigned int *ndb_mgm_get_clusterlog_loglevel_old(NdbMgmHandle handle);
1029 #endif
1030 
1031 
1048 #ifdef NDB_WIN
1049  SOCKET ndb_mgm_listen_event(NdbMgmHandle handle, const int filter[]);
1050 #else
1051  int ndb_mgm_listen_event(NdbMgmHandle handle, const int filter[]);
1052 #endif
1053 
1054 #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
1055 
1065  int ndb_mgm_set_loglevel_node(NdbMgmHandle handle,
1066  int nodeId,
1067  enum ndb_mgm_event_category category,
1068  int level,
1069  struct ndb_mgm_reply* reply);
1070 #endif
1071 
1076 
1086  NdbLogEventHandle ndb_mgm_create_logevent_handle(NdbMgmHandle,
1087  const int filter[]);
1088  void ndb_mgm_destroy_logevent_handle(NdbLogEventHandle*);
1089 
1098 #ifdef NDB_WIN
1099  SOCKET ndb_logevent_get_fd(const NdbLogEventHandle);
1100 #else
1101  int ndb_logevent_get_fd(const NdbLogEventHandle);
1102 #endif
1103 
1115  int ndb_logevent_get_next(const NdbLogEventHandle,
1116  struct ndb_logevent *dst,
1117  unsigned timeout_in_milliseconds);
1118 
1124  int ndb_logevent_get_latest_error(const NdbLogEventHandle);
1125 
1131  const char *ndb_logevent_get_latest_error_msg(const NdbLogEventHandle);
1132 
1133 
1153  int ndb_mgm_start_backup(NdbMgmHandle handle, int wait_completed,
1154  unsigned int* backup_id,
1155  struct ndb_mgm_reply* reply);
1156 
1171  int ndb_mgm_start_backup2(NdbMgmHandle handle, int wait_completed,
1172  unsigned int* backup_id,
1173  struct ndb_mgm_reply* reply,
1174  unsigned int input_backupId);
1175 
1191  int ndb_mgm_start_backup3(NdbMgmHandle handle, int wait_completed,
1192  unsigned int* backup_id,
1193  struct ndb_mgm_reply* reply,
1194  unsigned int input_backupId,
1195  unsigned int backuppoint);
1196 
1205  int ndb_mgm_abort_backup(NdbMgmHandle handle, unsigned int backup_id,
1206  struct ndb_mgm_reply* reply);
1207 
1208 
1223  int ndb_mgm_enter_single_user(NdbMgmHandle handle, unsigned int nodeId,
1224  struct ndb_mgm_reply* reply);
1225 
1234  int ndb_mgm_exit_single_user(NdbMgmHandle handle,
1235  struct ndb_mgm_reply* reply);
1236 
1237 #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
1238 
1254  struct ndb_mgm_configuration * ndb_mgm_get_configuration(NdbMgmHandle handle,
1255  unsigned version);
1256  void ndb_mgm_destroy_configuration(struct ndb_mgm_configuration *);
1257 
1258  int ndb_mgm_alloc_nodeid(NdbMgmHandle handle,
1259  unsigned version, int nodetype, int log_event);
1260 
1276  int ndb_mgm_end_session(NdbMgmHandle handle);
1277 
1290 #ifdef NDB_WIN
1291  SOCKET ndb_mgm_get_fd(NdbMgmHandle handle);
1292 #else
1293  int ndb_mgm_get_fd(NdbMgmHandle handle);
1294 #endif
1295 
1299  Uint32 ndb_mgm_get_mgmd_nodeid(NdbMgmHandle handle);
1300 
1305 
1307  (struct ndb_mgm_configuration *, unsigned type_of_section);
1308  void ndb_mgm_destroy_iterator(ndb_mgm_configuration_iterator*);
1309 
1310  int ndb_mgm_first(ndb_mgm_configuration_iterator*);
1311  int ndb_mgm_next(ndb_mgm_configuration_iterator*);
1312  int ndb_mgm_valid(const ndb_mgm_configuration_iterator*);
1313  int ndb_mgm_find(ndb_mgm_configuration_iterator*,
1314  int param, unsigned value);
1315 
1316  int ndb_mgm_get_int_parameter(const ndb_mgm_configuration_iterator*,
1317  int param, unsigned * value);
1318  int ndb_mgm_get_int64_parameter(const ndb_mgm_configuration_iterator*,
1319  int param, Uint64 * value);
1320  int ndb_mgm_get_string_parameter(const ndb_mgm_configuration_iterator*,
1321  int param, const char ** value);
1322  int ndb_mgm_purge_stale_sessions(NdbMgmHandle handle, char **);
1323  int ndb_mgm_check_connection(NdbMgmHandle handle);
1324 
1325  int ndb_mgm_report_event(NdbMgmHandle handle, Uint32 *data, Uint32 length);
1326 
1328  {
1329  Uint32 m_id;
1330  const char * m_name;
1331  };
1332  int ndb_mgm_get_db_parameter_info(Uint32 paramId, struct ndb_mgm_param_info * info,
1333  size_t * size);
1334 #endif
1335 
1336  int ndb_mgm_create_nodegroup(NdbMgmHandle handle,
1337  int * nodes,
1338  int * ng,
1339  struct ndb_mgm_reply* mgmreply);
1340 
1341  int ndb_mgm_drop_nodegroup(NdbMgmHandle handle,
1342  int ng,
1343  struct ndb_mgm_reply* mgmreply);
1344 
1345 #ifndef DOXYGEN_SHOULD_SKIP_DEPRECATED
1346  enum ndb_mgm_clusterlog_level {
1347  NDB_MGM_ILLEGAL_CLUSTERLOG_LEVEL = -1,
1348  NDB_MGM_CLUSTERLOG_ON = 0,
1349  NDB_MGM_CLUSTERLOG_DEBUG = 1,
1350  NDB_MGM_CLUSTERLOG_INFO = 2,
1351  NDB_MGM_CLUSTERLOG_WARNING = 3,
1352  NDB_MGM_CLUSTERLOG_ERROR = 4,
1353  NDB_MGM_CLUSTERLOG_CRITICAL = 5,
1354  NDB_MGM_CLUSTERLOG_ALERT = 6,
1355  NDB_MGM_CLUSTERLOG_ALL = 7
1356  };
1357  static inline
1358  int ndb_mgm_filter_clusterlog(NdbMgmHandle h,
1359  enum ndb_mgm_clusterlog_level s,
1360  int e, struct ndb_mgm_reply* r)
1362  e,r); }
1363  static inline
1364  const unsigned int * ndb_mgm_get_logfilter(NdbMgmHandle h)
1366 
1367  static inline
1368  int ndb_mgm_set_loglevel_clusterlog(NdbMgmHandle h, int n,
1369  enum ndb_mgm_event_category c,
1370  int l, struct ndb_mgm_reply* r)
1371  { return ndb_mgm_set_clusterlog_loglevel(h,n,c,l,r); }
1372 
1373  static inline
1374  const unsigned int * ndb_mgm_get_loglevel_clusterlog(NdbMgmHandle h)
1376 
1377 #endif
1378 
1390 #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
1391  1
1392 #endif
1393  ];
1394  };
1395 
1414  struct ndb_mgm_events*
1415  ndb_mgm_dump_events(NdbMgmHandle handle, enum Ndb_logevent_type type,
1416  int no_of_nodes, const int * node_list);
1417 
1418 #ifdef __cplusplus
1419 }
1420 #endif
1421 
1424 #endif
1425