Interface DataStructure
-
- All Known Implementing Classes:
ListDataStructure
,RWLockDataStructure
public interface DataStructure
Represents a pool datastructure. Helps to plug-in various implementations that the pool can use.
Datastructure need to synchronize the operations.- Author:
- Jagadish Ramu
-
-
Field Summary
Fields Modifier and Type Field Description static String
DS_TYPE_CIRCULAR_LIST
static String
DS_TYPE_DEFAULT
static String
DS_TYPE_PARTITIONED
-
Method Summary
All Methods Instance Methods Abstract 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 maxSize)
Set maxSize based on the new max pool size set on the connection pool during a reconfiguration.
-
-
-
Field Detail
-
DS_TYPE_DEFAULT
static final String DS_TYPE_DEFAULT
- See Also:
- Constant Field Values
-
DS_TYPE_CIRCULAR_LIST
static final String DS_TYPE_CIRCULAR_LIST
- See Also:
- Constant Field Values
-
DS_TYPE_PARTITIONED
static final String DS_TYPE_PARTITIONED
- See Also:
- Constant Field Values
-
-
Method Detail
-
setMaxSize
void setMaxSize(int maxSize)
Set maxSize based on the new max pool size set on the connection pool during a reconfiguration.- Parameters:
maxSize
-
-
addResource
int addResource(ResourceAllocator allocator, int count) throws PoolingException
creates a new resource and adds to the datastructure.- Parameters:
allocator
- ResourceAllocatorcount
- Number (units) of resources to create- Returns:
- int number of resources added.
- Throws:
PoolingException
- when unable to create a resource
-
getResource
ResourceHandle getResource()
get a resource from the datastructure- Returns:
- ResourceHandle
-
removeResource
void removeResource(ResourceHandle resource)
remove the specified resource from the datastructure- Parameters:
resource
- ResourceHandle
-
returnResource
void returnResource(ResourceHandle resource)
returns the resource to the datastructure- Parameters:
resource
- ResourceHandle
-
getFreeListSize
int getFreeListSize()
get the count of free resources in the datastructure- Returns:
- int count
-
removeAll
void removeAll()
remove & destroy all resources from the datastructure.
-
getResourcesSize
int getResourcesSize()
get total number of resources in the datastructure- Returns:
- int count
-
getAllResources
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.- Returns:
- ArrayList
-
-