Class ListDataStructure
- java.lang.Object
-
- com.sun.enterprise.resource.pool.datastructure.ListDataStructure
-
- All Implemented Interfaces:
DataStructure
public class ListDataStructure extends Object implements DataStructure
List based datastructure that can be used by connection pool- Author:
- Jagadish Ramu
-
-
Field Summary
-
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 ListDataStructure(String parameters, int maxSize, ResourceHandler handler, String strategyClass)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
addResource(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).int
getFreeListSize()
get the count of free resources in the datastructureResourceHandle
getResource()
get a resource from the datastructureint
getResourcesSize()
get total number of resources in the datastructurevoid
removeAll()
remove & destroy all resources from the datastructure.void
removeResource(ResourceHandle resource)
remove the specified resource from the datastructurevoid
returnResource(ResourceHandle resource)
returns the resource to the datastructurevoid
setMaxSize(int newMaxSize)
Set maxSize based on the new max pool size set on the connection pool during a reconfiguration.
-
-
-
Constructor Detail
-
ListDataStructure
public ListDataStructure(String parameters, int maxSize, ResourceHandler handler, String strategyClass)
-
-
Method Detail
-
setMaxSize
public void setMaxSize(int newMaxSize)
Set maxSize based on the new max pool size set on the connection pool during a reconfiguration. 1. When permits contained within the dynamic semaphore are greater than 0, maxSize is increased and hence so many permits are released. 2. When permits contained within the dynamic semaphore are less than 0, maxSize has reduced to a smaller value. Hence so many permits are reduced from the semaphore's available limit for the subsequent resource requests to act based on the new configuration.- Specified by:
setMaxSize
in interfaceDataStructure
- Parameters:
newMaxSize
-
-
addResource
public int addResource(ResourceAllocator allocator, int count) throws PoolingException
creates a new resource and adds to the datastructure.- Specified by:
addResource
in 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:
getResource
in interfaceDataStructure
- Returns:
- ResourceHandle
-
removeResource
public void removeResource(ResourceHandle resource)
remove the specified resource from the datastructure- Specified by:
removeResource
in interfaceDataStructure
- Parameters:
resource
- ResourceHandle
-
returnResource
public void returnResource(ResourceHandle resource)
returns the resource to the datastructure- Specified by:
returnResource
in interfaceDataStructure
- Parameters:
resource
- ResourceHandle
-
getFreeListSize
public int getFreeListSize()
get the count of free resources in the datastructure- Specified by:
getFreeListSize
in interfaceDataStructure
- Returns:
- int count
-
removeAll
public void removeAll()
remove & destroy all resources from the datastructure.- Specified by:
removeAll
in interfaceDataStructure
-
getResourcesSize
public int getResourcesSize()
get total number of resources in the datastructure- Specified by:
getResourcesSize
in interfaceDataStructure
- Returns:
- int count
-
getAllResources
public 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). This is used under special circumstances where there is a need to process all resources.- Specified by:
getAllResources
in interfaceDataStructure
- Returns:
- ArrayList
-
-