Package org.elasticsearch.discovery.zen
Class UnicastZenPing
- java.lang.Object
-
- org.elasticsearch.discovery.zen.UnicastZenPing
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,Releasable
,ZenPing
public class UnicastZenPing extends java.lang.Object implements ZenPing
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
UnicastZenPing.PingingRound
-
Nested classes/interfaces inherited from interface org.elasticsearch.discovery.zen.ZenPing
ZenPing.PingCollection, ZenPing.PingResponse
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
ACTION_NAME
static Setting<java.lang.Integer>
DISCOVERY_ZEN_PING_UNICAST_CONCURRENT_CONNECTS_SETTING
static Setting<TimeValue>
DISCOVERY_ZEN_PING_UNICAST_HOSTS_RESOLVE_TIMEOUT
protected EsThreadPoolExecutor
unicastZenPingExecutorService
-
Constructor Summary
Constructors Constructor Description UnicastZenPing(Settings settings, ThreadPool threadPool, TransportService transportService, UnicastHostsProvider unicastHostsProvider, PingContextProvider contextProvider)
-
Method Summary
Modifier and Type Method Description void
clearTemporalResponses()
Clears the list of cached ping responses.void
close()
protected void
finishPingingRound(UnicastZenPing.PingingRound pingingRound)
protected TransportResponseHandler<org.elasticsearch.discovery.zen.UnicastZenPing.UnicastPingResponse>
getPingResponseHandler(UnicastZenPing.PingingRound pingingRound, DiscoveryNode node)
protected Version
getVersion()
void
ping(java.util.function.Consumer<ZenPing.PingCollection> resultsConsumer, TimeValue duration)
Sends three rounds of pings notifying the specifiedConsumer
when pinging is complete.protected void
ping(java.util.function.Consumer<ZenPing.PingCollection> resultsConsumer, TimeValue scheduleDuration, TimeValue requestDuration)
a variant ofping(Consumer, TimeValue)
, but allows separating the scheduling duration from the duration used for request level time outs.static java.util.List<TransportAddress>
resolveHostsLists(java.util.concurrent.ExecutorService executorService, org.apache.logging.log4j.Logger logger, java.util.List<java.lang.String> hosts, int limitPortCounts, TransportService transportService, TimeValue resolveTimeout)
Resolves a list of hosts to a list of transport addresses.protected void
sendPings(TimeValue timeout, UnicastZenPing.PingingRound pingingRound)
void
start()
protected void
submitToExecutor(AbstractRunnable abstractRunnable)
-
-
-
Field Detail
-
ACTION_NAME
public static final java.lang.String ACTION_NAME
- See Also:
- Constant Field Values
-
DISCOVERY_ZEN_PING_UNICAST_CONCURRENT_CONNECTS_SETTING
public static final Setting<java.lang.Integer> DISCOVERY_ZEN_PING_UNICAST_CONCURRENT_CONNECTS_SETTING
-
DISCOVERY_ZEN_PING_UNICAST_HOSTS_RESOLVE_TIMEOUT
public static final Setting<TimeValue> DISCOVERY_ZEN_PING_UNICAST_HOSTS_RESOLVE_TIMEOUT
-
unicastZenPingExecutorService
protected final EsThreadPoolExecutor unicastZenPingExecutorService
-
-
Constructor Detail
-
UnicastZenPing
public UnicastZenPing(Settings settings, ThreadPool threadPool, TransportService transportService, UnicastHostsProvider unicastHostsProvider, PingContextProvider contextProvider)
-
-
Method Detail
-
resolveHostsLists
public static java.util.List<TransportAddress> resolveHostsLists(java.util.concurrent.ExecutorService executorService, org.apache.logging.log4j.Logger logger, java.util.List<java.lang.String> hosts, int limitPortCounts, TransportService transportService, TimeValue resolveTimeout)
Resolves a list of hosts to a list of transport addresses. Each host is resolved into a transport address (or a collection of addresses if the number of ports is greater than one). Host lookups are done in parallel using specified executor service up to the specified resolve timeout.- Parameters:
executorService
- the executor service used to parallelize hostname lookupslogger
- logger used for logging messages regarding hostname lookupshosts
- the hosts to resolvelimitPortCounts
- the number of ports to resolve (should be 1 for non-local transport)transportService
- the transport serviceresolveTimeout
- the timeout before returning from hostname lookups- Returns:
- a list of resolved transport addresses
-
close
public void close()
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Specified by:
close
in interfaceReleasable
-
clearTemporalResponses
public void clearTemporalResponses()
Clears the list of cached ping responses.
-
ping
public void ping(java.util.function.Consumer<ZenPing.PingCollection> resultsConsumer, TimeValue duration)
Sends three rounds of pings notifying the specifiedConsumer
when pinging is complete. Pings are sent after resolving configured unicast hosts to their IP address (subject to DNS caching within the JVM). A batch of pings is sent, then another batch of pings is sent at half the specifiedTimeValue
, and then another batch of pings is sent at the specifiedTimeValue
. The pings that are sent carry a timeout of 1.25 times the specifiedTimeValue
. When pinging each node, a connection and handshake is performed, with a connection timeout of the specifiedTimeValue
.
-
ping
protected void ping(java.util.function.Consumer<ZenPing.PingCollection> resultsConsumer, TimeValue scheduleDuration, TimeValue requestDuration)
a variant ofping(Consumer, TimeValue)
, but allows separating the scheduling duration from the duration used for request level time outs. This is useful for testing
-
finishPingingRound
protected void finishPingingRound(UnicastZenPing.PingingRound pingingRound)
-
sendPings
protected void sendPings(TimeValue timeout, UnicastZenPing.PingingRound pingingRound)
-
submitToExecutor
protected void submitToExecutor(AbstractRunnable abstractRunnable)
-
getPingResponseHandler
protected TransportResponseHandler<org.elasticsearch.discovery.zen.UnicastZenPing.UnicastPingResponse> getPingResponseHandler(UnicastZenPing.PingingRound pingingRound, DiscoveryNode node)
-
getVersion
protected Version getVersion()
-
-