mgmapi.h 25.8 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
/* Copyright (C) 2003 MySQL AB

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */

#ifndef MGMAPI_H
#define MGMAPI_H

/**
 * @mainpage NDB Cluster Management API
 *
23
 * The NDB Cluster Management API (MGM API) is a C API
24
 * that is used to:
25 26
 * - Start and stop database nodes (DB nodes)
 * - Start and stop NDB Cluster backups
27
 * - Control the NDB Cluster log
28
 * - Perform other administrative tasks
29 30 31
 *
 * @section  General Concepts
 *
32 33 34 35
 * Each MGM API function needs a management server handle
 * of type <code>Mgm_C_Api::NdbMgmHandle</code>.
 * This handle is initally created by calling the
 * function <code>ndb_mgm_create_handle()</code>.
36 37
 *
 * A function can return:
38 39 40 41
 *  -# An integer value.
 *     A value of <b>-1</b> indicates an error.
 *  -# A pointer value.  A <var>NULL</var> value indicates an error;
 *     Otherwise, the return value must be <code>free()</code>ed by the user of the MGM API.
42
 *
43
 * Error conditions can be identified by using the appropriate
44
 * error-reporting functions.
45 46 47 48 49 50
 */

/** @addtogroup MGM_C_API
 *  @{
 */

unknown's avatar
unknown committed
51
#include <ndb_types.h>
unknown's avatar
unknown committed
52 53
#include "mgmapi_config_parameters.h"

54 55 56 57 58 59 60 61 62 63 64 65 66
#ifdef __cplusplus
extern "C" {
#endif

  /**
   * The NdbMgmHandle.
   */
  typedef struct ndb_mgm_handle * NdbMgmHandle;

  /**
   *   NDB Cluster node types
   */
  enum ndb_mgm_node_type {
67 68 69 70 71 72 73 74
    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_NDB     = NODE_TYPE_DB, /*< A database node (DB)*/
    NDB_MGM_NODE_TYPE_MGM     = NODE_TYPE_MGM,/*< A mgmt server node (MGM)*/
    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*/
75 76 77 78 79 80
  };

  /**
   *   Database node status
   */
  enum ndb_mgm_node_status {
81 82 83 84 85 86 87 88 89 90 91 92
    NDB_MGM_NODE_STATUS_UNKNOWN       = 0,  /*< Node status not known*/
    NDB_MGM_NODE_STATUS_NO_CONTACT    = 1,  /*< No contact with node*/
    NDB_MGM_NODE_STATUS_NOT_STARTED   = 2,  /*< Has not run starting protocol*/
    NDB_MGM_NODE_STATUS_STARTING      = 3,  /*< Is running starting protocol*/
    NDB_MGM_NODE_STATUS_STARTED       = 4,  /*< Running*/
    NDB_MGM_NODE_STATUS_SHUTTING_DOWN = 5,  /*< Is shutting down*/
    NDB_MGM_NODE_STATUS_RESTARTING    = 6,  /*< Is restarting*/
    NDB_MGM_NODE_STATUS_SINGLEUSER    = 7,  /*< Maintenance mode*/
    NDB_MGM_NODE_STATUS_RESUME        = 8,  /*< Resume mode*/

    NDB_MGM_NODE_STATUS_MIN           = 0,  /*< Min valid value*/
    NDB_MGM_NODE_STATUS_MAX           = 6   /*< Max valid value*/
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124
  };

  /**
   *    Error codes
   */
  enum ndb_mgm_error {
    NDB_MGM_NO_ERROR = 0,

    /* Request for service errors */
    NDB_MGM_ILLEGAL_CONNECT_STRING = 1001,
    NDB_MGM_ILLEGAL_PORT_NUMBER = 1002,
    NDB_MGM_ILLEGAL_SOCKET = 1003,
    NDB_MGM_ILLEGAL_IP_ADDRESS = 1004,
    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,

    /* Service errors - Start/Stop Node or System */
    NDB_MGM_START_FAILED = 2001,
    NDB_MGM_STOP_FAILED = 2002,
    NDB_MGM_RESTART_FAILED = 2003,

    /* Service errors - Backup */
    NDB_MGM_COULD_NOT_START_BACKUP = 3001,
    NDB_MGM_COULD_NOT_ABORT_BACKUP = 3002,

    /* Service errors - Single User Mode */
    NDB_MGM_COULD_NOT_ENTER_SINGLE_USER_MODE = 4001,
125 126 127 128
    NDB_MGM_COULD_NOT_EXIT_SINGLE_USER_MODE = 4002,

    /* Usage errors */
    NDB_MGM_USAGE_ERROR = 5001
129 130 131 132
  };

  struct Ndb_Mgm_Error_Msg {
    enum ndb_mgm_error  code;
133
    const char *        msg;
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158
  };

  const struct Ndb_Mgm_Error_Msg ndb_mgm_error_msgs[] = {
    { NDB_MGM_NO_ERROR, "No error" },

    { NDB_MGM_ILLEGAL_CONNECT_STRING, "Illegal connect string" },
    { NDB_MGM_ILLEGAL_PORT_NUMBER, "Illegal port number" },
    { NDB_MGM_ILLEGAL_SOCKET, "Illegal socket" },
    { NDB_MGM_ILLEGAL_IP_ADDRESS, "Illegal IP address" },
    { NDB_MGM_ILLEGAL_SERVER_HANDLE, "Illegal server handle" },
    { 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, "Out of memory" },
    { NDB_MGM_SERVER_NOT_CONNECTED, "Management server not connected" },
    { NDB_MGM_COULD_NOT_CONNECT_TO_SOCKET, "Could not connect to socket" },

    /* Service errors - Start/Stop Node or System */
    { NDB_MGM_START_FAILED, "Start failed" },
    { NDB_MGM_STOP_FAILED, "Stop failed" },
    { NDB_MGM_RESTART_FAILED, "Restart failed" },

    /* Service errors - Backup */
    { NDB_MGM_COULD_NOT_START_BACKUP, "Could not start backup" },
    { NDB_MGM_COULD_NOT_ABORT_BACKUP, "Could not abort backup" },
159

160
    /* Service errors - Single User Mode */
161
    { NDB_MGM_COULD_NOT_ENTER_SINGLE_USER_MODE,
162
      "Could not enter single user mode" },
163
    { NDB_MGM_COULD_NOT_EXIT_SINGLE_USER_MODE,
164 165 166 167 168
      "Could not exit single user mode" },

    /* Usage errors */
    { NDB_MGM_USAGE_ERROR,
      "Usage error" }
169
  };
170 171

  const int ndb_mgm_noOfErrorMsgs =
172 173 174 175 176 177
  sizeof(ndb_mgm_error_msgs)/sizeof(struct Ndb_Mgm_Error_Msg);

  /**
   *   Structure returned by ndb_mgm_get_status
   */
  struct ndb_mgm_node_state {
178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195
    int node_id;                            /*< NDB Cluster node id*/
    enum ndb_mgm_node_type   node_type;     /*< Type of NDB Cluster node*/
    enum ndb_mgm_node_status node_status;   /*< State of node*/
    int start_phase;                        /*< Start phase.
					     *< @note Start phase is only
					     *< valid if
					     *< node_type is
					     *< NDB_MGM_NODE_TYPE_NDB and
					     *< node_status is
					     *< NDB_MGM_NODE_STATUS_STARTING
					     */
    int dynamic_id;                         /*< Id for heartbeats and
					     *< master take-over
					     *< (only valid for DB nodes)
					     */
    int node_group;                         /*< Node group of node
					     *< (only valid for DB nodes)*/
    int version;                            /*< Internal version number*/
196
    int connect_count;                      /*< Number of times node has connected
197 198
					     *< or disconnected to the mgm srv
					     */
unknown's avatar
unknown committed
199
    char connect_address[sizeof("000.000.000.000")+1];
200 201 202 203 204 205
  };

  /**
   *   Cluster status
   */
  struct ndb_mgm_cluster_state {
206
    int no_of_nodes;                        /*< No of entries in the
207 208 209
					     *< node_states array
					     */
    struct ndb_mgm_node_state               /*< An array with node_states*/
210
    node_states[1];
unknown's avatar
unknown committed
211
    const char *hostname;
212 213 214 215 216 217
  };

  /**
   *   Default reply from the server
   */
  struct ndb_mgm_reply {
218
    int return_code;                        /*< 0 if successful,
219 220 221
					     *< otherwise error code.
					     */
    char message[256];                      /*< Error or reply message.*/
222 223 224 225 226 227
  };

  /**
   *   Default information types
   */
  enum ndb_mgm_info {
228 229
    NDB_MGM_INFO_CLUSTER,                   /*< ?*/
    NDB_MGM_INFO_CLUSTERLOG                 /*< Cluster log*/
230 231 232 233 234 235 236
  };

  /**
   *   Signal log modes
   *   (Used only in the development of NDB Cluster.)
   */
  enum ndb_mgm_signal_log_mode {
237 238 239 240
    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*/
241 242 243 244 245 246
  };

  /**
   *   Log severities (used to filter the cluster log)
   */
  enum ndb_mgm_clusterlog_level {
247 248 249 250 251 252
    NDB_MGM_CLUSTERLOG_OFF = 0,             /*< Cluster log off*/
    NDB_MGM_CLUSTERLOG_DEBUG = 1,           /*< Used in NDB Cluster
					     *< developement
					     */
    NDB_MGM_CLUSTERLOG_INFO = 2,            /*< Informational messages*/
    NDB_MGM_CLUSTERLOG_WARNING = 3,         /*< Conditions that are not
253
					     *< error condition, but
254 255 256 257 258 259
					     *< might require handling
					     */
    NDB_MGM_CLUSTERLOG_ERROR = 4,           /*< Conditions that should be
					     *< corrected
					     */
    NDB_MGM_CLUSTERLOG_CRITICAL = 5,        /*< Critical conditions, like
260
					     *< device errors or out of
261 262 263 264 265 266 267
					     *< resources
					     */
    NDB_MGM_CLUSTERLOG_ALERT = 6,           /*< A condition that should be
					     *< corrected immediately,
					     *< such as a corrupted system
					     */
    NDB_MGM_CLUSTERLOG_ALL = 7              /*< All severities on*/
268 269 270 271 272 273
  };

  /**
   *   Log categories
   */
  enum ndb_mgm_event_category {
unknown's avatar
unknown committed
274 275 276 277
    /**
     * Invalid
     */
    NDB_MGM_ILLEGAL_EVENT_CATEGORY = -1,
278 279 280 281
    /**
     * Events during all kinds of startups
     */
    NDB_MGM_EVENT_CATEGORY_STARTUP = CFG_LOGLEVEL_STARTUP,
282

283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299
    /**
     * Events during shutdown
     */
    NDB_MGM_EVENT_CATEGORY_SHUTDOWN = CFG_LOGLEVEL_SHUTDOWN,

    /**
     * Transaction statistics (Job level, TCP/IP speed)
     */
    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_DEBUG = CFG_LOGLEVEL_DEBUG,
    NDB_MGM_EVENT_CATEGORY_INFO = CFG_LOGLEVEL_INFO,
    NDB_MGM_EVENT_CATEGORY_WARNING = CFG_LOGLEVEL_WARNING,
    NDB_MGM_EVENT_CATEGORY_ERROR = CFG_LOGLEVEL_ERROR,
    NDB_MGM_EVENT_CATEGORY_GREP = CFG_LOGLEVEL_GREP,
unknown's avatar
unknown committed
300
    NDB_MGM_EVENT_CATEGORY_BACKUP = CFG_LOGLEVEL_BACKUP,
301

302 303
    NDB_MGM_MIN_EVENT_CATEGORY = CFG_MIN_LOGLEVEL,
    NDB_MGM_MAX_EVENT_CATEGORY = CFG_MAX_LOGLEVEL
304
  };
305

306
  /***************************************************************************/
307
  /**
308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330
   * @name Functions: Error Handling
   * @{
   */

  /**
   * Get latest error associated with a management server handle
   *
   * @param   handle        Management handle
   * @return                Latest error code
   */
  int ndb_mgm_get_latest_error(const NdbMgmHandle handle);

  /**
   * Get latest main error message associated with a handle
   *
   * @param   handle        Management handle.
   * @return                Latest error message
   */
  const char * ndb_mgm_get_latest_error_msg(const NdbMgmHandle handle);

  /**
   * Get latest error description associated with a handle
   *
331
   * The error description gives some additional information to
332 333 334 335 336 337 338 339 340 341 342 343 344
   * the error message.
   *
   * @param   handle        Management handle.
   * @return                Latest error description
   */
  const char * ndb_mgm_get_latest_error_desc(const NdbMgmHandle handle);

#ifndef DOXYGEN_SHOULD_SKIP_DEPRECATED
  /**
   * Get latest internal source code error line associated with a handle
   *
   * @param   handle        Management handle.
   * @return                Latest internal source code line of latest error
345
   * @deprecated
346 347 348 349 350
   */
  int ndb_mgm_get_latest_error_line(const NdbMgmHandle handle);
#endif

  /** @} *********************************************************************/
351
  /**
352 353 354 355
   * @name Functions: Create/Destroy Management Server Handles
   * @{
   */

356
  /**
357 358
   * Create a handle to a management server
   *
359
   * @return                 A management handle<br>
360
   *                         or NULL if no management handle could be created.
361 362
   */
  NdbMgmHandle ndb_mgm_create_handle();
363

364 365 366 367 368 369
  /**
   * Destroy a management server handle
   *
   * @param   handle        Management handle
   */
  void ndb_mgm_destroy_handle(NdbMgmHandle * handle);
370

371
  /** @} *********************************************************************/
372
  /**
373 374 375 376
   * @name Functions: Connect/Disconnect Management Server
   * @{
   */

377
  /**
378 379 380
   * Set connect string to management server
   *
   * @param   handle         Management handle
381
   * @param   connect_string Connect string to the management server,
382 383 384 385 386 387
   *
   * @return                -1 on error.
   */
  int ndb_mgm_set_connectstring(NdbMgmHandle handle,
				const char *connect_string);

388
  /**
389 390 391 392 393 394 395 396 397 398 399
   * Get connectstring used for connection
   *
   * @note returns what the connectstring defaults to if the above call has
   *       not been performed
   *
   * @param   handle         Management handle
   *
   * @return                 connectstring
   */
  const char *ndb_mgm_get_connectstring(NdbMgmHandle handle, char *buf, int buf_sz);

400 401 402 403 404 405
  /**
   * Connect to a management server
   *
   * @param   handle        Management handle.
   * @return                -1 on error.
   */
406 407
  int ndb_mgm_connect(NdbMgmHandle handle, int no_retries,
		      int retry_delay_in_seconds, int verbose);
408

409 410 411 412 413 414 415
  /**
   * Disconnect from a management server
   *
   * @param  handle         Management handle.
   * @return                -1 on error.
   */
  int ndb_mgm_disconnect(NdbMgmHandle handle);
416 417

  /**
418 419 420 421 422 423 424 425
   * Get nodeid used in the connection
   *
   * @param   handle         Management handle
   *
   * @return                 node id
   */
  int ndb_mgm_get_configuration_nodeid(NdbMgmHandle handle);

426
  /**
427 428 429 430 431 432 433 434
   * Get port used in the connection
   *
   * @param   handle         Management handle
   *
   * @return                 port
   */
  int ndb_mgm_get_connected_port(NdbMgmHandle handle);

435
  /**
436 437 438 439 440 441 442 443
   * Get host used in the connection
   *
   * @param   handle         Management handle
   *
   * @return                 hostname
   */
  const char *ndb_mgm_get_connected_host(NdbMgmHandle handle);

444
  /** @} *********************************************************************/
445
  /**
446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465
   * @name Functions: Convert between different data formats
   * @{
   */

  /**
   * Convert a string to a ndb_mgm_node_type
   *
   * @param   type          Node type as string.
   * @return                NDB_MGM_NODE_TYPE_UNKNOWN if invalid string.
   */
  enum ndb_mgm_node_type ndb_mgm_match_node_type(const char * type);

  /**
   * Convert an ndb_mgm_node_type to a string
   *
   * @param   type          Node type.
   * @return                NULL if invalid id.
   */
  const char * ndb_mgm_get_node_type_string(enum ndb_mgm_node_type type);

466 467 468 469 470 471
  /**
   * Convert an ndb_mgm_node_type to a alias string
   *
   * @param   type          Node type.
   * @return                NULL if invalid id.
   */
472 473
  const char * ndb_mgm_get_node_type_alias_string(enum ndb_mgm_node_type type,
						  const char **str);
474

475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490
  /**
   * Convert a string to a ndb_mgm_node_status
   *
   * @param   status        NDB node status string.
   * @return                NDB_MGM_NODE_STATUS_UNKNOWN if invalid string.
   */
  enum ndb_mgm_node_status ndb_mgm_match_node_status(const char * status);

  /**
   * Convert an id to a string
   *
   * @param   status        NDB node status.
   * @return                NULL if invalid id.
   */
  const char * ndb_mgm_get_node_status_string(enum ndb_mgm_node_status status);

491
#ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
492 493
  ndb_mgm_event_category ndb_mgm_match_event_category(const char *);
  const char * ndb_mgm_get_event_category_string(enum ndb_mgm_event_category);
494
#endif
495

496
  /** @} *********************************************************************/
497
  /**
498 499 500 501 502 503 504 505 506 507
   * @name Functions: State of cluster
   * @{
   */

  /**
   * Get status of the nodes in an NDB Cluster
   *
   * Note the caller must free the pointer returned.
   *
   * @param   handle        Management handle.
508
   *
509 510 511 512 513
   * @return                Cluster state (or NULL on error).
   */
  struct ndb_mgm_cluster_state * ndb_mgm_get_status(NdbMgmHandle handle);

  /** @} *********************************************************************/
514 515
  /**
   * @name Functions: Start/stop nodes
516 517 518 519 520 521 522 523 524
   * @{
   */

  /**
   * Stop database nodes
   *
   * @param   handle        Management handle.
   * @param   no_of_nodes   no of database nodes<br>
   *                        0 - means all database nodes in cluster<br>
525
   *                        n - Means stop n node(s) specified in the
526 527
   *                            array node_list
   * @param   node_list     List of node ids of database nodes to be stopped
528
   *
529 530
   * @return                No of nodes stopped (or -1 on error)
   *
531
   * @note    The function is equivalent
532 533
   *          to ndb_mgm_stop2(handle, no_of_nodes, node_list, 0)
   */
534
  int ndb_mgm_stop(NdbMgmHandle handle, int no_of_nodes,
535 536 537 538 539 540 541 542
		   const int * node_list);

  /**
   * Stop database nodes
   *
   * @param   handle        Management handle.
   * @param   no_of_nodes   No of database nodes<br>
   *                        0 - means all database nodes in cluster<br>
543
   *                        n - Means stop n node(s) specified in
544 545
   *                            the array node_list
   * @param   node_list     List of node ids of database nodes to be stopped
546
   * @param   abort         Don't perform gracefull stop,
547
   *                        but rather stop immediatly
548
   *
549 550 551 552 553 554 555 556 557 558 559
   * @return                No of nodes stopped (or -1 on error).
   */
  int ndb_mgm_stop2(NdbMgmHandle handle, int no_of_nodes,
		    const int * node_list, int abort);

  /**
   * Restart database nodes
   *
   * @param   handle        Management handle.
   * @param   no_of_nodes   No of database nodes<br>
   *                        0 - means all database nodes in cluster<br>
560
   *                        n - Means stop n node(s) specified in the
561 562
   *                            array node_list
   * @param   node_list     List of node ids of database nodes to be stopped
563
   *
564 565
   * @return                No of nodes stopped (or -1 on error).
   *
566
   * @note    The function is equivalent to
567 568
   *          ndb_mgm_restart2(handle, no_of_nodes, node_list, 0, 0, 0);
   */
569
  int ndb_mgm_restart(NdbMgmHandle handle, int no_of_nodes,
570 571 572 573 574 575 576 577
		      const int * node_list);

  /**
   * Restart database nodes
   *
   * @param   handle        Management handle.
   * @param   no_of_nodes   No of database nodes<br>
   *                        0 - means all database nodes in cluster<br>
578
   *                        n - Means stop n node(s) specified in the
579 580 581
   *                            array node_list
   * @param   node_list     List of node ids of database nodes to be stopped
   * @param   initial       Remove filesystem from node(s) restarting
582
   * @param   nostart       Don't actually start node(s) but leave them
583
   *                        waiting for start command
584
   * @param   abort         Don't perform gracefull restart,
585
   *                        but rather restart immediatly
586
   *
587 588 589 590 591
   * @return                No of nodes stopped (or -1 on error).
   */
  int ndb_mgm_restart2(NdbMgmHandle handle, int no_of_nodes,
		       const int * node_list, int initial,
		       int nostart, int abort);
592

593 594 595 596 597 598
  /**
   * Start database nodes
   *
   * @param   handle        Management handle.
   * @param   no_of_nodes   No of database nodes<br>
   *                        0 - means all database nodes in cluster<br>
599
   *                        n - Means start n node(s) specified in
600 601
   *                            the array node_list
   * @param   node_list     List of node ids of database nodes to be started
602
   *
603 604
   * @return                No of nodes started (or -1 on error).
   *
605
   * @note    The nodes to start must have been started with nostart(-n)
606
   *          argument.
607 608
   *          This means that the database node binary is started and
   *          waiting for a START management command which will
609 610 611 612 613 614 615
   *          actually start the database node functionality
   */
  int ndb_mgm_start(NdbMgmHandle handle,
		    int no_of_nodes,
		    const int * node_list);

  /** @} *********************************************************************/
616
  /**
617 618 619 620 621 622 623 624 625 626
   * @name Functions: Logging and Statistics
   * @{
   */

  /**
   * Filter cluster log
   *
   * @param   handle        NDB management handle.
   * @param   level         A cluster log level to filter.
   * @param   reply         Reply message.
627
   *
628 629 630 631 632 633 634 635
   * @return                -1 on error.
   */
  int ndb_mgm_filter_clusterlog(NdbMgmHandle handle,
				enum ndb_mgm_clusterlog_level level,
				struct ndb_mgm_reply* reply);

  /**
   * Get log filter
636
   *
637
   * @param   handle        NDB management handle
638
   *
639
   * @return                A vector of seven elements,
640
   *                        where each element contains
641 642 643
   *                        1 if a severity is enabled and 0 if not.
   *                        A severity is stored at position
   *                        ndb_mgm_clusterlog_level,
644 645
   *                        for example the "error" level is stored in position
   *                        [NDB_MGM_CLUSTERLOG_ERROR-1].
646
   *                        The first element in the vector signals
647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663
   *                        whether the clusterlog
   *                        is disabled or enabled.
   */
  unsigned int *ndb_mgm_get_logfilter(NdbMgmHandle handle);

  /**
   * Set log category and levels for the cluster log
   *
   * @param   handle        NDB management handle.
   * @param   nodeId        Node id.
   * @param   category      Event category.
   * @param   level         Log level (0-15).
   * @param   reply         Reply message.
   * @return                -1 on error.
   */
  int ndb_mgm_set_loglevel_clusterlog(NdbMgmHandle handle,
				      int nodeId,
664
				      enum ndb_mgm_event_category category,
665 666
				      int level,
				      struct ndb_mgm_reply* reply);
667
#ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
668 669 670 671 672 673 674 675 676 677 678 679
  /**
   * Set log category and levels for the Node
   *
   * @param   handle        NDB management handle.
   * @param   nodeId        Node id.
   * @param   category      Event category.
   * @param   level         Log level (0-15).
   * @param   reply         Reply message.
   * @return                -1 on error.
   */
  int ndb_mgm_set_loglevel_node(NdbMgmHandle handle,
				int nodeId,
680
				enum ndb_mgm_event_category category,
681 682 683 684 685 686 687 688 689 690 691 692
				int level,
				struct ndb_mgm_reply* reply);

  /**
   * Returns the port number where statistics information is sent
   *
   * @param   handle        NDB management handle.
   * @param   reply         Reply message.
   * @return                -1 on error.
   */
  int ndb_mgm_get_stat_port(NdbMgmHandle handle,
			    struct ndb_mgm_reply* reply);
693
#endif
694 695

  /** @} *********************************************************************/
696
  /**
697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724
   * @name Functions: Backup
   * @{
   */

  /**
   * Start backup
   *
   * @param   handle        NDB management handle.
   * @param   backup_id     Backup id is returned from function.
   * @param   reply         Reply message.
   * @return                -1 on error.
   */
  int ndb_mgm_start_backup(NdbMgmHandle handle, unsigned int* backup_id,
			   struct ndb_mgm_reply* reply);

  /**
   * Abort backup
   *
   * @param   handle        NDB management handle.
   * @param   backup_id     Backup Id.
   * @param   reply         Reply message.
   * @return                -1 on error.
   */
  int ndb_mgm_abort_backup(NdbMgmHandle handle, unsigned int backup_id,
			   struct ndb_mgm_reply* reply);


  /** @} *********************************************************************/
725
  /**
726 727 728 729 730
   * @name Functions: Single User Mode
   * @{
   */

  /**
731
   * Enter Single user mode
732 733 734 735 736 737 738 739
   *
   * @param   handle        NDB management handle.
   * @param   nodeId        Node Id of the single user node
   * @param   reply         Reply message.
   * @return                -1 on error.
   */
  int ndb_mgm_enter_single_user(NdbMgmHandle handle, unsigned int nodeId,
				struct ndb_mgm_reply* reply);
740

741
  /**
742
   * Exit Single user mode
743 744 745 746
   *
   * @param   handle        NDB management handle.
   * @param   nodeId        Node Id of the single user node
   * @param   reply         Reply message.
747
   *
748 749
   * @return                -1 on error.
   */
750
  int ndb_mgm_exit_single_user(NdbMgmHandle handle,
751
			       struct ndb_mgm_reply* reply);
752

753 754 755 756 757
  /**
   * Listen event
   *
   * @param filter pairs of { level, category } that will be
   *        pushed to fd, level=0 ends lists
758
   *
759 760 761
   * @return fd which events will be pushed to
   */
  int ndb_mgm_listen_event(NdbMgmHandle handle, int filter[]);
762

763 764 765 766 767
  /**
   * Get configuration
   * @param   handle     NDB management handle.
   * @param   version    Version of configuration, 0 means latest
   *                     @see MAKE_VERSION
768 769 770 771
   *
   * @return configuration
   *
   * @note the caller must call ndb_mgm_detroy_configuration
772 773 774
   */
  struct ndb_mgm_configuration * ndb_mgm_get_configuration(NdbMgmHandle handle,
							   unsigned version);
775
  void ndb_mgm_destroy_configuration(struct ndb_mgm_configuration *);
unknown's avatar
unknown committed
776

777
#ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
unknown's avatar
unknown committed
778
  int ndb_mgm_alloc_nodeid(NdbMgmHandle handle,
779
			   unsigned version, int nodetype);
780 781 782 783 784 785 786 787
  /**
   * Config iterator
   */
  typedef struct ndb_mgm_configuration_iterator ndb_mgm_configuration_iterator;

  ndb_mgm_configuration_iterator* ndb_mgm_create_configuration_iterator
  (struct ndb_mgm_configuration *, unsigned type_of_section);
  void ndb_mgm_destroy_iterator(ndb_mgm_configuration_iterator*);
788

789 790 791
  int ndb_mgm_first(ndb_mgm_configuration_iterator*);
  int ndb_mgm_next(ndb_mgm_configuration_iterator*);
  int ndb_mgm_valid(const ndb_mgm_configuration_iterator*);
792
  int ndb_mgm_find(ndb_mgm_configuration_iterator*,
793
		   int param, unsigned value);
794 795

  int ndb_mgm_get_int_parameter(const ndb_mgm_configuration_iterator*,
796 797
				int param, unsigned * value);
  int ndb_mgm_get_int64_parameter(const ndb_mgm_configuration_iterator*,
unknown's avatar
unknown committed
798
				  int param, Uint64 * value);
799 800
  int ndb_mgm_get_string_parameter(const ndb_mgm_configuration_iterator*,
				   int param, const char  ** value);
801
  int ndb_mgm_purge_stale_sessions(NdbMgmHandle handle, char **);
802
  int ndb_mgm_check_connection(NdbMgmHandle handle);
803 804
#endif

805 806 807 808 809 810 811
#ifdef __cplusplus
}
#endif

/** @} */

#endif