This section provides information about MGM API functions that
are used to initiate, configure, and terminate connections to an
NDB
management server.
- Description
This function retrieves the connection string used for a connection.
This function returns the default connection string if no
call to
ndb_mgm_set_connectstring()
has been performed. In addition, the returned connection
string may be formatted slightly differently than the
original in that it may contain specifiers not present in
the original.
The connection string format is the same as that discussed for ndb_mgm_set_connectstring().
- Signature
const char* ndb_mgm_get_connectstring ( NdbMgmHandle handle, char* buffer, int size )
- Parameters
-
This function takes three arguments:
An
NdbMgmHandle
.A pointer to a
buffer
in which to place the result.The
size
of the buffer.
- Return value
The connection string—this is the same value that is pushed to the
buffer
.
- Description
This function gets the ID of the node to which the connection is being (or was) made.
- Signature
int ndb_mgm_get_configuration_nodeid ( NdbMgmHandle handle )
- Parameters
A management server handle.
- Return value
A node ID.
- Description
This function retrieves the number of the port used by the connection.
- Signature
int ndb_mgm_get_connected_port ( NdbMgmHandle handle )
- Parameters
An
NdbMgmHandle
.- Return value
A port number.
- Description
This function is used to obtain the name of the host to which the connection is made.
- Signature
const char* ndb_mgm_get_connected_host ( NdbMgmHandle handle )
- Parameters
A management server
handle
.- Return value
A host name.
- Description
Given a management server handle, this function gets
NDB
engine and MySQL Server version information for the indicated management server.- Signature
int ndb_mgm_get_version ( NdbMgmHandle handle, int* major, int* minor, int* build, int length, char* string )
- Parameters
An
NdbMgmHandle
, and pointers to theNDB
enginemajor
,minor
, andbuild
version values, as well as a pointer to the versionstring
(along with the strength'slength
).
The version string uses the format
mysql-
,
where x.x.x
ndb-y.y.y
-status
x.x.x
is the three-part MySQL
Server version, and y.y.y
is the
three-part NDB
storage engine version. The
status
string indicates the release
level or status; usually this is one of
beta
, rc
, or
ga
, but other values are sometimes
possible.
- Return value
ndb_mgm_get_version()
returns an integer: 0 on success; any nonzero value indicates an error.
- Description
Used to determine whether a connection has been established.
This function does not determine whether or not there is a
“live” management server at the other end of
the connection. Use
ndb_mgm_check_connection()
to accomplish that task.
- Signature
int ndb_mgm_is_connected ( NdbMgmHandle handle )
- Parameters
A management server
handle
.- Return value
-
This function returns an integer, whose value is interpreted as follows:
0
: Not connected to the management node.Any nonzero value: A connection has been established with the management node.
- Description
This function can be used to determine whether a management server is running on a given connection from a management client.
- Signature
int ndb_mgm_check_connection ( NdbMgmHandle handle )
- Parameters
An
NdbMgmHandle
(see Section 3.1, “MGM API Concepts”).- Return value
In NDB 7.5 and later, this function returns 0 on success, -1 when the handle is null, and -2 when not connected.
In NDB 7.4 and earlier, this function returned -1 in the event of an error; otherwise it returned 0, even when the management server handle was NULL, or when the connection check failed (Bug #53242, Bug #11760802).
- Description
This is a convenience function which provides an easy way to determine the number of management servers referenced in a connection string as set using
ndb_mgm_set_connectstring()
.- Signature
int ndb_mgm_number_of_mgmd_in_connect_string ( NdbMgmHandle handle )
- Parameters
A management handle (
NdbMgmHandle
).- Return value
On success, a nonnegative integer; a negative integer indicates failure.
- Description
This function makes it possible to set a local bind address for the management server. If used, it must be called before connecting to the management server.
- Signature
int ndb_mgm_set_bindaddress ( NdbMgmHandle handle, const char* address )
- Parameters
-
This function takes two parameters:
A management handle (
NdbMgmHandle
).A string
address
of the form
.host
[:port
]
- Return value
-
Returns an integer:
0
indicates success-
Any nonzero value indicates failure (the address was not valid)
ImportantErrors caused by binding an otherwise valid local address are not reported until the connection to the management is actually attempted.
- Description
-
Sets the number of seconds for timeout of network operations; the default is 3 seconds.
Supported in NDB 8.0.37 and later. Not supported by NDB 8.3.0.
- Signature
int ndb_mgm_set_connect_timeout ( NdbMgmHandle handle, unsigned int seconds )
- Parameters
-
ndb_mgm_set_connect_timeout()
takes two parameters:A management server
handle
.A timeout in
seconds
.
- Return value
This function returns
0
in the event of failure, otherwise indicates success.
- Description
This function is used to set the connection string for a management server connection to a node.
- Signature
int ndb_mgm_set_connectstring ( NdbMgmHandle handle, const char* connection_string )
- Parameters
-
ndb_mgm_set_connectstring()
takes two parameters:A management server
handle
.-
A
connection_string
whose format is shown here:connection_string := [nodeid-specification,]host-specification[,host-specification]
ndb_mgm_get_connectstring()
also uses this format for connection strings.It is possible to establish connections with multiple management servers using a single connection string.
nodeid-specification := nodeid=id host-specification := host[:port]
id
,port
, andhost
are defined as follows:id
: An integer greater than0
identifying a node inconfig.ini
.port
: An integer referring to a standard Unix port.host
: A string containing a valid network host address.
- Return value
This function returns
-1
in the event of failure.
- Description
This function sets the connection node ID.
- Signature
int ndb_mgm_set_configuration_nodeid ( NdbMgmHandle handle, int id )
- Parameters
-
This function requires two parameters:
An
NdbMgmHandle
.The
id
of the node to connect to.
- Return value
This function returns
-1
in the event of failure.
- Description
Sets the number of milliseconds for timeout of network operations; the default is 60 seconds.
The timeout set by this function applies not only to establishing network connections, but to every operation requiring communication using a network connection. This includes each network read or write performed by any MGM API function, NDB API method call, or ndb_mgm client command.
- Signature
int ndb_mgm_set_timeout ( NdbMgmHandle handle, unsigned int timeout_ms )
- Parameters
-
This function takes two parameters:
A management server handle (
NdbMgmHandle
).The amount of time to wait before timing out, expressed in milliseconds. Only multiples of 1000 are supported; no function is guaranteed to return in a fraction of a second.
- Return value
Returns
0
on success, with any other value representing failure.
- Description
This function establishes a connection to a management server specified by the connection string set by ndb_mgm_set_connectstring().
- Signature
int ndb_mgm_connect ( NdbMgmHandle handle, int retries, int delay, int verbose )
- Parameters
-
This function takes 4 arguments:
A management server
handle
.The number of
retries
to make when attempting to connect.0
for this value means that one connection attempt is made.-
The number of seconds to
delay
between connection attempts.NDB 8.0.37 and later : Uses the value specified by
ndb_mgm_set_connect_timeout()
if unspecified. If
verbose
is1
, then a message is printed for each connection attempt.
- Return value
This function returns
-1
in the event of failure.