Class ConstantGlobalPoolStrategy
- java.lang.Object
-
- jadex.platform.service.globalservicepool.ConstantGlobalPoolStrategy
-
- All Implemented Interfaces:
IGlobalPoolStrategy
public class ConstantGlobalPoolStrategy extends java.lang.Object implements IGlobalPoolStrategy
Simple strategy that demands a constant number of workers from the pool.
-
-
Field Summary
Fields Modifier and Type Field Description protected int
maxcnt
The max number of workers.protected long
timeout
The worker timeout.protected java.util.Set<IComponentIdentifier>
workers
The worker platforms.protected int
wpp
The worker per proxy count.
-
Constructor Summary
Constructors Constructor Description ConstantGlobalPoolStrategy()
Create a new constant strategy.ConstantGlobalPoolStrategy(long timeout, int maxcnt, int wpp)
Create a new constant strategy.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getDesiredWorkerCount()
Get the desired worker cnt.int
getWorkerCount()
Get the worker cnt.int
getWorkersPerProxy()
Get the number of workers that should be used by each proxy.long
getWorkerTimeout()
Get the component timeout.boolean
isCreateWorkerOn(IComponentIdentifier cid)
Ask strategy if a new worker should be added on a platform.void
workersAdded(IComponentIdentifier... workers)
Called when a new worker was added proactively to the pool.void
workersRemoved(IComponentIdentifier... workers)
Called when workers have been removed.boolean
workerTimeoutOccurred(IComponentIdentifier worker)
Notify the strategy that a timeout for a worker component has occurred, i.e.
-
-
-
Field Detail
-
workers
protected java.util.Set<IComponentIdentifier> workers
The worker platforms.
-
timeout
protected long timeout
The worker timeout.
-
maxcnt
protected int maxcnt
The max number of workers.
-
wpp
protected int wpp
The worker per proxy count.
-
-
Method Detail
-
workersAdded
public void workersAdded(IComponentIdentifier... workers)
Called when a new worker was added proactively to the pool.- Specified by:
workersAdded
in interfaceIGlobalPoolStrategy
- Parameters:
cnt
- The number of new workers.
-
workersRemoved
public void workersRemoved(IComponentIdentifier... workers)
Called when workers have been removed.- Specified by:
workersRemoved
in interfaceIGlobalPoolStrategy
- Parameters:
workers
- The workers.
-
workerTimeoutOccurred
public boolean workerTimeoutOccurred(IComponentIdentifier worker)
Notify the strategy that a timeout for a worker component has occurred, i.e. it was not needed for serving some worker.- Specified by:
workerTimeoutOccurred
in interfaceIGlobalPoolStrategy
- Returns:
- True, if the component be excluded from the pool.
-
getWorkerTimeout
public long getWorkerTimeout()
Get the component timeout.- Specified by:
getWorkerTimeout
in interfaceIGlobalPoolStrategy
- Returns:
- The timeout for the component to wait for new workers in the pool.
-
getWorkerCount
public int getWorkerCount()
Get the worker cnt.- Specified by:
getWorkerCount
in interfaceIGlobalPoolStrategy
-
getDesiredWorkerCount
public int getDesiredWorkerCount()
Get the desired worker cnt.- Specified by:
getDesiredWorkerCount
in interfaceIGlobalPoolStrategy
-
isCreateWorkerOn
public boolean isCreateWorkerOn(IComponentIdentifier cid)
Ask strategy if a new worker should be added on a platform.- Specified by:
isCreateWorkerOn
in interfaceIGlobalPoolStrategy
- Parameters:
cid
- The platform.- Returns:
- True, if worker should be created.
-
getWorkersPerProxy
public int getWorkersPerProxy()
Get the number of workers that should be used by each proxy.- Specified by:
getWorkersPerProxy
in interfaceIGlobalPoolStrategy
- Returns:
- The number of workers used by each proxy.
-
-