Class RWLockDataStructure
- java.lang.Object
-
- com.sun.enterprise.resource.pool.datastructure.RWLockDataStructure
-
- All Implemented Interfaces:
DataStructure
public class RWLockDataStructure extends Object implements DataStructure
ReadWriteLock based datastructure for pool- Author:
- Jagadish Ramu
-
-
Field Summary
Fields Modifier and Type Field Description protected static Logger_logger-
Fields inherited from interface com.sun.enterprise.resource.pool.datastructure.DataStructure
DS_TYPE_CIRCULAR_LIST, DS_TYPE_DEFAULT, DS_TYPE_PARTITIONED
-
-
Constructor Summary
Constructors Constructor Description RWLockDataStructure(int maxSize, ResourceHandler handler)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intaddResource(ResourceAllocator allocator, int count)creates a new resource and adds to the datastructure.ArrayList<ResourceHandle>getAllResources()Get all resources in the datastructure Note : do not use this for normal usages as it can potentially represent all resources (including the ones in use).intgetFreeListSize()get the count of free resources in the datastructureResourceHandlegetResource()get a resource from the datastructureintgetResourcesSize()get total number of resources in the datastructurevoidremoveAll()remove & destroy all resources from the datastructure.voidremoveResource(ResourceHandle resource)remove the specified resource from the datastructurevoidreturnResource(ResourceHandle resource)returns the resource to the datastructurevoidsetMaxSize(int maxSize)Set maxSize based on the new max pool size set on the connection pool during a reconfiguration.
-
-
-
Field Detail
-
_logger
protected static final Logger _logger
-
-
Constructor Detail
-
RWLockDataStructure
public RWLockDataStructure(int maxSize, ResourceHandler handler)
-
-
Method Detail
-
addResource
public int addResource(ResourceAllocator allocator, int count) throws PoolingException
creates a new resource and adds to the datastructure.- Specified by:
addResourcein interfaceDataStructure- Parameters:
allocator- ResourceAllocatorcount- Number (units) of resources to create- Returns:
- int number of resources added.
- Throws:
PoolingException- when unable to create a resource
-
getResource
public ResourceHandle getResource()
get a resource from the datastructure- Specified by:
getResourcein interfaceDataStructure- Returns:
- ResourceHandle
-
removeResource
public void removeResource(ResourceHandle resource)
remove the specified resource from the datastructure- Specified by:
removeResourcein interfaceDataStructure- Parameters:
resource- ResourceHandle
-
returnResource
public void returnResource(ResourceHandle resource)
returns the resource to the datastructure- Specified by:
returnResourcein interfaceDataStructure- Parameters:
resource- ResourceHandle
-
getFreeListSize
public int getFreeListSize()
get the count of free resources in the datastructure- Specified by:
getFreeListSizein interfaceDataStructure- Returns:
- int count
-
removeAll
public void removeAll()
remove & destroy all resources from the datastructure.- Specified by:
removeAllin interfaceDataStructure
-
getResourcesSize
public int getResourcesSize()
get total number of resources in the datastructure- Specified by:
getResourcesSizein interfaceDataStructure- Returns:
- int count
-
setMaxSize
public void setMaxSize(int maxSize)
Set maxSize based on the new max pool size set on the connection pool during a reconfiguration.- Specified by:
setMaxSizein interfaceDataStructure- Parameters:
maxSize-
-
getAllResources
public ArrayList<ResourceHandle> getAllResources()
Description copied from interface:DataStructureGet all resources in the datastructure Note : do not use this for normal usages as it can potentially represent all resources (including the ones in use). This is used under special circumstances where there is a need to process all resources.- Specified by:
getAllResourcesin interfaceDataStructure- Returns:
- ArrayList
-
-