public class NetworkLatencyStrategyFactory extends ArrayBasedStrategyFactory
| Modifier and Type | Class and Description |
|---|---|
protected static class |
NetworkLatencyStrategyFactory.Samples |
| Modifier and Type | Field and Description |
|---|---|
protected int |
collectCount
Number of samples used for average calculation.
|
protected java.lang.String |
nodeID |
protected int |
pingInterval
Ping period time, in SECONDS.
|
protected long |
pingTimeout
Ping timeout time, in MILLISECONDS.
|
protected java.util.concurrent.ScheduledFuture<?> |
pingTimer
Cancelable timer of ping loop
|
protected java.lang.String |
previousNodeID |
protected java.util.concurrent.ConcurrentHashMap<java.lang.String,NetworkLatencyStrategyFactory.Samples> |
responseTimes |
protected int |
sampleCount
This strategy compares number of 'sampleCount' random node.
|
protected java.util.concurrent.ScheduledExecutorService |
scheduler |
protected Transporter |
transporter |
preferLocalbroker, logger, name| Constructor and Description |
|---|
NetworkLatencyStrategyFactory() |
NetworkLatencyStrategyFactory(boolean preferLocal) |
| Modifier and Type | Method and Description |
|---|---|
<T extends Endpoint> |
create() |
protected long |
getAverageResponseTime(java.lang.String nextNodeID) |
int |
getCollectCount() |
int |
getPingInterval() |
long |
getPingTimeout() |
int |
getSampleCount() |
protected void |
sendNextPing() |
protected void |
sendPing(java.lang.String nextNodeID) |
void |
setCollectCount(int collectCount) |
void |
setPingInterval(int pingInterval) |
void |
setPingTimeout(long pingTimeout) |
void |
setSampleCount(int sampleCount) |
void |
started(ServiceBroker broker)
Initializes strategy instance.
|
void |
stopped() |
isPreferLocal, setPreferLocalgetBroker, getLogger, getNameprotected int sampleCount
protected int pingInterval
protected long pingTimeout
protected int collectCount
protected java.util.concurrent.ScheduledExecutorService scheduler
protected Transporter transporter
protected java.lang.String nodeID
protected final java.util.concurrent.ConcurrentHashMap<java.lang.String,NetworkLatencyStrategyFactory.Samples> responseTimes
protected volatile java.util.concurrent.ScheduledFuture<?> pingTimer
protected volatile java.lang.String previousNodeID
public NetworkLatencyStrategyFactory()
public NetworkLatencyStrategyFactory(boolean preferLocal)
public void started(ServiceBroker broker) throws java.lang.Exception
started in class MoleculerComponentbroker - parent ServiceBrokerjava.lang.Exceptionpublic void stopped()
stopped in class MoleculerComponentprotected void sendNextPing()
protected void sendPing(java.lang.String nextNodeID)
protected long getAverageResponseTime(java.lang.String nextNodeID)
public <T extends Endpoint> Strategy<T> create()
create in class StrategyFactorypublic int getSampleCount()
public void setSampleCount(int sampleCount)
public int getPingInterval()
public void setPingInterval(int pingInterval)
public long getPingTimeout()
public void setPingTimeout(long pingTimeout)
public int getCollectCount()
public void setCollectCount(int collectCount)