Commit 46fa321f authored by unknown's avatar unknown

fixed some mgmapi docs

added example to ndbapi docs


ndb/include/mgmapi/mgmapi.h:
  fixed some mgmapi docs
ndb/include/ndbapi/Ndb.hpp:
  added examples
ndb/src/mgmapi/mgmapi.cpp:
  removed unused parameter
parent 8538216c
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
* *
* The NDB Cluster Management API (MGM API) is a C API * The NDB Cluster Management API (MGM API) is a C API
* that is used to: * that is used to:
* - Start and stop database nodes (DB nodes) * - Start and stop database nodes (ndbd processes)
* - Start and stop NDB Cluster backups * - Start and stop NDB Cluster backups
* - Control the NDB Cluster log * - Control the NDB Cluster log
* - Perform other administrative tasks * - Perform other administrative tasks
...@@ -30,18 +30,23 @@ ...@@ -30,18 +30,23 @@
* @section General Concepts * @section General Concepts
* *
* Each MGM API function needs a management server handle * Each MGM API function needs a management server handle
* of type Mgm_C_Api::NdbMgmHandle. * of type @ref NdbMgmHandle.
* This handle is initally created by calling the * This handle is initally created by calling the
* function ndb_mgm_create_handle(). * function ndb_mgm_create_handle() and freed by calling
* ndb_mgm_destroy_handle().
* *
* A function can return: * A function can return:
* -# An integer value. * -# An integer value.
* A value of <b>-1</b> indicates an error. * A value of <b>-1</b> indicates an error.
* -# A pointer value. A <var>NULL</var> value indicates an error; * -# A non-const pointer value. A <var>NULL</var> value indicates an error;
* otherwise, the return value must be freed by the user of the MGM API. * otherwise, the return value must be freed
* by the user of the MGM API
* -# A const pointer value. A <var>NULL</var> value indicates an error.
* Returned value should not be freed.
* *
* Error conditions can be identified by using the appropriate * Error conditions can be identified by using the appropriate
* error-reporting functions. * error-reporting functions ndb_mgm_get_latest_error() and
* @ref ndb_mgm_error.
*/ */
/** @addtogroup MGM_C_API /** @addtogroup MGM_C_API
...@@ -64,32 +69,54 @@ extern "C" { ...@@ -64,32 +69,54 @@ extern "C" {
* NDB Cluster node types * NDB Cluster node types
*/ */
enum ndb_mgm_node_type { enum ndb_mgm_node_type {
NDB_MGM_NODE_TYPE_UNKNOWN = -1, /*< Node type not known*/ NDB_MGM_NODE_TYPE_UNKNOWN = -1 /** Node type not known*/
NDB_MGM_NODE_TYPE_API = NODE_TYPE_API,/*< An application node (API)*/ ,NDB_MGM_NODE_TYPE_API /** An application node (API) */
NDB_MGM_NODE_TYPE_NDB = NODE_TYPE_DB, /*< A database node (DB)*/ #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
NDB_MGM_NODE_TYPE_MGM = NODE_TYPE_MGM,/*< A mgmt server node (MGM)*/ = NODE_TYPE_API
NDB_MGM_NODE_TYPE_REP = NODE_TYPE_REP,/*< A replication node */ #endif
,NDB_MGM_NODE_TYPE_NDB /** A database node (DB) */
NDB_MGM_NODE_TYPE_MIN = 0, /*< Min valid value*/ #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
NDB_MGM_NODE_TYPE_MAX = 3 /*< Max valid value*/ = NODE_TYPE_DB
#endif
,NDB_MGM_NODE_TYPE_MGM /** A mgmt server node (MGM)*/
#ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
= NODE_TYPE_MGM
#endif
#ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
,NDB_MGM_NODE_TYPE_REP = NODE_TYPE_REP /** A replication node */
,NDB_MGM_NODE_TYPE_MIN = 0 /** Min valid value*/
,NDB_MGM_NODE_TYPE_MAX = 3 /** Max valid value*/
#endif
}; };
/** /**
* Database node status * Database node status
*/ */
enum ndb_mgm_node_status { enum ndb_mgm_node_status {
NDB_MGM_NODE_STATUS_UNKNOWN = 0, /*< Node status not known*/ /** Node status not known*/
NDB_MGM_NODE_STATUS_NO_CONTACT = 1, /*< No contact with node*/ NDB_MGM_NODE_STATUS_UNKNOWN = 0,
NDB_MGM_NODE_STATUS_NOT_STARTED = 2, /*< Has not run starting protocol*/ /** No contact with node*/
NDB_MGM_NODE_STATUS_STARTING = 3, /*< Is running starting protocol*/ NDB_MGM_NODE_STATUS_NO_CONTACT = 1,
NDB_MGM_NODE_STATUS_STARTED = 4, /*< Running*/ /** Has not run starting protocol*/
NDB_MGM_NODE_STATUS_SHUTTING_DOWN = 5, /*< Is shutting down*/ NDB_MGM_NODE_STATUS_NOT_STARTED = 2,
NDB_MGM_NODE_STATUS_RESTARTING = 6, /*< Is restarting*/ /** Is running starting protocol*/
NDB_MGM_NODE_STATUS_SINGLEUSER = 7, /*< Maintenance mode*/ NDB_MGM_NODE_STATUS_STARTING = 3,
NDB_MGM_NODE_STATUS_RESUME = 8, /*< Resume mode*/ /** Running*/
NDB_MGM_NODE_STATUS_STARTED = 4,
NDB_MGM_NODE_STATUS_MIN = 0, /*< Min valid value*/ /** Is shutting down*/
NDB_MGM_NODE_STATUS_MAX = 6 /*< Max valid value*/ NDB_MGM_NODE_STATUS_SHUTTING_DOWN = 5,
/** Is restarting*/
NDB_MGM_NODE_STATUS_RESTARTING = 6,
/** Maintenance mode*/
NDB_MGM_NODE_STATUS_SINGLEUSER = 7,
/** Resume mode*/
NDB_MGM_NODE_STATUS_RESUME = 8,
#ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
/** Min valid value*/
NDB_MGM_NODE_STATUS_MIN = 0,
/** Max valid value*/
NDB_MGM_NODE_STATUS_MAX = 8
#endif
}; };
/** /**
...@@ -128,14 +155,15 @@ extern "C" { ...@@ -128,14 +155,15 @@ extern "C" {
NDB_MGM_USAGE_ERROR = 5001 NDB_MGM_USAGE_ERROR = 5001
}; };
#ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
struct Ndb_Mgm_Error_Msg { struct Ndb_Mgm_Error_Msg {
enum ndb_mgm_error code; enum ndb_mgm_error code;
const char * msg; const char * msg;
}; };
const struct Ndb_Mgm_Error_Msg ndb_mgm_error_msgs[] = { const struct Ndb_Mgm_Error_Msg ndb_mgm_error_msgs[] = {
{ NDB_MGM_NO_ERROR, "No error" }, { NDB_MGM_NO_ERROR, "No error" },
/* Request for service errors */
{ NDB_MGM_ILLEGAL_CONNECT_STRING, "Illegal connect string" }, { NDB_MGM_ILLEGAL_CONNECT_STRING, "Illegal connect string" },
{ NDB_MGM_ILLEGAL_PORT_NUMBER, "Illegal port number" }, { NDB_MGM_ILLEGAL_PORT_NUMBER, "Illegal port number" },
{ NDB_MGM_ILLEGAL_SOCKET, "Illegal socket" }, { NDB_MGM_ILLEGAL_SOCKET, "Illegal socket" },
...@@ -167,66 +195,86 @@ extern "C" { ...@@ -167,66 +195,86 @@ extern "C" {
{ NDB_MGM_USAGE_ERROR, { NDB_MGM_USAGE_ERROR,
"Usage error" } "Usage error" }
}; };
const int ndb_mgm_noOfErrorMsgs = const int ndb_mgm_noOfErrorMsgs =
sizeof(ndb_mgm_error_msgs)/sizeof(struct Ndb_Mgm_Error_Msg); sizeof(ndb_mgm_error_msgs)/sizeof(struct Ndb_Mgm_Error_Msg);
#endif
/** /**
* Structure returned by ndb_mgm_get_status * Status of a node in the cluster
*
* Sub-structure in enum ndb_mgm_cluster_state
* returned by ndb_mgm_get_status()
*/ */
struct ndb_mgm_node_state { struct ndb_mgm_node_state {
int node_id; /*< NDB Cluster node id*/ /** NDB Cluster node id*/
enum ndb_mgm_node_type node_type; /*< Type of NDB Cluster node*/ int node_id;
enum ndb_mgm_node_status node_status; /*< State of node*/ /** Type of NDB Cluster node*/
int start_phase; /*< Start phase. enum ndb_mgm_node_type node_type;
*< @note Start phase is only /** State of node*/
*< valid if enum ndb_mgm_node_status node_status;
*< node_type is /** Start phase.
*< NDB_MGM_NODE_TYPE_NDB and *
*< node_status is * @note Start phase is only valid if node_type is
*< NDB_MGM_NODE_STATUS_STARTING * NDB_MGM_NODE_TYPE_NDB and node_status is
*/ * NDB_MGM_NODE_STATUS_STARTING
int dynamic_id; /*< Id for heartbeats and */
*< master take-over int start_phase;
*< (only valid for DB nodes) /** Id for heartbeats and master take-over (only valid for DB nodes)
*/ */
int node_group; /*< Node group of node int dynamic_id;
*< (only valid for DB nodes)*/ /** Node group of node (only valid for DB nodes)*/
int version; /*< Internal version number*/ int node_group;
int connect_count; /*< Number of times node has connected /** Internal version number*/
*< or disconnected to the mgm srv int version;
*/ /** Number of times node has connected or disconnected to the
char connect_address[sizeof("000.000.000.000")+1]; * management server
*/
int connect_count;
/** Ip adress of node when it connected to the management server.
* @note it will be empty if the management server has restarted
* after the node connected.
*/
char connect_address[
#ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
sizeof("000.000.000.000")+1
#endif
];
}; };
/** /**
* Cluster status * State of all nodes in the cluster returned from
* ndb_mgm_get_status()
*/ */
struct ndb_mgm_cluster_state { struct ndb_mgm_cluster_state {
int no_of_nodes; /*< No of entries in the /** No of entries in the node_states array */
*< node_states array int no_of_nodes;
*/ /** An array with node_states*/
struct ndb_mgm_node_state /*< An array with node_states*/ struct ndb_mgm_node_state node_states[
node_states[1]; #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
const char *hostname; 1
#endif
];
}; };
/** /**
* Default reply from the server * Default reply from the server (for future use, not used today)
*/ */
struct ndb_mgm_reply { struct ndb_mgm_reply {
int return_code; /*< 0 if successful, /** 0 if successful, otherwise error code. */
*< otherwise error code. int return_code;
*/ /** Error or reply message.*/
char message[256]; /*< Error or reply message.*/ char message[256];
}; };
#ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
/** /**
* Default information types * Default information types
*/ */
enum ndb_mgm_info { enum ndb_mgm_info {
NDB_MGM_INFO_CLUSTER, /*< ?*/ /** ?*/
NDB_MGM_INFO_CLUSTERLOG /*< Cluster log*/ NDB_MGM_INFO_CLUSTER,
/** Cluster log*/
NDB_MGM_INFO_CLUSTERLOG
}; };
/** /**
...@@ -234,11 +282,16 @@ extern "C" { ...@@ -234,11 +282,16 @@ extern "C" {
* (Used only in the development of NDB Cluster.) * (Used only in the development of NDB Cluster.)
*/ */
enum ndb_mgm_signal_log_mode { enum ndb_mgm_signal_log_mode {
NDB_MGM_SIGNAL_LOG_MODE_IN, /*< Log receiving signals */ /** Log receiving signals */
NDB_MGM_SIGNAL_LOG_MODE_OUT, /*< Log sending signals*/ NDB_MGM_SIGNAL_LOG_MODE_IN,
NDB_MGM_SIGNAL_LOG_MODE_INOUT, /*< Log both sending/receiving*/ /** Log sending signals*/
NDB_MGM_SIGNAL_LOG_MODE_OFF /*< Log off*/ NDB_MGM_SIGNAL_LOG_MODE_OUT,
/** Log both sending/receiving*/
NDB_MGM_SIGNAL_LOG_MODE_INOUT,
/** Log off*/
NDB_MGM_SIGNAL_LOG_MODE_OFF
}; };
#endif
/** /**
* Log severities (used to filter the cluster log) * Log severities (used to filter the cluster log)
...@@ -246,32 +299,31 @@ extern "C" { ...@@ -246,32 +299,31 @@ extern "C" {
enum ndb_mgm_clusterlog_level { enum ndb_mgm_clusterlog_level {
NDB_MGM_ILLEGAL_CLUSTERLOG_LEVEL = -1, NDB_MGM_ILLEGAL_CLUSTERLOG_LEVEL = -1,
/* must range from 0 and up, indexes into an array */ /* must range from 0 and up, indexes into an array */
NDB_MGM_CLUSTERLOG_ON = 0, /*< Cluster log on*/ /** Cluster log on*/
NDB_MGM_CLUSTERLOG_DEBUG = 1, /*< Used in NDB Cluster NDB_MGM_CLUSTERLOG_ON = 0,
*< developement /** Used in NDB Cluster developement */
*/ NDB_MGM_CLUSTERLOG_DEBUG = 1,
NDB_MGM_CLUSTERLOG_INFO = 2, /*< Informational messages*/ /** Informational messages*/
NDB_MGM_CLUSTERLOG_WARNING = 3, /*< Conditions that are not NDB_MGM_CLUSTERLOG_INFO = 2,
*< error condition, but /** Conditions that are not error condition, but might require handling
*< might require handling */
*/ NDB_MGM_CLUSTERLOG_WARNING = 3,
NDB_MGM_CLUSTERLOG_ERROR = 4, /*< Conditions that should be /** Conditions that should be corrected */
*< corrected NDB_MGM_CLUSTERLOG_ERROR = 4,
*/ /** Critical conditions, like device errors or out of resources */
NDB_MGM_CLUSTERLOG_CRITICAL = 5, /*< Critical conditions, like NDB_MGM_CLUSTERLOG_CRITICAL = 5,
*< device errors or out of /** A condition that should be corrected immediately,
*< resources * such as a corrupted system
*/ */
NDB_MGM_CLUSTERLOG_ALERT = 6, /*< A condition that should be NDB_MGM_CLUSTERLOG_ALERT = 6,
*< corrected immediately,
*< such as a corrupted system
*/
/* must be next number, works as bound in loop */ /* must be next number, works as bound in loop */
NDB_MGM_CLUSTERLOG_ALL = 7 /*< All severities */ /** All severities */
NDB_MGM_CLUSTERLOG_ALL = 7
}; };
/** /**
* Log categories * Log categories, used to set filter on the clusterlog using
* ndb_mgm_set_loglevel_clusterlog()
*/ */
enum ndb_mgm_event_category { enum ndb_mgm_event_category {
/** /**
...@@ -282,28 +334,56 @@ extern "C" { ...@@ -282,28 +334,56 @@ extern "C" {
* Events during all kinds of startups * Events during all kinds of startups
*/ */
NDB_MGM_EVENT_CATEGORY_STARTUP = CFG_LOGLEVEL_STARTUP, NDB_MGM_EVENT_CATEGORY_STARTUP = CFG_LOGLEVEL_STARTUP,
/** /**
* Events during shutdown * Events during shutdown
*/ */
NDB_MGM_EVENT_CATEGORY_SHUTDOWN = CFG_LOGLEVEL_SHUTDOWN, NDB_MGM_EVENT_CATEGORY_SHUTDOWN = CFG_LOGLEVEL_SHUTDOWN,
/** /**
* Transaction statistics (Job level, TCP/IP speed) * Transaction statistics (Job level, TCP/IP speed)
*/ */
NDB_MGM_EVENT_CATEGORY_STATISTIC = CFG_LOGLEVEL_STATISTICS, NDB_MGM_EVENT_CATEGORY_STATISTIC = CFG_LOGLEVEL_STATISTICS,
/**
* Events regarding checkpoints
*/
NDB_MGM_EVENT_CATEGORY_CHECKPOINT = CFG_LOGLEVEL_CHECKPOINT, NDB_MGM_EVENT_CATEGORY_CHECKPOINT = CFG_LOGLEVEL_CHECKPOINT,
/**
* Events during node restart
*/
NDB_MGM_EVENT_CATEGORY_NODE_RESTART = CFG_LOGLEVEL_NODERESTART, NDB_MGM_EVENT_CATEGORY_NODE_RESTART = CFG_LOGLEVEL_NODERESTART,
/**
* Events on connection between cluster nodes
*/
NDB_MGM_EVENT_CATEGORY_CONNECTION = CFG_LOGLEVEL_CONNECTION, NDB_MGM_EVENT_CATEGORY_CONNECTION = CFG_LOGLEVEL_CONNECTION,
/**
* Backup events
*/
NDB_MGM_EVENT_CATEGORY_BACKUP = CFG_LOGLEVEL_BACKUP,
/**
* Loglevel debug
*/
NDB_MGM_EVENT_CATEGORY_DEBUG = CFG_LOGLEVEL_DEBUG, NDB_MGM_EVENT_CATEGORY_DEBUG = CFG_LOGLEVEL_DEBUG,
/**
* Loglevel info
*/
NDB_MGM_EVENT_CATEGORY_INFO = CFG_LOGLEVEL_INFO, NDB_MGM_EVENT_CATEGORY_INFO = CFG_LOGLEVEL_INFO,
/**
* Loglevel warning
*/
NDB_MGM_EVENT_CATEGORY_WARNING = CFG_LOGLEVEL_WARNING, NDB_MGM_EVENT_CATEGORY_WARNING = CFG_LOGLEVEL_WARNING,
/**
* Loglevel error
*/
NDB_MGM_EVENT_CATEGORY_ERROR = CFG_LOGLEVEL_ERROR, NDB_MGM_EVENT_CATEGORY_ERROR = CFG_LOGLEVEL_ERROR,
#ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
/**
*
*/
NDB_MGM_EVENT_CATEGORY_GREP = CFG_LOGLEVEL_GREP, NDB_MGM_EVENT_CATEGORY_GREP = CFG_LOGLEVEL_GREP,
NDB_MGM_EVENT_CATEGORY_BACKUP = CFG_LOGLEVEL_BACKUP, #endif
#ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
NDB_MGM_MIN_EVENT_CATEGORY = CFG_MIN_LOGLEVEL, NDB_MGM_MIN_EVENT_CATEGORY = CFG_MIN_LOGLEVEL,
NDB_MGM_MAX_EVENT_CATEGORY = CFG_MAX_LOGLEVEL NDB_MGM_MAX_EVENT_CATEGORY = CFG_MAX_LOGLEVEL
#endif
}; };
/***************************************************************************/ /***************************************************************************/
...@@ -618,7 +698,7 @@ extern "C" { ...@@ -618,7 +698,7 @@ extern "C" {
/** @} *********************************************************************/ /** @} *********************************************************************/
/** /**
* @name Functions: Logging and Statistics * @name Functions: Logging
* @{ * @{
*/ */
...@@ -670,6 +750,17 @@ extern "C" { ...@@ -670,6 +750,17 @@ extern "C" {
enum ndb_mgm_event_category category, enum ndb_mgm_event_category category,
int level, int level,
struct ndb_mgm_reply* reply); struct ndb_mgm_reply* reply);
/**
* Listen to log events
*
* @param filter pairs of { level, ndb_mgm_event_category } that will be
* pushed to fd, level=0 ends lists
*
* @return fd which events will be pushed to
*/
int ndb_mgm_listen_event(NdbMgmHandle handle, int filter[]);
#ifndef DOXYGEN_SHOULD_SKIP_INTERNAL #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
/** /**
* Set log category and levels for the Node * Set log category and levels for the Node
...@@ -760,15 +851,11 @@ extern "C" { ...@@ -760,15 +851,11 @@ extern "C" {
int ndb_mgm_exit_single_user(NdbMgmHandle handle, int ndb_mgm_exit_single_user(NdbMgmHandle handle,
struct ndb_mgm_reply* reply); struct ndb_mgm_reply* reply);
/** @} *********************************************************************/
/** /**
* Listen event * @name Configuration handling
* * @{
* @param filter pairs of { level, category } that will be
* pushed to fd, level=0 ends lists
*
* @return fd which events will be pushed to
*/ */
int ndb_mgm_listen_event(NdbMgmHandle handle, int filter[]);
/** /**
* Get configuration * Get configuration
...@@ -778,7 +865,7 @@ extern "C" { ...@@ -778,7 +865,7 @@ extern "C" {
* *
* @return configuration * @return configuration
* *
* @note the caller must call ndb_mgm_detroy_configuration * @note the caller must call ndb_mgm_destroy_configuration()
*/ */
struct ndb_mgm_configuration * ndb_mgm_get_configuration(NdbMgmHandle handle, struct ndb_mgm_configuration * ndb_mgm_get_configuration(NdbMgmHandle handle,
unsigned version); unsigned version);
......
...@@ -435,6 +435,10 @@ ...@@ -435,6 +435,10 @@
*/ */
#ifndef DOXYGEN_SHOULD_SKIP_INTERNAL #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
/**
* @page ndbapi_async.cpp ndbapi_async.cpp
* @include ndbapi_async.cpp
*/
/** /**
* @page ndbapi_async1.cpp ndbapi_async1.cpp * @page ndbapi_async1.cpp ndbapi_async1.cpp
* @include ndbapi_async1.cpp * @include ndbapi_async1.cpp
...@@ -456,6 +460,11 @@ ...@@ -456,6 +460,11 @@
* @include ndbapi_scan.cpp * @include ndbapi_scan.cpp
*/ */
/**
* @page ndbapi_event.cpp ndbapi_event.cpp
* @include ndbapi_event.cpp
*/
/** /**
@page secAdapt Adaptive Send Algorithm @page secAdapt Adaptive Send Algorithm
......
...@@ -629,7 +629,6 @@ ndb_mgm_get_status(NdbMgmHandle handle) ...@@ -629,7 +629,6 @@ ndb_mgm_get_status(NdbMgmHandle handle)
malloc(sizeof(ndb_mgm_cluster_state)+ malloc(sizeof(ndb_mgm_cluster_state)+
noOfNodes*(sizeof(ndb_mgm_node_state)+sizeof("000.000.000.000#"))); noOfNodes*(sizeof(ndb_mgm_node_state)+sizeof("000.000.000.000#")));
state->hostname= 0;
state->no_of_nodes= noOfNodes; state->no_of_nodes= noOfNodes;
ndb_mgm_node_state * ptr = &state->node_states[0]; ndb_mgm_node_state * ptr = &state->node_states[0];
int nodeId = 0; int nodeId = 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment