Package com.verisign.epp.pool
Class EPPSessionPool
java.lang.Object
com.verisign.epp.pool.EPPSessionPool
Singleton EPP session pool that will handle creating sessions
dynamically, expiring session after an absolute timeout, keeping sessions
alive based on an idle timeout, and dynamically grows and shrinks the pool
based on configurable settings. One of the
init methods must be
called before useing the pool. The init() method uses configuration
settings defined in the Environment class. The
Environment settings include the following:- EPP.SessionPool.poolableFactoryClassName - EPPSessionPoolableFactory class used by the pool, with a default of EoT poolable factory of "com.verisign.epp.pool.EPPGenericSessionPoolableFactory".
- EPP.SessionPool.clientId - (required) Login name
- EPP.SessionPool.password - (required) password
- EPP.SessionPool.absoluteTimeout - (optional) Session absolute timeout. Default is 24 hours
EPP.SessionPool.minAbsoluteTimeout- Session minimum absolute timeout. If bothminAbsoluteTimeoutandmaxAbsoluteTimeoutis set, it will overrideabsoluteTimeoutand randomize the session absolute timeout between theminAbsoluteTimeoutandmaxAbsoluteTimeout.EPP.SessionPool.maxAbsoluteTimeout- Session maximum absolute timeout. If bothminAbsoluteTimeoutandmaxAbsoluteTimeoutis set, it will overrideabsoluteTimeoutand randomize the session absolute timeout between theminAbsoluteTimeoutandmaxAbsoluteTimeout.- EPP.SessionPool.idleTimeout - (optional) Session idle timeout used to determine when keep alive messages are sent. Default is 10 minutes.
- EPP.SessionPool.maxIdle - (optional) Maximum number of idle sessions in pool. Default is 10.
- EPP.SessionPool.maxTotal - (optional) Maximum number of active sessions in pool. Default is 10.
- EPP.SessionPool.initMaxTotal - (optional) Boolean value indicating if the
maxTotalsessions should be pre-initialized at initialization in theinit()method. Default isfalse. - EPP.SessionPool.maxWait - (optional) Maximum time in milliseconds for a client to block waiting for a pooled session. Default is 60 seconds.
- EPP.SessionPool.minIdle - (optional) Minimum number of idle sessions in the pool. Default is 0.
- EPP.SessionPool.timeBetweenEvictionRunsMillis - (optional) Frequency in milliseconds of scanning the pool for idle and absolute timeout sessions. Default is 60 seconds.
- EPP.SessionPool.borrowRetries - (optional) Number of retries to
get/create a session when calling
borrowObject(). Default is0.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringName of the default system session pool, which uses theborrowObject(),returnObject(EPPSession), andinvalidateObject(EPPSession).static final longThe default session absolute timeout.static final longThe default session absolute timeout.static final intThe default cap on the number of "sleeping" instances in the pool.static final intThe default cap on the total number of instances for the pool.static final longThe default maximum amount of time (in millis) theborrowObject()method should block before throwing an exception.static final intThe default minimum number of "sleeping" instances in the pool before before the evictor thread (if active) spawns new objects.static final longThe default "time between eviction runs" value.protected static EPPSessionPoolSingleton instance -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedDefault constructor as part of the Singleton Design Pattern. -
Method Summary
Modifier and TypeMethodDescriptionBorrows a session from the pool.borrowObject(String aSystem) Borrows a session from the pool.voidclose()Closes the session pool(s) contained inEPPSessionPoolcleanly.longGets the session absolute timeout.Gets the TCP server IP address or host name to connect from.Gets the client identifier used to authenticate.org.apache.commons.pool2.impl.GenericObjectPoolConfig<EPPPooledSession> Gets the configuration for theGenericObjectPool.Gets the factory associated with the pool.org.apache.commons.pool2.impl.GenericObjectPool<EPPPooledSession> Gets the containedGenericObjectPool.org.apache.commons.pool2.impl.GenericObjectPool<EPPPooledSession> getGenericObjectPool(String aSystem) Gets the containedGenericObjectPoolfor a system.longGets the session idle timeout.static EPPSessionPoolGets the Singleton Design Pattern instance.longGets the maximum session absolute timeout in milliseconds.longGets the minimum session absolute timeout in milliseconds.Gets the password used for authentication.Gets the TCP server IP address or host name, or the URL of the HTTP server.Gets the TCP server port number.getSystemSessionPool(String aSystem) Gets the containedEPPSystemSessionPoolfor a system.booleanhasSystemSessionPool(String aSystem) Does the system session pool exist?voidinit()voidinit(EPPSessionPoolableFactory aFactory, org.apache.commons.pool2.impl.GenericObjectPoolConfig<EPPPooledSession> aConfig) Initialize the pool with a specificEPPSessionPoolableFactoryandGenericObjectPoolConfigsetting.voidinvalidateObject(EPPSession aSession) Remove a borrowed session from the pool based on a known issue with it.voidinvalidateObject(String aSystem, EPPSession aSession) Remove a borrowed session from the system session pool based on a known issue with it.booleanInitialize the session via an EPP login on the call toPooledObjectFactory.makeObject()? The default value istrue.booleanReturns whether the absolute timeout will be randomized between theminAbsoluteTimeoutandmaxAbsoluteTimemout.voidreturnObject(EPPSession aSession) Returned a borrowed session to the pool.voidreturnObject(String aSystem, EPPSession aSession) Returned a borrowed session to a system session pool.voidsetClientHost(String aClientHost) Sets the TCP server IP address or host name to connect from.voidsetInitSessionOnMake(boolean aInitSessionOnMake) Set whether to initialize the session via an EPP login on the call toPooledObjectFactory.makeObject().voidsetServerName(String aServerName) Sets the TCP server IP address or host name or the URL of the HTTP server.voidsetServerPort(Integer aServerPort) Sets the TCP server port number.
-
Field Details
-
DEFAULT_ABSOLUTE_TIMEOUT
public static final long DEFAULT_ABSOLUTE_TIMEOUTThe default session absolute timeout.- See Also:
-
DEFAULT_IDLE_TIMEOUT
public static final long DEFAULT_IDLE_TIMEOUTThe default session absolute timeout.- See Also:
-
DEFAULT_MAX_WAIT
public static final long DEFAULT_MAX_WAITThe default maximum amount of time (in millis) theborrowObject()method should block before throwing an exception.- See Also:
-
DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS
public static final long DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLISThe default "time between eviction runs" value.- See Also:
-
DEFAULT_MAX_IDLE
public static final int DEFAULT_MAX_IDLEThe default cap on the number of "sleeping" instances in the pool.- See Also:
-
DEFAULT_MAX_TOTAL
public static final int DEFAULT_MAX_TOTALThe default cap on the total number of instances for the pool.- See Also:
-
DEFAULT_MIN_IDLE
public static final int DEFAULT_MIN_IDLEThe default minimum number of "sleeping" instances in the pool before before the evictor thread (if active) spawns new objects.- See Also:
-
instance
Singleton instance -
DEFAULT
Name of the default system session pool, which uses theborrowObject(),returnObject(EPPSession), andinvalidateObject(EPPSession).- See Also:
-
-
Constructor Details
-
EPPSessionPool
protected EPPSessionPool()Default constructor as part of the Singleton Design Pattern.
-
-
Method Details
-
getInstance
Gets the Singleton Design Pattern instance. Ensure theinit()is called at least once.- Returns:
- Singleton instance of
EPPSessionPool.
-
init
public void init(EPPSessionPoolableFactory aFactory, org.apache.commons.pool2.impl.GenericObjectPoolConfig<EPPPooledSession> aConfig) Initialize the pool with a specificEPPSessionPoolableFactoryandGenericObjectPoolConfigsetting.- Parameters:
aFactory- EPP session poolable object factoryaConfig- Configuration attributes for pool
-
init
- Throws:
EPPSessionPoolException
-
close
public void close()Closes the session pool(s) contained inEPPSessionPoolcleanly. Cleanly closing the session pools means clearing the pools that will execute an EPP logout for each of the idle sessions and close the pool. -
borrowObject
Borrows a session from the pool. The session must be returned by either callinginvalidateObject(com.verisign.epp.interfaces.EPPSession)orreturnObject(com.verisign.epp.interfaces.EPPSession). This method will block if there are no idle sessions in the pool formaxWaittime.- Returns:
- Borrowed
EPPSessioninstance. - Throws:
EPPSessionPoolException- On error
-
borrowObject
Borrows a session from the pool. The session must be returned by either callinginvalidateObject(com.verisign.epp.interfaces.EPPSession)orreturnObject(com.verisign.epp.interfaces.EPPSession). This method will block if there are no idle sessions in the pool formaxWaittime.- Parameters:
aSystem- the system name- Returns:
- Borrowed
EPPSessioninstance. - Throws:
EPPSessionPoolException- On error
-
invalidateObject
Remove a borrowed session from the pool based on a known issue with it. The should be done if an unexpected exception occurs with the session which might be due to the server being down or the session being expired.- Parameters:
aSession- Session that is invalid- Throws:
EPPSessionPoolException- On error
-
invalidateObject
Remove a borrowed session from the system session pool based on a known issue with it. The should be done if an unexpected exception occurs with the session which might be due to the server being down or the session being expired.- Parameters:
aSystem- the system nameaSession- Session that is invalid- Throws:
EPPSessionPoolException- On error
-
returnObject
Returned a borrowed session to the pool. This session must have been returned from a call toborrowObject().- Parameters:
aSession- Session to return- Throws:
EPPSessionPoolException- On error
-
returnObject
Returned a borrowed session to a system session pool. This session must have been returned from a call toborrowObject(String).- Parameters:
aSystem- the system nameaSession- Session to return- Throws:
EPPSessionPoolException- On error
-
getGenericObjectPool
Gets the containedGenericObjectPool.- Returns:
- Contained
GenericObjectPoolif defined;nullotherwise.
-
hasSystemSessionPool
Does the system session pool exist?- Parameters:
aSystem- System session pool name to find- Returns:
trueif the system session pool exists;falseotherwise.
-
getSystemSessionPool
Gets the containedEPPSystemSessionPoolfor a system.- Parameters:
aSystem- System name for pool- Returns:
- Contained
EPPSystemSessionPool. - Throws:
EPPSessionPoolException- When system pool can not be found
-
getGenericObjectPool
public org.apache.commons.pool2.impl.GenericObjectPool<EPPPooledSession> getGenericObjectPool(String aSystem) throws EPPSessionPoolException Gets the containedGenericObjectPoolfor a system.- Parameters:
aSystem- System name for pool- Returns:
- Contained
GenericObjectPool. - Throws:
EPPSessionPoolException- When system pool can not be found
-
getAbsoluteTimeout
public long getAbsoluteTimeout()Gets the session absolute timeout.- Returns:
- Returns the absolute timeout in milliseconds.
-
getMinAbsoluteTimeout
public long getMinAbsoluteTimeout()Gets the minimum session absolute timeout in milliseconds. If bothminAbsoluteTimeoutandmaxAbsoluteTimemoutare set, they will override the setting ofabsoluteTimeout.- Returns:
- Minimum absolute timeout in milliseconds
-
getMaxAbsoluteTimeout
public long getMaxAbsoluteTimeout()Gets the maximum session absolute timeout in milliseconds. If bothminAbsoluteTimeoutandmaxAbsoluteTimemoutare set, they will override the setting ofabsoluteTimeout.- Returns:
- Maximum absolute timeout in milliseconds
-
isRandomAbsoluteTimeout
public boolean isRandomAbsoluteTimeout()Returns whether the absolute timeout will be randomized between theminAbsoluteTimeoutandmaxAbsoluteTimemout.- Returns:
trueif the absolute timeout will be randomized;falseotherwise.
-
getClientId
Gets the client identifier used to authenticate.- Returns:
- Returns the client identifier.
-
getConfig
Gets the configuration for theGenericObjectPool.- Returns:
- Returns the config.
-
getFactory
Gets the factory associated with the pool.- Returns:
- Returns the factory.
-
getIdleTimeout
public long getIdleTimeout()Gets the session idle timeout.- Returns:
- Returns the idle timeout in milliseconds.
-
getPassword
Gets the password used for authentication.- Returns:
- Returns the password.
-
getServerName
Gets the TCP server IP address or host name, or the URL of the HTTP server.- Returns:
- Server host name, IP address, or URL
-
setServerName
Sets the TCP server IP address or host name or the URL of the HTTP server.- Parameters:
aServerName- Server host name, IP address, or URL
-
getServerPort
Gets the TCP server port number. This will benullif connecting to a HTTP server.- Returns:
- TCP server port number if defined;
nullotherwise.
-
setServerPort
Sets the TCP server port number.- Parameters:
aServerPort- TCP server port number
-
getClientHost
Gets the TCP server IP address or host name to connect from. Anullvalue will use the loop back.- Returns:
- Client host name or IP address if defined;
nullotherwise.
-
setClientHost
Sets the TCP server IP address or host name to connect from. Anullvalue will use the loop back.- Parameters:
aClientHost- Client host name or IP address
-
isInitSessionOnMake
public boolean isInitSessionOnMake()Initialize the session via an EPP login on the call toPooledObjectFactory.makeObject()? The default value istrue. This also impacts executing end session via the EPP logout on the call toPooledObjectFactory.destroyObject(PooledObject).- Returns:
truethe session will be initialized via an EPP login on the call toPooledObjectFactory.makeObject();falseotherwise
-
setInitSessionOnMake
public void setInitSessionOnMake(boolean aInitSessionOnMake) Set whether to initialize the session via an EPP login on the call toPooledObjectFactory.makeObject(). The default value istrue. This also impacts executing end session via the EPP logout on the call toPooledObjectFactory.destroyObject(PooledObject).- Parameters:
aInitSessionOnMake-truethe session will be initialized via an EPP login on the call toPooledObjectFactory.makeObject();falseotherwise
-