Package jadex.commons
Class DefaultPoolStrategy
- java.lang.Object
- 
- jadex.commons.DefaultPoolStrategy
 
- 
- All Implemented Interfaces:
- IPoolStrategy
 
 public class DefaultPoolStrategy extends java.lang.Object implements IPoolStrategy This strategy has two parameters: - The desired number of free workers in the pool. - The maximum timeout for workers to wait for new tasks.
- 
- 
Field SummaryFields Modifier and Type Field Description protected intcapacityThe number of free workers.protected intdeferdecThe defer factor to slow down thread deletion.protected intdeferdectargetprotected intdeferincThe defer factor to slow down thread creation.protected intdeferinctargetprotected intdesfreeThe desired number of free workers.protected booleandodeferdecDefer the deletion of threads according to their distance from desfree.protected booleandodeferincDefer the creation of threads according to their distance from desfree.protected intmaxcntThe maximum number of allowed workers.protected longmaxwaitThe max wait time for workers.protected java.util.List<java.lang.Double>waitingsThe waiting times of the pool.protected intworkercntThe number of workers in the pool.
 - 
Constructor SummaryConstructors Constructor Description DefaultPoolStrategy()Create a new default pool strategy.DefaultPoolStrategy(int desfree, int maxcnt)Create a new default pool strategy.DefaultPoolStrategy(int workercnt, int desfree, long maxwait, int maxcnt)Create a new default pool strategy.DefaultPoolStrategy(int workercnt, int desfree, long maxwait, int maxcnt, boolean defer)Create a new default pool strategy.DefaultPoolStrategy(int workercnt, int desfree, long maxwait, int maxcnt, boolean deferinc, boolean deferdec)Create a new default pool strategy.DefaultPoolStrategy(int desfree, long maxwait, int maxcnt)Create a new default pool strategy.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description intgetCapacity()Get the capacity.intgetDesiredFree()Get the desfree.intgetMaxCount()Get the max cnt.longgetMaxWait()Get the maxwait.intgetWorkerCount()Get the worker cnt.longgetWorkerTimeout()Get the worker timeout.voidsetCapacity(int capacity)Set the capacity.voidsetDesiredFree(int desfree)Set the desfree.voidsetMaxCount(int maxcnt)Set the max cnt.voidsetMaxWait(long maxwait)Set the maxwait.voidsetWorkerCount(int workercnt)Set the worker cnt.booleantaskAdded()Called when a new task was added to the pool.booleantaskFinished()Called when a task is finished.voidtaskServed(long waitdur)Called when a new task was served from the pool.java.lang.StringtoString()Get the string representation.voidworkersAdded(int cnt)Called when a new worker was added proactively to the pool.booleanworkerTimeoutOccurred()Notify the strategy that a timeout for a worker has occurred, i.e.
 
- 
- 
- 
Field Detail- 
workercntprotected int workercnt The number of workers in the pool.
 - 
capacityprotected int capacity The number of free workers.
 - 
desfreeprotected int desfree The desired number of free workers.
 - 
maxwaitprotected long maxwait The max wait time for workers.
 - 
maxcntprotected int maxcnt The maximum number of allowed workers.
 - 
dodeferincprotected boolean dodeferinc Defer the creation of threads according to their distance from desfree.
 - 
dodeferdecprotected boolean dodeferdec Defer the deletion of threads according to their distance from desfree.
 - 
deferincprotected int deferinc The defer factor to slow down thread creation.
 - 
deferinctargetprotected int deferinctarget 
 - 
deferdecprotected int deferdec The defer factor to slow down thread deletion.
 - 
deferdectargetprotected int deferdectarget 
 - 
waitingsprotected java.util.List<java.lang.Double> waitings The waiting times of the pool.
 
- 
 - 
Constructor Detail- 
DefaultPoolStrategypublic DefaultPoolStrategy() Create a new default pool strategy.
 - 
DefaultPoolStrategypublic DefaultPoolStrategy(int desfree, int maxcnt)Create a new default pool strategy.
 - 
DefaultPoolStrategypublic DefaultPoolStrategy(int desfree, long maxwait, int maxcnt)Create a new default pool strategy.
 - 
DefaultPoolStrategypublic DefaultPoolStrategy(int workercnt, int desfree, long maxwait, int maxcnt)Create a new default pool strategy.
 - 
DefaultPoolStrategypublic DefaultPoolStrategy(int workercnt, int desfree, long maxwait, int maxcnt, boolean defer)Create a new default pool strategy.
 - 
DefaultPoolStrategypublic DefaultPoolStrategy(int workercnt, int desfree, long maxwait, int maxcnt, boolean deferinc, boolean deferdec)Create a new default pool strategy.
 
- 
 - 
Method Detail- 
taskAddedpublic boolean taskAdded() Called when a new task was added to the pool.- Specified by:
- taskAddedin interface- IPoolStrategy
- Returns:
- True, if a new worker should be added to the pool.
 
 - 
workersAddedpublic void workersAdded(int cnt) Called when a new worker was added proactively to the pool.- Specified by:
- workersAddedin interface- IPoolStrategy
- Parameters:
- cnt- The number of new workers.
 
 - 
taskServedpublic void taskServed(long waitdur) Called when a new task was served from the pool.- Specified by:
- taskServedin interface- IPoolStrategy
- Parameters:
- waitdur- The waiting time of the task.
 
 - 
taskFinishedpublic boolean taskFinished() Called when a task is finished.- Specified by:
- taskFinishedin interface- IPoolStrategy
- Returns:
- True, if executing worker be excluded from the pool.
 
 - 
getWorkerTimeoutpublic long getWorkerTimeout() Get the worker timeout.- Specified by:
- getWorkerTimeoutin interface- IPoolStrategy
- Returns:
- The timeout for the worker to wait for new tasks in the pool.
 
 - 
workerTimeoutOccurredpublic boolean workerTimeoutOccurred() Notify the strategy that a timeout for a worker has occurred, i.e. it was not needed for serving some task.- Specified by:
- workerTimeoutOccurredin interface- IPoolStrategy
- Returns:
- True, if the worker be excluded from the pool.
 
 - 
getWorkerCountpublic int getWorkerCount() Get the worker cnt.- Specified by:
- getWorkerCountin interface- IPoolStrategy
 
 - 
setWorkerCountpublic void setWorkerCount(int workercnt) Set the worker cnt.- Parameters:
- workercnt- The workercnt to set.
 
 - 
getCapacitypublic int getCapacity() Get the capacity.- Specified by:
- getCapacityin interface- IPoolStrategy
- Returns:
- The capacity.
 
 - 
setCapacitypublic void setCapacity(int capacity) Set the capacity.- Parameters:
- capacity- The capacity to set.
 
 - 
getDesiredFreepublic int getDesiredFree() Get the desfree.- Returns:
- The desfree.
 
 - 
setDesiredFreepublic void setDesiredFree(int desfree) Set the desfree.- Parameters:
- desfree- The desfree to set.
 
 - 
getMaxWaitpublic long getMaxWait() Get the maxwait.- Returns:
- The maxwait.
 
 - 
setMaxWaitpublic void setMaxWait(long maxwait) Set the maxwait.- Parameters:
- maxwait- The maxwait to set.
 
 - 
getMaxCountpublic int getMaxCount() Get the max cnt.- Returns:
- The max cnt.
 
 - 
setMaxCountpublic void setMaxCount(int maxcnt) Set the max cnt.- Parameters:
- maxservicecnt- The max cnt to set.
 
 - 
toStringpublic java.lang.String toString() Get the string representation.- Overrides:
- toStringin class- java.lang.Object
 
 
- 
 
-