Package jadex.common
Class ConstantPoolStrategy
java.lang.Object
jadex.common.ConstantPoolStrategy
- All Implemented Interfaces:
IPoolStrategy
Simple strategy with a constant number of workers.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreate a new ConstantPoolStrategy.ConstantPoolStrategy(int workercnt) Create a new ConstantPoolStrategy. -
Method Summary
Modifier and TypeMethodDescriptionintGet the number of free workers.intGet the worker cnt.longGet the component timeout.booleanCalled when a new task was added to the pool.booleanCalled when a task is finished.voidtaskServed(long waitdur) Called when a new task was served from the pool.voidworkersAdded(int cnt) Called when a new worker was added proactively to the pool.booleanNotify the strategy that a timeout for a component has occurred, i.e.
-
Field Details
-
workercnt
protected int workercntThe number of workers in the pool. -
capacity
protected int capacityThe number of free workers.
-
-
Constructor Details
-
ConstantPoolStrategy
public ConstantPoolStrategy()Create a new ConstantPoolStrategy. -
ConstantPoolStrategy
public ConstantPoolStrategy(int workercnt) Create a new ConstantPoolStrategy.
-
-
Method Details
-
taskAdded
public boolean taskAdded()Called when a new task was added to the pool.- Specified by:
taskAddedin interfaceIPoolStrategy- Returns:
- True, if a new worker should be added to the pool.
-
workersAdded
public void workersAdded(int cnt) Called when a new worker was added proactively to the pool.- Specified by:
workersAddedin interfaceIPoolStrategy- Parameters:
cnt- The number of new workers.
-
taskServed
public void taskServed(long waitdur) Called when a new task was served from the pool.- Specified by:
taskServedin interfaceIPoolStrategy- Parameters:
waitdur- The waiting time of the task.
-
taskFinished
public boolean taskFinished()Called when a task is finished.- Specified by:
taskFinishedin interfaceIPoolStrategy- Returns:
- True, if executing worker should be removed from the pool.
-
getWorkerTimeout
public long getWorkerTimeout()Get the component timeout.- Specified by:
getWorkerTimeoutin interfaceIPoolStrategy- Returns:
- The timeout for the component to wait for new workers in the pool.
-
workerTimeoutOccurred
public boolean workerTimeoutOccurred()Notify the strategy that a timeout for a component has occurred, i.e. it was not needed for serving some worker.- Specified by:
workerTimeoutOccurredin interfaceIPoolStrategy- Returns:
- True, if the component be excluded from the pool.
-
getWorkerCount
public int getWorkerCount()Get the worker cnt.- Specified by:
getWorkerCountin interfaceIPoolStrategy
-
getCapacity
public int getCapacity()Get the number of free workers.- Specified by:
getCapacityin interfaceIPoolStrategy
-