MGM_C_API


Data Structures

struct  ndb_logevent
struct  ndb_mgm_cluster_state
struct  Ndb_Mgm_Error_Msg
struct  ndb_mgm_node_state
struct  ndb_mgm_reply

Configuration handling

typedef ndb_mgm_configuration_iterator ndb_mgm_configuration_iterator
enum  ndb_mgm_clusterlog_level {
  NDB_MGM_ILLEGAL_CLUSTERLOG_LEVEL = -1, NDB_MGM_CLUSTERLOG_ON = 0, NDB_MGM_CLUSTERLOG_DEBUG = 1, NDB_MGM_CLUSTERLOG_INFO = 2,
  NDB_MGM_CLUSTERLOG_WARNING = 3, NDB_MGM_CLUSTERLOG_ERROR = 4, NDB_MGM_CLUSTERLOG_CRITICAL = 5, NDB_MGM_CLUSTERLOG_ALERT = 6,
  NDB_MGM_CLUSTERLOG_ALL = 7
}
int ndb_mgm_alloc_nodeid (NdbMgmHandle handle, unsigned version, int nodetype)
int ndb_mgm_check_connection (NdbMgmHandle handle)
ndb_mgm_configuration_iteratorndb_mgm_create_configuration_iterator (struct ndb_mgm_configuration *, unsigned type_of_section)
void ndb_mgm_destroy_configuration (struct ndb_mgm_configuration *)
void ndb_mgm_destroy_iterator (ndb_mgm_configuration_iterator *)
int ndb_mgm_filter_clusterlog (NdbMgmHandle h, enum ndb_mgm_clusterlog_level s, int e, struct ndb_mgm_reply *r)
int ndb_mgm_find (ndb_mgm_configuration_iterator *, int param, unsigned value)
int ndb_mgm_first (ndb_mgm_configuration_iterator *)
ndb_mgm_configurationndb_mgm_get_configuration (NdbMgmHandle handle, unsigned version)
int ndb_mgm_get_int64_parameter (const ndb_mgm_configuration_iterator *, int param, Uint64 *value)
int ndb_mgm_get_int_parameter (const ndb_mgm_configuration_iterator *, int param, unsigned *value)
const unsigned int * ndb_mgm_get_logfilter (NdbMgmHandle h)
Uint32 ndb_mgm_get_mgmd_nodeid (NdbMgmHandle handle)
int ndb_mgm_get_string_parameter (const ndb_mgm_configuration_iterator *, int param, const char **value)
int ndb_mgm_next (ndb_mgm_configuration_iterator *)
int ndb_mgm_purge_stale_sessions (NdbMgmHandle handle, char **)
int ndb_mgm_set_loglevel_clusterlog (NdbMgmHandle h, int n, enum ndb_mgm_event_category c, int l, struct ndb_mgm_reply *r)
int ndb_mgm_valid (const ndb_mgm_configuration_iterator *)

Functions: Listening to log events

typedef ndb_logevent_handleNdbLogEventHandle
int ndb_logevent_get_fd (const NdbLogEventHandle)
int ndb_logevent_get_latest_error (const NdbLogEventHandle)
const char * ndb_logevent_get_latest_error_msg (const NdbLogEventHandle)
int ndb_logevent_get_next (const NdbLogEventHandle, struct ndb_logevent *dst, unsigned timeout_in_milliseconds)
NdbLogEventHandle ndb_mgm_create_logevent_handle (NdbMgmHandle, const int filter[])
void ndb_mgm_destroy_logevent_handle (NdbLogEventHandle *)
int ndb_mgm_get_stat_port (NdbMgmHandle handle, struct ndb_mgm_reply *reply)
int ndb_mgm_listen_event (NdbMgmHandle handle, const int filter[])
int ndb_mgm_set_loglevel_node (NdbMgmHandle handle, int nodeId, enum ndb_mgm_event_category category, int level, struct ndb_mgm_reply *reply)

Functions: Backup

int ndb_mgm_abort_backup (NdbMgmHandle handle, unsigned int backup_id, struct ndb_mgm_reply *reply)
int ndb_mgm_start_backup (NdbMgmHandle handle, int wait_completed, unsigned int *backup_id, struct ndb_mgm_reply *reply)

Functions: Connect/Disconnect Management Server

int ndb_mgm_connect (NdbMgmHandle handle, int no_retries, int retry_delay_in_seconds, int verbose)
int ndb_mgm_disconnect (NdbMgmHandle handle)
int ndb_mgm_get_configuration_nodeid (NdbMgmHandle handle)
const char * ndb_mgm_get_connected_host (NdbMgmHandle handle)
int ndb_mgm_get_connected_port (NdbMgmHandle handle)
const char * ndb_mgm_get_connectstring (NdbMgmHandle handle, char *buf, int buf_sz)
int ndb_mgm_is_connected (NdbMgmHandle handle)
int ndb_mgm_set_configuration_nodeid (NdbMgmHandle handle, int nodeid)
int ndb_mgm_set_connectstring (NdbMgmHandle handle, const char *connect_string)

Functions: Create/Destroy Management Server Handles

NdbMgmHandle ndb_mgm_create_handle ()
void ndb_mgm_destroy_handle (NdbMgmHandle *handle)

Functions: Single User Mode

int ndb_mgm_enter_single_user (NdbMgmHandle handle, unsigned int nodeId, struct ndb_mgm_reply *reply)
int ndb_mgm_exit_single_user (NdbMgmHandle handle, struct ndb_mgm_reply *reply)

Functions: Controlling Clusterlog output

const unsigned int * ndb_mgm_get_clusterlog_severity_filter (NdbMgmHandle handle)
int ndb_mgm_set_clusterlog_loglevel (NdbMgmHandle handle, int nodeId, enum ndb_mgm_event_category category, int level, struct ndb_mgm_reply *reply)
int ndb_mgm_set_clusterlog_severity_filter (NdbMgmHandle handle, enum ndb_mgm_event_severity severity, int enable, struct ndb_mgm_reply *reply)

Functions: Used to convert between different data formats

const char * ndb_mgm_get_event_category_string (enum ndb_mgm_event_category)
const char * ndb_mgm_get_event_severity_string (enum ndb_mgm_event_severity)
const char * ndb_mgm_get_node_status_string (enum ndb_mgm_node_status status)
const char * ndb_mgm_get_node_type_alias_string (enum ndb_mgm_node_type type, const char **str)
const char * ndb_mgm_get_node_type_string (enum ndb_mgm_node_type type)
ndb_mgm_event_category ndb_mgm_match_event_category (const char *)
enum ndb_mgm_node_status ndb_mgm_match_node_status (const char *status)
enum ndb_mgm_node_type ndb_mgm_match_node_type (const char *type)

Functions: Error Handling

int ndb_mgm_get_latest_error (const NdbMgmHandle handle)
const char * ndb_mgm_get_latest_error_desc (const NdbMgmHandle handle)
int ndb_mgm_get_latest_error_line (const NdbMgmHandle handle)
const char * ndb_mgm_get_latest_error_msg (const NdbMgmHandle handle)

Functions: Cluster status

ndb_mgm_cluster_statendb_mgm_get_status (NdbMgmHandle handle)

Functions: Start/stop nodes

int ndb_mgm_restart (NdbMgmHandle handle, int no_of_nodes, const int *node_list)
int ndb_mgm_restart2 (NdbMgmHandle handle, int no_of_nodes, const int *node_list, int initial, int nostart, int abort)
int ndb_mgm_start (NdbMgmHandle handle, int no_of_nodes, const int *node_list)
int ndb_mgm_stop (NdbMgmHandle handle, int no_of_nodes, const int *node_list)
int ndb_mgm_stop2 (NdbMgmHandle handle, int no_of_nodes, const int *node_list, int abort)

Typedefs

typedef ndb_mgm_handleNdbMgmHandle

Enumerations

enum  ndb_logevent_handle_error {
  NDB_LEH_NO_ERROR, NDB_LEH_READ_ERROR, NDB_LEH_MISSING_EVENT_SPECIFIER, NDB_LEH_UNKNOWN_EVENT_TYPE,
  NDB_LEH_UNKNOWN_EVENT_VARIABLE, NDB_LEH_INTERNAL_ERROR
}
enum  Ndb_logevent_type {
  NDB_LE_ILLEGAL_TYPE = -1, NDB_LE_Connected = 0, NDB_LE_Disconnected = 1, NDB_LE_CommunicationClosed = 2,
  NDB_LE_CommunicationOpened = 3, NDB_LE_ConnectedApiVersion = 51, NDB_LE_GlobalCheckpointStarted = 4, NDB_LE_GlobalCheckpointCompleted = 5,
  NDB_LE_LocalCheckpointStarted = 6, NDB_LE_LocalCheckpointCompleted = 7, NDB_LE_LCPStoppedInCalcKeepGci = 8, NDB_LE_LCPFragmentCompleted = 9,
  NDB_LE_NDBStartStarted = 10, NDB_LE_NDBStartCompleted = 11, NDB_LE_STTORRYRecieved = 12, NDB_LE_StartPhaseCompleted = 13,
  NDB_LE_CM_REGCONF = 14, NDB_LE_CM_REGREF = 15, NDB_LE_FIND_NEIGHBOURS = 16, NDB_LE_NDBStopStarted = 17,
  NDB_LE_NDBStopAborted = 18, NDB_LE_StartREDOLog = 19, NDB_LE_StartLog = 20, NDB_LE_UNDORecordsExecuted = 21,
  NDB_LE_NR_CopyDict = 22, NDB_LE_NR_CopyDistr = 23, NDB_LE_NR_CopyFragsStarted = 24, NDB_LE_NR_CopyFragDone = 25,
  NDB_LE_NR_CopyFragsCompleted = 26, NDB_LE_NodeFailCompleted = 27, NDB_LE_NODE_FAILREP = 28, NDB_LE_ArbitState = 29,
  NDB_LE_ArbitResult = 30, NDB_LE_GCP_TakeoverStarted = 31, NDB_LE_GCP_TakeoverCompleted = 32, NDB_LE_LCP_TakeoverStarted = 33,
  NDB_LE_LCP_TakeoverCompleted = 34, NDB_LE_TransReportCounters = 35, NDB_LE_OperationReportCounters = 36, NDB_LE_TableCreated = 37,
  NDB_LE_UndoLogBlocked = 38, NDB_LE_JobStatistic = 39, NDB_LE_SendBytesStatistic = 40, NDB_LE_ReceiveBytesStatistic = 41,
  NDB_LE_MemoryUsage = 50, NDB_LE_TransporterError = 42, NDB_LE_TransporterWarning = 43, NDB_LE_MissedHeartbeat = 44,
  NDB_LE_DeadDueToHeartbeat = 45, NDB_LE_WarningEvent = 46, NDB_LE_SentHeartbeat = 47, NDB_LE_CreateLogBytes = 48,
  NDB_LE_InfoEvent = 49, NDB_LE_GrepSubscriptionInfo = 52, NDB_LE_GrepSubscriptionAlert = 53, NDB_LE_BackupStarted = 54,
  NDB_LE_BackupFailedToStart = 55, NDB_LE_BackupCompleted = 56, NDB_LE_BackupAborted = 57
}
enum  ndb_mgm_error {
  NDB_MGM_NO_ERROR = 0, NDB_MGM_ILLEGAL_CONNECT_STRING = 1001, NDB_MGM_ILLEGAL_SERVER_HANDLE = 1005, NDB_MGM_ILLEGAL_SERVER_REPLY = 1006,
  NDB_MGM_ILLEGAL_NUMBER_OF_NODES = 1007, NDB_MGM_ILLEGAL_NODE_STATUS = 1008, NDB_MGM_OUT_OF_MEMORY = 1009, NDB_MGM_SERVER_NOT_CONNECTED = 1010,
  NDB_MGM_COULD_NOT_CONNECT_TO_SOCKET = 1011, NDB_MGM_START_FAILED = 2001, NDB_MGM_STOP_FAILED = 2002, NDB_MGM_RESTART_FAILED = 2003,
  NDB_MGM_COULD_NOT_START_BACKUP = 3001, NDB_MGM_COULD_NOT_ABORT_BACKUP = 3002, NDB_MGM_COULD_NOT_ENTER_SINGLE_USER_MODE = 4001, NDB_MGM_COULD_NOT_EXIT_SINGLE_USER_MODE = 4002,
  NDB_MGM_USAGE_ERROR = 5001
}
enum  ndb_mgm_event_category {
  NDB_MGM_ILLEGAL_EVENT_CATEGORY = -1, NDB_MGM_EVENT_CATEGORY_STARTUP = CFG_LOGLEVEL_STARTUP, NDB_MGM_EVENT_CATEGORY_SHUTDOWN = CFG_LOGLEVEL_SHUTDOWN, NDB_MGM_EVENT_CATEGORY_STATISTIC = CFG_LOGLEVEL_STATISTICS,
  NDB_MGM_EVENT_CATEGORY_CHECKPOINT = CFG_LOGLEVEL_CHECKPOINT, NDB_MGM_EVENT_CATEGORY_NODE_RESTART = CFG_LOGLEVEL_NODERESTART, NDB_MGM_EVENT_CATEGORY_CONNECTION = CFG_LOGLEVEL_CONNECTION, NDB_MGM_EVENT_CATEGORY_BACKUP = CFG_LOGLEVEL_BACKUP,
  NDB_MGM_EVENT_CATEGORY_CONGESTION = CFG_LOGLEVEL_CONGESTION, NDB_MGM_EVENT_CATEGORY_DEBUG = CFG_LOGLEVEL_DEBUG, NDB_MGM_EVENT_CATEGORY_INFO = CFG_LOGLEVEL_INFO, NDB_MGM_EVENT_CATEGORY_ERROR = CFG_LOGLEVEL_ERROR,
  NDB_MGM_MIN_EVENT_CATEGORY = CFG_MIN_LOGLEVEL, NDB_MGM_MAX_EVENT_CATEGORY = CFG_MAX_LOGLEVEL
}
enum  ndb_mgm_event_severity {
  NDB_MGM_ILLEGAL_EVENT_SEVERITY = -1, NDB_MGM_EVENT_SEVERITY_ON = 0, NDB_MGM_EVENT_SEVERITY_DEBUG = 1, NDB_MGM_EVENT_SEVERITY_INFO = 2,
  NDB_MGM_EVENT_SEVERITY_WARNING = 3, NDB_MGM_EVENT_SEVERITY_ERROR = 4, NDB_MGM_EVENT_SEVERITY_CRITICAL = 5, NDB_MGM_EVENT_SEVERITY_ALERT = 6,
  NDB_MGM_EVENT_SEVERITY_ALL = 7
}
enum  ndb_mgm_info { NDB_MGM_INFO_CLUSTER, NDB_MGM_INFO_CLUSTERLOG }
enum  ndb_mgm_node_status {
  NDB_MGM_NODE_STATUS_UNKNOWN = 0, NDB_MGM_NODE_STATUS_NO_CONTACT = 1, NDB_MGM_NODE_STATUS_NOT_STARTED = 2, NDB_MGM_NODE_STATUS_STARTING = 3,
  NDB_MGM_NODE_STATUS_STARTED = 4, NDB_MGM_NODE_STATUS_SHUTTING_DOWN = 5, NDB_MGM_NODE_STATUS_RESTARTING = 6, NDB_MGM_NODE_STATUS_SINGLEUSER = 7,
  NDB_MGM_NODE_STATUS_RESUME = 8, NDB_MGM_NODE_STATUS_MIN = 0, NDB_MGM_NODE_STATUS_MAX = 8
}
enum  ndb_mgm_node_type {
  NDB_MGM_NODE_TYPE_UNKNOWN = -1, NDB_MGM_NODE_TYPE_API = NODE_TYPE_API, NDB_MGM_NODE_TYPE_NDB = NODE_TYPE_DB, NDB_MGM_NODE_TYPE_MGM = NODE_TYPE_MGM,
  NDB_MGM_NODE_TYPE_REP = NODE_TYPE_REP, NDB_MGM_NODE_TYPE_MIN = 0, NDB_MGM_NODE_TYPE_MAX = 3
}
enum  ndb_mgm_signal_log_mode { NDB_MGM_SIGNAL_LOG_MODE_IN, NDB_MGM_SIGNAL_LOG_MODE_OUT, NDB_MGM_SIGNAL_LOG_MODE_INOUT, NDB_MGM_SIGNAL_LOG_MODE_OFF }

Variables

const struct Ndb_Mgm_Error_Msg ndb_mgm_error_msgs []
const int ndb_mgm_noOfErrorMsgs


Typedef Documentation

typedef struct ndb_mgm_configuration_iterator ndb_mgm_configuration_iterator
 

Config iterator

Definition at line 995 of file mgmapi.h.

typedef struct ndb_logevent_handle* NdbLogEventHandle
 

The NdbLogEventHandle

Definition at line 844 of file mgmapi.h.

typedef struct ndb_mgm_handle* NdbMgmHandle
 

The NdbMgmHandle.

Definition at line 150 of file mgmapi.h.


Enumeration Type Documentation

enum ndb_logevent_handle_error
 

Enumerator:
NDB_LEH_NO_ERROR 
NDB_LEH_READ_ERROR 
NDB_LEH_MISSING_EVENT_SPECIFIER 
NDB_LEH_UNKNOWN_EVENT_TYPE 
NDB_LEH_UNKNOWN_EVENT_VARIABLE 
NDB_LEH_INTERNAL_ERROR 

Definition at line 603 of file ndb_logevent.h.

enum Ndb_logevent_type
 

Available log events grouped by ndb_mgm_event_category

Enumerator:
NDB_LE_ILLEGAL_TYPE 
NDB_LE_Connected  NDB_MGM_EVENT_CATEGORY_CONNECTION
NDB_LE_Disconnected  NDB_MGM_EVENT_CATEGORY_CONNECTION
NDB_LE_CommunicationClosed  NDB_MGM_EVENT_CATEGORY_CONNECTION
NDB_LE_CommunicationOpened  NDB_MGM_EVENT_CATEGORY_CONNECTION
NDB_LE_ConnectedApiVersion  NDB_MGM_EVENT_CATEGORY_CONNECTION
NDB_LE_GlobalCheckpointStarted  NDB_MGM_EVENT_CATEGORY_CHECKPOINT
NDB_LE_GlobalCheckpointCompleted  NDB_MGM_EVENT_CATEGORY_CHECKPOINT
NDB_LE_LocalCheckpointStarted  NDB_MGM_EVENT_CATEGORY_CHECKPOINT
NDB_LE_LocalCheckpointCompleted  NDB_MGM_EVENT_CATEGORY_CHECKPOINT
NDB_LE_LCPStoppedInCalcKeepGci  NDB_MGM_EVENT_CATEGORY_CHECKPOINT
NDB_LE_LCPFragmentCompleted  NDB_MGM_EVENT_CATEGORY_CHECKPOINT
NDB_LE_NDBStartStarted  NDB_MGM_EVENT_CATEGORY_STARTUP
NDB_LE_NDBStartCompleted  NDB_MGM_EVENT_CATEGORY_STARTUP
NDB_LE_STTORRYRecieved  NDB_MGM_EVENT_CATEGORY_STARTUP
NDB_LE_StartPhaseCompleted  NDB_MGM_EVENT_CATEGORY_STARTUP
NDB_LE_CM_REGCONF  NDB_MGM_EVENT_CATEGORY_STARTUP
NDB_LE_CM_REGREF  NDB_MGM_EVENT_CATEGORY_STARTUP
NDB_LE_FIND_NEIGHBOURS  NDB_MGM_EVENT_CATEGORY_STARTUP
NDB_LE_NDBStopStarted  NDB_MGM_EVENT_CATEGORY_STARTUP
NDB_LE_NDBStopAborted  NDB_MGM_EVENT_CATEGORY_STARTUP
NDB_LE_StartREDOLog  NDB_MGM_EVENT_CATEGORY_STARTUP
NDB_LE_StartLog  NDB_MGM_EVENT_CATEGORY_STARTUP
NDB_LE_UNDORecordsExecuted  NDB_MGM_EVENT_CATEGORY_STARTUP
NDB_LE_NR_CopyDict  NDB_MGM_EVENT_CATEGORY_NODE_RESTART
NDB_LE_NR_CopyDistr  NDB_MGM_EVENT_CATEGORY_NODE_RESTART
NDB_LE_NR_CopyFragsStarted  NDB_MGM_EVENT_CATEGORY_NODE_RESTART
NDB_LE_NR_CopyFragDone  NDB_MGM_EVENT_CATEGORY_NODE_RESTART
NDB_LE_NR_CopyFragsCompleted  NDB_MGM_EVENT_CATEGORY_NODE_RESTART
NDB_LE_NodeFailCompleted  NDB_MGM_EVENT_CATEGORY_NODE_RESTART
NDB_LE_NODE_FAILREP  NDB_MGM_EVENT_CATEGORY_NODE_RESTART
NDB_LE_ArbitState  NDB_MGM_EVENT_CATEGORY_NODE_RESTART
NDB_LE_ArbitResult  NDB_MGM_EVENT_CATEGORY_NODE_RESTART
NDB_LE_GCP_TakeoverStarted  NDB_MGM_EVENT_CATEGORY_NODE_RESTART
NDB_LE_GCP_TakeoverCompleted  NDB_MGM_EVENT_CATEGORY_NODE_RESTART
NDB_LE_LCP_TakeoverStarted  NDB_MGM_EVENT_CATEGORY_NODE_RESTART
NDB_LE_LCP_TakeoverCompleted  NDB_MGM_EVENT_CATEGORY_NODE_RESTART
NDB_LE_TransReportCounters  NDB_MGM_EVENT_CATEGORY_STATISTIC
NDB_LE_OperationReportCounters  NDB_MGM_EVENT_CATEGORY_STATISTIC
NDB_LE_TableCreated  NDB_MGM_EVENT_CATEGORY_STATISTIC
NDB_LE_UndoLogBlocked  NDB_MGM_EVENT_CATEGORY_STATISTIC
NDB_LE_JobStatistic  NDB_MGM_EVENT_CATEGORY_STATISTIC
NDB_LE_SendBytesStatistic  NDB_MGM_EVENT_CATEGORY_STATISTIC
NDB_LE_ReceiveBytesStatistic  NDB_MGM_EVENT_CATEGORY_STATISTIC
NDB_LE_MemoryUsage  NDB_MGM_EVENT_CATEGORY_STATISTIC
NDB_LE_TransporterError  NDB_MGM_EVENT_CATEGORY_ERROR
NDB_LE_TransporterWarning  NDB_MGM_EVENT_CATEGORY_ERROR
NDB_LE_MissedHeartbeat  NDB_MGM_EVENT_CATEGORY_ERROR
NDB_LE_DeadDueToHeartbeat  NDB_MGM_EVENT_CATEGORY_ERROR
NDB_LE_WarningEvent  NDB_MGM_EVENT_CATEGORY_ERROR
NDB_LE_SentHeartbeat  NDB_MGM_EVENT_CATEGORY_INFO
NDB_LE_CreateLogBytes  NDB_MGM_EVENT_CATEGORY_INFO
NDB_LE_InfoEvent  NDB_MGM_EVENT_CATEGORY_INFO
NDB_LE_GrepSubscriptionInfo 
NDB_LE_GrepSubscriptionAlert 
NDB_LE_BackupStarted  NDB_MGM_EVENT_CATEGORY_BACKUP
NDB_LE_BackupFailedToStart  NDB_MGM_EVENT_CATEGORY_BACKUP
NDB_LE_BackupCompleted  NDB_MGM_EVENT_CATEGORY_BACKUP
NDB_LE_BackupAborted  NDB_MGM_EVENT_CATEGORY_BACKUP

Definition at line 34 of file ndb_logevent.h.

00034                          {
00035 
00036     NDB_LE_ILLEGAL_TYPE = -1,
00037 
00039     NDB_LE_Connected = 0,
00041     NDB_LE_Disconnected = 1,
00043     NDB_LE_CommunicationClosed = 2,
00045     NDB_LE_CommunicationOpened = 3,
00047     NDB_LE_ConnectedApiVersion = 51,
00048 
00050     NDB_LE_GlobalCheckpointStarted = 4,
00052     NDB_LE_GlobalCheckpointCompleted = 5,
00054     NDB_LE_LocalCheckpointStarted = 6,
00056     NDB_LE_LocalCheckpointCompleted = 7,
00058     NDB_LE_LCPStoppedInCalcKeepGci = 8,
00060     NDB_LE_LCPFragmentCompleted = 9,
00061 
00063     NDB_LE_NDBStartStarted = 10,
00065     NDB_LE_NDBStartCompleted = 11,
00067     NDB_LE_STTORRYRecieved = 12,
00069     NDB_LE_StartPhaseCompleted = 13,
00071     NDB_LE_CM_REGCONF = 14,
00073     NDB_LE_CM_REGREF = 15,
00075     NDB_LE_FIND_NEIGHBOURS = 16,
00077     NDB_LE_NDBStopStarted = 17,
00079     NDB_LE_NDBStopAborted = 18,
00081     NDB_LE_StartREDOLog = 19,
00083     NDB_LE_StartLog = 20,
00085     NDB_LE_UNDORecordsExecuted = 21,
00086 
00088     NDB_LE_NR_CopyDict = 22,
00090     NDB_LE_NR_CopyDistr = 23,
00092     NDB_LE_NR_CopyFragsStarted = 24,
00094     NDB_LE_NR_CopyFragDone = 25,
00096     NDB_LE_NR_CopyFragsCompleted = 26,
00097 
00098     /* NODEFAIL */
00100     NDB_LE_NodeFailCompleted = 27,
00102     NDB_LE_NODE_FAILREP = 28,
00104     NDB_LE_ArbitState = 29,
00106     NDB_LE_ArbitResult = 30,
00108     NDB_LE_GCP_TakeoverStarted = 31,
00110     NDB_LE_GCP_TakeoverCompleted = 32,
00112     NDB_LE_LCP_TakeoverStarted = 33,
00114     NDB_LE_LCP_TakeoverCompleted = 34,
00115 
00117     NDB_LE_TransReportCounters = 35,
00119     NDB_LE_OperationReportCounters = 36,
00121     NDB_LE_TableCreated = 37,
00123     NDB_LE_UndoLogBlocked = 38,
00125     NDB_LE_JobStatistic = 39,
00127     NDB_LE_SendBytesStatistic = 40,
00129     NDB_LE_ReceiveBytesStatistic = 41,
00131     NDB_LE_MemoryUsage = 50,
00132 
00134     NDB_LE_TransporterError = 42,
00136     NDB_LE_TransporterWarning = 43,
00138     NDB_LE_MissedHeartbeat = 44,
00140     NDB_LE_DeadDueToHeartbeat = 45,
00142     NDB_LE_WarningEvent = 46,
00143 
00145     NDB_LE_SentHeartbeat = 47,
00147     NDB_LE_CreateLogBytes = 48,
00149     NDB_LE_InfoEvent = 49,
00150 
00151     /* GREP */
00152     NDB_LE_GrepSubscriptionInfo = 52,
00153     NDB_LE_GrepSubscriptionAlert = 53,
00154 
00156     NDB_LE_BackupStarted = 54,
00158     NDB_LE_BackupFailedToStart = 55,
00160     NDB_LE_BackupCompleted = 56,
00162     NDB_LE_BackupAborted = 57
00163   };

enum ndb_mgm_clusterlog_level
 

Enumerator:
NDB_MGM_ILLEGAL_CLUSTERLOG_LEVEL 
NDB_MGM_CLUSTERLOG_ON 
NDB_MGM_CLUSTERLOG_DEBUG 
NDB_MGM_CLUSTERLOG_INFO 
NDB_MGM_CLUSTERLOG_WARNING 
NDB_MGM_CLUSTERLOG_ERROR 
NDB_MGM_CLUSTERLOG_CRITICAL 
NDB_MGM_CLUSTERLOG_ALERT 
NDB_MGM_CLUSTERLOG_ALL 

Definition at line 1018 of file mgmapi.h.

enum ndb_mgm_error
 

Error codes

Enumerator:
NDB_MGM_NO_ERROR  Not an error
NDB_MGM_ILLEGAL_CONNECT_STRING  Supplied connectstring is illegal
NDB_MGM_ILLEGAL_SERVER_HANDLE  Supplied NdbMgmHandle is illegal
NDB_MGM_ILLEGAL_SERVER_REPLY  Illegal reply from server
NDB_MGM_ILLEGAL_NUMBER_OF_NODES  Illegal number of nodes
NDB_MGM_ILLEGAL_NODE_STATUS  Illegal node status
NDB_MGM_OUT_OF_MEMORY  Memory allocation error
NDB_MGM_SERVER_NOT_CONNECTED  Management server not connected
NDB_MGM_COULD_NOT_CONNECT_TO_SOCKET  Could not connect to socker
NDB_MGM_START_FAILED  Start failed
NDB_MGM_STOP_FAILED  Stop failed
NDB_MGM_RESTART_FAILED  Restart failed
NDB_MGM_COULD_NOT_START_BACKUP  Unable to start backup
NDB_MGM_COULD_NOT_ABORT_BACKUP  Unable to abort backup
NDB_MGM_COULD_NOT_ENTER_SINGLE_USER_MODE  Unable to enter single user mode
NDB_MGM_COULD_NOT_EXIT_SINGLE_USER_MODE  Unable to exit single user mode
NDB_MGM_USAGE_ERROR  Usage error

Definition at line 209 of file mgmapi.h.

00212                      {
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     /* Service errors - Start/Stop Node or System */
00236     NDB_MGM_START_FAILED = 2001,
00238     NDB_MGM_STOP_FAILED = 2002,
00240     NDB_MGM_RESTART_FAILED = 2003,
00241 
00242     /* Service errors - Backup */
00244     NDB_MGM_COULD_NOT_START_BACKUP = 3001,
00246     NDB_MGM_COULD_NOT_ABORT_BACKUP = 3002,
00247 
00248     /* Service errors - Single User Mode */
00250     NDB_MGM_COULD_NOT_ENTER_SINGLE_USER_MODE = 4001,
00252     NDB_MGM_COULD_NOT_EXIT_SINGLE_USER_MODE = 4002,
00253 
00254     /* Usage errors */

enum ndb_mgm_event_category
 

Log event categories, used to set filter level on the log events using ndb_mgm_set_clusterlog_loglevel() and ndb_mgm_listen_event()

Enumerator:
NDB_MGM_ILLEGAL_EVENT_CATEGORY  Invalid log event category
NDB_MGM_EVENT_CATEGORY_STARTUP  Log events during all kinds of startups
NDB_MGM_EVENT_CATEGORY_SHUTDOWN  Log events during shutdown
NDB_MGM_EVENT_CATEGORY_STATISTIC  Statistics log events
NDB_MGM_EVENT_CATEGORY_CHECKPOINT  Log events related to checkpoints
NDB_MGM_EVENT_CATEGORY_NODE_RESTART  Log events during node restart
NDB_MGM_EVENT_CATEGORY_CONNECTION  Log events related to connections between cluster nodes
NDB_MGM_EVENT_CATEGORY_BACKUP  Backup related log events
NDB_MGM_EVENT_CATEGORY_CONGESTION  Congestion related log events
NDB_MGM_EVENT_CATEGORY_DEBUG  Loglevel debug
NDB_MGM_EVENT_CATEGORY_INFO  Uncategorized log events (severity info)
NDB_MGM_EVENT_CATEGORY_ERROR  Uncategorized log events (severity warning or higher)
NDB_MGM_MIN_EVENT_CATEGORY 
NDB_MGM_MAX_EVENT_CATEGORY 

Definition at line 199 of file ndb_logevent.h.

enum ndb_mgm_event_severity
 

Log event severities (used to filter the cluster log, ndb_mgm_set_clusterlog_severity_filter(), and filter listening to events ndb_mgm_listen_event())

Enumerator:
NDB_MGM_ILLEGAL_EVENT_SEVERITY 
NDB_MGM_EVENT_SEVERITY_ON  Cluster log on
NDB_MGM_EVENT_SEVERITY_DEBUG  Used in NDB Cluster developement
NDB_MGM_EVENT_SEVERITY_INFO  Informational messages
NDB_MGM_EVENT_SEVERITY_WARNING  Conditions that are not error condition, but might require handling.
NDB_MGM_EVENT_SEVERITY_ERROR  Conditions that, while not fatal, should be corrected.
NDB_MGM_EVENT_SEVERITY_CRITICAL  Critical conditions, like device errors or out of resources
NDB_MGM_EVENT_SEVERITY_ALERT  A condition that should be corrected immediately, such as a corrupted system
NDB_MGM_EVENT_SEVERITY_ALL  All severities

Definition at line 170 of file ndb_logevent.h.

00170                               {
00171     NDB_MGM_ILLEGAL_EVENT_SEVERITY = -1,
00172     /*  Must be a nonnegative integer (used for array indexing) */
00174     NDB_MGM_EVENT_SEVERITY_ON    = 0,
00176     NDB_MGM_EVENT_SEVERITY_DEBUG = 1,
00178     NDB_MGM_EVENT_SEVERITY_INFO = 2,
00181     NDB_MGM_EVENT_SEVERITY_WARNING = 3,
00183     NDB_MGM_EVENT_SEVERITY_ERROR = 4,
00185     NDB_MGM_EVENT_SEVERITY_CRITICAL = 5,
00189     NDB_MGM_EVENT_SEVERITY_ALERT = 6,
00190     /* must be next number, works as bound in loop */
00192     NDB_MGM_EVENT_SEVERITY_ALL = 7
00193   };

enum ndb_mgm_info
 

Default information types

Enumerator:
NDB_MGM_INFO_CLUSTER  ?
NDB_MGM_INFO_CLUSTERLOG  Cluster log

Definition at line 373 of file mgmapi.h.

00376                     {
00378     NDB_MGM_INFO_CLUSTER,

enum ndb_mgm_node_status
 

Database node status

Enumerator:
NDB_MGM_NODE_STATUS_UNKNOWN  Node status not known
NDB_MGM_NODE_STATUS_NO_CONTACT  No contact with node
NDB_MGM_NODE_STATUS_NOT_STARTED  Has not run starting protocol
NDB_MGM_NODE_STATUS_STARTING  Is running starting protocol
NDB_MGM_NODE_STATUS_STARTED  Running
NDB_MGM_NODE_STATUS_SHUTTING_DOWN  Is shutting down
NDB_MGM_NODE_STATUS_RESTARTING  Is restarting
NDB_MGM_NODE_STATUS_SINGLEUSER  Maintenance mode
NDB_MGM_NODE_STATUS_RESUME  Resume mode
NDB_MGM_NODE_STATUS_MIN  Min valid value
NDB_MGM_NODE_STATUS_MAX  Max valid value

Definition at line 179 of file mgmapi.h.

enum ndb_mgm_node_type
 

NDB Cluster node types

Enumerator:
NDB_MGM_NODE_TYPE_UNKNOWN 
NDB_MGM_NODE_TYPE_API  An application (NdbApi) node
NDB_MGM_NODE_TYPE_NDB  A database node
NDB_MGM_NODE_TYPE_MGM  A management server node
NDB_MGM_NODE_TYPE_REP 
NDB_MGM_NODE_TYPE_MIN 
NDB_MGM_NODE_TYPE_MAX 

Definition at line 155 of file mgmapi.h.

00158                          {
00159     NDB_MGM_NODE_TYPE_UNKNOWN = -1  
00160     ,NDB_MGM_NODE_TYPE_API    
00161 #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
00162     = NODE_TYPE_API
00163 #endif
00164     ,NDB_MGM_NODE_TYPE_NDB    
00165 #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
00166     = NODE_TYPE_DB
00167 #endif
00168     ,NDB_MGM_NODE_TYPE_MGM    
00169 #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
00170     = NODE_TYPE_MGM
00171 #endif
00172 #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
00173     ,NDB_MGM_NODE_TYPE_REP = NODE_TYPE_REP  
00174     ,NDB_MGM_NODE_TYPE_MIN     = 0          

enum ndb_mgm_signal_log_mode
 

Signal log modes (Used only in the development of NDB Cluster.)

Enumerator:
NDB_MGM_SIGNAL_LOG_MODE_IN  Log receiving signals
NDB_MGM_SIGNAL_LOG_MODE_OUT  Log sending signals
NDB_MGM_SIGNAL_LOG_MODE_INOUT  Log both sending/receiving
NDB_MGM_SIGNAL_LOG_MODE_OFF  Log off

Definition at line 384 of file mgmapi.h.


Function Documentation

int ndb_logevent_get_fd const   NdbLogEventHandle  ) 
 

Retrieve filedescriptor from NdbLogEventHandle. May be used in e.g. an application select() statement.

Note:
Do not attemt to read from it, it will corrupt the parsing.
Returns:
filedescriptor, -1 on failure.

int ndb_logevent_get_latest_error const   NdbLogEventHandle  ) 
 

Retrieve laterst error code

Returns:
error code

const char* ndb_logevent_get_latest_error_msg const   NdbLogEventHandle  ) 
 

Retrieve laterst error message

Returns:
error message

int ndb_logevent_get_next const   NdbLogEventHandle,
struct ndb_logevent dst,
unsigned  timeout_in_milliseconds
 

Attempt to retrieve next log event and will fill in the supplied struct dst

Parameters:
dst Pointer to struct to fill in event information
timeout_in_milliseconds Timeout for waiting for event
Returns:
>0 if event exists, 0 no event (timed out), or -1 on error.
Note:
Return value <=0 will leave dst untouched

Referenced by main().

int ndb_mgm_abort_backup NdbMgmHandle  handle,
unsigned int  backup_id,
struct ndb_mgm_reply reply
 

Abort backup

Parameters:
handle NDB management handle.
backup_id Backup ID.
reply Reply message.
Returns:
-1 on error.

Definition at line 1647 of file mgmapi.cpp.

References args, buf, CHECK_CONNECTED, CHECK_HANDLE, CHECK_REPLY, Properties::get(), MGM_ARG, MGM_CMD, MGM_END, ndb_mgm_call(), NDB_MGM_COULD_NOT_ABORT_BACKUP, NDB_MGM_NO_ERROR, NULL, Properties::put(), and SET_ERROR.

Referenced by CommandInterpreter::executeAbortBackup().

01649 {
01650   SET_ERROR(handle, NDB_MGM_NO_ERROR, "Executing: ndb_mgm_abort_backup");
01651   const ParserRow<ParserDummy> stop_backup_reply[] = {
01652     MGM_CMD("abort backup reply", NULL, ""),
01653     MGM_ARG("result", String, Mandatory, "Error message"),    
01654     MGM_END()
01655   };
01656   CHECK_HANDLE(handle, -1);
01657   CHECK_CONNECTED(handle, -1);
01658   
01659   Properties args;
01660   args.put("id", backupId);
01661 
01662   const Properties *prop;
01663   prop = ndb_mgm_call(handle, stop_backup_reply, "abort backup", &args);
01664   CHECK_REPLY(prop, -1);
01665 
01666   const char * buf;
01667   prop->get("result", &buf);
01668   if(strcmp(buf,"Ok")!=0) {
01669     SET_ERROR(handle, NDB_MGM_COULD_NOT_ABORT_BACKUP, buf);
01670     delete prop;    
01671     return -1;
01672   }
01673 
01674   delete prop;
01675   return 0;
01676 }

int ndb_mgm_alloc_nodeid NdbMgmHandle  handle,
unsigned  version,
int  nodetype
 

Referenced by ConfigRetriever::allocNodeId().

int ndb_mgm_check_connection NdbMgmHandle  handle  ) 
 

Definition at line 2083 of file mgmapi.cpp.

References buf, CHECK_CONNECTED, CHECK_HANDLE, SocketInputStream::gets(), ndb_mgm_disconnect(), SocketOutputStream::println(), ndb_mgm_handle::read_timeout, and ndb_mgm_handle::socket.

Referenced by CommandInterpreter::printError().

02083                                              {
02084   CHECK_HANDLE(handle, 0);
02085   CHECK_CONNECTED(handle, 0);
02086   SocketOutputStream out(handle->socket);
02087   SocketInputStream in(handle->socket, handle->read_timeout);
02088   char buf[32];
02089 
02090   if (out.println("check connection"))
02091     goto ndb_mgm_check_connection_error;
02092 
02093   if (out.println(""))
02094     goto ndb_mgm_check_connection_error;
02095 
02096   in.gets(buf, sizeof(buf));
02097   if(strcmp("check connection reply\n", buf))
02098     goto ndb_mgm_check_connection_error;
02099 
02100   in.gets(buf, sizeof(buf));
02101   if(strcmp("result: Ok\n", buf))
02102     goto ndb_mgm_check_connection_error;
02103 
02104   in.gets(buf, sizeof(buf));
02105   if(strcmp("\n", buf))
02106     goto ndb_mgm_check_connection_error;
02107 
02108   return 0;
02109 
02110 ndb_mgm_check_connection_error:
02111   ndb_mgm_disconnect(handle);
02112   return -1;
02113 }

int ndb_mgm_connect NdbMgmHandle  handle,
int  no_retries,
int  retry_delay_in_seconds,
int  verbose
 

Connect to a management server

Do connect

Definition at line 363 of file mgmapi.cpp.

References buf, ndb_mgm_handle::cfg, ndb_mgm_handle::cfg_i, CHECK_HANDLE, SocketClient::connect(), ndb_mgm_handle::connected, DBUG_ENTER, DBUG_PRINT, DBUG_RETURN, LocalConfig::ids, LocalConfig::makeConnectString(), MgmId_TCP, NDB_INVALID_SOCKET, NDB_MGM_COULD_NOT_CONNECT_TO_SOCKET, NDB_MGM_NO_ERROR, NDB_SOCKET_TYPE, ndbout(), ndbout_c(), NdbSleep_SecSleep(), SET_ERROR, setError(), Vector< T >::size(), BaseString::snprintf(), and ndb_mgm_handle::socket.

Referenced by NdbRestarter::connect(), CommandInterpreter::connect(), connect_ndb_mgm(), TransporterRegistry::connect_ndb_mgmd(), ConfigRetriever::do_connect(), main(), TransporterRegistry::start_clients_thread(), and waitClusterStatus().

00365 {
00366   SET_ERROR(handle, NDB_MGM_NO_ERROR, "Executing: ndb_mgm_connect");
00367   CHECK_HANDLE(handle, -1);
00368 
00369   DBUG_ENTER("ndb_mgm_connect");
00370 #ifdef MGMAPI_LOG
00371 
00374   char logname[64];
00375   BaseString::snprintf(logname, 64, "mgmapi.log");
00376   handle->logfile = fopen(logname, "w");
00377 #endif
00378 
00382   LocalConfig &cfg= handle->cfg;
00383   NDB_SOCKET_TYPE sockfd= NDB_INVALID_SOCKET;
00384   Uint32 i;
00385   while (sockfd == NDB_INVALID_SOCKET)
00386   {
00387     // do all the mgmt servers
00388     for (i = 0; i < cfg.ids.size(); i++)
00389     {
00390       if (cfg.ids[i].type != MgmId_TCP)
00391         continue;
00392       SocketClient s(cfg.ids[i].name.c_str(), cfg.ids[i].port);
00393       sockfd = s.connect();
00394       if (sockfd != NDB_INVALID_SOCKET)
00395         break;
00396     }
00397     if (sockfd != NDB_INVALID_SOCKET)
00398       break;
00399 #ifndef DBUG_OFF
00400     {
00401       char buf[1024];
00402       DBUG_PRINT("info",("Unable to connect with connect string: %s",
00403                          cfg.makeConnectString(buf,sizeof(buf))));
00404     }
00405 #endif
00406     if (verbose > 0) {
00407       char buf[1024];
00408       ndbout_c("Unable to connect with connect string: %s",
00409                cfg.makeConnectString(buf,sizeof(buf)));
00410       verbose= -1;
00411     }
00412     if (no_retries == 0) {
00413       char buf[1024];
00414       setError(handle, NDB_MGM_COULD_NOT_CONNECT_TO_SOCKET, __LINE__,
00415                "Unable to connect with connect string: %s",
00416                cfg.makeConnectString(buf,sizeof(buf)));
00417       if (verbose == -2)
00418         ndbout << ", failed." << endl;
00419       DBUG_RETURN(-1);
00420     }
00421     if (verbose == -1) {
00422       ndbout << "Retrying every " << retry_delay_in_seconds << " seconds";
00423       if (no_retries > 0)
00424         ndbout << ". Attempts left:";
00425       else
00426         ndbout << ", until connected.";;        
00427       ndbout << flush;
00428       verbose= -2;
00429     }
00430     if (no_retries > 0) {
00431       if (verbose == -2) {
00432         ndbout << " " << no_retries;
00433         ndbout << flush;
00434       }
00435       no_retries--;
00436     }
00437     NdbSleep_SecSleep(retry_delay_in_seconds);
00438   }
00439   if (verbose == -2)
00440     ndbout << endl;
00441 
00442   handle->cfg_i = i;
00443 
00444   handle->socket    = sockfd;
00445   handle->connected = 1;
00446 
00447   DBUG_RETURN(0);
00448 }

ndb_mgm_configuration_iterator* ndb_mgm_create_configuration_iterator ndb_mgm_configuration conf,
unsigned  type_of_section
 

Published C interface

Definition at line 94 of file mgmapi_configuration.cpp.

References malloc.

Referenced by Configuration::calcSizeAlt(), CommandInterpreter::executeShow(), Configuration::setupConfiguration(), and ConfigRetriever::verifyConfig().

00095                                                                {
00096   ndb_mgm_configuration_iterator* iter = (ndb_mgm_configuration_iterator*)
00097     malloc(sizeof(ndb_mgm_configuration_iterator));
00098   if(iter == 0)
00099     return 0;
00100 
00101   return new(iter) ndb_mgm_configuration_iterator(* conf, type_of_section);
00102 }

NdbMgmHandle ndb_mgm_create_handle  ) 
 

Create a handle to a management server.

Returns:
A management handle
or NULL if no management handle could be created.

Definition at line 145 of file mgmapi.cpp.

References ndb_mgm_handle::cfg, ndb_mgm_handle::cfg_i, ndb_mgm_handle::connected, DBUG_ENTER, DBUG_PRINT, DBUG_RETURN, h, LocalConfig::init(), ndb_mgm_handle::last_error, ndb_mgm_handle::last_error_desc, ndb_mgm_handle::last_error_line, my_malloc(), MY_WME, MYF, NDB_INVALID_SOCKET, NDB_MGM_MAX_ERR_DESC_SIZE, ndb_mgm_handle::read_timeout, ndb_mgm_handle::socket, and ndb_mgm_handle::write_timeout.

Referenced by CommandInterpreter::CommandInterpreter(), ConfigRetriever::ConfigRetriever(), NdbRestarter::connect(), connect_ndb_mgm(), TransporterRegistry::connect_ndb_mgmd(), main(), and waitClusterStatus().

00146 {
00147   DBUG_ENTER("ndb_mgm_create_handle");
00148   NdbMgmHandle h     =
00149     (NdbMgmHandle)my_malloc(sizeof(ndb_mgm_handle),MYF(MY_WME));
00150   h->connected       = 0;
00151   h->last_error      = 0;
00152   h->last_error_line = 0;
00153   h->socket          = NDB_INVALID_SOCKET;
00154   h->read_timeout    = 50000;
00155   h->write_timeout   = 100;
00156   h->cfg_i           = -1;
00157 
00158   strncpy(h->last_error_desc, "No error", NDB_MGM_MAX_ERR_DESC_SIZE);
00159 
00160   new (&(h->cfg)) LocalConfig;
00161   h->cfg.init(0, 0);
00162 
00163 #ifdef MGMAPI_LOG
00164   h->logfile = 0;
00165 #endif
00166 
00167   DBUG_PRINT("info", ("handle=0x%x", (UintPtr)h));
00168   DBUG_RETURN(h);
00169 }

NdbLogEventHandle ndb_mgm_create_logevent_handle NdbMgmHandle  ,
const int  filter[]
 

Listen to log events.

Parameters:
handle NDB management handle.
filter pairs of { level, ndb_mgm_event_category } that will be pushed to fd, level=0 ends list.
Returns:
NdbLogEventHandle

Definition at line 54 of file ndb_logevent.cpp.

References h, my_malloc(), MY_WME, MYF, ndb_mgm_listen_event_internal(), and ndb_logevent_handle::socket.

Referenced by main().

00056 {
00057   int fd= ndb_mgm_listen_event_internal(mh, filter, 1);
00058 
00059   if (fd == -1)
00060     return 0;
00061 
00062   NdbLogEventHandle h=
00063     (NdbLogEventHandle)my_malloc(sizeof(ndb_logevent_handle),MYF(MY_WME));
00064 
00065   h->socket= fd;
00066 
00067   return h;
00068 }

void ndb_mgm_destroy_configuration struct ndb_mgm_configuration  ) 
 

Definition at line 1771 of file mgmapi.cpp.

References free.

Referenced by Ndb_cluster_connection::connect().

01772 {
01773   if (cfg) {
01774     ((ConfigValues *)cfg)->~ConfigValues();
01775     free((void *)cfg);
01776   }
01777 }

void ndb_mgm_destroy_handle NdbMgmHandle handle  ) 
 

Destroy a handle

important! only disconnect if connected other code relies on this

Definition at line 197 of file mgmapi.cpp.

References DBUG_ENTER, DBUG_PRINT, DBUG_VOID_RETURN, MY_ALLOW_ZERO_PTR, my_free, MYF, and ndb_mgm_disconnect().

Referenced by TransporterRegistry::connect_ndb_mgmd(), NdbRestarter::disconnect(), main(), ndb_mgm_convert_to_transporter(), TransporterRegistry::set_mgm_handle(), CommandInterpreter::~CommandInterpreter(), ConfigRetriever::~ConfigRetriever(), and TransporterRegistry::~TransporterRegistry().

00198 {
00199   DBUG_ENTER("ndb_mgm_destroy_handle");
00200   if(!handle)
00201     DBUG_VOID_RETURN;
00202   DBUG_PRINT("info", ("handle=0x%x", (UintPtr)(* handle)));
00207   if((* handle)->connected){
00208     ndb_mgm_disconnect(* handle);
00209   }
00210 #ifdef MGMAPI_LOG
00211   if ((* handle)->logfile != 0){
00212     fclose((* handle)->logfile);
00213     (* handle)->logfile = 0;
00214   }
00215 #endif
00216   (*handle)->cfg.~LocalConfig();
00217   my_free((char*)* handle,MYF(MY_ALLOW_ZERO_PTR));
00218   * handle = 0;
00219   DBUG_VOID_RETURN;
00220 }

void ndb_mgm_destroy_iterator ndb_mgm_configuration_iterator  ) 
 

Definition at line 106 of file mgmapi_configuration.cpp.

References free, and ndb_mgm_configuration_iterator::~ndb_mgm_configuration_iterator().

Referenced by Configuration::setupConfiguration().

00106                                                                    {
00107   if(iter != 0){
00108     iter->~ndb_mgm_configuration_iterator();
00109     free(iter);
00110   }
00111 }

void ndb_mgm_destroy_logevent_handle NdbLogEventHandle  ) 
 

Definition at line 71 of file ndb_logevent.cpp.

References close(), MY_ALLOW_ZERO_PTR, my_free, and MYF.

Referenced by main().

00072 {
00073   if( !h )
00074     return;
00075 
00076   if ( *h )
00077     close((*h)->socket);
00078 
00079   my_free((char*)* h,MYF(MY_ALLOW_ZERO_PTR));
00080   * h = 0;
00081 }

int ndb_mgm_disconnect NdbMgmHandle  handle  ) 
 

Disconnect from a mgm server

Definition at line 455 of file mgmapi.cpp.

References CHECK_CONNECTED, CHECK_HANDLE, ndb_mgm_handle::connected, NDB_CLOSE_SOCKET, NDB_INVALID_SOCKET, NDB_MGM_NO_ERROR, SET_ERROR, and ndb_mgm_handle::socket.

Referenced by NdbRestarter::disconnect(), CommandInterpreter::disconnect(), ndb_mgm_check_connection(), ndb_mgm_destroy_handle(), TransporterRegistry::start_clients_thread(), and ConfigRetriever::~ConfigRetriever().

00456 {
00457   SET_ERROR(handle, NDB_MGM_NO_ERROR, "Executing: ndb_mgm_disconnect");
00458   CHECK_HANDLE(handle, -1);
00459   CHECK_CONNECTED(handle, -1);
00460 
00461   NDB_CLOSE_SOCKET(handle->socket);
00462   handle->socket = NDB_INVALID_SOCKET;
00463   handle->connected = 0;
00464 
00465   return 0;
00466 }

int ndb_mgm_enter_single_user NdbMgmHandle  handle,
unsigned int  nodeId,
struct ndb_mgm_reply reply
 

Enter Single user mode

Parameters:
handle NDB management handle.
nodeId Node ID of the single user node
reply Reply message.
Returns:
-1 on error.

Definition at line 714 of file mgmapi.cpp.

References args, BaseString::c_str(), CHECK_CONNECTED, CHECK_HANDLE, CHECK_REPLY, Properties::get(), MGM_ARG, MGM_CMD, MGM_END, ndb_mgm_call(), NDB_MGM_COULD_NOT_ENTER_SINGLE_USER_MODE, NDB_MGM_NO_ERROR, NULL, Properties::put(), and SET_ERROR.

Referenced by NdbRestarter::enterSingleUserMode(), and CommandInterpreter::executeEnterSingleUser().

00717 {
00718   SET_ERROR(handle, NDB_MGM_NO_ERROR, "Executing: ndb_mgm_enter_single_user");
00719   const ParserRow<ParserDummy> enter_single_reply[] = {
00720     MGM_CMD("enter single user reply", NULL, ""),
00721     MGM_ARG("result", String, Mandatory, "Error message"),
00722     MGM_END()
00723   };
00724   CHECK_HANDLE(handle, -1);
00725   CHECK_CONNECTED(handle, -1);
00726 
00727   Properties args;
00728   args.put("nodeId", nodeId);
00729   const Properties *reply;
00730   reply = ndb_mgm_call(handle, enter_single_reply, "enter single user", &args);
00731   CHECK_REPLY(reply, -1);
00732 
00733   BaseString result;
00734   reply->get("result", result);
00735   if(strcmp(result.c_str(), "Ok") != 0) {
00736     SET_ERROR(handle, NDB_MGM_COULD_NOT_ENTER_SINGLE_USER_MODE, 
00737               result.c_str());
00738     delete reply;
00739     return -1;
00740   }
00741 
00742   delete reply;
00743   return 0;
00744 }

int ndb_mgm_exit_single_user NdbMgmHandle  handle,
struct ndb_mgm_reply reply
 

Exit Single user mode

Parameters:
handle NDB management handle.
reply Reply message.
Returns:
-1 on error.

Definition at line 749 of file mgmapi.cpp.

References buf, CHECK_CONNECTED, CHECK_HANDLE, CHECK_REPLY, Properties::get(), MGM_ARG, MGM_CMD, MGM_END, ndb_mgm_call(), NDB_MGM_COULD_NOT_EXIT_SINGLE_USER_MODE, NDB_MGM_NO_ERROR, NULL, and SET_ERROR.

Referenced by CommandInterpreter::executeExitSingleUser(), and NdbRestarter::exitSingleUserMode().

00750 {
00751   SET_ERROR(handle, NDB_MGM_NO_ERROR, "Executing: ndb_mgm_exit_single_user");
00752   const ParserRow<ParserDummy> exit_single_reply[] = {
00753     MGM_CMD("exit single user reply", NULL, ""),
00754     MGM_ARG("result", String, Mandatory, "Error message"),
00755     MGM_END()
00756   };
00757   CHECK_HANDLE(handle, -1);
00758   CHECK_CONNECTED(handle, -1);
00759 
00760   const Properties *reply;
00761   reply = ndb_mgm_call(handle, exit_single_reply, "exit single user", 0);
00762   CHECK_REPLY(reply, -1);
00763 
00764   const char * buf;
00765   reply->get("result", &buf);
00766   if(strcmp(buf,"Ok")!=0) {
00767     SET_ERROR(handle, NDB_MGM_COULD_NOT_EXIT_SINGLE_USER_MODE, buf);
00768     delete reply;    
00769     return -1;
00770   }
00771 
00772   delete reply;
00773   return 0;
00774 }

int ndb_mgm_filter_clusterlog NdbMgmHandle  h,
enum ndb_mgm_clusterlog_level  s,
int  e,
struct ndb_mgm_reply r
[inline]
 

Definition at line 1030 of file mgmapi.h.

int ndb_mgm_find ndb_mgm_configuration_iterator ,
int  param,
unsigned  value
 

Definition at line 154 of file mgmapi_configuration.cpp.

References ndb_mgm_configuration_iterator::find().

Referenced by print_nodes(), and ConfigRetriever::verifyConfig().

00155                                         {
00156   return iter->find(param, search);
00157 }

int ndb_mgm_first ndb_mgm_configuration_iterator  ) 
 

Definition at line 115 of file mgmapi_configuration.cpp.

References ndb_mgm_configuration_iterator::first().

Referenced by Configuration::calcSizeAlt(), Cmvmi::Cmvmi(), Qmgr::initData(), and print_nodes().

00115                                                    {
00116   return iter->first();
00117 }

const unsigned int* ndb_mgm_get_clusterlog_severity_filter NdbMgmHandle  handle  ) 
 

Get clusterlog severity filter

Parameters:
handle NDB management handle
Returns:
A vector of seven elements, where each element contains 1 if a severity indicator is enabled and 0 if not. A severity level is stored at position ndb_mgm_clusterlog_level; for example the "error" level is stored in position [NDB_MGM_EVENT_SEVERITY_ERROR]. The first element [NDB_MGM_EVENT_SEVERITY_ON] in the vector signals whether the cluster log is disabled or enabled.

Definition at line 1006 of file mgmapi.cpp.

References args, CHECK_CONNECTED, CHECK_HANDLE, CHECK_REPLY, clusterlog_severity_names, Properties::get(), int, MGM_ARG, MGM_CMD, ndb_mgm_call(), NDB_MGM_EVENT_SEVERITY_ALL, NDB_MGM_NO_ERROR, NULL, and SET_ERROR.

Referenced by ndb_mgm_set_loglevel_clusterlog().

01007 {
01008   SET_ERROR(handle, NDB_MGM_NO_ERROR, "Executing: ndb_mgm_get_clusterlog_severity_filter");
01009   static unsigned int enabled[(int)NDB_MGM_EVENT_SEVERITY_ALL]=
01010     {0,0,0,0,0,0,0};
01011   const ParserRow<ParserDummy> getinfo_reply[] = {
01012     MGM_CMD("clusterlog", NULL, ""),
01013     MGM_ARG(clusterlog_severity_names[0], Int, Mandatory, ""),
01014     MGM_ARG(clusterlog_severity_names[1], Int, Mandatory, ""),
01015     MGM_ARG(clusterlog_severity_names[2], Int, Mandatory, ""),
01016     MGM_ARG(clusterlog_severity_names[3], Int, Mandatory, ""),
01017     MGM_ARG(clusterlog_severity_names[4], Int, Mandatory, ""),
01018     MGM_ARG(clusterlog_severity_names[5], Int, Mandatory, ""),
01019     MGM_ARG(clusterlog_severity_names[6], Int, Mandatory, ""),
01020   };
01021   CHECK_HANDLE(handle, NULL);
01022   CHECK_CONNECTED(handle, NULL);
01023 
01024   Properties args;
01025   const Properties *reply;
01026   reply = ndb_mgm_call(handle, getinfo_reply, "get info clusterlog", &args);
01027   CHECK_REPLY(reply, NULL);
01028   
01029   for(int i=0; i < (int)NDB_MGM_EVENT_SEVERITY_ALL; i++) {
01030     reply->get(clusterlog_severity_names[i], &enabled[i]);
01031   }
01032   return enabled;
01033 }

struct ndb_mgm_configuration* ndb_mgm_get_configuration NdbMgmHandle  handle,
unsigned  version
 

Get configuration

Parameters:
handle NDB management handle.
version Version of configuration, 0 means latest (Currently this is the only supported value for this parameter)
Returns:
configuration
Note:
The caller is responsible for calling ndb_mgm_destroy_configuration()

Referenced by CommandInterpreter::executeShow(), NdbBackup::getBackupDataDirForNode(), NdbRestarter::getConfig(), and ConfigRetriever::getConfig().

int ndb_mgm_get_configuration_nodeid NdbMgmHandle  handle  ) 
 

Gets connection node ID

Parameters:
handle Management handle
Returns:
Node ID; 0 indicates that no node ID has been specified

Definition at line 1790 of file mgmapi.cpp.

References LocalConfig::_ownNodeId, ndb_mgm_handle::cfg, and CHECK_HANDLE.

Referenced by ConfigRetriever::get_configuration_nodeid().

01791 {
01792   CHECK_HANDLE(handle, 0);
01793   return handle->cfg._ownNodeId;
01794 }

const char * ndb_mgm_get_connected_host NdbMgmHandle  handle  ) 
 

Gets connection host

Parameters:
handle Management handle
Returns:
hostname

Definition at line 1806 of file mgmapi.cpp.

References ndb_mgm_handle::cfg, ndb_mgm_handle::cfg_i, and LocalConfig::ids.

Referenced by CommandInterpreter::connect(), NdbBackup::execRestore(), ConfigRetriever::get_mgmd_host(), ndb_mgm_alloc_nodeid(), and ndb_mgm_listen_event_internal().

01807 {
01808   if (handle->cfg_i >= 0)
01809     return handle->cfg.ids[handle->cfg_i].name.c_str();
01810   else
01811     return 0;
01812 }

int ndb_mgm_get_connected_port NdbMgmHandle  handle  ) 
 

Gets connection port

Parameters:
handle Management handle
Returns:
port

Definition at line 1797 of file mgmapi.cpp.

References ndb_mgm_handle::cfg, ndb_mgm_handle::cfg_i, and LocalConfig::ids.

Referenced by CommandInterpreter::connect(), NdbBackup::execRestore(), ConfigRetriever::get_mgmd_port(), ndb_mgm_alloc_nodeid(), and ndb_mgm_listen_event_internal().

01798 {
01799   if (handle->cfg_i >= 0)
01800     return handle->cfg.ids[handle->cfg_i].port;
01801   else
01802     return 0;
01803 }

const char * ndb_mgm_get_connectstring NdbMgmHandle  handle,
char *  buf,
int  buf_sz
 

Gets the connectstring used for a connection

Note:
This function returns the default connectstring if no call to ndb_mgm_set_connectstring() has been performed. Also, the returned connectstring may be formatted differently.
Parameters:
handle Management handle
buf Buffer to hold result
buf_sz Size of buffer.
Returns:
connectstring (same as buf)

Definition at line 1815 of file mgmapi.cpp.

References ndb_mgm_handle::cfg, and LocalConfig::makeConnectString().

Referenced by ConfigRetriever::get_connectstring(), and TransporterRegistry::set_mgm_handle().

01816 {
01817   return handle->cfg.makeConnectString(buf,buf_sz);
01818 }

const char* ndb_mgm_get_event_category_string enum  ndb_mgm_event_category  ) 
 

Referenced by CommandInterpreter::executeHelp().

const char* ndb_mgm_get_event_severity_string enum  ndb_mgm_event_severity  ) 
 

Referenced by CommandInterpreter::executeClusterLog().

int ndb_mgm_get_int64_parameter const ndb_mgm_configuration_iterator ,
int  param,
Uint64 value
 

Definition at line 140 of file mgmapi_configuration.cpp.

References ndb_mgm_configuration_iterator::get().

Referenced by Configuration::calcSizeAlt().

00141                                                       {
00142   return iter->get(param, value);
00143 }

int ndb_mgm_get_int_parameter const ndb_mgm_configuration_iterator ,
int  param,
unsigned *  value
 

Definition at line 133 of file mgmapi_configuration.cpp.

References ndb_mgm_configuration_iterator::get().

Referenced by Backup::Backup(), Configuration::calcSizeAlt(), Cmvmi::Cmvmi(), Dbacc::Dbacc(), Dbdict::Dbdict(), Dblqh::Dblqh(), Dbtc::Dbtc(), Dbtup::Dbtup(), Ndbcntr::execCONTINUEB(), Dbtux::execREAD_CONFIG_REQ(), Dbtup::execREAD_CONFIG_REQ(), Dbtc::execREAD_CONFIG_REQ(), Dblqh::execREAD_CONFIG_REQ(), Dbdih::execREAD_CONFIG_REQ(), Dbdict::execREAD_CONFIG_REQ(), Dbacc::execREAD_CONFIG_REQ(), Ndbcntr::execREAD_NODESCONF(), Dbdih::initCommonData(), Qmgr::initData(), SimBlockList::load(), SumaParticipant::SumaParticipant(), and ConfigRetriever::verifyConfig().

00134                                                       {
00135   return iter->get(param, value);
00136 }

int ndb_mgm_get_latest_error const NdbMgmHandle  h  ) 
 

Get latest error associated with a handle

Definition at line 231 of file mgmapi.cpp.

References ndb_mgm_handle::last_error.

Referenced by CommandInterpreter::connect(), TransporterRegistry::connect_ndb_mgmd(), CommandInterpreter::printError(), and wait_ndb().

00232 {
00233   return h->last_error;
00234 }

const char* ndb_mgm_get_latest_error_desc const NdbMgmHandle  handle  ) 
 

Get the most recent error description associated with a handle

The error description gives some additional information regarding the error message.

Parameters:
handle Management handle.
Returns:
Latest error description

Definition at line 238 of file mgmapi.cpp.

References ndb_mgm_handle::last_error_desc.

Referenced by ConfigRetriever::allocNodeId(), ConfigRetriever::ConfigRetriever(), TransporterRegistry::connect_ndb_mgmd(), ConfigRetriever::getConfig(), CommandInterpreter::printError(), and wait_ndb().

00238                                                    {
00239   return h->last_error_desc;
00240 }

int ndb_mgm_get_latest_error_line const NdbMgmHandle  handle  ) 
 

Get the most recent internal source code error line associated with a handle

Parameters:
handle Management handle.
Returns:
Latest internal source code line of latest error
Deprecated:

Definition at line 244 of file mgmapi.cpp.

References ndb_mgm_handle::last_error_line.

00245 {
00246   return h->last_error_line;
00247 }

const char* ndb_mgm_get_latest_error_msg const NdbMgmHandle  handle  ) 
 

Get the most recent general error message associated with a handle

Parameters:
handle Management handle.
Returns:
Latest error message

Definition at line 251 of file mgmapi.cpp.

References ndb_mgm_handle::last_error, Ndb_Mgm_Error_Msg::msg, ndb_mgm_error_msgs, and ndb_mgm_noOfErrorMsgs.

Referenced by CommandInterpreter::connect(), NdbBackup::getBackupDataDirForNode(), CommandInterpreter::printError(), and wait_ndb().

00252 {
00253   for (int i=0; i<ndb_mgm_noOfErrorMsgs; i++) {
00254     if (ndb_mgm_error_msgs[i].code == h->last_error)
00255       return ndb_mgm_error_msgs[i].msg;
00256   }
00257 
00258   return "Error"; // Unknown Error message
00259 }

const unsigned int* ndb_mgm_get_logfilter NdbMgmHandle  h  )  [inline]
 

Definition at line 1037 of file mgmapi.h.

Referenced by CommandInterpreter::executeClusterLog().

Uint32 ndb_mgm_get_mgmd_nodeid NdbMgmHandle  handle  ) 
 

Get the node id of the mgm server we're connected to

Definition at line 2228 of file mgmapi.cpp.

References args, CHECK_CONNECTED, CHECK_HANDLE, CHECK_REPLY, DBUG_ENTER, DBUG_RETURN, Properties::get(), MGM_ARG, MGM_CMD, MGM_END, ndb_mgm_call(), ndbout_c(), and NULL.

Referenced by TransporterRegistry::connect_client().

02229 {
02230   Uint32 nodeid=0;
02231 
02232   DBUG_ENTER("ndb_mgm_get_mgmd_nodeid");
02233   CHECK_HANDLE(handle, 0);
02234   CHECK_CONNECTED(handle, 0);
02235   
02236   Properties args;
02237 
02238   const ParserRow<ParserDummy> reply[]= {
02239     MGM_CMD("get mgmd nodeid reply", NULL, ""),
02240     MGM_ARG("nodeid", Int, Mandatory, "Node ID"),
02241     MGM_END()
02242   };
02243   
02244   const Properties *prop;
02245   prop = ndb_mgm_call(handle, reply, "get mgmd nodeid", &args);
02246   CHECK_REPLY(prop, 0);
02247 
02248   if(!prop->get("nodeid",&nodeid)){
02249     ndbout_c("Unable to get value");
02250     return 0;
02251   }
02252 
02253   delete prop;
02254   DBUG_RETURN(nodeid);
02255 }

const char* ndb_mgm_get_node_status_string enum ndb_mgm_node_status  status  ) 
 

Converts an ID to a string

Parameters:
status NDB node status.
Returns:
NULL if invalid ID.

Definition at line 559 of file mgmapi.cpp.

References NDB_MGM_NODE_STATUS_UNKNOWN, no_of_status_values, ndb_mgm_status_atoi::str, and ndb_mgm_status_atoi::value.

Referenced by printNodeStatus(), waitClusterStatus(), and NdbRestarter::waitNodesState().

00560 {
00561   int i;
00562   for(i = 0; i<no_of_status_values; i++)
00563     if(status_values[i].value == status)
00564       return status_values[i].str;
00565 
00566   for(i = 0; i<no_of_status_values; i++)
00567     if(status_values[i].value == NDB_MGM_NODE_STATUS_UNKNOWN)
00568       return status_values[i].str;
00569   
00570   return 0;
00571 }

const char* ndb_mgm_get_node_type_alias_string enum ndb_mgm_node_type  type,
const char **  str
 

Converts an ndb_mgm_node_type to a alias string

Parameters:
type Node type.
Returns:
NULL if the ID is invalid.

Definition at line 511 of file mgmapi.cpp.

References ndb_mgm_type_atoi::alias, no_of_type_values, ndb_mgm_type_atoi::str, and ndb_mgm_type_atoi::value.

Referenced by MgmtSrvr::alloc_node_id(), MgmApiSession::get_nodeid(), and ConfigRetriever::verifyConfig().

00512 {
00513   for(int i = 0; i<no_of_type_values; i++)
00514     if(type_values[i].value == type)
00515       {
00516         if (str)
00517           *str= type_values[i].str;
00518         return type_values[i].alias;
00519       }
00520   return 0;
00521 }

const char* ndb_mgm_get_node_type_string enum ndb_mgm_node_type  type  ) 
 

Converts an ndb_mgm_node_type to a string

Parameters:
type Node type.
Returns:
NULL if invalid ID.

Definition at line 501 of file mgmapi.cpp.

References no_of_type_values, ndb_mgm_type_atoi::str, and ndb_mgm_type_atoi::value.

Referenced by print_nodes(), and printNodeStatus().

00502 {
00503   for(int i = 0; i<no_of_type_values; i++)
00504     if(type_values[i].value == type)
00505       return type_values[i].str;
00506   return 0;
00507 }

int ndb_mgm_get_stat_port NdbMgmHandle  handle,
struct ndb_mgm_reply reply
 

Returns the port number where statistics information is sent

Parameters:
handle NDB management handle.
reply Reply message.
Returns:
-1 on error.

Definition at line 1257 of file mgmapi.cpp.

References args, CHECK_CONNECTED, CHECK_HANDLE, CHECK_REPLY, Properties::get(), MGM_ARG, MGM_CMD, MGM_END, ndb_mgm_call(), NDB_MGM_NO_ERROR, NULL, port, and SET_ERROR.

01258 {
01259   SET_ERROR(handle, NDB_MGM_NO_ERROR, "Executing: ndb_mgm_get_stat_port");
01260   const ParserRow<ParserDummy> stat_reply[] = {
01261     MGM_CMD("error", NULL, ""),
01262     MGM_ARG("result", String, Mandatory, "Error message"),
01263     MGM_CMD("get statport reply", NULL, ""),
01264     MGM_ARG("tcpport", Int, Mandatory, "TCP port for statistics"),
01265     MGM_END()
01266   };
01267   CHECK_HANDLE(handle, -1);
01268   CHECK_CONNECTED(handle, -1);
01269   
01270   Properties args;
01271   const Properties *reply;
01272   reply = ndb_mgm_call(handle, stat_reply, "get statport", &args);
01273   CHECK_REPLY(reply, -1);
01274 
01275   Uint32 port;
01276   reply->get("tcpport", &port);
01277 
01278   delete reply;
01279   return port;
01280 }

struct ndb_mgm_cluster_state* ndb_mgm_get_status NdbMgmHandle  handle  ) 
 

Gets status of the nodes in an NDB Cluster

Note:
The caller must free the pointer returned by this function.
Parameters:
handle Management handle.
Returns:
Cluster state (or NULL on error).

Definition at line 620 of file mgmapi.cpp.

References abort(), BaseString::assign(), atoi(), buf, CHECK_CONNECTED, CHECK_HANDLE, cmp_state(), ndb_mgm_node_state::connect_address, free, SocketInputStream::gets(), malloc, NDB_MGM_ILLEGAL_NODE_STATUS, NDB_MGM_NO_ERROR, ndb_mgm_cluster_state::no_of_nodes, ndb_mgm_node_state::node_id, ndb_mgm_cluster_state::node_states, NULL, SocketOutputStream::println(), qsort(), ndb_mgm_handle::read_timeout, SET_ERROR, Vector< T >::size(), ndb_mgm_handle::socket, split(), BaseString::split(), status_ackumulate(), and BaseString::trim().

Referenced by CommandInterpreter::executeForAll(), CommandInterpreter::executeShow(), CommandInterpreter::executeShutdown(), CommandInterpreter::executeStatus(), getStatus(), NdbRestarter::getStatus(), and wait_ndb().

00621 {
00622   SET_ERROR(handle, NDB_MGM_NO_ERROR, "Executing: ndb_mgm_get_status");
00623   CHECK_HANDLE(handle, NULL);
00624   CHECK_CONNECTED(handle, NULL);
00625 
00626   SocketOutputStream out(handle->socket);
00627   SocketInputStream in(handle->socket, handle->read_timeout);
00628 
00629   out.println("get status");
00630   out.println("");
00631 
00632   char buf[1024];
00633   in.gets(buf, sizeof(buf));
00634   if(buf[strlen(buf)-1] == '\n')
00635     buf[strlen(buf)-1] = '\0';
00636 
00637   if(strcmp("node status", buf) != 0) {
00638     SET_ERROR(handle, NDB_MGM_ILLEGAL_NODE_STATUS, buf);
00639     return NULL;
00640   }
00641 
00642   in.gets(buf, sizeof(buf));
00643   if(buf[strlen(buf)-1] == '\n')
00644     buf[strlen(buf)-1] = '\0';
00645   
00646   BaseString tmp(buf);
00647   Vector<BaseString> split;
00648   tmp.split(split, ":");
00649   if(split.size() != 2){
00650     abort();
00651     return NULL;
00652   }
00653  
00654   if(!(split[0].trim() == "nodes")){
00655     abort();
00656     return NULL;
00657   }
00658 
00659   const int noOfNodes = atoi(split[1].c_str());
00660 
00661   ndb_mgm_cluster_state *state = (ndb_mgm_cluster_state*)
00662     malloc(sizeof(ndb_mgm_cluster_state)+
00663            noOfNodes*(sizeof(ndb_mgm_node_state)+sizeof("000.000.000.000#")));
00664 
00665   state->no_of_nodes= noOfNodes;
00666   ndb_mgm_node_state * ptr = &state->node_states[0];
00667   int nodeId = 0;
00668   int i;
00669   for (i= 0; i < noOfNodes; i++) {
00670     state->node_states[i].connect_address[0]= 0;
00671   }
00672   i = -1; ptr--;
00673   for(; i<noOfNodes; ){
00674     in.gets(buf, sizeof(buf));
00675     tmp.assign(buf);
00676 
00677     if(tmp.trim() == ""){
00678       break;
00679     }
00680     
00681     Vector<BaseString> split;
00682     tmp.split(split, ":.", 4);
00683     if(split.size() != 4)
00684       break;
00685     
00686     const int id = atoi(split[1].c_str());
00687     if(id != nodeId){
00688       ptr++;
00689       i++;
00690       nodeId = id;
00691       ptr->node_id = id;
00692     }
00693 
00694     split[3].trim(" \t\n");
00695 
00696     if(status_ackumulate(ptr,split[2].c_str(), split[3].c_str()) != 0) {
00697       break;
00698     }
00699   }
00700 
00701   if(i+1 != noOfNodes){
00702     free(state);
00703     abort();
00704     return NULL;
00705   }
00706 
00707   qsort(state->node_states, state->no_of_nodes, sizeof(state->node_states[0]),
00708         cmp_state);
00709   return state;
00710 }

int ndb_mgm_get_string_parameter const ndb_mgm_configuration_iterator ,
int  param,
const char **  value
 

Definition at line 147 of file mgmapi_configuration.cpp.

References ndb_mgm_configuration_iterator::get().

Referenced by print_nodes(), and ConfigRetriever::verifyConfig().

00148                                                              {
00149   return iter->get(param, value);
00150 }

int ndb_mgm_is_connected NdbMgmHandle  handle  ) 
 

Returns true if connected

Definition at line 351 of file mgmapi.cpp.

References ndb_mgm_handle::connected.

Referenced by TransporterRegistry::start_clients_thread().

00352 {
00353   if(!handle)
00354     return 0;
00355   return handle->connected;
00356 }

int ndb_mgm_listen_event NdbMgmHandle  handle,
const int  filter[]
 

Listen to log events. They are read from the return file descriptor and the format is textual, and the same as in the cluster log.

Parameters:
handle NDB management handle.
filter pairs of { level, ndb_mgm_event_category } that will be pushed to fd, level=0 ends list.
Returns:
fd filedescriptor to read events from

Definition at line 1250 of file mgmapi.cpp.

References ndb_mgm_listen_event_internal().

Referenced by event_thread_run(), and CommandInterpreter::executeStartBackup().

01251 {
01252   return ndb_mgm_listen_event_internal(handle,filter,0);
01253 }

ndb_mgm_event_category ndb_mgm_match_event_category const char *   ) 
 

Definition at line 1097 of file mgmapi.cpp.

References categories, ndb_mgm_event_categories::category, ndb_mgm_event_categories::name, name, and NDB_MGM_ILLEGAL_EVENT_CATEGORY.

Referenced by CommandInterpreter::executeEventReporting(), and CommandInterpreter::executeLogLevel().

01098 {
01099   if(status == 0)
01100     return NDB_MGM_ILLEGAL_EVENT_CATEGORY;
01101   
01102   for(int i = 0; categories[i].name !=0 ; i++)
01103     if(strcmp(status, categories[i].name) == 0)
01104       return categories[i].category;
01105 
01106   return NDB_MGM_ILLEGAL_EVENT_CATEGORY;
01107 }

enum ndb_mgm_node_status ndb_mgm_match_node_status const char *  status  ) 
 

Converts a string to a ndb_mgm_node_status value

Parameters:
status NDB node status string.
Returns:
NDB_MGM_NODE_STATUS_UNKNOWN if invalid string.

Definition at line 545 of file mgmapi.cpp.

References NDB_MGM_NODE_STATUS_UNKNOWN, no_of_status_values, ndb_mgm_status_atoi::str, and ndb_mgm_status_atoi::value.

Referenced by status_ackumulate().

00546 {
00547   if(status == 0)
00548     return NDB_MGM_NODE_STATUS_UNKNOWN;
00549   
00550   for(int i = 0; i<no_of_status_values; i++)
00551     if(strcmp(status, status_values[i].str) == 0)
00552       return status_values[i].value;
00553 
00554   return NDB_MGM_NODE_STATUS_UNKNOWN;
00555 }

enum ndb_mgm_node_type ndb_mgm_match_node_type const char *  type  ) 
 

Converts a string to an ndb_mgm_node_type value

Parameters:
type Node type as string.
Returns:
NDB_MGM_NODE_TYPE_UNKNOWN if invalid string.

Definition at line 487 of file mgmapi.cpp.

References NDB_MGM_NODE_TYPE_UNKNOWN, no_of_type_values, ndb_mgm_type_atoi::str, and ndb_mgm_type_atoi::value.

Referenced by status_ackumulate().

00488 {
00489   if(type == 0)
00490     return NDB_MGM_NODE_TYPE_UNKNOWN;
00491   
00492   for(int i = 0; i<no_of_type_values; i++)
00493     if(strcmp(type, type_values[i].str) == 0)
00494       return type_values[i].value;
00495 
00496   return NDB_MGM_NODE_TYPE_UNKNOWN;
00497 }

int ndb_mgm_next ndb_mgm_configuration_iterator  ) 
 

Definition at line 121 of file mgmapi_configuration.cpp.

References ndb_mgm_configuration_iterator::next().

Referenced by Configuration::calcSizeAlt(), Cmvmi::Cmvmi(), and Qmgr::initData().

00121                                                   {
00122   return iter->next();
00123 }

int ndb_mgm_purge_stale_sessions NdbMgmHandle  handle,
char ** 
 

Definition at line 2041 of file mgmapi.cpp.

References args, buf, CHECK_CONNECTED, CHECK_HANDLE, EIO, Properties::get(), MGM_ARG, MGM_CMD, MGM_END, ndb_mgm_call(), ndbout_c(), NULL, SET_ERROR, and strdup().

Referenced by CommandInterpreter::executePurge().

02041                                                                 {
02042   CHECK_HANDLE(handle, 0);
02043   CHECK_CONNECTED(handle, 0);
02044   
02045   Properties args;
02046   
02047   const ParserRow<ParserDummy> reply[]= {
02048     MGM_CMD("purge stale sessions reply", NULL, ""),
02049     MGM_ARG("purged", String, Optional, ""),
02050     MGM_ARG("result", String, Mandatory, "Error message"),
02051     MGM_END()
02052   };
02053   
02054   const Properties *prop;
02055   prop= ndb_mgm_call(handle, reply, "purge stale sessions", &args);
02056   
02057   if(prop == NULL) {
02058     SET_ERROR(handle, EIO, "Unable to purge stale sessions");
02059     return -1;
02060   }
02061 
02062   int res= -1;
02063   do {
02064     const char * buf;
02065     if(!prop->get("result", &buf) || strcmp(buf, "Ok") != 0){
02066       ndbout_c("ERROR Message: %s\n", buf);
02067       break;
02068     }
02069     if (purged) {
02070       if (prop->get("purged", &buf))
02071         *purged= strdup(buf);
02072       else
02073         *purged= 0;
02074     }
02075     res= 0;
02076   } while(0);
02077   delete prop;
02078   return res;
02079 }

int ndb_mgm_restart NdbMgmHandle  handle,
int  no_of_nodes,
const int *  node_list
 

Restart database nodes

Parameters:
handle Management handle.
no_of_nodes Number of database nodes to restart
0: All database nodes in cluster
n: Restart the n node(s) specified in the array node_list
node_list List of node IDs of database nodes to be restarted
Returns:
Number of nodes restarted (-1 on error).
Note:
This function is equivalent to calling ndb_mgm_restart2(handle, no_of_nodes, node_list, 0, 0, 0);

Definition at line 952 of file mgmapi.cpp.

References NDB_MGM_NO_ERROR, ndb_mgm_restart2(), and SET_ERROR.

00953 {
00954   SET_ERROR(handle, NDB_MGM_NO_ERROR, "Executing: ndb_mgm_restart");
00955   return ndb_mgm_restart2(handle, no_of_nodes, node_list, 0, 0, 0);
00956 }

int ndb_mgm_restart2 NdbMgmHandle  handle,
int  no_of_nodes,
const int *  node_list,
int  initial,
int  nostart,
int  abort
 

Restart database nodes

Parameters:
handle Management handle.
no_of_nodes Number of database nodes to be restarted:
0: Restart all database nodes in the cluster
n: Restart the n node(s) specified in the array node_list
node_list List of node IDs of database nodes to be restarted
initial Remove filesystem from restarting node(s)
nostart Don't actually start node(s) but leave them waiting for start command
abort Don't perform graceful restart, but rather restart immediately
Returns:
Number of nodes stopped (-1 on error).

Definition at line 869 of file mgmapi.cpp.

References BaseString::appfmt(), args, BaseString::assfmt(), BaseString::c_str(), CHECK_CONNECTED, CHECK_HANDLE, CHECK_REPLY, Properties::get(), MGM_ARG, MGM_CMD, MGM_END, ndb_mgm_call(), NDB_MGM_NO_ERROR, NDB_MGM_RESTART_FAILED, NULL, Properties::put(), ndb_mgm_handle::read_timeout, SET_ERROR, and timeout.

Referenced by CommandInterpreter::executeRestart(), ndb_mgm_restart(), NdbRestarter::restartAll(), and NdbRestarter::restartOneDbNode().

00871 {
00872   SET_ERROR(handle, NDB_MGM_NO_ERROR, "Executing: ndb_mgm_restart2");
00873   Uint32 restarted = 0;
00874   const ParserRow<ParserDummy> restart_reply[] = {
00875     MGM_CMD("restart reply", NULL, ""),
00876     MGM_ARG("result", String, Mandatory, "Error message"),
00877     MGM_ARG("restarted", Int, Optional, "No of restarted nodes"),
00878     MGM_END()
00879   };
00880   CHECK_HANDLE(handle, -1);
00881   CHECK_CONNECTED(handle, -1);
00882   
00883   if(no_of_nodes < 0){
00884     SET_ERROR(handle, NDB_MGM_RESTART_FAILED, 
00885               "Restart requested of negative number of nodes");
00886     return -1;
00887   }
00888   
00889   if(no_of_nodes == 0) {
00890     Properties args;    
00891     args.put("abort", abort);
00892     args.put("initialstart", initial);
00893     args.put("nostart", nostart);
00894     const Properties *reply;
00895     const int timeout = handle->read_timeout;
00896     handle->read_timeout= 5*60*1000; // 5 minutes
00897     reply = ndb_mgm_call(handle, restart_reply, "restart all", &args);
00898     handle->read_timeout= timeout;
00899     CHECK_REPLY(reply, -1);
00900 
00901     BaseString result;
00902     reply->get("result", result);
00903     if(strcmp(result.c_str(), "Ok") != 0) {
00904       SET_ERROR(handle, NDB_MGM_RESTART_FAILED, result.c_str());
00905       delete reply;
00906       return -1;
00907     }
00908     if(!reply->get("restarted", &restarted)){
00909       SET_ERROR(handle, NDB_MGM_RESTART_FAILED, 
00910                 "Could not get restarted number of nodes from mgm server");
00911       delete reply;
00912       return -1;
00913     }
00914     delete reply;
00915     return restarted;
00916   }      
00917 
00918   BaseString node_list_str;
00919   node_list_str.assfmt("%d", node_list[0]);
00920   for(int node = 1; node < no_of_nodes; node++)
00921     node_list_str.appfmt(" %d", node_list[node]);
00922 
00923   Properties args;
00924   
00925   args.put("node", node_list_str.c_str());
00926   args.put("abort", abort);
00927   args.put("initialstart", initial);
00928   args.put("nostart", nostart);
00929 
00930   const Properties *reply;
00931   const int timeout = handle->read_timeout;
00932   handle->read_timeout= 5*60*1000; // 5 minutes
00933   reply = ndb_mgm_call(handle, restart_reply, "restart node", &args);
00934   handle->read_timeout= timeout;
00935   if(reply != NULL) {
00936     BaseString result;
00937     reply->get("result", result);
00938     if(strcmp(result.c_str(), "Ok") != 0) {
00939       SET_ERROR(handle, NDB_MGM_RESTART_FAILED, result.c_str());
00940       delete reply;
00941       return -1;
00942     }
00943     reply->get("restarted", &restarted);
00944     delete reply;
00945   } 
00946   
00947   return restarted;
00948 }

int ndb_mgm_set_clusterlog_loglevel NdbMgmHandle  handle,
int  nodeId,
enum ndb_mgm_event_category  category,
int  level,
struct ndb_mgm_reply reply
 

Set log category and levels for the cluster log

Parameters:
handle NDB management handle.
nodeId Node ID.
category Event category.
level Log level (0-15).
reply Reply message.
Returns:
-1 on error.

Definition at line 1123 of file mgmapi.cpp.

References args, BaseString::c_str(), CHECK_CONNECTED, CHECK_HANDLE, CHECK_REPLY, DBUG_ENTER, DBUG_PRINT, DBUG_RETURN, Properties::get(), MGM_ARG, MGM_CMD, MGM_END, ndb_mgm_call(), NDB_MGM_NO_ERROR, NULL, Properties::put(), and SET_ERROR.

01127 {
01128   SET_ERROR(handle, NDB_MGM_NO_ERROR, 
01129             "Executing: ndb_mgm_set_clusterlog_loglevel");
01130   const ParserRow<ParserDummy> clusterlog_reply[] = {
01131     MGM_CMD("set cluster loglevel reply", NULL, ""),
01132     MGM_ARG("result", String, Mandatory, "Error message"),
01133     MGM_END()
01134   };
01135   CHECK_HANDLE(handle, -1);
01136   CHECK_CONNECTED(handle, -1);
01137 
01138   Properties args;
01139   args.put("node", nodeId);
01140   args.put("category", cat);
01141   args.put("level", level);
01142   
01143   const Properties *reply;
01144   reply = ndb_mgm_call(handle, clusterlog_reply, 
01145                        "set cluster loglevel", &args);
01146   CHECK_REPLY(reply, -1);
01147   
01148   DBUG_ENTER("ndb_mgm_set_clusterlog_loglevel");
01149   DBUG_PRINT("enter",("node=%d, category=%d, level=%d", nodeId, cat, level));
01150 
01151   BaseString result;
01152   reply->get("result", result);
01153   if(strcmp(result.c_str(), "Ok") != 0) {
01154     SET_ERROR(handle, EINVAL, result.c_str());
01155     delete reply;
01156     DBUG_RETURN(-1);
01157   }
01158   delete reply;
01159   DBUG_RETURN(0);
01160 }

int ndb_mgm_set_clusterlog_severity_filter NdbMgmHandle  handle,
enum ndb_mgm_event_severity  severity,
int  enable,
struct ndb_mgm_reply reply
 

Filter cluster log severities

Parameters:
handle NDB management handle.
severity A cluster log severity to filter.
enable set 1=enable o 0=disable
reply Reply message.
Returns:
-1 on error.

Definition at line 1037 of file mgmapi.cpp.

References args, BaseString::c_str(), CHECK_CONNECTED, CHECK_HANDLE, CHECK_REPLY, Properties::get(), MGM_ARG, MGM_CMD, MGM_END, ndb_mgm_call(), NDB_MGM_NO_ERROR, NULL, Properties::put(), retval, and SET_ERROR.

Referenced by CommandInterpreter::executeClusterLog().

01041 {
01042   SET_ERROR(handle, NDB_MGM_NO_ERROR,
01043             "Executing: ndb_mgm_set_clusterlog_severity_filter");
01044   const ParserRow<ParserDummy> filter_reply[] = {
01045     MGM_CMD("set logfilter reply", NULL, ""),
01046     MGM_ARG("result", String, Mandatory, "Error message"),
01047     MGM_END()
01048   };
01049   int retval = -1;
01050   CHECK_HANDLE(handle, -1);
01051   CHECK_CONNECTED(handle, -1);
01052 
01053   Properties args;
01054   args.put("level", severity);
01055   args.put("enable", enable);
01056   
01057   const Properties *reply;
01058   reply = ndb_mgm_call(handle, filter_reply, "set logfilter", &args);
01059   CHECK_REPLY(reply, retval);
01060 
01061   BaseString result;
01062   reply->get("result", result);
01063 
01064   if (strcmp(result.c_str(), "1") == 0)
01065     retval = 1;
01066   else if (strcmp(result.c_str(), "0") == 0)
01067     retval = 0;
01068   else
01069   {
01070     SET_ERROR(handle, EINVAL, result.c_str());
01071   }
01072   delete reply;
01073   return retval;
01074 }

int ndb_mgm_set_configuration_nodeid NdbMgmHandle  handle,
int  nodeid
 

Definition at line 1781 of file mgmapi.cpp.

References LocalConfig::_ownNodeId, ndb_mgm_handle::cfg, and CHECK_HANDLE.

Referenced by ConfigRetriever::setNodeId().

01782 {
01783   CHECK_HANDLE(handle, -1);
01784   handle->cfg._ownNodeId= nodeid;
01785   return 0;
01786 }

int ndb_mgm_set_connectstring NdbMgmHandle  handle,
const char *  connect_string
 

Sets the connectstring for a management server

Parameters:
handle Management handle
connect_string Connect string to the management server,
Returns:
-1 on error.
 <connectstring> := [<nodeid-specification>,]<host-specification>[,<host-specification>]
 <nodeid-specification> := nodeid=<id>
 <host-specification> := <host>[:<port>]
 <id> is an integer greater than 0 identifying a node in config.ini
 <port> is an integer referring to a regular unix port
 <host> is a string containing a valid network host address

Definition at line 173 of file mgmapi.cpp.

References DBUG_ENTER, DBUG_PRINT, DBUG_RETURN, NDB_MGM_ILLEGAL_CONNECT_STRING, and SET_ERROR.

Referenced by CommandInterpreter::CommandInterpreter(), ConfigRetriever::ConfigRetriever(), NdbRestarter::connect(), CommandInterpreter::connect(), connect_ndb_mgm(), TransporterRegistry::connect_ndb_mgmd(), CommandInterpreter::executeConnect(), MgmtSrvr::set_connect_string(), and waitClusterStatus().

00174 {
00175   DBUG_ENTER("ndb_mgm_set_connectstring");
00176   DBUG_PRINT("info", ("handle=0x%x", (UintPtr)handle));
00177   handle->cfg.~LocalConfig();
00178   new (&(handle->cfg)) LocalConfig;
00179   if (!handle->cfg.init(mgmsrv, 0) ||
00180       handle->cfg.ids.size() == 0)
00181   {
00182     handle->cfg.~LocalConfig();
00183     new (&(handle->cfg)) LocalConfig;
00184     handle->cfg.init(0, 0); /* reset the LocalConfig */
00185     SET_ERROR(handle, NDB_MGM_ILLEGAL_CONNECT_STRING, "");
00186     DBUG_RETURN(-1);
00187   }
00188   handle->cfg_i= -1;
00189   DBUG_RETURN(0);
00190 }

int ndb_mgm_set_loglevel_clusterlog NdbMgmHandle  h,
int  n,
enum ndb_mgm_event_category  c,
int  l,
struct ndb_mgm_reply r
[inline]
 

Definition at line 1041 of file mgmapi.h.

References ndb_mgm_get_clusterlog_severity_filter().

Referenced by CommandInterpreter::executeEventReporting().

01041   { return ndb_mgm_get_clusterlog_severity_filter(h); }
01042 
01043   inline
01044   int ndb_mgm_set_loglevel_clusterlog(NdbMgmHandle h, int n,

int ndb_mgm_set_loglevel_node NdbMgmHandle  handle,
int  nodeId,
enum ndb_mgm_event_category  category,
int  level,
struct ndb_mgm_reply reply
 

Set log category and levels for the Node

Parameters:
handle NDB management handle.
nodeId Node ID.
category Event category.
level Log level (0-15).
reply Reply message.
Returns:
-1 on error.

Definition at line 1164 of file mgmapi.cpp.

References args, BaseString::c_str(), CHECK_CONNECTED, CHECK_HANDLE, CHECK_REPLY, Properties::get(), MGM_ARG, MGM_CMD, MGM_END, ndb_mgm_call(), NDB_MGM_NO_ERROR, NULL, Properties::put(), and SET_ERROR.

Referenced by CommandInterpreter::executeLogLevel().

01168 {
01169   SET_ERROR(handle, NDB_MGM_NO_ERROR, "Executing: ndb_mgm_set_loglevel_node");
01170   const ParserRow<ParserDummy> loglevel_reply[] = {
01171     MGM_CMD("set loglevel reply", NULL, ""),
01172     MGM_ARG("result", String, Mandatory, "Error message"),
01173     MGM_END()
01174   };
01175   CHECK_HANDLE(handle, -1);
01176   CHECK_CONNECTED(handle, -1);
01177 
01178   Properties args;
01179   args.put("node", nodeId);
01180   args.put("category", category);
01181   args.put("level", level);
01182   const Properties *reply;
01183   reply = ndb_mgm_call(handle, loglevel_reply, "set loglevel", &args);
01184   CHECK_REPLY(reply, -1);
01185 
01186   BaseString result;
01187   reply->get("result", result);
01188   if(strcmp(result.c_str(), "Ok") != 0) {
01189     SET_ERROR(handle, EINVAL, result.c_str());
01190     delete reply;
01191     return -1;
01192   }
01193 
01194   delete reply;
01195   return 0;
01196 }

int ndb_mgm_start NdbMgmHandle  handle,
int  no_of_nodes,
const int *  node_list
 

Start database nodes

Parameters:
handle Management handle.
no_of_nodes Number of database nodes to be started
0: Start all database nodes in the cluster
n: Start the n node(s) specified in the array node_list
node_list List of node IDs of database nodes to be started
Returns:
Number of nodes actually started (-1 on error).
Note:
The nodes to be started must have been started with nostart(-n) argument. This means that the database node binary is started and waiting for a START management command which will actually enable the database node

Definition at line 1542 of file mgmapi.cpp.

References args, BaseString::c_str(), CHECK_CONNECTED, CHECK_HANDLE, CHECK_REPLY, count, Properties::get(), MGM_ARG, MGM_CMD, MGM_END, ndb_mgm_call(), NDB_MGM_NO_ERROR, NULL, Properties::put(), and SET_ERROR.

Referenced by CommandInterpreter::executeStart(), NdbRestarter::restartAll(), NdbRestarter::startAll(), NdbRestarter::startNodes(), and wait_ndb().

01543 {
01544   SET_ERROR(handle, NDB_MGM_NO_ERROR, "Executing: ndb_mgm_start");
01545   const ParserRow<ParserDummy> start_reply[] = {
01546     MGM_CMD("start reply", NULL, ""),
01547     MGM_ARG("started", Int, Optional, "No of started nodes"),
01548     MGM_ARG("result", String, Mandatory, "Error message"),
01549     MGM_END()
01550   };
01551   int started = 0;
01552   CHECK_HANDLE(handle, -1);
01553   CHECK_CONNECTED(handle, -1);
01554 
01555   if(no_of_nodes < 0){
01556     SET_ERROR(handle, EINVAL, "");
01557     return -1;
01558   }
01559 
01560   if(no_of_nodes == 0){
01561     Properties args;
01562     const Properties *reply;
01563     reply = ndb_mgm_call(handle, start_reply, "start all", &args);
01564     CHECK_REPLY(reply, -1);
01565 
01566     Uint32 count = 0;
01567     if(!reply->get("started", &count)){
01568       delete reply;
01569       return -1;
01570     }
01571     delete reply;
01572     return count;
01573   }
01574 
01575   for(int node = 0; node < no_of_nodes; node++) {
01576     Properties args;
01577     args.put("node", node_list[node]);
01578 
01579     const Properties *reply;
01580     reply = ndb_mgm_call(handle, start_reply, "start", &args);
01581 
01582     if(reply != NULL) {
01583       BaseString result;
01584       reply->get("result", result);
01585       if(strcmp(result.c_str(), "Ok") == 0) {
01586         started++;
01587       } else {
01588         SET_ERROR(handle, EINVAL, result.c_str());
01589         delete reply;
01590         return -1;
01591       }
01592     }
01593     delete reply;
01594   }
01595 
01596   return started;
01597 }

int ndb_mgm_start_backup NdbMgmHandle  handle,
int  wait_completed,
unsigned int *  backup_id,
struct ndb_mgm_reply reply
 

Start backup

Parameters:
handle NDB management handle.
wait_completed 0: Don't wait for confirmation
1: Wait for backup to be started
2: Wait for backup to be completed
backup_id Backup ID is returned from function.
reply Reply message.
Returns:
-1 on error.
Note:
backup_id will not be returned if wait_completed == 0

Definition at line 1604 of file mgmapi.cpp.

References args, BaseString::c_str(), CHECK_CONNECTED, CHECK_HANDLE, CHECK_REPLY, Properties::get(), MGM_ARG, MGM_CMD, MGM_END, ndb_mgm_call(), NDB_MGM_COULD_NOT_START_BACKUP, NDB_MGM_NO_ERROR, NULL, Properties::put(), ndb_mgm_handle::read_timeout, and SET_ERROR.

Referenced by CommandInterpreter::executeStartBackup().

01607 {
01608   SET_ERROR(handle, NDB_MGM_NO_ERROR, "Executing: ndb_mgm_start_backup");
01609   const ParserRow<ParserDummy> start_backup_reply[] = {
01610     MGM_CMD("start backup reply", NULL, ""),
01611     MGM_ARG("result", String, Mandatory, "Error message"),
01612     MGM_ARG("id", Int, Optional, "Id of the started backup"),
01613     MGM_END()
01614   };
01615   CHECK_HANDLE(handle, -1);
01616   CHECK_CONNECTED(handle, -1);
01617 
01618   Properties args;
01619   args.put("completed", wait_completed);
01620   const Properties *reply;
01621   { // start backup can take some time, set timeout high
01622     Uint64 old_timeout= handle->read_timeout;
01623     if (wait_completed == 2)
01624       handle->read_timeout= 48*60*60*1000; // 48 hours
01625     else if (wait_completed == 1)
01626       handle->read_timeout= 10*60*1000; // 10 minutes
01627     reply = ndb_mgm_call(handle, start_backup_reply, "start backup", &args);
01628     handle->read_timeout= old_timeout;
01629   }
01630   CHECK_REPLY(reply, -1);
01631 
01632   BaseString result;
01633   reply->get("result", result);
01634   reply->get("id", _backup_id);
01635   if(strcmp(result.c_str(), "Ok") != 0) {
01636     SET_ERROR(handle, NDB_MGM_COULD_NOT_START_BACKUP, result.c_str());
01637     delete reply;
01638     return -1;
01639   }
01640 
01641   delete reply;
01642   return 0;
01643 }

int ndb_mgm_stop NdbMgmHandle  handle,
int  no_of_nodes,
const int *  node_list
 

Stops database nodes

Parameters:
handle Management handle.
no_of_nodes Number of database nodes to be stopped
0: All database nodes in cluster
n: Stop the n node(s) specified in the array node_list
node_list List of node IDs for database nodes to be stopped
Returns:
Number of nodes stopped (-1 on error)
Note:
This function is equivalent to calling ndb_mgm_stop2(handle, no_of_nodes, node_list, 0)

Definition at line 778 of file mgmapi.cpp.

References NDB_MGM_NO_ERROR, ndb_mgm_stop2(), and SET_ERROR.

Referenced by CommandInterpreter::executeShutdown(), and CommandInterpreter::executeStop().

00779 {
00780   SET_ERROR(handle, NDB_MGM_NO_ERROR, "Executing: ndb_mgm_stop");
00781   return ndb_mgm_stop2(handle, no_of_nodes, node_list, 0);
00782 }

int ndb_mgm_stop2 NdbMgmHandle  handle,
int  no_of_nodes,
const int *  node_list,
int  abort
 

All database nodes should be stopped

A list of database nodes should be stopped

Definition at line 787 of file mgmapi.cpp.

References BaseString::appfmt(), args, BaseString::assfmt(), BaseString::c_str(), CHECK_CONNECTED, CHECK_HANDLE, CHECK_REPLY, Properties::get(), MGM_ARG, MGM_CMD, MGM_END, ndb_mgm_call(), NDB_MGM_ILLEGAL_NUMBER_OF_NODES, NDB_MGM_NO_ERROR, NDB_MGM_STOP_FAILED, NULL, Properties::put(), and SET_ERROR.

Referenced by ndb_mgm_stop().

00789 {
00790   SET_ERROR(handle, NDB_MGM_NO_ERROR, "Executing: ndb_mgm_stop2");
00791   const ParserRow<ParserDummy> stop_reply[] = {
00792     MGM_CMD("stop reply", NULL, ""),
00793     MGM_ARG("stopped", Int, Optional, "No of stopped nodes"),
00794     MGM_ARG("result", String, Mandatory, "Error message"),
00795     MGM_END()
00796   };
00797   CHECK_HANDLE(handle, -1);
00798   CHECK_CONNECTED(handle, -1);
00799 
00800   if(no_of_nodes < 0){
00801     SET_ERROR(handle, NDB_MGM_ILLEGAL_NUMBER_OF_NODES, 
00802               "Negative number of nodes requested to stop");
00803     return -1;
00804   }
00805 
00806   Uint32 stoppedNoOfNodes = 0;
00807   if(no_of_nodes == 0){
00811     Properties args;
00812     args.put("abort", abort);
00813     const Properties *reply;
00814     reply = ndb_mgm_call(handle, stop_reply, "stop all", &args);
00815     CHECK_REPLY(reply, -1);
00816 
00817     if(!reply->get("stopped", &stoppedNoOfNodes)){
00818       SET_ERROR(handle, NDB_MGM_STOP_FAILED, 
00819                 "Could not get number of stopped nodes from mgm server");
00820       delete reply;
00821       return -1;
00822     }
00823     BaseString result;
00824     reply->get("result", result);
00825     if(strcmp(result.c_str(), "Ok") != 0) {
00826       SET_ERROR(handle, NDB_MGM_STOP_FAILED, result.c_str());
00827       delete reply;
00828       return -1;
00829     }
00830     delete reply;
00831     return stoppedNoOfNodes;
00832   }
00833 
00837   Properties args;
00838 
00839   BaseString node_list_str;
00840   node_list_str.assfmt("%d", node_list[0]);
00841   for(int node = 1; node < no_of_nodes; node++)
00842     node_list_str.appfmt(" %d", node_list[node]);
00843   
00844   args.put("node", node_list_str.c_str());
00845   args.put("abort", abort);
00846 
00847   const Properties *reply;
00848   reply = ndb_mgm_call(handle, stop_reply, "stop", &args);
00849   CHECK_REPLY(reply, stoppedNoOfNodes);
00850   if(!reply->get("stopped", &stoppedNoOfNodes)){
00851     SET_ERROR(handle, NDB_MGM_STOP_FAILED, 
00852               "Could not get number of stopped nodes from mgm server");
00853     delete reply;
00854     return -1;
00855   }
00856   BaseString result;
00857   reply->get("result", result);
00858   if(strcmp(result.c_str(), "Ok") != 0) {
00859     SET_ERROR(handle, NDB_MGM_STOP_FAILED, result.c_str());
00860     delete reply;
00861     return -1;
00862   }
00863   delete reply;
00864   return stoppedNoOfNodes;
00865 }

int ndb_mgm_valid const ndb_mgm_configuration_iterator  ) 
 

Definition at line 127 of file mgmapi_configuration.cpp.

References ndb_mgm_configuration_iterator::valid().

Referenced by Configuration::calcSizeAlt(), Cmvmi::Cmvmi(), and Qmgr::initData().

00127                                                          {
00128   return iter->valid();
00129 }


Variable Documentation

const struct Ndb_Mgm_Error_Msg ndb_mgm_error_msgs[]
 

Definition at line 261 of file mgmapi.h.

Referenced by ndb_mgm_get_latest_error_msg().

const int ndb_mgm_noOfErrorMsgs
 

Initial value:

  sizeof(ndb_mgm_error_msgs)/sizeof(struct Ndb_Mgm_Error_Msg)

Definition at line 293 of file mgmapi.h.

Referenced by ndb_mgm_get_latest_error_msg().


Generated on Wed Jul 20 21:14:58 2005 for MySQL 5.0.9 Beta by  doxygen 1.4.3