Documentation Home
MySQL NDB Cluster API Developer Guide
Related Documentation Download this Manual
PDF (US Ltr) - 3.6Mb
PDF (A4) - 3.6Mb


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 int getRecvThreadActivationThreshold();
  public abstract short[] getRecvThreadCPUids();
  public abstract Session getSession();
  public abstract Session getSession(Map properties);
  public abstract void reconnect();
  public abstract void reconnect(int timeout);
  public abstract void setRecvThreadActivationThreshold(int threshold);
  public abstract void setRecvThreadCPUids(short[] cpuids);
}
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 getRecvThreadActivationThreshold()
public abstract int getRecvThreadActivationThreshold();

Get the receive thread activation threshold for all connections in the connection pool. 16 or higher means that receive threads are never used as receivers. 0 means that the receive thread is always active, and that retains poll rights for its own exclusive use, effectively blocking all user threads from becoming receivers. In such cases care should be taken to ensure that the receive thread does not compete with the user thread for CPU resources; it is preferable for it to be locked to a CPU for its own exclusive use. The default is 8.

Since

7.5.7

4.3.1.21.6 getRecvThreadCPUids()
public abstract short[] getRecvThreadCPUids();

Get receive thread bindings to cpus for all connections in the connection pool. If a receive thread is not bound to a cpu, the corresponding value will be -1.

Since

7.5.7

4.3.1.21.7 getSession()
public abstract Session getSession();

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

Table 4.71 getSession()

Parameter Description
return the session

4.3.1.21.8 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.

Table 4.72 getSession(Map)

Parameter Description
properties overriding some properties for this session
return the session

4.3.1.21.9 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.10 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.

Table 4.73 reconnect(int)

Parameter Description
timeout the timeout value in seconds; 0 to disable automatic reconnection

Since

7.5.7

4.3.1.21.11 setRecvThreadActivationThreshold(int)
public abstract void setRecvThreadActivationThreshold(int threshold);

Set the receive thread activation threshold for all connections in the connection pool. 16 or higher means that receive threads are never used as receivers. 0 means that the receive thread is always active, and that retains poll rights for its own exclusive use, effectively blocking all user threads from becoming receivers. In such cases care should be taken to ensure that the receive thread does not compete with the user thread for CPU resources; it is preferable for it to be locked to a CPU for its own exclusive use. The default is 8.

Exceptions

ClusterJUserException

if the value is negative

ClusterJFatalInternalException

if the method fails due to some internal reason.

Since

7.5.7

4.3.1.21.12 setRecvThreadCPUids(short[])
public abstract void setRecvThreadCPUids(short[] cpuids);

Bind receive threads to cpuids for all connections in the connection pool. Specify -1 to unset receive thread cpu binding for a connection. The cpuid must be between 0 and the number of cpus in the machine.

Exceptions

ClusterJUserException

if the cpuid is illegal or if the number of elements in cpuids is not equal to the number of connections in the connection pool.

ClusterJFatalInternalException

if the binding fails due to some internal reason.

Since

7.5.7