Poolable |
createPoolable()
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 java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
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
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
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 ProcessorNotifier - 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
(c) Copyright IBM Corporation 1998, 2009
|