1 /*
2    Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
3 
4    This program is free software; you can redistribute it and/or modify
5    it under the terms of the GNU General Public License, version 2.0,
6    as published by the Free Software Foundation.
7 
8    This program is also distributed with certain software (including
9    but not limited to OpenSSL) that is licensed under separate terms,
10    as designated in a particular file or component or in included license
11    documentation.  The authors of MySQL hereby grant you an additional
12    permission to link the program and your derivative works with the
13    separately licensed software that they have included with MySQL.
14 
15    This program is distributed in the hope that it will be useful,
16    but WITHOUT ANY WARRANTY; without even the implied warranty of
17    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18    GNU General Public License, version 2.0, for more details.
19 
20    You should have received a copy of the GNU General Public License
21    along with this program; if not, write to the Free Software
22    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
23 */
24 
25 #ifndef MGMAPI_H
26 #define MGMAPI_H
27 
28 #include "mgmapi_config_parameters.h"
29 #include "ndb_logevent.h"
30 #include "mgmapi_error.h"
31 
32 #define MGM_LOGLEVELS CFG_MAX_LOGLEVEL - CFG_MIN_LOGLEVEL + 1
33 #define NDB_MGM_MAX_LOGLEVEL 15
34 
35 /**
36  * @section MySQL Cluster Management API
37  *
38  * The MySQL Cluster Management API (MGM API) is a C language API
39  * that is used for:
40  * - Starting and stopping database nodes (ndbd processes)
41  * - Starting and stopping Cluster backups
42  * - Controlling the NDB Cluster log
43  * - Performing other administrative tasks
44  *
45  * @section  secMgmApiGeneral General Concepts
46  *
47  * Each MGM API function needs a management server handle
48  * of type @ref NdbMgmHandle.
49  * This handle is created by calling the function
50  * function ndb_mgm_create_handle() and freed by calling
51  * ndb_mgm_destroy_handle().
52  *
53  * A function can return any of the following:
54  *  -# An integer value, with
55  *     a value of <b>-1</b> indicating an error.
56  *  -# A non-constant pointer value.  A <var>NULL</var> value indicates an error;
57  *     otherwise, the return value must be freed
58  *     by the programmer
59  *  -# A constant pointer value, with a <var>NULL</var> value indicating an error.
60  *     The returned value should <em>not</em> be freed.
61  *
62  * Error conditions can be identified by using the appropriate
63  * error-reporting functions ndb_mgm_get_latest_error() and
64  * @ref ndb_mgm_error.
65  *
66  * Here is an example using the MGM API (without error handling for brevity's sake).
67  * @code
68  *   NdbMgmHandle handle= ndb_mgm_create_handle();
69  *   ndb_mgm_connect(handle,0,0,0);
70  *   struct ndb_mgm_cluster_state *state= ndb_mgm_get_status(handle);
71  *   for(int i=0; i < state->no_of_nodes; i++)
72  *   {
73  *     struct ndb_mgm_node_state *node_state= &state->node_states[i];
74  *     printf("node with ID=%d ", node_state->node_id);
75  *     if(node_state->version != 0)
76  *       printf("connected\n");
77  *     else
78  *       printf("not connected\n");
79  *   }
80  *   free((void*)state);
81  *   ndb_mgm_destroy_handle(&handle);
82  * @endcode
83  *
84  * @section secLogEvents  Log Events
85  *
86  * The database nodes and management server(s) regularly and on specific
87  * occations report on various log events that occurs in the cluster. These
88  * log events are written to the cluster log.  Optionally a mgmapi client
89  * may listen to these events by using the method ndb_mgm_listen_event().
90  * Each log event belongs to a category, @ref ndb_mgm_event_category, and
91  * has a severity, @ref ndb_mgm_event_severity, associated with it.  Each
92  * log event also has a level (0-15) associated with it.
93  *
94  * Which log events that come out is controlled with ndb_mgm_listen_event(),
95  * ndb_mgm_set_clusterlog_loglevel(), and
96  * ndb_mgm_set_clusterlog_severity_filter().
97  *
98  * Below is an example of how to listen to events related to backup.
99  *
100  * @code
101  *   int filter[] = { 15, NDB_MGM_EVENT_CATEGORY_BACKUP, 0 };
102  *   int fd = ndb_mgm_listen_event(handle, filter);
103  * @endcode
104  *
105  *
106  * @section secSLogEvents  Structured Log Events
107  *
108  * The following steps are involved:
109  * - Create a NdbEventLogHandle using ndb_mgm_create_logevent_handle()
110  * - Wait and store log events using ndb_logevent_get_next()
111  * - The log event data is available in the struct ndb_logevent. The
112  *   data which is specific to a particular event is stored in a union
113  *   between structs so use ndb_logevent::type to decide which struct
114  *   is valid.
115  *
116  * Sample code for listening to Backup related events.  The availaable log
117  * events are listed in @ref ndb_logevent.h
118  *
119  * @code
120  *   int filter[] = { 15, NDB_MGM_EVENT_CATEGORY_BACKUP, 0 };
121  *   NdbEventLogHandle le_handle= ndb_mgm_create_logevent_handle(handle, filter);
122  *   struct ndb_logevent le;
123  *   int r= ndb_logevent_get_next(le_handle,&le,0);
124  *   if (r < 0) error
125  *   else if (r == 0) no event
126  *
127  *   switch (le.type)
128  *   {
129  *   case NDB_LE_BackupStarted:
130  *     ... le.BackupStarted.starting_node;
131  *     ... le.BackupStarted.backup_id;
132  *     break;
133  *   case NDB_LE_BackupFailedToStart:
134  *     ... le.BackupFailedToStart.error;
135  *     break;
136  *   case NDB_LE_BackupCompleted:
137  *     ... le.BackupCompleted.stop_gci;
138  *     break;
139  *   case NDB_LE_BackupAborted:
140  *     ... le.BackupStarted.backup_id;
141  *     break;
142  *   default:
143  *     break;
144  *   }
145  * @endcode
146  */
147 
148 /*
149  * @page ndb_logevent.h ndb_logevent.h
150  * @include ndb_logevent.h
151  */
152 
153 /** @addtogroup MGM_C_API
154  *  @{
155  */
156 
157 #include <stdio.h>
158 #include <ndb_types.h>
159 #include "ndb_logevent.h"
160 #include "mgmapi_config_parameters.h"
161 
162 #ifdef __cplusplus
163 extern "C" {
164 #endif
165 
166   /**
167    * The NdbMgmHandle.
168    */
169   typedef struct ndb_mgm_handle * NdbMgmHandle;
170 
171   /**
172    *   NDB Cluster node types
173    */
174   enum ndb_mgm_node_type {
175     NDB_MGM_NODE_TYPE_UNKNOWN = -1  /** Node type not known*/
176     ,NDB_MGM_NODE_TYPE_API    /** An application (NdbApi) node */
177 #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
178     = NODE_TYPE_API
179 #endif
180     ,NDB_MGM_NODE_TYPE_NDB    /** A database node */
181 #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
182     = NODE_TYPE_DB
183 #endif
184     ,NDB_MGM_NODE_TYPE_MGM    /** A management server node */
185 #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
186     = NODE_TYPE_MGM
187 #endif
188 #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
189     ,NDB_MGM_NODE_TYPE_MIN     = 0          /** Min valid value*/
190     ,NDB_MGM_NODE_TYPE_MAX     = 3          /** Max valid value*/
191 #endif
192   };
193 
194   /**
195    *   Database node status
196    */
197   enum ndb_mgm_node_status {
198     /** Node status not known*/
199     NDB_MGM_NODE_STATUS_UNKNOWN       = 0,
200     /** No contact with node*/
201     NDB_MGM_NODE_STATUS_NO_CONTACT    = 1,
202     /** Has not run starting protocol*/
203     NDB_MGM_NODE_STATUS_NOT_STARTED   = 2,
204     /** Is running starting protocol*/
205     NDB_MGM_NODE_STATUS_STARTING      = 3,
206     /** Running*/
207     NDB_MGM_NODE_STATUS_STARTED       = 4,
208     /** Is shutting down*/
209     NDB_MGM_NODE_STATUS_SHUTTING_DOWN = 5,
210     /** Is restarting*/
211     NDB_MGM_NODE_STATUS_RESTARTING    = 6,
212     /** Maintenance mode*/
213     NDB_MGM_NODE_STATUS_SINGLEUSER    = 7,
214     /** Resume mode*/
215     NDB_MGM_NODE_STATUS_RESUME        = 8,
216     /** Node is connected */
217     NDB_MGM_NODE_STATUS_CONNECTED     = 9,
218 #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
219     /** Min valid value*/
220     NDB_MGM_NODE_STATUS_MIN           = 0,
221     /** Max valid value*/
222     NDB_MGM_NODE_STATUS_MAX           = 9
223 #endif
224   };
225 
226   /**
227    *   Status of a node in the cluster.
228    *
229    *   Sub-structure in enum ndb_mgm_cluster_state
230    *   returned by ndb_mgm_get_status().
231    *
232    *   @note <var>node_status</var>, <var>start_phase</var>,
233    *         <var>dynamic_id</var>
234    *         and <var>node_group</var> are relevant only for database nodes,
235    *         i.e. <var>node_type</var> == @ref NDB_MGM_NODE_TYPE_NDB.
236    */
237   struct ndb_mgm_node_state {
238     /** NDB Cluster node ID*/
239     int node_id;
240     /** Type of NDB Cluster node*/
241     enum ndb_mgm_node_type   node_type;
242    /** State of node*/
243     enum ndb_mgm_node_status node_status;
244     /** Start phase.
245      *
246      *  @note Start phase is only valid if the <var>node_type</var> is
247      *        NDB_MGM_NODE_TYPE_NDB and the <var>node_status</var> is
248      *        NDB_MGM_NODE_STATUS_STARTING
249      */
250     int start_phase;
251     /** ID for heartbeats and master take-over (only valid for DB nodes)
252      */
253     int dynamic_id;
254     /** Node group of node (only valid for DB nodes)*/
255     int node_group;
256     /** Internal version number*/
257     int version;
258     /** Number of times node has connected or disconnected to the
259      *  management server
260      */
261     int connect_count;
262     /** IP address of node when it connected to the management server.
263      *  @note This value will be empty if the management server has restarted
264      *        since the node last connected.
265      */
266     char connect_address[
267 #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
268 			 sizeof("000.000.000.000")+1
269 #endif
270     ];
271 
272     /** MySQL version number */
273     int mysql_version;
274   };
275 
276   /**
277    *   State of all nodes in the cluster; returned from
278    *   ndb_mgm_get_status()
279    */
280   struct ndb_mgm_cluster_state {
281     /** Number of entries in the node_states array */
282     int no_of_nodes;
283     /** An array with node_states*/
284     struct ndb_mgm_node_state node_states[
285 #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
286 					  1
287 #endif
288     ];
289   };
290 
291   /**
292    *   Default reply from the server (reserved for future use)
293    */
294   struct ndb_mgm_reply {
295     /** 0 if successful, otherwise error code. */
296     int return_code;
297     /** Error or reply message.*/
298     char message[256];
299   };
300 
301 #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
302   /**
303    *   Default information types
304    */
305   enum ndb_mgm_info {
306     /** ?*/
307     NDB_MGM_INFO_CLUSTER,
308     /** Cluster log*/
309     NDB_MGM_INFO_CLUSTERLOG
310   };
311 
312   /**
313    *   Signal log modes
314    *   (Used only in the development of NDB Cluster.)
315    */
316   enum ndb_mgm_signal_log_mode {
317     /** Log receiving signals */
318     NDB_MGM_SIGNAL_LOG_MODE_IN,
319     /** Log sending signals*/
320     NDB_MGM_SIGNAL_LOG_MODE_OUT,
321     /** Log both sending/receiving*/
322     NDB_MGM_SIGNAL_LOG_MODE_INOUT,
323     /** Log off*/
324     NDB_MGM_SIGNAL_LOG_MODE_OFF
325   };
326 #endif
327 
328   struct ndb_mgm_severity {
329     enum ndb_mgm_event_severity category;
330     unsigned int value;
331   };
332 
333   struct ndb_mgm_loglevel {
334     enum ndb_mgm_event_category category;
335     unsigned int value;
336   };
337 
338 
339   /***************************************************************************/
340   /**
341    * @name Functions: Error Handling
342    * @{
343    */
344 
345   /**
346    *  Get the most recent error associated with the management server whose handle
347    *  is used as the value of <var>handle</var>.
348    *
349    * @param   handle        Management handle
350    * @return                Latest error code
351    */
352   int ndb_mgm_get_latest_error(const NdbMgmHandle handle);
353 
354   /**
355    * Get the most recent general error message associated with a handle
356    *
357    * @param   handle        Management handle.
358    * @return                Latest error message
359    */
360   const char * ndb_mgm_get_latest_error_msg(const NdbMgmHandle handle);
361 
362   /**
363    * Get the most recent error description associated with a handle
364    *
365    * The error description gives some additional information regarding
366    * the error message.
367    *
368    * @param   handle        Management handle.
369    * @return                Latest error description
370    */
371   const char * ndb_mgm_get_latest_error_desc(const NdbMgmHandle handle);
372 
373 #ifndef DOXYGEN_SHOULD_SKIP_DEPRECATED
374   /**
375    * Get the most recent internal source code error line associated with a handle
376    *
377    * @param   handle        Management handle.
378    * @return                Latest internal source code line of latest error
379    * @deprecated
380    */
381   int ndb_mgm_get_latest_error_line(const NdbMgmHandle handle);
382 #endif
383 
384   /**
385    * Set error stream
386    */
387   void ndb_mgm_set_error_stream(NdbMgmHandle, FILE *);
388 
389 
390   /** @} *********************************************************************/
391   /**
392    * @name Functions: Create/Destroy Management Server Handles
393    * @{
394    */
395 
396   /**
397    * Create a handle to a management server.
398    *
399    * @return                 A management handle<br>
400    *                         or <var>NULL</var> if no management handle could be created.
401    */
402   NdbMgmHandle ndb_mgm_create_handle();
403 
404   /**
405    * Destroy a management server handle.
406    *
407    * @param   handle        Management handle
408    */
409   void ndb_mgm_destroy_handle(NdbMgmHandle * handle);
410 
411   /**
412    * Set a name of the handle.  Name is reported in cluster log.
413    *
414    * @param   handle        Management handle
415    * @param   name          Name
416    */
417   void ndb_mgm_set_name(NdbMgmHandle handle, const char *name);
418 
419   /**
420    * Set 'ignore_sigpipe' behaviour
421    *
422    * The mgmapi will by default install a signal handler
423    * that ignores all SIGPIPE signals that might occur when
424    * writing to an already closed or reset socket. An application
425    * that wish to use its own handler for SIGPIPE should call this
426    * function after 'ndb_mgm_create_handle' and before
427    * 'ndb_mgm_connect'(where the signal handler is installed)
428    *
429    * @param   handle        Management handle
430    * @param   val           Value
431    *                        0 - Don't ignore SIGPIPE
432    *                        1 - Ignore SIGPIPE(default)
433    */
434   int ndb_mgm_set_ignore_sigpipe(NdbMgmHandle handle, int val);
435 
436   /** @} *********************************************************************/
437   /**
438    * @name Functions: Connect/Disconnect Management Server
439    * @{
440    */
441 
442   /**
443    * Sets the connectstring for a management server
444    *
445    * @param   handle         Management handle
446    * @param   connect_string Connect string to the management server,
447    *
448    * @return                -1 on error.
449    *
450    * @code
451    * <connectstring> := [<nodeid-specification>,]<host-specification>[,<host-specification>]
452    * <nodeid-specification> := nodeid=<id>
453    * <host-specification> := <host>[:<port>]
454    * <id> is an integer greater than 0 identifying a node in config.ini
455    * <port> is an integer referring to a regular unix port
456    * <host> is a string containing a valid network host address
457    * @endcode
458    */
459   int ndb_mgm_set_connectstring(NdbMgmHandle handle,
460 				const char *connect_string);
461 
462   /**
463    * Returns the number of management servers in the connect string
464    * (as set by ndb_mgm_set_connectstring()). This can be used
465    * to help work out how long the maximum amount of time that
466    * ndb_mgm_connect can take.
467    *
468    * @param   handle         Management handle
469    *
470    * @return                < 0 on error
471    */
472   int ndb_mgm_number_of_mgmd_in_connect_string(NdbMgmHandle handle);
473 
474   int ndb_mgm_set_configuration_nodeid(NdbMgmHandle handle, int nodeid);
475 
476   /**
477    * Set local bindaddress
478    * @param arg - Srting of form "host[:port]"
479    * @note must be called before connect
480    * @note Error on binding local address will not be reported until connect
481    * @return 0 on success
482    */
483   int ndb_mgm_set_bindaddress(NdbMgmHandle, const char * arg);
484 
485   /**
486    * Gets the connectstring used for a connection
487    *
488    * @note This function returns the default connectstring if no call to
489    *       ndb_mgm_set_connectstring() has been performed. Also, the
490    *       returned connectstring may be formatted differently.
491    *
492    * @param   handle         Management handle
493    * @param   buf            Buffer to hold result
494    * @param   buf_sz         Size of buffer.
495    *
496    * @return                 connectstring (same as <var>buf</var>)
497    */
498   const char *ndb_mgm_get_connectstring(NdbMgmHandle handle, char *buf, int buf_sz);
499 
500   /**
501    * DEPRECATED: use ndb_mgm_set_timeout instead.
502    *
503    * @param handle  NdbMgmHandle
504    * @param seconds number of seconds
505    * @return non-zero on success
506    */
507   int ndb_mgm_set_connect_timeout(NdbMgmHandle handle, unsigned int seconds);
508 
509   /**
510    * Sets the number of milliseconds for timeout of network operations
511    * Default is 60 seconds.
512    * Only increments of 1000 ms are supported. No function is gaurenteed
513    * to return in a fraction of a second.
514    *
515    * @param handle  NdbMgmHandle
516    * @param timeout_ms number of milliseconds
517    * @return zero on success
518    */
519   int ndb_mgm_set_timeout(NdbMgmHandle handle, unsigned int timeout_ms);
520 
521   /**
522    * Connects to a management server. Connectstring is set by
523    * ndb_mgm_set_connectstring().
524    *
525    * The timeout value is for connect to each management server.
526    * Use ndb_mgm_number_of_mgmd_in_connect_string to work out
527    * the approximate maximum amount of time that could be spent in this
528    * function.
529    *
530    * @param   handle        Management handle.
531    * @param   no_retries    Number of retries to connect
532    *                        (0 means connect once).
533    * @param   retry_delay_in_seconds
534    *                        How long to wait until retry is performed.
535    * @param   verbose       Make printout regarding connect retries.
536    *
537    * @return                -1 on error.
538    */
539   int ndb_mgm_connect(NdbMgmHandle handle, int no_retries,
540 		      int retry_delay_in_seconds, int verbose);
541   /**
542    * Return true if connected.
543    *
544    * @param   handle        Management handle
545    * @return  0 if not connected, non-zero if connected.
546    */
547   int ndb_mgm_is_connected(NdbMgmHandle handle);
548 
549   /**
550    * Disconnects from a management server
551    *
552    * @param  handle         Management handle.
553    * @return                -1 on error.
554    */
555   int ndb_mgm_disconnect(NdbMgmHandle handle);
556 
557   /**
558    * Gets connection node ID
559    *
560    * @param   handle         Management handle
561    *
562    * @return                 Node ID; 0 indicates that no node ID has been
563    *                         specified
564    */
565   int ndb_mgm_get_configuration_nodeid(NdbMgmHandle handle);
566 
567   /**
568    * Gets connection port
569    *
570    * @param   handle         Management handle
571    *
572    * @return                 port
573    */
574   int ndb_mgm_get_connected_port(NdbMgmHandle handle);
575 
576   /**
577    * Gets connection host
578    *
579    * @param   handle         Management handle
580    *
581    * @return                 hostname
582    */
583   const char *ndb_mgm_get_connected_host(NdbMgmHandle handle);
584 
585   /**
586    * Gets connection bind address
587    *
588    * @param   handle         Management handle
589    *
590    * @return                 hostname
591    */
592   const char *ndb_mgm_get_connected_bind_address(NdbMgmHandle handle);
593 
594   /**
595    * Get the version of the mgm server we're talking to.
596    *
597    * @param   handle         Management handle
598    * @param   major          Returns the major version number for NDB
599    * @param   minor          Returns the minor version number for NDB
600    * @param   build          Returns the build version number for NDB
601    * @param   len            Specifies the max size of the buffer
602    *                         available to return version string in
603    * @param   str            Pointer to buffer where to return the
604    *                         version string which is in the
605    *                         form "mysql-X.X.X ndb-Y.Y.Y-status"
606    *
607    * @return  0 for error and 1 for success
608    */
609   int ndb_mgm_get_version(NdbMgmHandle handle,
610                           int *major, int *minor, int* build,
611                           int len, char* str);
612 
613 #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
614   /** @} *********************************************************************/
615   /**
616    * @name Functions: Used to convert between different data formats
617    * @{
618    */
619 
620   /**
621    * Converts a string to an <var>ndb_mgm_node_type</var> value
622    *
623    * @param   type          Node type as string.
624    * @return                NDB_MGM_NODE_TYPE_UNKNOWN if invalid string.
625    */
626   enum ndb_mgm_node_type ndb_mgm_match_node_type(const char * type);
627 
628   /**
629    * Converts an ndb_mgm_node_type to a string
630    *
631    * @param   type          Node type.
632    * @return                <var>NULL</var> if invalid ID.
633    */
634   const char * ndb_mgm_get_node_type_string(enum ndb_mgm_node_type type);
635 
636   /**
637    * Converts an ndb_mgm_node_type to a alias string
638    *
639    * @param   type          Node type.
640    * @return                <var>NULL</var> if the ID is invalid.
641    */
642   const char * ndb_mgm_get_node_type_alias_string(enum ndb_mgm_node_type type,
643 						  const char **str);
644 
645   /**
646    * Converts a string to a <var>ndb_mgm_node_status</var> value
647    *
648    * @param   status        NDB node status string.
649    * @return                NDB_MGM_NODE_STATUS_UNKNOWN if invalid string.
650    */
651   enum ndb_mgm_node_status ndb_mgm_match_node_status(const char * status);
652 
653   /**
654    * Converts an ID to a string
655    *
656    * @param   status        NDB node status.
657    * @return                <var>NULL</var> if invalid ID.
658    */
659   const char * ndb_mgm_get_node_status_string(enum ndb_mgm_node_status status);
660 
661   const char * ndb_mgm_get_event_severity_string(enum ndb_mgm_event_severity);
662   enum ndb_mgm_event_category ndb_mgm_match_event_category(const char *);
663   const char * ndb_mgm_get_event_category_string(enum ndb_mgm_event_category);
664 #endif
665 
666   /** @} *********************************************************************/
667   /**
668    * @name Functions: Cluster status
669    * @{
670    */
671 
672   /**
673    * Gets status of the nodes in an NDB Cluster
674    *
675    * @note The caller must free the pointer returned by this function.
676    *
677    * @param   handle        Management handle.
678    *
679    * @return                Cluster state (or <var>NULL</var> on error).
680    */
681   struct ndb_mgm_cluster_state * ndb_mgm_get_status(NdbMgmHandle handle);
682 
683 
684   /**
685    * Gets status of the nodes *of specified types* in an NDB Cluster
686    *
687    * @note The caller must free the pointer returned by this function.
688    * @note Passing a NULL pointer into types make this equivalent to
689    *       ndb_mgm_get_status
690    *
691    * @param   handle        Management handle.
692    * @param   types         Pointer to array of interesting node types.
693    *                        Array should be terminated
694    *                        by *NDB_MGM_NODE_TYPE_UNKNOWN*.
695    *
696    * @return                Cluster state (or <var>NULL</var> on error).
697    */
698   struct ndb_mgm_cluster_state *
699   ndb_mgm_get_status2(NdbMgmHandle handle,
700                       const enum ndb_mgm_node_type types[]);
701 
702 
703 
704   /**
705    * Dump state
706    *
707    * @param handle the NDB management handle.
708    * @param nodeId the node id.
709    * @param args integer array
710    * @param number of args in int array
711    * @param reply the reply message.
712    * @return 0 if successful or an error code.
713    */
714   int ndb_mgm_dump_state(NdbMgmHandle handle,
715 			 int nodeId,
716 			 const int * args,
717 			 int num_args,
718 			 struct ndb_mgm_reply* reply);
719 
720   /**
721    * Get the current configuration from a node.
722    *
723    * @param handle the NDB management handle.
724    * @param nodeId of the node for which the configuration is requested.
725    * @return the current configuration from the requested node.
726    */
727   struct ndb_mgm_configuration *
728   ndb_mgm_get_configuration_from_node(NdbMgmHandle handle,
729                                       int nodeid);
730 
731 
732   /** @} *********************************************************************/
733   /**
734    * @name Functions: Start/stop nodes
735    * @{
736    */
737 
738   /**
739    * Stops database nodes
740    *
741    * @param   handle        Management handle.
742    * @param   no_of_nodes   Number of database nodes to be stopped<br>
743    *                          0: All database nodes in cluster<br>
744    *                          n: Stop the <var>n</var> node(s) specified in the
745    *                            array node_list
746    * @param   node_list     List of node IDs for database nodes to be stopped
747    *
748    * @return                Number of nodes stopped (-1 on error)
749    *
750    * @note    This function is equivalent
751    *          to calling ndb_mgm_stop2(handle, no_of_nodes, node_list, 0)
752    */
753   int ndb_mgm_stop(NdbMgmHandle handle, int no_of_nodes,
754 		   const int * node_list);
755 
756   /**
757    * Stops database nodes
758    *
759    * @param   handle        Management handle.
760    * @param   no_of_nodes   Number of database nodes to stop<br>
761    *                          0: All database nodes in cluster<br>
762    *                          n: Stop the <var>n</var> node(s) specified in
763    *                            the array node_list
764    * @param   node_list     List of node IDs of database nodes to be stopped
765    * @param   abort         Don't perform graceful stop,
766    *                        but rather stop immediately
767    *
768    * @return                Number of nodes stopped (-1 on error).
769    */
770   int ndb_mgm_stop2(NdbMgmHandle handle, int no_of_nodes,
771 		    const int * node_list, int abort);
772 
773   /**
774    * Stops cluster nodes
775    *
776    * @param   handle        Management handle.
777    * @param   no_of_nodes   Number of database nodes to stop<br>
778    *                         -1: All database and management nodes<br>
779    *                          0: All database nodes in cluster<br>
780    *                          n: Stop the <var>n</var> node(s) specified in
781    *                            the array node_list
782    * @param   node_list     List of node IDs of database nodes to be stopped
783    * @param   abort         Don't perform graceful stop,
784    *                        but rather stop immediately
785    * @param   disconnect    Returns true if you need to disconnect to apply
786    *                        the stop command (e.g. stopping the mgm server
787    *                        that handle is connected to)
788    *
789    * @return                Number of nodes stopped (-1 on error).
790    */
791   int ndb_mgm_stop3(NdbMgmHandle handle, int no_of_nodes,
792 		    const int * node_list, int abort, int *disconnect);
793 
794   /**
795    * Stops cluster nodes
796    *
797     * @param   handle        Management handle.
798    * @param   no_of_nodes   Number of database nodes to stop<br>
799    *                         -1: All database and management nodes<br>
800    *                          0: All database nodes in cluster<br>
801    *                          n: Stop the <var>n</var> node(s) specified in
802    *                            the array node_list
803    * @param   node_list     List of node IDs of database nodes to be stopped
804    * @param   abort         Don't perform graceful stop,
805    *                        but rather stop immediately
806    * @param   force         Force stop of nodes even if it means the
807    *                        whole cluster will be shutdown
808    * @param   disconnect    Returns true if you need to disconnect to apply
809    *                        the stop command (e.g. stopping the mgm server
810    *                        that handle is connected to)
811    *
812    * @return                Number of nodes stopped (-1 on error).
813    */
814    int ndb_mgm_stop4(NdbMgmHandle handle, int no_of_nodes,
815 		    const int * node_list, int abort, int force,
816                     int *disconnect);
817 
818   /**
819    * Restart database nodes
820    *
821    * @param   handle        Management handle.
822    * @param   no_of_nodes   Number of database nodes to restart<br>
823    *                          0: All database nodes in cluster<br>
824    *                          n: Restart the <var>n</var> node(s) specified in the
825    *                            array node_list
826    * @param   node_list     List of node IDs of database nodes to be restarted
827    *
828    * @return                Number of nodes restarted (-1 on error).
829    *
830    * @note    This function is equivalent to calling
831    *          ndb_mgm_restart2(handle, no_of_nodes, node_list, 0, 0, 0);
832    */
833   int ndb_mgm_restart(NdbMgmHandle handle, int no_of_nodes,
834 		      const int * node_list);
835 
836   /**
837    * Restart database nodes
838    *
839    * @param   handle        Management handle.
840    * @param   no_of_nodes   Number of database nodes to be restarted:<br>
841    *                          0: Restart all database nodes in the cluster<br>
842    *                          n: Restart the <var>n</var> node(s) specified in the
843    *                            array node_list
844    * @param   node_list     List of node IDs of database nodes to be restarted
845    * @param   initial       Remove filesystem from restarting node(s)
846    * @param   nostart       Don't actually start node(s) but leave them
847    *                        waiting for start command
848    * @param   abort         Don't perform graceful restart,
849    *                        but rather restart immediately
850    *
851    * @return                Number of nodes stopped (-1 on error).
852    */
853   int ndb_mgm_restart2(NdbMgmHandle handle, int no_of_nodes,
854 		       const int * node_list, int initial,
855 		       int nostart, int abort);
856 
857   /**
858    * Restart nodes
859    *
860    * @param   handle        Management handle.
861    * @param   no_of_nodes   Number of database nodes to be restarted:<br>
862    *                          0: Restart all database nodes in the cluster<br>
863    *                          n: Restart the <var>n</var> node(s) specified in the
864    *                            array node_list
865    * @param   node_list     List of node IDs of database nodes to be restarted
866    * @param   initial       Remove filesystem from restarting node(s)
867    * @param   nostart       Don't actually start node(s) but leave them
868    *                        waiting for start command
869    * @param   abort         Don't perform graceful restart,
870    *                        but rather restart immediately
871    * @param   disconnect    Returns true if mgmapi client must disconnect from
872    *                        server to apply the requested operation. (e.g.
873    *                        restart the management server)
874    *
875    *
876    * @return                Number of nodes stopped (-1 on error).
877    */
878   int ndb_mgm_restart3(NdbMgmHandle handle, int no_of_nodes,
879 		       const int * node_list, int initial,
880 		       int nostart, int abort, int *disconnect);
881 
882   /**
883    * Restart nodes
884    *
885    * @param   handle        Management handle.
886    * @param   no_of_nodes   Number of database nodes to be restarted:<br>
887    *                          0: Restart all database nodes in the cluster<br>
888    *                          n: Restart the <var>n</var> node(s) specified
889    *                             in the array node_list
890    * @param   node_list     List of node IDs of database nodes to be restarted
891    * @param   initial       Remove filesystem from restarting node(s)
892    * @param   nostart       Don't actually start node(s) but leave them
893    *                        waiting for start command
894    * @param   abort         Don't perform graceful restart,
895    *                        but rather restart immediately
896    * @param   force         Force restart of nodes even if it means the
897    *                        whole cluster will be restarted
898    * @param   disconnect    Returns true if mgmapi client must disconnect from
899    *                        server to apply the requested operation. (e.g.
900    *                        restart the management server)
901    *
902    *
903    * @return                Number of nodes stopped (-1 on error).
904    */
905   int ndb_mgm_restart4(NdbMgmHandle handle, int no_of_nodes,
906 		       const int * node_list, int initial,
907 		       int nostart, int abort, int force, int *disconnect);
908 
909   /**
910    * Start database nodes
911    *
912    * @param   handle        Management handle.
913    * @param   no_of_nodes   Number of database nodes to be started<br>
914    *                        0: Start all database nodes in the cluster<br>
915    *                        n: Start the <var>n</var> node(s) specified in
916    *                            the array node_list
917    * @param   node_list     List of node IDs of database nodes to be started
918    *
919    * @return                Number of nodes actually started (-1 on error).
920    *
921    * @note    The nodes to be started must have been started with nostart(-n)
922    *          argument.
923    *          This means that the database node binary is started and
924    *          waiting for a START management command which will
925    *          actually enable the database node
926    */
927   int ndb_mgm_start(NdbMgmHandle handle,
928 		    int no_of_nodes,
929 		    const int * node_list);
930 
931   /** @} *********************************************************************/
932   /**
933    * @name Functions: Controlling Clusterlog output
934    * @{
935    */
936 
937   /**
938    * Filter cluster log severities
939    *
940    * @param   handle        NDB management handle.
941    * @param   severity      A cluster log severity to filter.
942    * @param   enable        set 1=enable o 0=disable
943    * @param   reply         Reply message.
944    *
945    * @return                -1 on error.
946    */
947   int ndb_mgm_set_clusterlog_severity_filter(NdbMgmHandle handle,
948 					     enum ndb_mgm_event_severity severity,
949 					     int enable,
950 					     struct ndb_mgm_reply* reply);
951   /**
952    * Get clusterlog severity filter
953    *
954    * @param   handle        NDB management handle
955    *
956    * @param loglevel        A vector of seven (NDB_MGM_EVENT_SEVERITY_ALL)
957    *                        elements of struct ndb_mgm_severity,
958    *                        where each element contains
959    *                        1 if a severity indicator is enabled and 0 if not.
960    *                        A severity level is stored at position
961    *                        ndb_mgm_clusterlog_level;
962    *                        for example the "error" level is stored in position
963    *                        [NDB_MGM_EVENT_SEVERITY_ERROR].
964    *                        The first element [NDB_MGM_EVENT_SEVERITY_ON] in
965    *                        the vector signals whether the cluster log
966    *                        is disabled or enabled.
967    * @param severity_size   The size of the vector (NDB_MGM_EVENT_SEVERITY_ALL)
968    * @return                Number of returned severities or -1 on error
969    */
970   int ndb_mgm_get_clusterlog_severity_filter(NdbMgmHandle handle,
971 					     struct ndb_mgm_severity* severity,
972 					     unsigned int severity_size);
973 
974 #ifndef DOXYGEN_SHOULD_SKIP_DEPRECATED
975   /**
976    * Get clusterlog severity filter
977    *
978    * @param   handle        NDB management handle
979    *
980    * @return                A vector of seven elements,
981    *                        where each element contains
982    *                        1 if a severity indicator is enabled and 0 if not.
983    *                        A severity level is stored at position
984    *                        ndb_mgm_clusterlog_level;
985    *                        for example the "error" level is stored in position
986    *                        [NDB_MGM_EVENT_SEVERITY_ERROR].
987    *                        The first element [NDB_MGM_EVENT_SEVERITY_ON] in
988    *                        the vector signals
989    *                        whether the cluster log
990    *                        is disabled or enabled.
991    */
992   const unsigned int *ndb_mgm_get_clusterlog_severity_filter_old(NdbMgmHandle handle);
993 #endif
994 
995   /**
996    * Set log category and levels for the cluster log
997    *
998    * @param   handle        NDB management handle.
999    * @param   nodeId        Node ID.
1000    * @param   category      Event category.
1001    * @param   level         Log level (0-15).
1002    * @param   reply         Reply message.
1003    * @return                -1 on error.
1004    */
1005   int ndb_mgm_set_clusterlog_loglevel(NdbMgmHandle handle,
1006 				      int nodeId,
1007 				      enum ndb_mgm_event_category category,
1008 				      int level,
1009 				      struct ndb_mgm_reply* reply);
1010 
1011   /**
1012    * get log category and levels
1013    *
1014    * @param   handle        NDB management handle.
1015    * @param loglevel        A vector of twelve (MGM_LOGLEVELS) elements
1016    *                        of struct ndb_mgm_loglevel,
1017    *                        where each element contains
1018    *                        loglevel of corresponding category
1019    * @param loglevel_size   The size of the vector (MGM_LOGLEVELS)
1020    * @return                Number of returned loglevels or -1 on error
1021    */
1022   int ndb_mgm_get_clusterlog_loglevel(NdbMgmHandle handle,
1023 				      struct ndb_mgm_loglevel* loglevel,
1024 				      unsigned int loglevel_size);
1025 
1026 #ifndef DOXYGEN_SHOULD_SKIP_DEPRECATED
1027   /**
1028    * get log category and levels
1029    *
1030    * @param   handle        NDB management handle.
1031    * @return                A vector of twelve elements,
1032    *                        where each element contains
1033    *                        loglevel of corresponding category
1034    */
1035   const unsigned int *ndb_mgm_get_clusterlog_loglevel_old(NdbMgmHandle handle);
1036 #endif
1037 
1038 
1039   /** @} *********************************************************************/
1040   /**
1041    * @name Functions: Listening to log events
1042    * @{
1043    */
1044 
1045   /**
1046    * Listen to log events. They are read from the return file descriptor
1047    * and the format is textual, and the same as in the cluster log.
1048    *
1049    * @param handle NDB management handle.
1050    * @param filter pairs of { level, ndb_mgm_event_category } that will be
1051    *               pushed to fd, level=0 ends list.
1052    *
1053    * @return fd    filedescriptor to read events from
1054    */
1055 #ifdef NDB_WIN
1056   SOCKET ndb_mgm_listen_event(NdbMgmHandle handle, const int filter[]);
1057 #else
1058   int ndb_mgm_listen_event(NdbMgmHandle handle, const int filter[]);
1059 #endif
1060 
1061 #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
1062   /**
1063    * Set log category and levels for the Node
1064    *
1065    * @param   handle        NDB management handle.
1066    * @param   nodeId        Node ID.
1067    * @param   category      Event category.
1068    * @param   level         Log level (0-15).
1069    * @param   reply         Reply message.
1070    * @return                -1 on error.
1071    */
1072   int ndb_mgm_set_loglevel_node(NdbMgmHandle handle,
1073 				int nodeId,
1074 				enum ndb_mgm_event_category category,
1075 				int level,
1076 				struct ndb_mgm_reply* reply);
1077 #endif
1078 
1079   /**
1080    * The NdbLogEventHandle
1081    */
1082   typedef struct ndb_logevent_handle * NdbLogEventHandle;
1083 
1084   /**
1085    * Listen to log events.
1086    *
1087    * @param handle NDB management handle.
1088    * @param filter pairs of { level, ndb_mgm_event_category } that will be
1089    *               pushed to fd, level=0 ends list.
1090    *
1091    * @return       NdbLogEventHandle
1092    */
1093   NdbLogEventHandle ndb_mgm_create_logevent_handle(NdbMgmHandle,
1094 						   const int filter[]);
1095   void ndb_mgm_destroy_logevent_handle(NdbLogEventHandle*);
1096 
1097   /**
1098    * Retrieve filedescriptor from NdbLogEventHandle.  May be used in
1099    * e.g. an application select() statement.
1100    *
1101    * @note Do not attemt to read from it, it will corrupt the parsing.
1102    *
1103    * @return       filedescriptor, -1 on failure.
1104    */
1105 #ifdef NDB_WIN
1106   SOCKET ndb_logevent_get_fd(const NdbLogEventHandle);
1107 #else
1108   int ndb_logevent_get_fd(const NdbLogEventHandle);
1109 #endif
1110 
1111   /**
1112    * Attempt to retrieve next log event and will fill in the supplied
1113    * struct dst
1114    *
1115    * @param dst Pointer to struct to fill in event information
1116    * @param timeout_in_milliseconds Timeout for waiting for event
1117    *
1118    * @return     >0 if event exists, 0 no event (timed out), or -1 on error.
1119    *
1120    * @note Return value <=0 will leave dst untouched
1121    */
1122   int ndb_logevent_get_next(const NdbLogEventHandle,
1123 			    struct ndb_logevent *dst,
1124 			    unsigned timeout_in_milliseconds);
1125 
1126   /**
1127    * Retrieve laterst error code
1128    *
1129    * @return     error code
1130    */
1131   int ndb_logevent_get_latest_error(const NdbLogEventHandle);
1132 
1133   /**
1134    * Retrieve laterst error message
1135    *
1136    * @return     error message
1137    */
1138   const char *ndb_logevent_get_latest_error_msg(const NdbLogEventHandle);
1139 
1140 
1141   /** @} *********************************************************************/
1142   /**
1143    * @name Functions: Backup
1144    * @{
1145    */
1146 
1147   /**
1148    * Start backup
1149    *
1150    * @param   handle          NDB management handle.
1151    * @param   wait_completed  0:  Don't wait for confirmation<br>
1152    *                          1:  Wait for backup to be started<br>
1153    *                          2:  Wait for backup to be completed
1154    * @param   backup_id       Backup ID is returned from function.
1155    * @param   reply           Reply message.
1156    * @return                  -1 on error.
1157    * @note                    backup_id will not be returned if
1158    *                          wait_completed == 0
1159    */
1160   int ndb_mgm_start_backup(NdbMgmHandle handle, int wait_completed,
1161 			   unsigned int* backup_id,
1162 			   struct ndb_mgm_reply* reply);
1163 
1164   /**
1165    * Start backup
1166    *
1167    * @param   handle          NDB management handle.
1168    * @param   wait_completed  0:  Don't wait for confirmation<br>
1169    *                          1:  Wait for backup to be started<br>
1170    *                          2:  Wait for backup to be completed
1171    * @param   backup_id       Backup ID is returned from function.
1172    * @param   reply           Reply message.
1173    * @param   input_backupId  run as backupId and set next backup id to input_backupId+1.
1174    * @return                  -1 on error.
1175    * @note                    backup_id will not be returned if
1176    *                          wait_completed == 0
1177    */
1178   int ndb_mgm_start_backup2(NdbMgmHandle handle, int wait_completed,
1179 			   unsigned int* backup_id,
1180 			   struct ndb_mgm_reply* reply,
1181 			   unsigned int input_backupId);
1182 
1183   /**
1184    * Start backup
1185    *
1186    * @param   handle          NDB management handle.
1187    * @param   wait_completed  0:  Don't wait for confirmation<br>
1188    *                          1:  Wait for backup to be started<br>
1189    *                          2:  Wait for backup to be completed
1190    * @param   backup_id       Backup ID is returned from function.
1191    * @param   reply           Reply message.
1192    * @param   input_backupId  run as backupId and set next backup id to input_backupId+1.
1193    * @param   backuppoint     Backup happen at start time(1) or complete time(0).
1194    * @return                  -1 on error.
1195    * @note                    backup_id will not be returned if
1196    *                          wait_completed == 0
1197    */
1198   int ndb_mgm_start_backup3(NdbMgmHandle handle, int wait_completed,
1199 			   unsigned int* backup_id,
1200 			   struct ndb_mgm_reply* reply,
1201 			   unsigned int input_backupId,
1202 			   unsigned int backuppoint);
1203 
1204   /**
1205    * Abort backup
1206    *
1207    * @param   handle        NDB management handle.
1208    * @param   backup_id     Backup ID.
1209    * @param   reply         Reply message.
1210    * @return                -1 on error.
1211    */
1212   int ndb_mgm_abort_backup(NdbMgmHandle handle, unsigned int backup_id,
1213 			   struct ndb_mgm_reply* reply);
1214 
1215 
1216   /** @} *********************************************************************/
1217   /**
1218    * @name Functions: Single User Mode
1219    * @{
1220    */
1221 
1222   /**
1223    * Enter Single user mode
1224    *
1225    * @param   handle        NDB management handle.
1226    * @param   nodeId        Node ID of the single user node
1227    * @param   reply         Reply message.
1228    * @return                -1 on error.
1229    */
1230   int ndb_mgm_enter_single_user(NdbMgmHandle handle, unsigned int nodeId,
1231 				struct ndb_mgm_reply* reply);
1232 
1233   /**
1234    * Exit Single user mode
1235    *
1236    * @param   handle        NDB management handle.
1237    * @param   reply         Reply message.
1238    *
1239    * @return                -1 on error.
1240    */
1241   int ndb_mgm_exit_single_user(NdbMgmHandle handle,
1242 			       struct ndb_mgm_reply* reply);
1243 
1244 #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
1245   /** @} *********************************************************************/
1246   /**
1247    * @name Configuration handling
1248    * @{
1249    */
1250 
1251   /**
1252    * Get configuration
1253    * @param   handle     NDB management handle.
1254    * @param   version    Version of configuration, 0 means latest
1255    *                     (Currently this is the only supported value for this parameter)
1256    *
1257    * @return configuration
1258    *
1259    * @note The caller is responsible for calling ndb_mgm_destroy_configuration()
1260    */
1261   struct ndb_mgm_configuration * ndb_mgm_get_configuration(NdbMgmHandle handle,
1262 							   unsigned version);
1263   void ndb_mgm_destroy_configuration(struct ndb_mgm_configuration *);
1264 
1265   int ndb_mgm_alloc_nodeid(NdbMgmHandle handle,
1266 			   unsigned version, int nodetype, int log_event);
1267 
1268   /**
1269    * End Session
1270    *
1271    * This function tells the mgm server to free all resources associated with
1272    * this connection. It will also close it.
1273    *
1274    * This differs from just disconnecting as we now synchronously clean up,
1275    * so that a quickly restarting server that needs the same node id can
1276    * get it when it restarts.
1277    *
1278    * @param  handle NDB management handle
1279    * @return 0 on success
1280    *
1281    * @note you still have to destroy the NdbMgmHandle.
1282    */
1283   int ndb_mgm_end_session(NdbMgmHandle handle);
1284 
1285   /**
1286    * ndb_mgm_get_fd
1287    *
1288    * get the file descriptor of the handle.
1289    * On Win32, returns SOCKET.
1290    * INTERNAL ONLY.
1291    * USE FOR TESTING. OTHER USES ARE NOT A GOOD IDEA.
1292    *
1293    * @param  handle NDB management handle
1294    * @return handle->socket
1295    *
1296    */
1297 #ifdef NDB_WIN
1298   SOCKET ndb_mgm_get_fd(NdbMgmHandle handle);
1299 #else
1300   int ndb_mgm_get_fd(NdbMgmHandle handle);
1301 #endif
1302 
1303   /**
1304    * Get the node id of the mgm server we're connected to
1305    */
1306   Uint32 ndb_mgm_get_mgmd_nodeid(NdbMgmHandle handle);
1307 
1308   /**
1309    * Config iterator
1310    */
1311   typedef struct ndb_mgm_configuration_iterator ndb_mgm_configuration_iterator;
1312 
1313   ndb_mgm_configuration_iterator* ndb_mgm_create_configuration_iterator
1314   (struct ndb_mgm_configuration *, unsigned type_of_section);
1315   void ndb_mgm_destroy_iterator(ndb_mgm_configuration_iterator*);
1316 
1317   int ndb_mgm_first(ndb_mgm_configuration_iterator*);
1318   int ndb_mgm_next(ndb_mgm_configuration_iterator*);
1319   int ndb_mgm_valid(const ndb_mgm_configuration_iterator*);
1320   int ndb_mgm_find(ndb_mgm_configuration_iterator*,
1321 		   int param, unsigned value);
1322 
1323   int ndb_mgm_get_int_parameter(const ndb_mgm_configuration_iterator*,
1324 				int param, unsigned * value);
1325   int ndb_mgm_get_int64_parameter(const ndb_mgm_configuration_iterator*,
1326 				  int param, Uint64 * value);
1327   int ndb_mgm_get_string_parameter(const ndb_mgm_configuration_iterator*,
1328 				   int param, const char  ** value);
1329   int ndb_mgm_purge_stale_sessions(NdbMgmHandle handle, char **);
1330   int ndb_mgm_check_connection(NdbMgmHandle handle);
1331 
1332   int ndb_mgm_report_event(NdbMgmHandle handle, Uint32 *data, Uint32 length);
1333 
1334   struct ndb_mgm_param_info
1335   {
1336     Uint32 m_id;
1337     const char * m_name;
1338   };
1339   int ndb_mgm_get_db_parameter_info(Uint32 paramId, struct ndb_mgm_param_info * info,
1340              size_t * size);
1341 #endif
1342 
1343   int ndb_mgm_create_nodegroup(NdbMgmHandle handle,
1344                                int * nodes,
1345                                int * ng,
1346                                struct ndb_mgm_reply* mgmreply);
1347 
1348   int ndb_mgm_drop_nodegroup(NdbMgmHandle handle,
1349                              int ng,
1350                              struct ndb_mgm_reply* mgmreply);
1351 
1352 #ifndef DOXYGEN_SHOULD_SKIP_DEPRECATED
1353   enum ndb_mgm_clusterlog_level {
1354      NDB_MGM_ILLEGAL_CLUSTERLOG_LEVEL = -1,
1355      NDB_MGM_CLUSTERLOG_ON    = 0,
1356      NDB_MGM_CLUSTERLOG_DEBUG = 1,
1357      NDB_MGM_CLUSTERLOG_INFO = 2,
1358      NDB_MGM_CLUSTERLOG_WARNING = 3,
1359      NDB_MGM_CLUSTERLOG_ERROR = 4,
1360      NDB_MGM_CLUSTERLOG_CRITICAL = 5,
1361      NDB_MGM_CLUSTERLOG_ALERT = 6,
1362      NDB_MGM_CLUSTERLOG_ALL = 7
1363   };
1364   static inline
ndb_mgm_filter_clusterlog(NdbMgmHandle h,enum ndb_mgm_clusterlog_level s,int e,struct ndb_mgm_reply * r)1365   int ndb_mgm_filter_clusterlog(NdbMgmHandle h,
1366 				enum ndb_mgm_clusterlog_level s,
1367 				int e, struct ndb_mgm_reply* r)
1368   { return ndb_mgm_set_clusterlog_severity_filter(h,(enum ndb_mgm_event_severity)s,
1369 						  e,r); }
1370   static inline
ndb_mgm_get_logfilter(NdbMgmHandle h)1371   const unsigned int * ndb_mgm_get_logfilter(NdbMgmHandle h)
1372   { return ndb_mgm_get_clusterlog_severity_filter_old(h); }
1373 
1374   static inline
ndb_mgm_set_loglevel_clusterlog(NdbMgmHandle h,int n,enum ndb_mgm_event_category c,int l,struct ndb_mgm_reply * r)1375   int ndb_mgm_set_loglevel_clusterlog(NdbMgmHandle h, int n,
1376 				      enum ndb_mgm_event_category c,
1377 				      int l, struct ndb_mgm_reply* r)
1378   { return ndb_mgm_set_clusterlog_loglevel(h,n,c,l,r); }
1379 
1380   static inline
ndb_mgm_get_loglevel_clusterlog(NdbMgmHandle h)1381   const unsigned int * ndb_mgm_get_loglevel_clusterlog(NdbMgmHandle h)
1382   { return ndb_mgm_get_clusterlog_loglevel_old(h); }
1383 
1384 #endif
1385 
1386   /**
1387    *   Struct containing array of ndb_logevents
1388    *   of the requested type, describing for example
1389    *   memoryusage or baclupstatus for the whole cluster,
1390    *   returned from ndb_mgm_dump_events()
1391    */
1392   struct ndb_mgm_events {
1393     /** Number of entries in the logevents array */
1394     int no_of_events;
1395     /** Array of ndb_logevents  */
1396     struct ndb_logevent events [
1397 #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
1398                     1
1399 #endif
1400     ];
1401   };
1402 
1403   /**
1404    * Get an array of ndb_logevent of a specified type, describing
1405    * for example memoryusage or backupstatus for the whole cluster
1406    *
1407    * @note The caller must free the pointer returned by this function.
1408    *
1409    * @param   handle        Management handle.
1410    * @param   type          Which ndb_logevent to request
1411    * @param   no_of_nodes   Number of database nodes to request info from<br>
1412    *                          0: All database nodes in cluster<br>
1413    *                          n: Only the <var>n</var> node(s) specified in<br>
1414    *                             the array node_list
1415    * @param   node_list     List of node IDs of database nodes to request<br>
1416    *                        info from
1417    *
1418    * @return                struct with array of ndb_logevent's
1419    *                        (or <var>NULL</var> on error).
1420    */
1421   struct ndb_mgm_events*
1422   ndb_mgm_dump_events(NdbMgmHandle handle, enum Ndb_logevent_type type,
1423                       int no_of_nodes, const int * node_list);
1424 
1425 #ifdef __cplusplus
1426 }
1427 #endif
1428 
1429 /** @} */
1430 
1431 #endif
1432 
1433