Documentation Home
MySQL NDB Cluster API Developer Guide
Download this Manual

4.3.1.21 SessionFactory

SessionFactory represents a cluster.

4.3.1.21.1 Synopsis
 public interface SessionFactory {
// Public Methods  public abstract void close();
  public abstract State currentState();
  public abstract List<Integer> getConnectionPoolSessionCounts();
  public abstract Session getSession();
  public abstract Session getSession(Map properties);
  public abstract void reconnect();
  public abstract void reconnect(int timeout);
}

Figure 4.20 SessionFactory Class

SessionFactory Class

4.3.1.21.2 close()
public abstract void close();

Close this session factory. Release all resources. Set the current state to Closed. When closed, calls to getSession will throw ClusterJUserException.

4.3.1.21.3 currentState()
public abstract State currentState();

Get the current state of this session factory.

4.3.1.21.4 getConnectionPoolSessionCounts()
public abstract List<Integer> getConnectionPoolSessionCounts();

Get a list containing the number of open sessions for each connection in the connection pool.

Since

7.3.14, 7.4.12, 7.5.2

4.3.1.21.5 getSession()
public abstract Session getSession();

Create a Session to use with the cluster, using all the properties of the SessionFactory.

Parameters

return

the session

4.3.1.21.6 getSession(Map)
public abstract Session getSession(Map properties);

Create a session to use with the cluster, overriding some properties. Properties PROPERTY_CLUSTER_CONNECTSTRING, PROPERTY_CLUSTER_DATABASE, and PROPERTY_CLUSTER_MAX_TRANSACTIONS may not be overridden.

Parameters

properties

overriding some properties for this session

return

the session

4.3.1.21.7 reconnect()
public abstract void reconnect();

Reconnect this session factory using the most recent timeout value specified. The timeout may have been specified in the original session factory properties or may have been changed by an application call to reconnect(int timeout).

See Also
reconnect(int)
Since

7.5.7

4.3.1.21.8 reconnect(int)
public abstract void reconnect(int timeout);

Disconnect and reconnect this session factory using the specified timeout value and change the saved timeout value. This is a heavyweight method and should be used rarely. It is intended for cases where the process in which clusterj is running has lost connectivity to the cluster and is not able to function normally. Reconnection is done in several phases. First, the session factory is set to state Reconnecting and a reconnect thread is started to manage the reconnection procedure. In the Reconnecting state, the getSession methods throw ClusterJUserException and the connection pool is quiesced until all sessions have closed. If sessions fail to close normally after timeout seconds, the sessions are forced to close. Next, all connections in the connection pool are closed, which frees their connection slots in the cluster. Finally, the connection pool is recreated using the original connection pool properties and the state is set to Open. The reconnection procedure is asynchronous. To observe the progress of the procedure, use the methods currentState and getConnectionPoolSessionCounts. If the timeout value is non-zero, automatic reconnection will be done by the clusterj implementation upon recognizing that a network failure has occurred. If the timeout value is 0, automatic reconnection is disabled. If the current state of this session factory is Reconnecting, this method silently does nothing.

Parameters

timeout

the timeout value in seconds; 0 to disable automatic reconnection

Since

7.5.7


User Comments
Sign Up Login You must be logged in to post a comment.