IBM WebSphere Multichannel Bank Transformation Toolkit Javadoc

com.ibm.btt.services.comms
Class CommunicationsPool

java.lang.Object
  extended by com.ibm.btt.base.DSENotifier
      extended by com.ibm.btt.base.Service
          extended by com.ibm.btt.services.comms.CommunicationsPool
All Implemented Interfaces:
Notifier, CommunicationsPoolService, java.io.Externalizable, java.io.Serializable, java.lang.Runnable

@ATTR(value={"size#String#IMPLIED","spare#String#IMPLIED","maxPoolSize#String#IMPLIED","timeBetweenRetries#String#IMPLIED","cleanupTime#String#IMPLIED","identicalElements#String#REQUIRED"})
public class CommunicationsPool
extends Service
implements CommunicationsPoolService, java.lang.Runnable

The CommunicationsPool is a pool that manages communications services that implement the CommonCommunicationsService interface. The pool has an initial size externalized in the service definition. The pool size grows if more instances of communications services are required and the current size is lower than the maximum size. The maximum size is also externalized. The pool size shrinks if the maximum number of concurrent request for communications services during a period of time is lower than the current number of services in the pool.

See Also:
Serialized Form

Field Summary
(package private)  int cleanupTime
          Time between resizing processes
static java.lang.String COMPID
           
(package private)  boolean identicalElements
          Indicates if the elements on the pool are identical
(package private)  int indexOfLastSession
          Index of the last service assigned
(package private)  int initialSize
          Initial pool size
(package private)  int maxConcurrents
          Maximum number of concurrent request from the last resizing process
(package private)  int maxPoolSize
          Maximum pool size
(package private)  long nameIndex
          nameIndex
(package private)  java.util.Vector pool
          The communications pool
(package private)  java.lang.Object poolSem
          Object used for synchronization purposes
(package private)  int requestsCount
          Counter of concurrent request
(package private)  Semaphore sem
          Internal semaphore used to notify that a service has been released
(package private)  int size
          Current pool size
(package private)  int spare
          Additional percentage of the pool size to be added during the resizing process
(package private)  long timeBetweenRetries
          Time to wait for a retry when no free service is available
 
Fields inherited from class com.ibm.btt.base.Service
externalizer, name
 
Fields inherited from class com.ibm.btt.base.DSENotifier
handlersList
 
Constructor Summary
CommunicationsPool()
          This constructor creates a CommunicationsPool object.
CommunicationsPool(java.lang.String aName)
          This constructor creates a CommunicationsPool object.
 
Method Summary
 boolean areAllServicesOffline()
          Checks if at least one service in the pool is in session.
 void closeAll()
          Closes all pool instances.
protected  void freeAll()
          Marks every pool element as not used.
 int getCleanupTime()
          Returns the cleanupTime attribute.
 boolean getIdenticalElements()
          Returns the identicalElements attribute.
 int getMaxPoolSize()
          Returns the maxPoolSize attribute.
 CommonCommunicationsService getPoolService()
          Returns the first free service in the pool or null if no free services are available.
 int getRequestsCount()
          returns a count of the number of pool elements that are in use.
protected  CommonCommunicationsService getSessionWithName(java.lang.String name)
          Returns a communications service from the pool.
 int getSize()
          Returns the size attribute.
 int getSpare()
          Returns the spare attribute.
 Tag getTag()
          Returns the tag attribute.
 long getTimeBetweenRetries()
          Returns the timeBetweenRetries attribute.
 java.lang.Object initializeFrom(Tag aTag)
          Initializes a CommunicationsPool with the Tag attributes.
 void initInstance()
          Initializes the thread responsible for resizing the pool.
 void insertService(CommonCommunicationsService aService)
          Inserts a new communications service in the pool.
 boolean isThreadIsAlive()
          Returns the status of the thread responsible for resizing the pool.
 void openAll()
          Opens all the communications services in the pool by sending ccOpen() to all the services in the pool.
 void releaseAndRemovePoolService(CommonCommunicationsService aService)
          Release a communication service and then remove it from communication pool.
 void releasePoolService(CommonCommunicationsService aService)
          Releases a communications service.
protected  void removeAll()
          Removes all the communications services from the pool.
 void removeService(CommonCommunicationsService aService)
          Removes a communications service from the pool.
 void run()
          Runs the pool thread.
 void setCleanupTime(int aTime)
          Sets cleanupTime attribute value.
 void setIdenticalElements(boolean aBoolean)
          Sets identicalElements attribute value.
 void setMaxPoolSize(int aMaxPoolSize)
          Sets maxPoolSize attribute value.
 void setSize(int aSize)
          Sets size attribute value.
 void setSpare(int aSpare)
          Sets spare attribute value.
 void setTag(Tag aTag)
          Sets tag attribute value.
 void setTimeBetweenRetries(int aTime)
          Sets timeBetweenRetries attribute value.
 void terminate()
          Frees and closes all the services from the pool.
 java.lang.String toString()
          Converts this CommonCommunicationsService to a String.
 
Methods inherited from class com.ibm.btt.base.Service
externalizer, getExternalizer, getTagName, readExternal, readExternal, readObject, removeExternal, setExternalizer, toStrings, toTags, writeExternal, writeExternal
 
Methods inherited from class com.ibm.btt.base.DSENotifier
addHandler, getHandlersList, getName, removeHandler, setName, signalEvent, signalEvent, signalEvent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.ibm.btt.base.Externalizable
getName, setName
 

Field Detail

COMPID

public static final java.lang.String COMPID
See Also:
Constant Field Values

indexOfLastSession

int indexOfLastSession
Index of the last service assigned


size

int size
Current pool size


nameIndex

long nameIndex
nameIndex


initialSize

int initialSize
Initial pool size


identicalElements

boolean identicalElements
Indicates if the elements on the pool are identical


pool

java.util.Vector pool
The communications pool


poolSem

java.lang.Object poolSem
Object used for synchronization purposes


maxPoolSize

int maxPoolSize
Maximum pool size


timeBetweenRetries

long timeBetweenRetries
Time to wait for a retry when no free service is available


cleanupTime

int cleanupTime
Time between resizing processes


requestsCount

int requestsCount
Counter of concurrent request


maxConcurrents

int maxConcurrents
Maximum number of concurrent request from the last resizing process


spare

int spare
Additional percentage of the pool size to be added during the resizing process


sem

Semaphore sem
Internal semaphore used to notify that a service has been released

Constructor Detail

CommunicationsPool

public CommunicationsPool()
This constructor creates a CommunicationsPool object.


CommunicationsPool

public CommunicationsPool(java.lang.String aName)
                   throws java.io.IOException
This constructor creates a CommunicationsPool object.

Parameters:
aName - java.lang.String - Communications pool service name.
Throws:
java.io.IOException.
java.io.IOException
Method Detail

areAllServicesOffline

public boolean areAllServicesOffline()
Checks if at least one service in the pool is in session. Returns:

Specified by:
areAllServicesOffline in interface CommunicationsPoolService
Returns:
boolean

closeAll

public void closeAll()
Closes all pool instances. Executes ccClose() on each pool element.

Specified by:
closeAll in interface CommunicationsPoolService

freeAll

protected void freeAll()
Marks every pool element as not used.


getPoolService

public CommonCommunicationsService getPoolService()
Returns the first free service in the pool or null if no free services are available. See getPoolService(boolean)

Specified by:
getPoolService in interface CommunicationsPoolService
Returns:
com.ibm.btt.services.comms.CommonCommunicationsService

getSessionWithName

protected CommonCommunicationsService getSessionWithName(java.lang.String name)
Returns a communications service from the pool.

Parameters:
name - String - The name of the service to be returned
Returns:
com.ibm.btt.services.comms.CommonCommunicationsService

initializeFrom

public java.lang.Object initializeFrom(Tag aTag)
                                throws java.io.IOException,
                                       DSEInvalidArgumentException,
                                       DSEException
Initializes a CommunicationsPool with the Tag attributes.

Overrides:
initializeFrom in class Service
Parameters:
aTag - Tag, the Tag
Returns:
CommunicationsPool - the initialized CommunicationsPool
Throws:
java.io.IOException
DSEInvalidArgumentException
DSEException

initInstance

public void initInstance()
                  throws DSEException
Initializes the thread responsible for resizing the pool.

Throws:
DSEException

insertService

public void insertService(CommonCommunicationsService aService)
Inserts a new communications service in the pool.

Specified by:
insertService in interface CommunicationsPoolService
Parameters:
aService - com.ibm.btt.services.comms.CommonCommunicationsService - The service to be added to the pool

isThreadIsAlive

public boolean isThreadIsAlive()
Returns the status of the thread responsible for resizing the pool.

Returns:
boolean

openAll

public void openAll()
Opens all the communications services in the pool by sending ccOpen() to all the services in the pool.

Specified by:
openAll in interface CommunicationsPoolService

releasePoolService

public void releasePoolService(CommonCommunicationsService aService)
Releases a communications service. This method returns the released communications service to the pool and signals that it is available.

Specified by:
releasePoolService in interface CommunicationsPoolService
Parameters:
aService - com.ibm.btt.services.comms.CommonCommunicationsService - The service to be released

removeAll

protected void removeAll()
Removes all the communications services from the pool.


releaseAndRemovePoolService

public void releaseAndRemovePoolService(CommonCommunicationsService aService)
Release a communication service and then remove it from communication pool. This method should only be used for the service that is corrupt.

Parameters:
aService -

removeService

public void removeService(CommonCommunicationsService aService)
Removes a communications service from the pool. If the communications service does not exist, no action is taken.

Specified by:
removeService in interface CommunicationsPoolService
Parameters:
aService - com.ibm.btt.services.comms.CommonCommunicationsService - The service to be removed

run

public void run()
Runs the pool thread.

Specified by:
run in interface java.lang.Runnable

terminate

public void terminate()
Frees and closes all the services from the pool.

Specified by:
terminate in interface Notifier
Specified by:
terminate in interface CommunicationsPoolService
Overrides:
terminate in class Service

toString

public java.lang.String toString()
Converts this CommonCommunicationsService to a String.

Overrides:
toString in class Service
Returns:
java.lang.String

getCleanupTime

public int getCleanupTime()
Returns the cleanupTime attribute.

Specified by:
getCleanupTime in interface CommunicationsPoolService

getIdenticalElements

public boolean getIdenticalElements()
Returns the identicalElements attribute.

Specified by:
getIdenticalElements in interface CommunicationsPoolService

getMaxPoolSize

public int getMaxPoolSize()
Returns the maxPoolSize attribute.

Specified by:
getMaxPoolSize in interface CommunicationsPoolService

getSize

public int getSize()
Returns the size attribute.

Specified by:
getSize in interface CommunicationsPoolService

getSpare

public int getSpare()
Returns the spare attribute.

Specified by:
getSpare in interface CommunicationsPoolService

getTag

public Tag getTag()
Returns the tag attribute.

Specified by:
getTag in interface CommunicationsPoolService

getTimeBetweenRetries

public long getTimeBetweenRetries()
Returns the timeBetweenRetries attribute.

Specified by:
getTimeBetweenRetries in interface CommunicationsPoolService

setCleanupTime

public void setCleanupTime(int aTime)
Sets cleanupTime attribute value.

Specified by:
setCleanupTime in interface CommunicationsPoolService

setIdenticalElements

public void setIdenticalElements(boolean aBoolean)
Sets identicalElements attribute value.

Specified by:
setIdenticalElements in interface CommunicationsPoolService

setMaxPoolSize

public void setMaxPoolSize(int aMaxPoolSize)
Sets maxPoolSize attribute value.

Specified by:
setMaxPoolSize in interface CommunicationsPoolService

setSize

public void setSize(int aSize)
Sets size attribute value.

Specified by:
setSize in interface CommunicationsPoolService

setSpare

public void setSpare(int aSpare)
Sets spare attribute value.

Specified by:
setSpare in interface CommunicationsPoolService

setTag

public void setTag(Tag aTag)
Sets tag attribute value.

Specified by:
setTag in interface CommunicationsPoolService

setTimeBetweenRetries

public void setTimeBetweenRetries(int aTime)
Sets timeBetweenRetries attribute value.

Specified by:
setTimeBetweenRetries in interface CommunicationsPoolService

getRequestsCount

public int getRequestsCount()
returns a count of the number of pool elements that are in use. Added for APAR JR18668


IBM WebSphere Multichannel Bank Transformation Toolkit Javadoc

(c) Copyright IBM Corporation 1998, 2010