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]; 
    nodes[0].address = "localhost:5001";
    nodes[1].address = "localhost:5002";
     
    int main(int argc, char** argv)
    {
        try {

            McoSql::AsyncDistributedSqlEngine engine(nWorkers);
            OpenParameters params = new OpenParameters(sizeof(nodes) / sizeof(nodes[0]));
            params.nodes = nodes;
            int badNode = -1;
             
            if (!engine.open(&params, &badNode)) 
            {
                printf("Open failed: %s\n", engine.getError()->cstr());
                return 1;
            }
            ...
        }
    }