20.1.4 Connection pool clustering operations
This section describes the available functionality and operations when a connection pool is clustered. You can execute the following functionality with a clustered connection pool:
-
Suspending a connection pool
-
Restarting a connection pool
This section also describes the connection pool states and how to select a connection pool when a connection request is received.
- Organization of this subsection
(1) Suspending a connection pool
You can block and suspend a member connection pool. If you execute suspend, a member connection pool is blocked and suspended.
When a J2EE application sends a connection request to the root resource adapter, no connection request is sent to a blocked or suspended member connection pool.
You suspend the member connection pool in the following cases:
-
When an error occurs in a database node
-
When maintenance is performed for a database node
Note that the suspension methods include the following two methods:
-
Auto-suspension
-
Manual suspension
- Reference note
-
With the suspension processing, the connections that the J2EE application has finished using are destroyed, all the connections in the connection pool are destroyed, and then the connection pool is suspended. When a network error or a database node error occurs, a connection is destroyed after waiting for the network to timeout, so the processing from blocking to suspending the connection pool might take time.
(a) Auto-suspension
You can automatically suspend the member connection pool when a database node error occurs. When an error is detected, the member connection pool is automatically blocked and then suspended.
If the following events occur when a connection is obtained, a database node error is determined, and the member connection pool is automatically suspended:
-
When a timeout occurs during the detection of the connection errors while a connection is being obtained
-
When a physical connection cannot be obtained
-
When the obtaining of a physical connection times out
-
When the connection management threads deplete
This functionality is enabled by default. Specify the settings for enabling or disabling this functionality as a root resource adapter property. For details on the resource adapter settings, see 5.4 Defining resource adapter properties in the uCosminexus Application Server Application Setup Guide.
(b) Manual suspension
When you perform operations such as database node maintenance, you execute the cjsuspendpool command to manually suspend a connection pool. You can execute manual suspension when the status of a member connection pool is Start, Reserved Start, Auto-suspend, and Reserved Auto-suspend. If you execute the cjsuspendpool command when the member connection pool is in an auto-suspension state, the status changes to manual suspension. Due to this, you can execute operations so that the member connection pool is not restarted automatically after auto-suspension. For details on the manual suspension procedure, see 20.1.5(2) Suspending the connection pool. For command details, see cjsuspendpool (suspend member connection pool).
- Important note
-
A connection pool that is suspended manually with the cjsuspendpool command is not restarted automatically. Restart the connection pool manually.
(2) Restarting a connection pool
You can restart a suspended member connection pool. When the J2EE application makes a connection request to the root resource adapter, the connection requests are now sent to the restarted member connection pool again.
Note that to restart a connection pool, the number of unused connection management threads must be equal to or more than the maximum number of connections in the connection pool.
You restart the connection pool in the following cases:
-
When the database node error is recovered
-
When the maintenance of the database node finishes
The restart methods include the following two methods:
-
Auto-restart
-
Manual restart
- Reference note
-
-
If the number of unused connection management threads becomes equal to the maximum number of connections in the connection pool when the connection pool is stopped, a message is output. When the execution of the cjresumepool command fails, check the displayed message and then re-execute the command.
-
When the connection pool warming up functionality is enabled, the member connection pool starts after the minimum number of connections defined in the connection pool settings is pooled. If an attempt to generate a connection fails while the connections are being pooled, the member connection pool returns to the suspended state. Also, if the connection pool warming up functionality is disabled, the member connection pool starts immediately.
-
(a) Auto-restart
You can automatically restart an auto-suspended member connection pool.
The auto-suspended member connection pool sends a physical connection request at regular intervals to check the state of the database node. At this time, if a connection is obtained successfully, the database node is determined to have recovered, and the restart processing is performed automatically. Also, if you do not want to automatically restart an auto-suspended member connection pool, manually suspend the member connection pool after the pool is suspended automatically. To restart the pool, use manual restart.
Note that if the root resource adapter is stopped, the auto-restart processing is not performed. However, if you stop the root resource adapter while the member connection pool is auto-restarting, the running auto-restart processing is continued.
This functionality is enabled by default. Specify the settings for switching between enabling and disabling and for the interval to check the database node state as the root resource adapter properties. For details on the resource adapter settings, see 5.4 Defining resource adapter properties in the uCosminexus Application Server Application Setup Guide.
(b) Manual restart
You can manually restart an auto-suspended or manually suspended connection pool. To restart manually, use the cjresumepool command. You can execute manual restart when the status of the connection pool is as follows:
-
Auto-suspension
-
Manual suspension
-
Reserved auto-suspension
-
Reserved manual suspension
For details on the manual restart procedure, see 20.1.5(3) Restarting the connection pool. For the command details, see cjresumepool (restart member connection pool).
(3) States of the connection pool
A connection pool state only exists for the member connection pools. Note that the connection pool state is maintained even after you restart the J2EE server and resource adapter.
You can check the state of the member connection pool with the following methods. When you execute manual suspension or manual restart, check the connection pool state before you execute the commands.
-
cjlistrar command
The cjlistrar command outputs the names and states of all the deployed resource adapters to the standard output. If you specify -clusterpool, you can also display the states of the member connection pools.
For the command details, see cjlistrar (list resource adapters) in the uCosminexus Application Server Command Reference Guide.
-
cjlistpool command
The cjlistpool command displays the connection pool information. The command can also display the states of the member connection pools for the member resource adapters. For details on examples of displaying the connection information of a member resource adapter, see the manual uCosminexus Application Server Common Container Functionality Guide.
For the command details, see cjlistpool (list connection pools) in the uCosminexus Application Server Command Reference Guide.
This section describes the states of the member connection pools.
The state of the member connection pool is maintained even if you restart the J2EE server and member resource adapter. For the procedure for checking the connection pool states, see 20.1.5(1) Checking the connection pool state.
Note that the connection pools other than those for the member resource adapters do not have a state.
(a) Transition of the connection pool state
The following figure shows the transition of the member connection pool state.
Note that when the J2EE server starts, if the status of the connection pool is Resuming or Blocked, the connection pool status transits to Suspended.
The following table describes each status.
(b) Executability of commands based on the connection pool status
Depending on the state of the connection pool, some commands can be executed and some cannot be executed. The following table describes whether the commands can be executed for each connection pool state.
Command |
Connection pool status |
|||||||
---|---|---|---|---|---|---|---|---|
Start |
Reserved Start |
Auto-restarting/ Manual Restarting |
Automatically Blocked/ Manually Blocked |
Auto-suspension |
Manual Suspension |
Reserved Auto-suspension |
Reserved Manual Suspension |
|
cjstartrar |
N |
Y |
N |
N |
N |
N |
Y |
Y |
cjstoprar |
Y |
N |
R#1 |
R#2 |
Y |
Y |
N |
N |
cjclearpool |
Y |
N |
N |
N |
N |
N |
N |
N |
cjlistrar |
Y |
Y |
Y |
Y |
Y |
Y |
Y |
Y |
cjsuspendpool |
Y |
Y |
N |
N |
Y |
N |
Y |
N |
cjresumepool |
N |
N |
N |
N |
Y |
Y |
Y |
Y |
cjstopsv (for a normal termination) |
Y |
Y |
R#1 |
R#2 |
Y |
Y |
Y |
Y |
cjstopsv (for a forced termination) |
Y |
Y |
Y |
Y |
Y |
Y |
Y |
Y |
(4) How to select a connection pool
When the J2EE application sends a connection request to the root resource adapter, one member connection pool is selected. The method by which the member connection pool is selected at this time is the round-robin method.
The connection pool that is selected is a member connection pool with the Start status. A member connection pool that has free connections is selected on priority.
However, if only a member connection pool with depleted connections is available, the connection request changes to pending. Furthermore, if a timeout occurs in a pending connection, the connection cannot be obtained. Also, if a connection pool is blocked when a connection request is pending, the connection request is restarted and an attempt is made to obtain a connection from the member connection pool that is next in the priority order. If a connection cannot be obtained from any of the member connection pools, the attempt to obtain the connection fails.
Note that if there is a connection request when a member connection pool with the Start status does not exist, the attempt to obtain the connection fails.
To specify the maximum size of each member connection pool, use the following guideline:
Maximum-size-of -the-member-connection-pool-(number) = Maximum-number-of-concurrent-connections-permitted-for-the-system / number-of-database-nodes