This article is deprecated.
Start the connection pool, and synchronously connect all worker processes.
Prototype
bool open(char const* const* nodes, int nNodes, int nReplicas = 1, ReplicationType replType = SQL_REPLICATION, int maxConnectAttempts = 10, int* badNode = NULL, bool localDomain = false, void* sslParameters = NULL, timer_unit connectTimeout = 2*1000, timer_unit readTimeout = 1200*1000);Arguments
nodes An array with the node names and ports ("NAME:PORT") nNodes The number of nodes nReplicas The number of replicas; this number should be a divider of nNodesmeaning that the remainder ofnNodes / nReplicasis0. For example, the values ofnNodesandnReplicascould be (4 and 2) or (12 and 3) but not (6 and 4) because 6 % 4 = 2replType The replication method maxConnectAttempts The maximum number of attempts to connect to the server badNode If this parameter is not null and the open fails, then the index of the node specification in nodesfor the node that could not be connected is stored inbadNodelocalDomain Indicates that Unix Domain Socket instead of networked TCP socket is used for RSQL communication which is possible only when server and client are on the same host sslParameters A pointer to a mco_ssl_params_tstructure containing SSL connection settingsconnectTimeout The timeout for each connect attempt in milliseconds; the total connection time can be up to connectTimeout * maxConnectionAttemptsmillisecondsreadTimeout The timeout for read operations in milliseconds Description
This method opens an eXtremeDB database, an eXtremeDB SQL mapper and the AsyncDistributedSqlEngine instance with the list of parameters specified. Internally, it creates worker processes, each of which handles connections, sends queries and receives results.
Returns
This method returns
trueif the connection to the server was successfully established,falseotherwise.Example
const size_t nWorkers = 4; const char *nodes[] = { "localhost:5001", "localhost:5002" }; int main(int argc, char** argv) { try { McoSql::AsyncDistributedSqlEngine engine(nWorkers); if (!engine.open(nodes, sizeof(nodes) / sizeof(nodes[0]))) { printf("Open failed: %s\n", engine.getError()->cstr()); return 1; } ... } }