AsyncDistributedSqlEngine:open( OpenParameters )

This article is deprecated.

Start the connection pool, and synchronously connect all worker processes.

Prototype

    bool open(OpenParameters *params, int *badNode = 0);

Arguments

params
An initialized instance of struct OpenParameters.
badNode
If this parameter is not null and the open fails, then the index of the node that is not available is stored in badNode.

Description

This method opens an eXtremeDB database, an eXtremeDB SQL mapper and the AsyncDistributedSqlEngine instance with the parameters specified in params. It then calls the open( parameter list ) method passing the specified parameter values.

Returns

This method returns true if the connection to the server was successfully established, false otherwise.

Example

    const size_t nWorkers = 4;
    OpenParameters::NodeParams nodes[2];

    int main(int argc, char** argv)
    {
        try {
            nodes[0].address = "localhost:5001";
            nodes[1].address = "localhost:5002";

            McoSql::AsyncDistributedSqlEngine engine(nWorkers);
            OpenParameters params(sizeof(nodes) / sizeof(nodes[0]));
            params.nodes[0] = nodes[0];
            params.nodes[1] = nodes[1];
            int badNode = -1;

            if (!engine.open(&params, &badNode))
            {
                printf("Open failed: %s\n", engine.getError()->cstr());
                return 1;
            }
            ...
        }
    }