You get pointers to all the Servers currently known to the client by calling objectstore::get_all_servers(). Here is an example of a handler for err_broken_server_connection:
TIX_HANDLE (err_broken_server_connection) { /* code that could encounter broken connection */ } TIX_EXCEPTION { tix_exception *cur = tix_handler::get_exception(); /* It might be necessary to abort a transaction in progress. This is a tricky situation since under some circumstances it is not needed, and in others it is. */ if (objectstore::abort_in_progress()) os_transaction::abort_top_level(); /* here is how the application can find the lost servers. */ os_int32 nservers = objectstore::get_n_servers(); os_server **svrlist = new os_server * [nservers]; char *svr_name = NULL; os_int32 ignore; objectstore::get_all_servers(nservers, svrlist, ignore); for (os_int32 i = 0; i < nservers; ++i) { if (svrlist[i]->connection_is_broken()) { svr_name = svrlist[i]->get_host_name(); printf("lost server %s\n", svr_name); delete [] svr_name; } } delete [] svrlist; } TIX_END_HANDLE;When handling err_broken_server_connection, call os_transaction::abort_top_level() if objectstore::abort_in_progress() returns nonzero. If you do not abort the transaction, attempts to proceed might cause err_broken_server_connection to be reraised.
When ObjectStore raises err_broken_server_connection, it immediately aborts all transactions. Any databases currently open on the lost Server are considered by ObjectStore to remain open. Subsequent uses of these databases (or others managed by that Server) will cause ObjectStore to attempt to reconnect with the Server.
os_boolean connection_is_broken();Returns nonzero if the connection with the specified Server is currently lost; otherwise returns 0.
void disconnect();Disconnects the specified Server. Call this function outside any transaction; otherwise err_trans is signaled. It is harmless to call this member if the connection has already been lost for any reason. The result of this call is very much like the result of unintentionally losing a connection. The client retains all its information about the Server and its databases, but marks them as having lost the connection. An attempt to access a database on the Server will cause ObjectStore to attempt to reconnect to the Server. You can also call os_server::reconnect() on the Server.
void get_databases( os_int32 max_to_return, os_database_p * dbs, os_int32& n_ret );Provides access to all the databases associated with the specified Server, whether open or closed. The os_database_p* is an array of pointers to os_database objects. This array must be allocated by the user. The function os_server::get_n_databases() can be used to determine how large an array to allocate. max_to_return is specified by the user, and is the maximum number of elements the array is to have. n_ret refers to the actual number of elements in the array.
char *get_host_name() const;Returns the name of the host of the specified Server. It is the caller's responsibility to deallocate the string when it is no longer needed.
char* get_host_name();For failover Servers, this function returns the logical failover Server host name. Note that the logical Server name is not always identical to the Server name for the machine providing access to the database. The caller should delete the returned value. See os_failover_server::get_online_server().
os_int32 get_n_databases();Returns the number of databases associated with the specified Server, whether open or closed.
os_boolean is_failover() const;Returns true if and only if the os_server* is an os_failover_server also.
This method is used to identify the os_failover_server in the list of Servers returned by objectstore::get_all_servers().
void reconnect();Causes ObjectStore to immediately attempt to reconnect to the specified Server. Note that exceptions, such as err_server_refused_connection, might result. Calling this function has no effect if the connection is not currently broken.
Updated: 03/31/98 17:25:09