00001 /* Copyright (C) 2003 MySQL AB 00002 00003 This program is free software; you can redistribute it and/or modify 00004 it under the terms of the GNU General Public License as published by 00005 the Free Software Foundation; either version 2 of the License, or 00006 (at your option) any later version. 00007 00008 This program is distributed in the hope that it will be useful, 00009 but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00011 GNU General Public License for more details. 00012 00013 You should have received a copy of the GNU General Public License 00014 along with this program; if not, write to the Free Software 00015 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ 00016 00017 #ifndef MGMAPI_H 00018 #define MGMAPI_H 00019 00133 /* 00134 * @page ndb_logevent.h ndb_logevent.h 00135 * @include ndb_logevent.h 00136 */ 00137 00142 #include <stdio.h> 00143 #include <ndb_types.h> 00144 #include "ndb_logevent.h" 00145 #include "mgmapi_config_parameters.h" 00146 00147 #ifdef __cplusplus 00148 extern "C" { 00149 #endif 00150 00154 typedef struct ndb_mgm_handle * NdbMgmHandle; 00155 00159 enum ndb_mgm_node_type { 00160 NDB_MGM_NODE_TYPE_UNKNOWN = -1 00161 ,NDB_MGM_NODE_TYPE_API 00162 #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL 00163 = NODE_TYPE_API 00164 #endif 00165 ,NDB_MGM_NODE_TYPE_NDB 00166 #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL 00167 = NODE_TYPE_DB 00168 #endif 00169 ,NDB_MGM_NODE_TYPE_MGM 00170 #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL 00171 = NODE_TYPE_MGM 00172 #endif 00173 #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL 00174 ,NDB_MGM_NODE_TYPE_MIN = 0 00175 ,NDB_MGM_NODE_TYPE_MAX = 3 00176 #endif 00177 }; 00178 00182 enum ndb_mgm_node_status { 00184 NDB_MGM_NODE_STATUS_UNKNOWN = 0, 00186 NDB_MGM_NODE_STATUS_NO_CONTACT = 1, 00188 NDB_MGM_NODE_STATUS_NOT_STARTED = 2, 00190 NDB_MGM_NODE_STATUS_STARTING = 3, 00192 NDB_MGM_NODE_STATUS_STARTED = 4, 00194 NDB_MGM_NODE_STATUS_SHUTTING_DOWN = 5, 00196 NDB_MGM_NODE_STATUS_RESTARTING = 6, 00198 NDB_MGM_NODE_STATUS_SINGLEUSER = 7, 00200 NDB_MGM_NODE_STATUS_RESUME = 8, 00201 #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL 00202 00203 NDB_MGM_NODE_STATUS_MIN = 0, 00205 NDB_MGM_NODE_STATUS_MAX = 8 00206 #endif 00207 }; 00208 00212 enum ndb_mgm_error { 00214 NDB_MGM_NO_ERROR = 0, 00215 00216 /* Request for service errors */ 00218 NDB_MGM_ILLEGAL_CONNECT_STRING = 1001, 00220 NDB_MGM_ILLEGAL_SERVER_HANDLE = 1005, 00222 NDB_MGM_ILLEGAL_SERVER_REPLY = 1006, 00224 NDB_MGM_ILLEGAL_NUMBER_OF_NODES = 1007, 00226 NDB_MGM_ILLEGAL_NODE_STATUS = 1008, 00228 NDB_MGM_OUT_OF_MEMORY = 1009, 00230 NDB_MGM_SERVER_NOT_CONNECTED = 1010, 00232 NDB_MGM_COULD_NOT_CONNECT_TO_SOCKET = 1011, 00233 00234 /* Alloc node id failures */ 00236 NDB_MGM_ALLOCID_ERROR = 1101, 00238 NDB_MGM_ALLOCID_CONFIG_MISMATCH = 1102, 00239 00240 /* Service errors - Start/Stop Node or System */ 00242 NDB_MGM_START_FAILED = 2001, 00244 NDB_MGM_STOP_FAILED = 2002, 00246 NDB_MGM_RESTART_FAILED = 2003, 00247 00248 /* Service errors - Backup */ 00250 NDB_MGM_COULD_NOT_START_BACKUP = 3001, 00252 NDB_MGM_COULD_NOT_ABORT_BACKUP = 3002, 00253 00254 /* Service errors - Single User Mode */ 00256 NDB_MGM_COULD_NOT_ENTER_SINGLE_USER_MODE = 4001, 00258 NDB_MGM_COULD_NOT_EXIT_SINGLE_USER_MODE = 4002, 00259 00260 /* Usage errors */ 00262 NDB_MGM_USAGE_ERROR = 5001 00263 }; 00264 00265 #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL 00266 struct Ndb_Mgm_Error_Msg { 00267 enum ndb_mgm_error code; 00268 const char * msg; 00269 }; 00270 const struct Ndb_Mgm_Error_Msg ndb_mgm_error_msgs[] = { 00271 { NDB_MGM_NO_ERROR, "No error" }, 00272 00273 /* Request for service errors */ 00274 { NDB_MGM_ILLEGAL_CONNECT_STRING, "Illegal connect string" }, 00275 { NDB_MGM_ILLEGAL_SERVER_HANDLE, "Illegal server handle" }, 00276 { NDB_MGM_ILLEGAL_SERVER_REPLY, "Illegal reply from server" }, 00277 { NDB_MGM_ILLEGAL_NUMBER_OF_NODES, "Illegal number of nodes" }, 00278 { NDB_MGM_ILLEGAL_NODE_STATUS, "Illegal node status" }, 00279 { NDB_MGM_OUT_OF_MEMORY, "Out of memory" }, 00280 { NDB_MGM_SERVER_NOT_CONNECTED, "Management server not connected" }, 00281 { NDB_MGM_COULD_NOT_CONNECT_TO_SOCKET, "Could not connect to socket" }, 00282 00283 /* Service errors - Start/Stop Node or System */ 00284 { NDB_MGM_START_FAILED, "Start failed" }, 00285 { NDB_MGM_STOP_FAILED, "Stop failed" }, 00286 { NDB_MGM_RESTART_FAILED, "Restart failed" }, 00287 00288 /* Service errors - Backup */ 00289 { NDB_MGM_COULD_NOT_START_BACKUP, "Could not start backup" }, 00290 { NDB_MGM_COULD_NOT_ABORT_BACKUP, "Could not abort backup" }, 00291 00292 /* Service errors - Single User Mode */ 00293 { NDB_MGM_COULD_NOT_ENTER_SINGLE_USER_MODE, 00294 "Could not enter single user mode" }, 00295 { NDB_MGM_COULD_NOT_EXIT_SINGLE_USER_MODE, 00296 "Could not exit single user mode" }, 00297 00298 /* Usage errors */ 00299 { NDB_MGM_USAGE_ERROR, 00300 "Usage error" } 00301 }; 00302 const int ndb_mgm_noOfErrorMsgs = 00303 sizeof(ndb_mgm_error_msgs)/sizeof(struct Ndb_Mgm_Error_Msg); 00304 #endif 00305 00317 struct ndb_mgm_node_state { 00319 int node_id; 00321 enum ndb_mgm_node_type node_type; 00323 enum ndb_mgm_node_status node_status; 00330 int start_phase; 00333 int dynamic_id; 00335 int node_group; 00337 int version; 00341 int connect_count; 00346 char connect_address[ 00347 #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL 00348 sizeof("000.000.000.000")+1 00349 #endif 00350 ]; 00351 }; 00352 00357 struct ndb_mgm_cluster_state { 00359 int no_of_nodes; 00361 struct ndb_mgm_node_state node_states[ 00362 #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL 00363 1 00364 #endif 00365 ]; 00366 }; 00367 00371 struct ndb_mgm_reply { 00373 int return_code; 00375 char message[256]; 00376 }; 00377 00378 #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL 00379 00382 enum ndb_mgm_info { 00384 NDB_MGM_INFO_CLUSTER, 00386 NDB_MGM_INFO_CLUSTERLOG 00387 }; 00388 00393 enum ndb_mgm_signal_log_mode { 00395 NDB_MGM_SIGNAL_LOG_MODE_IN, 00397 NDB_MGM_SIGNAL_LOG_MODE_OUT, 00399 NDB_MGM_SIGNAL_LOG_MODE_INOUT, 00401 NDB_MGM_SIGNAL_LOG_MODE_OFF 00402 }; 00403 #endif 00404 00405 /***************************************************************************/ 00418 int ndb_mgm_get_latest_error(const NdbMgmHandle handle); 00419 00426 const char * ndb_mgm_get_latest_error_msg(const NdbMgmHandle handle); 00427 00437 const char * ndb_mgm_get_latest_error_desc(const NdbMgmHandle handle); 00438 00439 #ifndef DOXYGEN_SHOULD_SKIP_DEPRECATED 00440 00447 int ndb_mgm_get_latest_error_line(const NdbMgmHandle handle); 00448 #endif 00449 00453 void ndb_mgm_set_error_stream(NdbMgmHandle, FILE *); 00454 00455 00468 NdbMgmHandle ndb_mgm_create_handle(); 00469 00475 void ndb_mgm_destroy_handle(NdbMgmHandle * handle); 00476 00483 void ndb_mgm_set_name(NdbMgmHandle handle, const char *name); 00484 00508 int ndb_mgm_set_connectstring(NdbMgmHandle handle, 00509 const char *connect_string); 00510 00511 int ndb_mgm_set_configuration_nodeid(NdbMgmHandle handle, int nodeid); 00512 int ndb_mgm_get_configuration_nodeid(NdbMgmHandle handle); 00513 int ndb_mgm_get_connected_port(NdbMgmHandle handle); 00514 const char *ndb_mgm_get_connected_host(NdbMgmHandle handle); 00515 const char *ndb_mgm_get_connectstring(NdbMgmHandle handle, char *buf, int buf_sz); 00516 00530 const char *ndb_mgm_get_connectstring(NdbMgmHandle handle, char *buf, int buf_sz); 00531 00545 int ndb_mgm_connect(NdbMgmHandle handle, int no_retries, 00546 int retry_delay_in_seconds, int verbose); 00553 int ndb_mgm_is_connected(NdbMgmHandle handle); 00554 00561 int ndb_mgm_disconnect(NdbMgmHandle handle); 00562 00571 int ndb_mgm_get_configuration_nodeid(NdbMgmHandle handle); 00572 00580 int ndb_mgm_get_connected_port(NdbMgmHandle handle); 00581 00589 const char *ndb_mgm_get_connected_host(NdbMgmHandle handle); 00590 00591 #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL 00592 00604 enum ndb_mgm_node_type ndb_mgm_match_node_type(const char * type); 00605 00612 const char * ndb_mgm_get_node_type_string(enum ndb_mgm_node_type type); 00613 00620 const char * ndb_mgm_get_node_type_alias_string(enum ndb_mgm_node_type type, 00621 const char **str); 00622 00629 enum ndb_mgm_node_status ndb_mgm_match_node_status(const char * status); 00630 00637 const char * ndb_mgm_get_node_status_string(enum ndb_mgm_node_status status); 00638 00639 const char * ndb_mgm_get_event_severity_string(enum ndb_mgm_event_severity); 00640 ndb_mgm_event_category ndb_mgm_match_event_category(const char *); 00641 const char * ndb_mgm_get_event_category_string(enum ndb_mgm_event_category); 00642 #endif 00643 00659 struct ndb_mgm_cluster_state * ndb_mgm_get_status(NdbMgmHandle handle); 00660 00682 int ndb_mgm_stop(NdbMgmHandle handle, int no_of_nodes, 00683 const int * node_list); 00684 00699 int ndb_mgm_stop2(NdbMgmHandle handle, int no_of_nodes, 00700 const int * node_list, int abort); 00701 00720 int ndb_mgm_stop3(NdbMgmHandle handle, int no_of_nodes, 00721 const int * node_list, int abort, int *disconnect); 00722 00723 00739 int ndb_mgm_restart(NdbMgmHandle handle, int no_of_nodes, 00740 const int * node_list); 00741 00759 int ndb_mgm_restart2(NdbMgmHandle handle, int no_of_nodes, 00760 const int * node_list, int initial, 00761 int nostart, int abort); 00762 00784 int ndb_mgm_restart3(NdbMgmHandle handle, int no_of_nodes, 00785 const int * node_list, int initial, 00786 int nostart, int abort, int *disconnect); 00787 00806 int ndb_mgm_start(NdbMgmHandle handle, 00807 int no_of_nodes, 00808 const int * node_list); 00809 00826 int ndb_mgm_set_clusterlog_severity_filter(NdbMgmHandle handle, 00827 enum ndb_mgm_event_severity severity, 00828 int enable, 00829 struct ndb_mgm_reply* reply); 00847 const unsigned int *ndb_mgm_get_clusterlog_severity_filter(NdbMgmHandle handle); 00848 00859 int ndb_mgm_set_clusterlog_loglevel(NdbMgmHandle handle, 00860 int nodeId, 00861 enum ndb_mgm_event_category category, 00862 int level, 00863 struct ndb_mgm_reply* reply); 00864 00881 int ndb_mgm_listen_event(NdbMgmHandle handle, const int filter[]); 00882 00883 #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL 00884 00894 int ndb_mgm_set_loglevel_node(NdbMgmHandle handle, 00895 int nodeId, 00896 enum ndb_mgm_event_category category, 00897 int level, 00898 struct ndb_mgm_reply* reply); 00899 #endif 00900 00904 typedef struct ndb_logevent_handle * NdbLogEventHandle; 00905 00915 NdbLogEventHandle ndb_mgm_create_logevent_handle(NdbMgmHandle, 00916 const int filter[]); 00917 void ndb_mgm_destroy_logevent_handle(NdbLogEventHandle*); 00918 00927 int ndb_logevent_get_fd(const NdbLogEventHandle); 00928 00940 int ndb_logevent_get_next(const NdbLogEventHandle, 00941 struct ndb_logevent *dst, 00942 unsigned timeout_in_milliseconds); 00943 00949 int ndb_logevent_get_latest_error(const NdbLogEventHandle); 00950 00956 const char *ndb_logevent_get_latest_error_msg(const NdbLogEventHandle); 00957 00958 00978 int ndb_mgm_start_backup(NdbMgmHandle handle, int wait_completed, 00979 unsigned int* backup_id, 00980 struct ndb_mgm_reply* reply); 00981 00990 int ndb_mgm_abort_backup(NdbMgmHandle handle, unsigned int backup_id, 00991 struct ndb_mgm_reply* reply); 00992 00993 01008 int ndb_mgm_enter_single_user(NdbMgmHandle handle, unsigned int nodeId, 01009 struct ndb_mgm_reply* reply); 01010 01019 int ndb_mgm_exit_single_user(NdbMgmHandle handle, 01020 struct ndb_mgm_reply* reply); 01021 01022 #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL 01023 01039 struct ndb_mgm_configuration * ndb_mgm_get_configuration(NdbMgmHandle handle, 01040 unsigned version); 01041 void ndb_mgm_destroy_configuration(struct ndb_mgm_configuration *); 01042 01043 int ndb_mgm_alloc_nodeid(NdbMgmHandle handle, 01044 unsigned version, int nodetype, int log_event); 01045 01061 int ndb_mgm_end_session(NdbMgmHandle handle); 01062 01066 Uint32 ndb_mgm_get_mgmd_nodeid(NdbMgmHandle handle); 01067 01073 int ndb_mgm_get_version(NdbMgmHandle handle, 01074 int *major, int *minor, int* build, 01075 int len, char* str); 01076 01077 01081 typedef struct ndb_mgm_configuration_iterator ndb_mgm_configuration_iterator; 01082 01083 ndb_mgm_configuration_iterator* ndb_mgm_create_configuration_iterator 01084 (struct ndb_mgm_configuration *, unsigned type_of_section); 01085 void ndb_mgm_destroy_iterator(ndb_mgm_configuration_iterator*); 01086 01087 int ndb_mgm_first(ndb_mgm_configuration_iterator*); 01088 int ndb_mgm_next(ndb_mgm_configuration_iterator*); 01089 int ndb_mgm_valid(const ndb_mgm_configuration_iterator*); 01090 int ndb_mgm_find(ndb_mgm_configuration_iterator*, 01091 int param, unsigned value); 01092 01093 int ndb_mgm_get_int_parameter(const ndb_mgm_configuration_iterator*, 01094 int param, unsigned * value); 01095 int ndb_mgm_get_int64_parameter(const ndb_mgm_configuration_iterator*, 01096 int param, Uint64 * value); 01097 int ndb_mgm_get_string_parameter(const ndb_mgm_configuration_iterator*, 01098 int param, const char ** value); 01099 int ndb_mgm_purge_stale_sessions(NdbMgmHandle handle, char **); 01100 int ndb_mgm_check_connection(NdbMgmHandle handle); 01101 01102 int ndb_mgm_report_event(NdbMgmHandle handle, Uint32 *data, Uint32 length); 01103 #endif 01104 01105 #ifndef DOXYGEN_SHOULD_SKIP_DEPRECATED 01106 enum ndb_mgm_clusterlog_level { 01107 NDB_MGM_ILLEGAL_CLUSTERLOG_LEVEL = -1, 01108 NDB_MGM_CLUSTERLOG_ON = 0, 01109 NDB_MGM_CLUSTERLOG_DEBUG = 1, 01110 NDB_MGM_CLUSTERLOG_INFO = 2, 01111 NDB_MGM_CLUSTERLOG_WARNING = 3, 01112 NDB_MGM_CLUSTERLOG_ERROR = 4, 01113 NDB_MGM_CLUSTERLOG_CRITICAL = 5, 01114 NDB_MGM_CLUSTERLOG_ALERT = 6, 01115 NDB_MGM_CLUSTERLOG_ALL = 7 01116 }; 01117 inline 01118 int ndb_mgm_filter_clusterlog(NdbMgmHandle h, 01119 enum ndb_mgm_clusterlog_level s, 01120 int e, struct ndb_mgm_reply* r) 01121 { return ndb_mgm_set_clusterlog_severity_filter(h,(ndb_mgm_event_severity)s, 01122 e,r); } 01123 01124 inline 01125 const unsigned int *ndb_mgm_get_logfilter(NdbMgmHandle h) 01126 { return ndb_mgm_get_clusterlog_severity_filter(h); } 01127 01128 inline 01129 int ndb_mgm_set_loglevel_clusterlog(NdbMgmHandle h, int n, 01130 enum ndb_mgm_event_category c, 01131 int l, struct ndb_mgm_reply* r) 01132 { return ndb_mgm_set_clusterlog_loglevel(h,n,c,l,r); } 01133 #endif 01134 01135 #ifdef __cplusplus 01136 } 01137 #endif 01138 01141 #endif
1.4.7

