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 intmaxcntThe max number of workers.protected longtimeoutThe worker timeout.protected java.util.Set<IComponentIdentifier>workersThe worker platforms.protected intwppThe 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 intgetDesiredWorkerCount()Get the desired worker cnt.intgetWorkerCount()Get the worker cnt.intgetWorkersPerProxy()Get the number of workers that should be used by each proxy.longgetWorkerTimeout()Get the component timeout.booleanisCreateWorkerOn(IComponentIdentifier cid)Ask strategy if a new worker should be added on a platform.voidworkersAdded(IComponentIdentifier... workers)Called when a new worker was added proactively to the pool.voidworkersRemoved(IComponentIdentifier... workers)Called when workers have been removed.booleanworkerTimeoutOccurred(IComponentIdentifier worker)Notify the strategy that a timeout for a worker component has occurred, i.e. it was not needed for serving some worker.
-
-
-
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:
workersAddedin interfaceIGlobalPoolStrategy- Parameters:
cnt- The number of new workers.
-
workersRemoved
public void workersRemoved(IComponentIdentifier... workers)
Called when workers have been removed.- Specified by:
workersRemovedin 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:
workerTimeoutOccurredin interfaceIGlobalPoolStrategy- Returns:
- True, if the component be excluded from the pool.
-
getWorkerTimeout
public long getWorkerTimeout()
Get the component timeout.- Specified by:
getWorkerTimeoutin 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:
getWorkerCountin interfaceIGlobalPoolStrategy
-
getDesiredWorkerCount
public int getDesiredWorkerCount()
Get the desired worker cnt.- Specified by:
getDesiredWorkerCountin interfaceIGlobalPoolStrategy
-
isCreateWorkerOn
public boolean isCreateWorkerOn(IComponentIdentifier cid)
Ask strategy if a new worker should be added on a platform.- Specified by:
isCreateWorkerOnin 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:
getWorkersPerProxyin interfaceIGlobalPoolStrategy- Returns:
- The number of workers used by each proxy.
-
-