There is no restriction against instantiating multiple
Ndb_cluster_connection objects representing
connections to different management servers in a single
application, nor against using these for creating multiple
instances of the
Ndb class. Such
Ndb_cluster_connection objects (and the
Ndb instances based on them) are
not required even to connect to the same cluster.
For example, it is entirely possible to perform
partitioning of data in such a manner that data meeting
one set of criteria are “handed off” to one cluster
Ndb object that makes
use of an
representing a connection to that cluster, while data not meeting
those criteria (or perhaps a different set of criteria) can be
sent to a different cluster through a different instance of Ndb
that makes use of an
“pointing” to the second cluster.
It is possible to extend this scenario to develop a single application that accesses an arbitrary number of clusters. However, in doing so, the following conditions and requirements must be kept in mind:
A cluster management server (ndb_mgmd) can connect to one and only one cluster without being restarted and reconfigured, as it must read the data telling it which data nodes make up the cluster from a configuration file (
Ndb_cluster_connectionobject “belongs” to a single management server whose host name or IP address is used in instantiating this object (passed as the
connection_stringargument to its constructor); once the object is created, it cannot be used to initiate a connection to a different management server.
Ndbobject making use of this connection (
Ndb_cluster_connection) cannot be re-used to connect to a different cluster management server (and thus to a different collection of data nodes making up a cluster). Any given instance of
Ndbis bound to a specific
Ndb_cluster_connectionwhen created, and that
Ndb_cluster_connectionis in turn bound to a single and unique management server when it is instantiated.
(See Ndb Class Constructor.)
The bindings previously described persist for the lifetimes of the
Ndb_cluster_connectionobjects in question.
Therefore, it is imperative in designing and implementing any
application that accesses multiple clusters in a single session,
that a separate set of
Ndb objects be instantiated
for connecting to each cluster management server, and that no
confusion arises as to which of these is used to access which NDB
It is also important to keep in mind that no direct “sharing” of data or data nodes between different clusters is possible. A data node can belong to one and only one cluster, and any movement of data between clusters must be accomplished on the application level.
For examples demonstrating how connections to two different clusters can be made and used in a single application, see Section 2.5.2, “NDB API Example Using Synchronous Transactions and Multiple Clusters”, and Section 3.6.2, “MGM API Event Handling with Multiple Clusters”.