MySQL NDB Cluster API Developer Guide
This section provides information about MGM API functions that
are used to initiate, configure, and terminate connections to an
NDB
management server.
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().
const char* ndb_mgm_get_connectstring ( NdbMgmHandlehandle
, char*buffer
, intsize
)
This function takes three arguments:
An NdbMgmHandle
.
A pointer to a buffer
in
which to place the result.
The size
of the buffer.
The connection string—this is the same value that
is pushed to the buffer
.
This function gets the ID of the node to which the connection is being (or was) made.
int ndb_mgm_get_configuration_nodeid
(
NdbMgmHandle handle
)
A management server handle.
A node ID.
This function retrieves the number of the port used by the connection.
int ndb_mgm_get_connected_port
(
NdbMgmHandle handle
)
An NdbMgmHandle
.
A port number.
This function is used to obtain the name of the host to which the connection is made.
const char* ndb_mgm_get_connected_host
(
NdbMgmHandle handle
)
A management server handle
.
A host name.
Given a management server handle, this function gets
NDB
engine and MySQL Server version
information for the indicated management server.
int ndb_mgm_get_version ( NdbMgmHandlehandle
, int*major
, int*minor
, int*build
, intlength
, char*string
)
An NdbMgmHandle
, and pointers to the
NDB
engine
major
,
minor
, and
build
version values, as well
as a pointer to the version
string
(along with the
strength's length
).
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.
ndb_mgm_get_version()
returns an
integer: 0 on success; any nonzero value indicates an
error.
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.
int ndb_mgm_is_connected
(
NdbMgmHandle handle
)
A management server handle
.
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.
This function can be used to determine whether a management server is running on a given connection from a management client.
int ndb_mgm_check_connection
(
NdbMgmHandle handle
)
An NdbMgmHandle
(see
Section 3.1, “MGM API Concepts”).
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).
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()
.
int ndb_mgm_number_of_mgmd_in_connect_string
(
NdbMgmHandle handle
)
A management handle (NdbMgmHandle
).
On success, a nonnegative integer; a negative integer indicates failure.
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.
int ndb_mgm_set_bindaddress ( NdbMgmHandlehandle
, const char*address
)
This function takes two parameters:
A management handle
(NdbMgmHandle
).
A string address
of the
form
.
host
[:port
]
Returns an integer:
0
indicates success
Any nonzero value indicates failure (the address was not valid)
Errors caused by binding an otherwise valid local address are not reported until the connection to the management is actually attempted.
This function is used to set the connection string for a management server connection to a node.
int ndb_mgm_set_connectstring ( NdbMgmHandlehandle
, const char*connection_string
)
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
, and
host
are defined as
follows:
id
: An integer
greater than 0
identifying a
node in config.ini
.
port
: An integer
referring to a standard Unix port.
host
: A string
containing a valid network host address.
This function returns -1
in the event
of failure.
This function sets the connection node ID.
int ndb_mgm_set_configuration_nodeid ( NdbMgmHandlehandle
, intid
)
This function requires two parameters:
An NdbMgmHandle
.
The id
of the node to connect to.
This function returns -1
in the event
of failure.
Normally, network operations time out after 60 seconds. This function permits you to vary this time.
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.
int ndb_mgm_set_timeout ( NdbMgmHandlehandle
, unsigned inttimeout
)
This function takes two parameters:
A management server handle
(NdbMgmHandle
).
An amount of time to wait before timing out, expressed in milliseconds.
Returns 0
on success, with any other
value representing failure.
This function establishes a connection to a management server specified by the connection string set by ndb_mgm_set_connectstring().
int ndb_mgm_connect ( NdbMgmHandlehandle
, intretries
, intdelay
, intverbose
)
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.
If verbose
is
1
, then a message is printed for
each connection attempt.
This function returns -1
in the event
of failure.