public class CpuUsageStrategyFactory extends ArrayBasedStrategyFactory
Modifier and Type | Field and Description |
---|---|
protected int |
lowCpuUsage
lowCpuUsage ~= zero CPU usage
|
protected int |
sampleCount
This strategy compares number of 'sampleCount' random node.
|
protected Transporter |
transporter |
preferLocal
broker, logger, name
Constructor and Description |
---|
CpuUsageStrategyFactory()
Constructor that calls for service based primarily on its own (CPU-based)
logic.
|
CpuUsageStrategyFactory(boolean preferLocal)
Constructor that can be configured to use local services if possible.
|
CpuUsageStrategyFactory(boolean preferLocal,
int sampleCount,
int lowCpuUsage) |
Modifier and Type | Method and Description |
---|---|
<T extends Endpoint> |
create() |
int |
getLowCpuUsage() |
int |
getSampleCount() |
void |
setLowCpuUsage(int lowCpuUsage) |
void |
setSampleCount(int sampleCount) |
void |
started(ServiceBroker broker)
Initializes strategy instance.
|
isPreferLocal, setPreferLocal
getBroker, getLogger, getName, stopped
protected int sampleCount
protected int lowCpuUsage
protected Transporter transporter
public CpuUsageStrategyFactory()
public CpuUsageStrategyFactory(boolean preferLocal)
preferLocal
- invoke local actions if possiblepublic CpuUsageStrategyFactory(boolean preferLocal, int sampleCount, int lowCpuUsage)
public void started(ServiceBroker broker) throws java.lang.Exception
started
in interface MoleculerLifecycle
started
in class MoleculerComponent
broker
- parent ServiceBrokerjava.lang.Exception
public <T extends Endpoint> Strategy<T> create()
create
in class StrategyFactory
public int getSampleCount()
public void setSampleCount(int sampleCount)
public int getLowCpuUsage()
public void setLowCpuUsage(int lowCpuUsage)