IBM WebSphere Multichannel Bank Transformation Toolkit Javadoc

com.ibm.btt.services
Class GenericPool

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

@ATTR(value={"className#String#IMPLIED","serviceName#String#IMPLIED","maxPoolSize#String#IMPLIED","initialSize#String#IMPLIED","timeBetweenRetries#String#IMPLIED","cleanupTime#String#IMPLIED"})
public class GenericPool
extends Service
implements java.lang.Runnable

The GenericPool is a pool that manages objects that implement the Poolable interface. The pool has an initial size externalized in the service definition. The pool size grows if more instances of Poolable objects 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 elements in the pool.

See Also:
Serialized Form

Field Summary
 java.lang.String className
           
(package private)  int cleanupTime
          Time between resizing processes
static java.lang.String COMPID
           
(package private)  int indexOfLastSession
          Index of the last element that was 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
 java.util.Vector pool
          The pool
(package private)  java.lang.Object poolSem
          Object used for synchronization purposes
(package private)  int requestsCount
          Counter of current concurrent requests
(package private)  Semaphore sem
          Internal semaphore used to notify that a service has been released
 java.lang.String serviceName
          The service name
(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
GenericPool()
          Default GenericPool constructor
GenericPool(java.lang.String aName)
          This constructor creates a GenericPool object.
 
Method Summary
 Poolable createPoolable()
          Returns a new instance of the Poolable element that is managed in the pool.
protected  void freeAll()
          Marks every pool element as not in use.
 java.lang.String getClassName()
          Returns the class name of the Poolable object to place in the pool.
 Poolable getPoolable()
          Returns the first element in the pool that is not in use.
 Poolable getPoolable(boolean newChance)
          Returns the first free element available in the pool.
 java.lang.String getServiceName()
          Returns the service name.
 int getSize()
          Returns the current pool's size.
 void initialize()
          Initializes some values, fills the pool, and creates a Thread for the resizing process if necessary.
 java.lang.Object initializeFrom(Tag aTag)
          Initializes the Service reading its attributes values from aTag.
 void initInstance()
          Initializes the thread responsible for resizing the pool.
 void insertPoolable(Poolable poolable)
          Inserts a new Poolable object in the pool.
 boolean isThreadIsAlive()
          Returns the status of the thread responsible for resizing the pool.
 void releasePoolable(Poolable poolable)
          Releases a Poolable object.
protected  void removeAll()
          Removes all the Poolable objects from the pool.
 void removePoolable(Poolable poolable)
          Removes a Poolable object from the pool.
 void run()
          Runs the pool thread.
 void setClassName(java.lang.String name)
          Sets the className attribute to the string provided as an argument.
 void setServiceName(java.lang.String name)
          Sets the serviceName attribute to the string provided as an argument.
 void setSize(int i)
          Sets the size attribute to the int provided as an argument.
 void terminate()
          Frees and closes all the objects from the pool.
 java.lang.String toString()
          Converts this GenericPoolService to 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

className

public java.lang.String className

serviceName

public java.lang.String serviceName
The service name


pool

public java.util.Vector pool
The pool


COMPID

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

indexOfLastSession

int indexOfLastSession
Index of the last element that was assigned


size

int size
Current pool size


initialSize

int initialSize
Initial pool size


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 current concurrent requests


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

GenericPool

public GenericPool()
Default GenericPool constructor


GenericPool

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

Parameters:
aName - The generic pool service name
Throws:
java.io.IOException
Method Detail

createPoolable

public Poolable createPoolable()
                        throws DSEInvalidArgumentException
Returns a new instance of the Poolable element that is managed in the pool.

Returns:
com.ibm.dse.cs.mq.Poolable - The new instance
Throws:
com.ibm.dse.base.DSEInvalidArgumentException
DSEInvalidArgumentException

freeAll

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


getClassName

public java.lang.String getClassName()
Returns the class name of the Poolable object to place in the pool.

Returns:
java.lang.String - The class name

getPoolable

public Poolable getPoolable()
Returns the first element in the pool that is not in use. The returned element is marked as in use to prevent it from being used by another client. If there are no free elements, this method creates a new instance if the pool size is lower than the maximum pool size.

Returns:
com.ibm.dse.cs.mq.Poolable - The element that is not in use

getPoolable

public Poolable getPoolable(boolean newChance)
Returns the first free element available in the pool. The returned element is marked as in use to prevent it from being used by another client. If there are no free elements, this method creates a new instance if the pool size is lower that the maximum pool size. The newChance parameter determines if the request is a retry (false) or if it is the first time (true) an element is requested.

Parameters:
newChance - boolean Set to false if the current request is a retry
Returns:
com.ibm.dse.cs.mq.Pooleable - The element that is not in use

getServiceName

public java.lang.String getServiceName()
Returns the service name.

Returns:
java.lang.String - The service name

getSize

public int getSize()
Returns the current pool's size.

Returns:
int - The size

initialize

public void initialize()
                throws DSEException
Initializes some values, fills the pool, and creates a Thread for the resizing process if necessary.

Throws:
com.ibm.dse.base.DSEException
DSEException

initializeFrom

public java.lang.Object initializeFrom(Tag aTag)
                                throws java.io.IOException,
                                       DSEException
Initializes the Service reading its attributes values from aTag.

Overrides:
initializeFrom in class Service
Parameters:
aTag - com.ibm.dse.base.Tag
Returns:
java.lang.Object - The GenericPool Object
Throws:
java.io.IOException
DSEException

initInstance

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

Throws:
com.ibm.dse.base.DSEException
DSEException

insertPoolable

public void insertPoolable(Poolable poolable)
Inserts a new Poolable object in the pool.

Parameters:
Poolable - The object to be added to the pool

isThreadIsAlive

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

Returns:
boolean - The status of the thread

releasePoolable

public void releasePoolable(Poolable poolable)
Releases a Poolable object. The released object is returned to the pool and signaled as available (not in use).

Parameters:
Poolable - - The object to be released

removeAll

protected void removeAll()
Removes all the Poolable objects from the pool.


removePoolable

public void removePoolable(Poolable poolable)
Removes a Poolable object from the pool.

Parameters:
Poolable - The object to be removed

run

public void run()
Runs the pool thread.

Specified by:
run in interface java.lang.Runnable

setClassName

public void setClassName(java.lang.String name)
Sets the className attribute to the string provided as an argument.

Parameters:
name - The new className

setServiceName

public void setServiceName(java.lang.String name)
Sets the serviceName attribute to the string provided as an argument.

Parameters:
name - The new service name

setSize

public void setSize(int i)
Sets the size attribute to the int provided as an argument.

Parameters:
i - The size of the pool

terminate

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

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

toString

public java.lang.String toString()
Converts this GenericPoolService to string.

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

IBM WebSphere Multichannel Bank Transformation Toolkit Javadoc

(c) Copyright IBM Corporation 1998, 2010