- 4.3.1.23.1 Synopsis
- 4.3.1.23.2 close()
- 4.3.1.23.3 currentState()
- 4.3.1.23.4 getConnectionPoolSessionCounts()
- 4.3.1.23.5 getRecvThreadActivationThreshold()
- 4.3.1.23.6 getRecvThreadCPUids()
- 4.3.1.23.7 getSession()
- 4.3.1.23.8 getSession(Map)
- 4.3.1.23.9 getSession(String)
- 4.3.1.23.10 reconnect()
- 4.3.1.23.11 reconnect(int)
- 4.3.1.23.12 setRecvThreadActivationThreshold(int)
- 4.3.1.23.13 setRecvThreadCPUids(short[])
SessionFactory represents a cluster.
public interface SessionFactory {
// Public Methodspublic 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(String database);
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);
}
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. Actual connections to the database are managed in a global connection pool, and may be shared by several session factories; each connection will be closed when the last session factory using it is closed.
public abstract State currentState();
Get the current state of this session factory.
- Since
7.5.7
- See Also
- com.mysql.clusterj.SessionFactory.State
public abstract List<Integer> getConnectionPoolSessionCounts();
Get a list containing the number of open sessions for each connection that it uses from the global connection pool.
- Since
7.3.14, 7.4.12, 7.5.2
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
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
public abstract Session getSession();
Create a Session to use with the cluster, using all the properties of the SessionFactory, including the default database.
public abstract Session getSession(Map properties);
Create a session to use with the cluster, overriding some default properties with the properties supplied in the map. The property com.mysql.clusterj.connectstring may not be overridden.
Table 4.74 getSession(Map)
Parameter | Description |
---|---|
properties | map overriding some properties for this session |
return | the session |
Exceptions
-
ClusterJUserException
if properties contains an unexpected value for com.mysql.clusterj.connectstring
public abstract Session getSession(String database);
Create a Session to use with the cluster, using the default properties of the SessionFactory except for the database name. This requires the property com.mysql.clusterj.multidb to have been set to true when the SessionFactory was created.
Table 4.75 getSession(String)
Parameter | Description |
---|---|
database | name of the database to use for this session. If database is null, the default database is used. |
return | the session # |
Exceptions
-
ClusterJUserException
if SessionFactory is not a multi-db SessionFactory, and database is not its configured database and is not null.
- Since
9.4.0
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
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, managed by the global connection pool. First, a set of connections is set to state Reconnecting and a reconnect thread is started to manage the reconnection procedure. Then all SessionFactories are notified of the pending reconnection; every affected SessionFactory will transition into the Reconnecting state. 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 connections are 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.76 reconnect(int)
Parameter | Description |
---|---|
timeout | the timeout value in seconds; 0 to disable automatic reconnection |
- Since
7.5.7
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
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