@IgniteSpiMultipleInstancesSupport(value=true) @DiscoverySpiOrderSupport(value=true) @DiscoverySpiHistorySupport(value=true) @DiscoverySpiMutableCustomMessageSupport(value=true) public class TcpDiscoverySpi extends IgniteSpiAdapter implements org.apache.ignite.internal.managers.discovery.IgniteDiscoverySpi
Nodes are organized in ring. So almost all network exchange (except few cases) is done across it.
If node is configured as client node (see IgniteConfiguration.clientMode
)
TcpDiscoverySpi starts in client mode as well. In this case node does not take its place in the ring,
but it connects to random node in the ring (IP taken from IP finder configured) and
use it as a router for discovery traffic.
Therefore slow client node or its shutdown will not affect whole cluster. If TcpDiscoverySpi
needs to be started in server mode regardless of IgniteConfiguration.clientMode
,
forceSrvMode
should be set to true.
At startup SPI tries to send messages to random IP taken from
TcpDiscoveryIpFinder
about self start (stops when send succeeds)
and then this info goes to coordinator. When coordinator processes join request
and issues node added messages and all other nodes then receive info about new node.
IgniteConfiguration.getFailureDetectionTimeout()
) for details) are chosen to make possible for discovery
SPI work reliably on most of hardware and virtual deployments, but this has made failure detection time worse.
If it's needed to tune failure detection then it's highly recommended to do this using
IgniteConfiguration.setFailureDetectionTimeout(long)
. This failure timeout automatically controls the
following parameters: getSocketTimeout()
, getAckTimeout()
, getMaxAckTimeout()
,
getReconnectCount()
. If any of those parameters is set explicitly, then the failure timeout setting will be
ignored. As an example, for stable low-latency networks the failure detection timeout may be set to ~120 ms.
If it's required to perform advanced settings of failure detection and
IgniteConfiguration.getFailureDetectionTimeout()
is unsuitable then various TcpDiscoverySpi
configuration parameters may be used. As an example, for stable low-latency networks the following more aggressive
settings are recommended (which allows failure detection time ~200ms):
setSocketTimeout(long)
) - 200mssetAckTimeout(long)
) - 50mssetIpFinder(TcpDiscoveryIpFinder)
).
See the following IP finder implementations for details on configuration:
setLocalAddress(String)
)setLocalPort(int)
)setLocalPortRange(int)
)setReconnectCount(int)
)setNetworkTimeout(long)
)setSocketTimeout(long)
)setAckTimeout(long)
)setMaxAckTimeout(long)
)setJoinTimeout(long)
)setThreadPriority(int)
)setIpFinderCleanFrequency(long)
)setStatisticsPrintFrequency(long)
setForceServerMode(boolean)
TcpDiscoverySpi spi = new TcpDiscoverySpi(); TcpDiscoveryVmIpFinder finder = new GridTcpDiscoveryVmIpFinder(); spi.setIpFinder(finder); IgniteConfiguration cfg = new IgniteConfiguration(); // Override default discovery SPI. cfg.setDiscoverySpi(spi); // Start grid. Ignition.start(cfg);
<bean id="grid.custom.cfg" class="org.apache.ignite.configuration.IgniteConfiguration" singleton="true"> ... <property name="discoverySpi"> <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi"> <property name="ipFinder"> <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder" /> </property> </bean> </property> ... </bean>
For information about Spring framework visit www.springframework.org
DiscoverySpi
Modifier and Type | Field and Description |
---|---|
static String |
ATTR_EXT_ADDRS
Node attribute that is mapped to node's external addresses (value is disc.tcp.ext-addrs).
|
protected UUID |
cfgNodeId |
protected long |
connRecoveryTimeout
Default connection recovery timeout in ms.
|
static long |
DFLT_ACK_TIMEOUT
Default timeout for receiving message acknowledgement in milliseconds (value is 5000ms).
|
static long |
DFLT_ACK_TIMEOUT_CLIENT
Default timeout for receiving message acknowledgement in milliseconds (value is 5000ms).
|
static long |
DFLT_CONNECTION_RECOVERY_TIMEOUT
Default connection recovery timeout in ms.
|
static int |
DFLT_DISCO_FAILED_CLIENT_RECONNECT_DELAY |
static int |
DFLT_DISCOVERY_CLIENT_RECONNECT_HISTORY_SIZE |
static int |
DFLT_DISCOVERY_METRICS_QNT_WARN |
static String |
DFLT_IP_ADDR
Default IP address to seek other nodes at.
|
static long |
DFLT_IP_FINDER_CLEAN_FREQ
Default IP finder clean frequency in milliseconds (value is 60,000ms).
|
static long |
DFLT_JOIN_TIMEOUT
Default timeout for joining topology (value is 0).
|
static long |
DFLT_MAX_ACK_TIMEOUT
Maximum ack timeout value for receiving message acknowledgement in milliseconds (value is 600,000ms).
|
static long |
DFLT_NETWORK_TIMEOUT
Default network timeout in milliseconds (value is 5000ms).
|
static int |
DFLT_NODE_IDS_HISTORY_SIZE |
static int |
DFLT_PORT
Default port to listen (value is 47500).
|
static int |
DFLT_PORT_RANGE
Default local port range (value is 100).
|
static int |
DFLT_RECONNECT_CNT
Default reconnect attempts count (value is 10).
|
static long |
DFLT_RECONNECT_DELAY
Default delay between attempts to connect to the cluster in milliseconds (value is 2000).
|
static int |
DFLT_SO_LINGER
Default SO_LINGER to set for socket, 0 means enabled with 0 timeout.
|
static long |
DFLT_SOCK_TIMEOUT
Default socket operations timeout in milliseconds (value is 5000ms).
|
static long |
DFLT_SOCK_TIMEOUT_CLIENT
Default socket operations timeout in milliseconds (value is 5000ms).
|
static long |
DFLT_STATS_PRINT_FREQ
Default statistics print frequency in milliseconds (value is 0ms).
|
static int |
DFLT_THREAD_PRI
Default value for thread priority (value is 10).
|
static int |
DFLT_THROTTLE_RECONNECT_RESET_TIMEOUT_INTERVAL |
static int |
DFLT_TOP_HISTORY_SIZE
Default size of topology snapshots history.
|
static String |
DISCO_METRICS
Name of the discovery metrics registry.
|
protected DiscoverySpiDataExchange |
exchange
Data exchange.
|
protected long |
gridStartTime
Start time of the very first grid node.
|
protected org.apache.ignite.spi.discovery.tcp.TcpDiscoveryImpl |
impl |
protected CopyOnWriteArrayList<IgniteInClosure<Socket>> |
incomeConnLsnrs |
protected TcpDiscoveryIpFinder |
ipFinder
IP finder.
|
protected long |
ipFinderCleanFreq
The frequency with which coordinator cleans IP finder and keeps it in the correct state, which means that
coordinator unregisters addresses of the nodes that have left the topology and re-registries missing addresses.
|
protected long |
joinTimeout
Join timeout, in milliseconds.
|
protected String |
locAddr
Local address.
|
protected InetAddress |
locHost
Local host.
|
protected org.apache.ignite.spi.discovery.tcp.internal.TcpDiscoveryNode |
locNode
Local node.
|
protected Collection<InetSocketAddress> |
locNodeAddrs
Internal and external addresses of local node.
|
protected Map<String,Object> |
locNodeAttrs
Local node attributes.
|
protected IgniteProductVersion |
locNodeVer
Local node version.
|
protected int |
locPort
Local port which node uses.
|
protected int |
locPortRange
Local port range.
|
protected IgniteLogger |
log
Logger.
|
protected DiscoverySpiListener |
lsnr
Grid discovery listener.
|
protected DiscoveryMetricsProvider |
metricsProvider
Metrics provider.
|
protected long |
metricsUpdateFreq
Metrics update messages issuing frequency.
|
protected long |
netTimeout
Network timeout.
|
protected DiscoverySpiNodeAuthenticator |
nodeAuth
Node authenticator.
|
protected CopyOnWriteArrayList<IgniteInClosure<org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryAbstractMessage>> |
sndMsgLsnrs |
protected IgniteSpiContext |
spiCtx |
protected boolean |
sslEnable
SSL enable/disable flag.
|
protected SSLSocketFactory |
sslSockFactory
SSL socket factory.
|
protected SSLServerSocketFactory |
sslSrvSockFactory
SSL server socket factory.
|
protected org.apache.ignite.spi.discovery.tcp.internal.TcpDiscoveryStatistics |
stats
Statistics.
|
protected long |
statsPrintFreq
Statistics print frequency.
|
protected int |
threadPri
Thread priority for all threads started by SPI.
|
protected int |
topHistSize
Size of topology snapshots history.
|
ignite, igniteInstanceName
Constructor and Description |
---|
TcpDiscoverySpi() |
Modifier and Type | Method and Description |
---|---|
void |
addIncomeConnectionListener(IgniteInClosure<Socket> lsnr)
FOR TEST ONLY!!!
|
void |
addSendMessageListener(IgniteInClosure<org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryAbstractMessage> lsnr)
FOR TEST ONLY!!!
|
boolean |
allNodesSupport(org.apache.ignite.internal.IgniteFeatures feature) |
boolean |
allNodesSupport(org.apache.ignite.internal.IgniteFeatures feature,
IgnitePredicate<ClusterNode> nodesPred) |
protected IgniteSpiException |
authenticationFailedError(org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryAuthFailedMessage msg) |
void |
brakeConnection()
FOR TEST PURPOSE ONLY!
|
protected IgniteSpiException |
checkFailedError(org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryCheckFailedMessage msg) |
void |
clientReconnect() |
boolean |
clientReconnectSupported() |
int |
clientWorkerCount()
FOR TEST ONLY!!!
|
@Nullable Serializable |
consistentId()
Gets consistent ID.
|
void |
disconnect()
Tells discovery SPI to disconnect from topology.
|
void |
dumpDebugInfo()
Dumps debug info using configured logger.
|
protected IgniteSpiException |
duplicateIdError(org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryDuplicateIdMessage msg) |
protected boolean |
ensured(org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryAbstractMessage msg) |
void |
failNode(UUID nodeId,
@Nullable String warning)
Initiates failure of provided node.
|
long |
getAckTimeout()
Gets message acknowledgement timeout.
|
AddressResolver |
getAddressResolver()
Gets address resolver.
|
long |
getAvgMessageProcessingTime()
Gets avg message processing time.
|
long |
getConnectionRecoveryTimeout()
Gets timeout that defines how long server node would try to recovery connection.
|
UUID |
getCoordinator()
Gets current coordinator.
|
long |
getCoordinatorSinceTimestamp()
Gets time local node has been coordinator since.
|
long |
getEffectiveSocketTimeout(boolean srvrOperation)
Gets effective or resulting socket timeout with considering failure detection timeout
|
long |
getGridStartTime()
Gets start time of the very first node in the grid.
|
TcpDiscoveryIpFinder |
getIpFinder()
Gets IP finder for IP addresses sharing and storing.
|
long |
getIpFinderCleanFrequency()
Gets frequency with which coordinator cleans IP finder and keeps it in the correct state, unregistering addresses of
the nodes that have left the topology.
|
String |
getIpFinderFormatted()
Gets
TcpDiscoveryIpFinder (string representation). |
long |
getJoinTimeout()
Get join timeout, in milliseconds.
|
String |
getLocalAddress()
Gets local address that was set to SPI with
setLocalAddress(String) method. |
ClusterNode |
getLocalNode()
Gets local node.
|
UUID |
getLocalNodeId()
Gets ID of the local node.
|
int |
getLocalPort()
Gets local TCP port SPI listens to.
|
int |
getLocalPortRange()
Gets local TCP port range.
|
long |
getMaxAckTimeout()
Gets maximum message acknowledgement timeout.
|
long |
getMaxMessageProcessingTime()
Gets max message processing time.
|
int |
getMessageWorkerQueueSize()
Gets message worker queue current size.
|
long |
getNetworkTimeout()
Gets network timeout.
|
@Nullable ClusterNode |
getNode(UUID nodeId)
Gets node by ID.
|
ClusterNode |
getNode0(UUID id) |
long |
getNodesFailed()
Gets failed nodes count.
|
long |
getNodesJoined()
Gets joined nodes count.
|
long |
getNodesLeft()
Gets left nodes count.
|
long |
getPendingMessagesDiscarded()
Gets pending messages discarded count.
|
long |
getPendingMessagesRegistered()
Gets pending messages registered count.
|
Map<String,Integer> |
getProcessedMessages()
Gets processed messages counts (grouped by type).
|
Map<String,Integer> |
getReceivedMessages()
Gets received messages counts (grouped by type).
|
int |
getReconnectCount()
Gets number of connection attempts.
|
long |
getReconnectDelay()
Gets the amount of time in milliseconds that node waits before retrying to (re)connect to the cluster.
|
Collection<ClusterNode> |
getRemoteNodes()
Gets collection of remote nodes in grid or empty collection if no remote nodes found.
|
long |
getSocketTimeout()
Gets socket timeout.
|
int |
getSoLinger()
Gets SO_LINGER timeout for socket.
|
IgniteSpiContext |
getSpiContext()
Gets SPI context.
|
String |
getSpiState()
Gets current SPI state.
|
long |
getStatisticsPrintFrequency()
Gets statistics print frequency.
|
int |
getThreadPriority()
Gets thread priority.
|
long |
getTopHistorySize() |
int |
getTotalProcessedMessages()
Gets total processed messages count.
|
int |
getTotalReceivedMessages()
Gets total received messages count.
|
protected void |
initLocalNode(int srvPort,
boolean addExtAddrAttr) |
Collection<Object> |
injectables()
This method returns SPI internal instances that need to be injected as well.
|
protected void |
injectResources(Ignite ignite)
Inject resources
|
boolean |
isClientMode()
Whether or not discovery is started in client mode.
|
boolean |
isClientReconnectDisabled()
If
true client does not try to reconnect after
server detected client node failure. |
boolean |
isForceServerMode()
Deprecated.
Will be removed at 3.0.
|
boolean |
isLocalNodeCoordinator()
Checks whether local node is coordinator.
|
boolean |
knownNode(UUID nodeId) |
protected Marshaller |
marshaller() |
protected void |
onContextDestroyed0()
Method to be called in the beginning of onContextDestroyed() method.
|
protected void |
onContextInitialized0(IgniteSpiContext spiCtx)
Method to be called in the end of onContextInitialized method.
|
protected void |
onExchange(org.apache.ignite.spi.discovery.tcp.internal.DiscoveryDataPacket dataPacket,
ClassLoader clsLdr) |
protected Socket |
openSocket(InetSocketAddress sockAddr,
IgniteSpiOperationTimeoutHelper timeoutHelper) |
protected Socket |
openSocket(Socket sock,
InetSocketAddress remAddr,
IgniteSpiOperationTimeoutHelper timeoutHelper)
Connects to remote address sending
U.IGNITE_HEADER when connection is established. |
boolean |
pingNode(UUID nodeId)
Pings the remote node to see if it's alive.
|
protected <T> T |
readMessage(Socket sock,
@Nullable InputStream in,
long timeout)
Reads message from the socket limiting read time.
|
protected int |
readReceipt(Socket sock,
long timeout)
Reads message delivery receipt from the socket.
|
protected Collection<InetSocketAddress> |
registeredAddresses()
Gets addresses registered in the IP finder, initializes addresses having no
port (or 0 port) with
DFLT_PORT . |
void |
removeIncomeConnectionListener(IgniteInClosure<Socket> lsnr)
FOR TEST ONLY!!!
|
void |
removeSendMessageListener(IgniteInClosure<org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryAbstractMessage> lsnr)
FOR TEST ONLY!!!
|
void |
resolveCommunicationFailure(ClusterNode node,
Exception err) |
protected Collection<InetSocketAddress> |
resolvedAddresses()
Resolves addresses registered in the IP finder, removes duplicates and local host
address and returns the collection of.
|
void |
sendCustomEvent(DiscoverySpiCustomMessage msg)
Sends custom message across the ring.
|
TcpDiscoverySpi |
setAckTimeout(long ackTimeout)
Sets timeout for receiving acknowledgement for sent message.
|
void |
setAddressResolver(AddressResolver addrRslvr)
Sets address resolver.
|
void |
setAuthenticator(DiscoverySpiNodeAuthenticator auth)
Sets discovery SPI node authenticator.
|
void |
setClientReconnectDisabled(boolean clientReconnectDisabled)
Sets client reconnect disabled flag.
|
void |
setConnectionRecoveryTimeout(long connRecoveryTimeout)
Sets timeout that defines how long server node would try to recovery connection.
|
void |
setDataExchange(DiscoverySpiDataExchange exchange)
Sets a handler for initial data exchange between Ignite nodes.
|
TcpDiscoverySpi |
setForceServerMode(boolean forceSrvMode)
Deprecated.
Will be removed at 3.0.
|
void |
setGridStartTime(long val)
Sets grid start time.
|
void |
setInternalListener(org.apache.ignite.internal.managers.discovery.IgniteDiscoverySpiInternalListener lsnr)
For TESTING only.
|
TcpDiscoverySpi |
setIpFinder(TcpDiscoveryIpFinder ipFinder)
Sets IP finder for IP addresses sharing and storing.
|
TcpDiscoverySpi |
setIpFinderCleanFrequency(long ipFinderCleanFreq)
Sets IP finder clean frequency in milliseconds.
|
TcpDiscoverySpi |
setJoinTimeout(long joinTimeout)
Sets join timeout.
|
void |
setListener(@Nullable DiscoverySpiListener lsnr)
Sets a listener for discovery events.
|
TcpDiscoverySpi |
setLocalAddress(String locAddr)
Sets local host IP address that discovery SPI uses.
|
TcpDiscoverySpi |
setLocalPort(int locPort)
Sets local port to listen to.
|
TcpDiscoverySpi |
setLocalPortRange(int locPortRange)
Range for local ports.
|
TcpDiscoverySpi |
setMaxAckTimeout(long maxAckTimeout)
Sets maximum timeout for receiving acknowledgement for sent message.
|
void |
setMetricsProvider(DiscoveryMetricsProvider metricsProvider)
Sets discovery metrics provider.
|
TcpDiscoverySpi |
setName(String name)
Sets SPI name.
|
TcpDiscoverySpi |
setNetworkTimeout(long netTimeout)
Sets maximum network timeout to use for network operations.
|
void |
setNodeAttributes(Map<String,Object> attrs,
IgniteProductVersion ver)
Sets node attributes and node version which will be distributed in grid during
join process.
|
TcpDiscoverySpi |
setReconnectCount(int reconCnt)
Number of times node tries to (re)establish connection to another node.
|
TcpDiscoverySpi |
setReconnectDelay(int reconDelay)
Sets the amount of time in milliseconds that node waits before retrying to (re)connect to the cluster.
|
TcpDiscoverySpi |
setSocketTimeout(long sockTimeout)
Sets socket operations timeout.
|
void |
setSoLinger(int soLinger)
Sets SO_LINGER to use for all created sockets.
|
TcpDiscoverySpi |
setStatisticsPrintFrequency(long statsPrintFreq)
Sets statistics print frequency.
|
TcpDiscoverySpi |
setThreadPriority(int threadPri)
Sets thread priority.
|
TcpDiscoverySpi |
setTopHistorySize(int topHistSize)
Sets size of topology snapshots history.
|
void |
simulateNodeFailure()
FOR TEST ONLY!!!
|
void |
spiStart(@Nullable String igniteInstanceName)
This method is called to start SPI.
|
void |
spiStop()
This method is called to stop SPI.
|
protected void |
startMessageProcess(org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryAbstractMessage msg) |
boolean |
supportsCommunicationFailureResolve() |
String |
toString() |
void |
waitForClientMessagePrecessed()
FOR TEST PURPOSE ONLY!
|
protected void |
writeToSocket(ClusterNode node,
Socket sock,
OutputStream out,
org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryAbstractMessage msg,
long timeout) |
protected void |
writeToSocket(Socket sock,
OutputStream out,
org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryAbstractMessage msg,
long timeout)
Writes message to the socket.
|
protected void |
writeToSocket(Socket sock,
org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryAbstractMessage msg,
byte[] data,
long timeout)
Writes message to the socket.
|
protected void |
writeToSocket(Socket sock,
org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryAbstractMessage msg,
long timeout)
Writes message to the socket.
|
protected void |
writeToSocket(org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryAbstractMessage msg,
Socket sock,
int res,
long timeout)
Writes response to the socket.
|
addTimeoutObject, assertParameter, checkConfigurationConsistency0, clientFailureDetectionTimeout, configInfo, createSpiAttributeName, failureDetectionTimeout, failureDetectionTimeoutEnabled, failureDetectionTimeoutEnabled, getConsistentAttributeNames, getExceptionRegistry, getName, getNodeAttributes, ignite, initFailureDetectionTimeout, isNodeStopping, onBeforeStart, onClientDisconnected, onClientReconnected, onContextDestroyed, onContextInitialized, registerMBean, removeTimeoutObject, started, startInfo, startStopwatch, stopInfo, unregisterMBean
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getName, getNodeAttributes, onClientDisconnected, onClientReconnected, onContextDestroyed, onContextInitialized
public static final String ATTR_EXT_ADDRS
public static final int DFLT_PORT_RANGE
public static final int DFLT_PORT
public static final String DFLT_IP_ADDR
public static final long DFLT_JOIN_TIMEOUT
public static final long DFLT_NETWORK_TIMEOUT
public static final int DFLT_THREAD_PRI
public static final int DFLT_TOP_HISTORY_SIZE
public static final long DFLT_SOCK_TIMEOUT
public static final long DFLT_ACK_TIMEOUT
public static final long DFLT_SOCK_TIMEOUT_CLIENT
public static final long DFLT_ACK_TIMEOUT_CLIENT
public static final int DFLT_RECONNECT_CNT
public static final long DFLT_RECONNECT_DELAY
public static final long DFLT_IP_FINDER_CLEAN_FREQ
public static final long DFLT_STATS_PRINT_FREQ
public static final long DFLT_MAX_ACK_TIMEOUT
public static final int DFLT_SO_LINGER
public static final long DFLT_CONNECTION_RECOVERY_TIMEOUT
public static final int DFLT_DISCOVERY_CLIENT_RECONNECT_HISTORY_SIZE
IgniteSystemProperties#IGNITE_DISCOVERY_CLIENT_RECONNECT_HISTORY_SIZE
,
Constant Field Valuespublic static final int DFLT_NODE_IDS_HISTORY_SIZE
IgniteSystemProperties#IGNITE_NODE_IDS_HISTORY_SIZE
,
Constant Field Valuespublic static final int DFLT_DISCO_FAILED_CLIENT_RECONNECT_DELAY
IgniteSystemProperties#IGNITE_DISCO_FAILED_CLIENT_RECONNECT_DELAY
,
Constant Field Valuespublic static final int DFLT_THROTTLE_RECONNECT_RESET_TIMEOUT_INTERVAL
IgniteSystemProperties#CLIENT_THROTTLE_RECONNECT_RESET_TIMEOUT_INTERVAL
,
Constant Field Valuespublic static final int DFLT_DISCOVERY_METRICS_QNT_WARN
IgniteSystemProperties#IGNITE_DISCOVERY_METRICS_QNT_WARN
,
Constant Field Valuespublic static final String DISCO_METRICS
protected String locAddr
protected TcpDiscoveryIpFinder ipFinder
protected long netTimeout
protected long joinTimeout
protected int threadPri
protected long metricsUpdateFreq
protected int topHistSize
protected long connRecoveryTimeout
protected volatile DiscoverySpiListener lsnr
protected DiscoverySpiDataExchange exchange
protected DiscoveryMetricsProvider metricsProvider
protected IgniteProductVersion locNodeVer
protected org.apache.ignite.spi.discovery.tcp.internal.TcpDiscoveryNode locNode
protected UUID cfgNodeId
protected InetAddress locHost
protected Collection<InetSocketAddress> locNodeAddrs
protected volatile long gridStartTime
protected final org.apache.ignite.spi.discovery.tcp.internal.TcpDiscoveryStatistics stats
protected int locPort
protected int locPortRange
protected long statsPrintFreq
protected long ipFinderCleanFreq
ServerImpl.IpFinderCleaner
protected DiscoverySpiNodeAuthenticator nodeAuth
protected SSLServerSocketFactory sslSrvSockFactory
protected SSLSocketFactory sslSockFactory
protected boolean sslEnable
protected final CopyOnWriteArrayList<IgniteInClosure<org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryAbstractMessage>> sndMsgLsnrs
protected final CopyOnWriteArrayList<IgniteInClosure<Socket>> incomeConnLsnrs
@LoggerResource protected IgniteLogger log
protected org.apache.ignite.spi.discovery.tcp.TcpDiscoveryImpl impl
protected IgniteSpiContext spiCtx
public String getSpiState()
public int getMessageWorkerQueueSize()
public UUID getCoordinator()
public Collection<ClusterNode> getRemoteNodes()
getRemoteNodes
in interface DiscoverySpi
@Nullable public @Nullable ClusterNode getNode(UUID nodeId)
getNode
in interface DiscoverySpi
nodeId
- Node ID.null
if node is not found.public ClusterNode getNode0(UUID id)
id
- Id.public boolean pingNode(UUID nodeId)
pingNode
in interface DiscoverySpi
nodeId
- Node Id.true
if node alive, false
otherwise.public void disconnect() throws IgniteSpiException
IgniteSpi.spiStop()
with accounting that it is not a full stop,
but disconnect due to segmentation.disconnect
in interface DiscoverySpi
IgniteSpiException
- If any error occurs.public void setAuthenticator(DiscoverySpiNodeAuthenticator auth)
setAuthenticator
in interface DiscoverySpi
auth
- Discovery SPI authenticator.public void sendCustomEvent(DiscoverySpiCustomMessage msg) throws IgniteException
sendCustomEvent
in interface DiscoverySpi
msg
- Custom message.IgniteException
- if failed to sent the event message.public void failNode(UUID nodeId, @Nullable @Nullable String warning)
failNode
in interface DiscoverySpi
nodeId
- Node ID.warning
- Optional warning to be shown on all cluster nodes.public void dumpDebugInfo()
public boolean isClientMode()
isClientMode
in interface DiscoverySpi
true
if node is in client mode.@Deprecated public boolean isForceServerMode()
true
TcpDiscoverySpi will started in server mode regardless
of IgniteConfiguration.isClientMode()
@IgniteSpiConfiguration(optional=true) @Deprecated public TcpDiscoverySpi setForceServerMode(boolean forceSrvMode)
If true
TcpDiscoverySpi is started in server mode regardless
of IgniteConfiguration.isClientMode()
.
forceSrvMode
- forceServerMode flag.this
for chaining.public boolean isClientReconnectDisabled()
true
client does not try to reconnect after
server detected client node failure.@IgniteSpiConfiguration(optional=true) public void setClientReconnectDisabled(boolean clientReconnectDisabled)
If true
client does not try to reconnect after
server detected client node failure.
clientReconnectDisabled
- Client reconnect disabled flag.@IgniteInstanceResource protected void injectResources(Ignite ignite)
injectResources
in class IgniteSpiAdapter
ignite
- Ignite.@IgniteSpiConfiguration(optional=true) public TcpDiscoverySpi setLocalAddress(String locAddr)
If not provided, by default a first found non-loopback address
will be used. If there is no non-loopback address available,
then InetAddress.getLocalHost()
will be used.
locAddr
- IP address.this
for chaining.public String getLocalAddress()
setLocalAddress(String)
method.@IgniteSpiConfiguration(optional=true) public void setAddressResolver(AddressResolver addrRslvr)
addrRslvr
- Address resolver.public AddressResolver getAddressResolver()
public int getReconnectCount()
@IgniteSpiConfiguration(optional=true) public TcpDiscoverySpi setReconnectCount(int reconCnt)
Note that SPI implementation will increase ackTimeout
by factor 2
on every retry.
If not specified, default is DFLT_RECONNECT_CNT
.
When this property is explicitly set IgniteConfiguration.getFailureDetectionTimeout()
is ignored.
reconCnt
- Number of retries during message sending.this
for chaining.setAckTimeout(long)
public long getReconnectDelay()
@IgniteSpiConfiguration(optional=true) public TcpDiscoverySpi setReconnectDelay(int reconDelay)
If not specified, default is DFLT_RECONNECT_DELAY
.
reconDelay
- Delay between attempts to connect to the cluster in milliseconds.this
for chaining.public long getMaxAckTimeout()
@IgniteSpiConfiguration(optional=true) public TcpDiscoverySpi setMaxAckTimeout(long maxAckTimeout)
If acknowledgement is not received within this timeout, sending is considered as failed
and SPI tries to repeat message sending. Every time SPI retries messing sending, ack
timeout will be increased. If no acknowledgement is received and maxAckTimeout
is reached, then the process of message sending is considered as failed.
If not specified, default is DFLT_MAX_ACK_TIMEOUT
.
Affected server nodes only.
When this property is explicitly set IgniteConfiguration.getFailureDetectionTimeout()
is ignored.
maxAckTimeout
- Maximum acknowledgement timeout.this
for chaining.public int getLocalPort()
@IgniteSpiConfiguration(optional=true) public TcpDiscoverySpi setLocalPort(int locPort)
If not specified, default is DFLT_PORT
.
Affected server nodes only.
locPort
- Local port to bind.this
for chaining.public int getLocalPortRange()
@IgniteSpiConfiguration(optional=true) public TcpDiscoverySpi setLocalPortRange(int locPortRange)
getLocalPort()
up until
getLocalPort()
+ locPortRange
.
If port range value is 0, then implementation will try bind only to the port provided by
setLocalPort(int)
method and fail if binding to this port did not succeed.
If not specified, default is DFLT_PORT_RANGE
.
Affected server nodes only.
locPortRange
- Local port range to bind.this
for chaining.public long getStatisticsPrintFrequency()
@IgniteSpiConfiguration(optional=true) public TcpDiscoverySpi setStatisticsPrintFrequency(long statsPrintFreq)
If not set default value is DFLT_STATS_PRINT_FREQ
.
0 indicates that no print is required. If value is greater than 0 and log is
not quiet then statistics are printed out with INFO level.
This may be very helpful for tracing topology problems.
statsPrintFreq
- Statistics print frequency in milliseconds.this
for chaining.public long getIpFinderCleanFrequency()
@IgniteSpiConfiguration(optional=true) public TcpDiscoverySpi setIpFinderCleanFrequency(long ipFinderCleanFreq)
If not provided, default value is DFLT_IP_FINDER_CLEAN_FREQ
Affected server nodes only.
ipFinderCleanFreq
- IP finder clean frequency.this
for chaining.public TcpDiscoveryIpFinder getIpFinder()
@IgniteSpiConfiguration(optional=true) public TcpDiscoverySpi setIpFinder(TcpDiscoveryIpFinder ipFinder)
If not provided TcpDiscoveryMulticastIpFinder
will
be used by default.
ipFinder
- IP finder.this
for chaining.@IgniteSpiConfiguration(optional=true) public TcpDiscoverySpi setSocketTimeout(long sockTimeout)
Note that when running Ignite on Amazon EC2, socket timeout must be set to a value
significantly greater than the default (e.g. to 30000
).
If not specified, default is DFLT_SOCK_TIMEOUT
or DFLT_SOCK_TIMEOUT_CLIENT
.
When this property is explicitly set IgniteConfiguration.getFailureDetectionTimeout()
is ignored.
sockTimeout
- Socket connection timeout.this
for chaining.@IgniteSpiConfiguration(optional=true) public TcpDiscoverySpi setAckTimeout(long ackTimeout)
If acknowledgement is not received within this timeout, sending is considered as failed and SPI tries to repeat message sending.
If not specified, default is DFLT_ACK_TIMEOUT
or DFLT_ACK_TIMEOUT_CLIENT
.
When this property is explicitly set IgniteConfiguration.getFailureDetectionTimeout()
is ignored.
ackTimeout
- Acknowledgement timeout.this
for chaining.@IgniteSpiConfiguration(optional=true) public void setSoLinger(int soLinger)
If not specified, default is DFLT_SO_LINGER
@IgniteSpiConfiguration(optional=true) public TcpDiscoverySpi setNetworkTimeout(long netTimeout)
If not specified, default is DFLT_NETWORK_TIMEOUT
.
netTimeout
- Network timeout.this
for chaining.public long getJoinTimeout()
@IgniteSpiConfiguration(optional=true) public TcpDiscoverySpi setJoinTimeout(long joinTimeout)
If non-shared IP finder is used and node fails to connect to any address from IP finder, node keeps trying to join within this timeout. If all addresses are still unresponsive, exception is thrown and node startup fails.
If not specified, default is DFLT_JOIN_TIMEOUT
.
joinTimeout
- Join timeout (0
means wait forever).this
for chaining.TcpDiscoveryIpFinder.isShared()
@IgniteSpiConfiguration(optional=true) public TcpDiscoverySpi setThreadPriority(int threadPri)
If not provided, default value is DFLT_THREAD_PRI
threadPri
- Thread priority.this
for chaining.public long getTopHistorySize()
@IgniteSpiConfiguration(optional=true) public TcpDiscoverySpi setTopHistorySize(int topHistSize)
DFLT_TOP_HISTORY_SIZE
.topHistSize
- Size of topology snapshots history.this
for chaining.public long getConnectionRecoveryTimeout()
setConnectionRecoveryTimeout(long)
for details.public void setConnectionRecoveryTimeout(long connRecoveryTimeout)
In case local node has temporary connectivity issues with part of the cluster, it may sequentially fail nodes one-by-one till successfully connect to one that has a fine connection with. This leads to fail of big number of nodes.
To overcome that issue, local node will do a sequential connection tries to next nodes. But if new next node has connection to previous it forces local node to retry connect to previous. These tries will last till timeout will not finished. When timeout is over, but no success in connecting to nodes it will segment itself.
Cannot be greater than IgniteSpiAdapter.failureDetectionTimeout()
.
Default is DFLT_CONNECTION_RECOVERY_TIMEOUT
.
connRecoveryTimeout
- Timeout that defines how long server node would try to recovery connection.
0
means node will not recheck failed nodes.public void setNodeAttributes(Map<String,Object> attrs, IgniteProductVersion ver)
setNodeAttributes
in interface DiscoverySpi
attrs
- Map of node attributes.ver
- Product version.public UUID getLocalNodeId()
@Nullable public @Nullable Serializable consistentId() throws IgniteSpiException
consistentId
in interface DiscoverySpi
null
if not applicable.IgniteSpiException
- If failed.protected void initLocalNode(int srvPort, boolean addExtAddrAttr)
srvPort
- Server port.addExtAddrAttr
- If true
adds ATTR_EXT_ADDRS
attribute.public Collection<Object> injectables()
injectables
in class IgniteSpiAdapter
public long getSocketTimeout()
public long getEffectiveSocketTimeout(boolean srvrOperation)
srvrOperation
- True
if socket connect to server node,
False
if socket connect to client node.public long getAckTimeout()
public int getSoLinger()
public long getNetworkTimeout()
public int getThreadPriority()
public String getIpFinderFormatted()
TcpDiscoveryIpFinder
(string representation).public long getNodesJoined()
public long getNodesLeft()
public long getNodesFailed()
public long getPendingMessagesRegistered()
public long getPendingMessagesDiscarded()
public long getAvgMessageProcessingTime()
public long getMaxMessageProcessingTime()
public int getTotalReceivedMessages()
public Map<String,Integer> getReceivedMessages()
public int getTotalProcessedMessages()
public Map<String,Integer> getProcessedMessages()
public long getCoordinatorSinceTimestamp()
protected void onContextInitialized0(IgniteSpiContext spiCtx) throws IgniteSpiException
onContextInitialized0
in class IgniteSpiAdapter
spiCtx
- SPI context.IgniteSpiException
- In case of errors.protected void onContextDestroyed0()
onContextDestroyed0
in class IgniteSpiAdapter
public IgniteSpiContext getSpiContext()
getSpiContext
in class IgniteSpiAdapter
public ClusterNode getLocalNode()
getLocalNode
in interface DiscoverySpi
getLocalNode
in class IgniteSpiAdapter
public void setListener(@Nullable @Nullable DiscoverySpiListener lsnr)
DiscoveryEvent
for a set of all possible
discovery events.
TODO: This method should be removed from public API in Apache Ignite 3.0
setListener
in interface DiscoverySpi
lsnr
- Listener to discovery events or null
to unset the listener.public void setDataExchange(DiscoverySpiDataExchange exchange)
setDataExchange
in interface DiscoverySpi
exchange
- Discovery data exchange handler.public void setMetricsProvider(DiscoveryMetricsProvider metricsProvider)
DiscoveryMetricsProvider.metrics()
method to exchange
dynamic metrics between nodes.setMetricsProvider
in interface DiscoverySpi
metricsProvider
- Provider of metrics data.public long getGridStartTime()
getGridStartTime
in interface DiscoverySpi
0
if SPI implementation
does not support this method.public void setGridStartTime(long val)
val
- New time value.protected Socket openSocket(InetSocketAddress sockAddr, IgniteSpiOperationTimeoutHelper timeoutHelper) throws IOException, IgniteSpiOperationTimeoutException
sockAddr
- Remote address.timeoutHelper
- Timeout helper.IOException
- If failed.IgniteSpiOperationTimeoutException
- In case of timeout.protected Socket openSocket(Socket sock, InetSocketAddress remAddr, IgniteSpiOperationTimeoutHelper timeoutHelper) throws IOException, IgniteSpiOperationTimeoutException
U.IGNITE_HEADER
when connection is established.sock
- Socket bound to a local host address.remAddr
- Remote address.timeoutHelper
- Timeout helper.IOException
- If failed.IgniteSpiOperationTimeoutException
- In case of timeout.protected void writeToSocket(Socket sock, org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryAbstractMessage msg, byte[] data, long timeout) throws IOException
sock
- Socket.msg
- Message.data
- Raw data to write.timeout
- Socket write timeout.IOException
- If IO failed or write timed out.protected void writeToSocket(Socket sock, org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryAbstractMessage msg, long timeout) throws IOException, IgniteCheckedException
sock
- Socket.msg
- Message.timeout
- Socket write timeout.IOException
- If IO failed or write timed out.IgniteCheckedException
- If marshalling failed.@TestOnly protected void startMessageProcess(org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryAbstractMessage msg)
msg
- Message.protected void writeToSocket(ClusterNode node, Socket sock, OutputStream out, org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryAbstractMessage msg, long timeout) throws IOException, IgniteCheckedException
node
- Target node.sock
- Socket.out
- Stream to write to.msg
- Message.timeout
- Timeout.IOException
- If IO failed or write timed out.IgniteCheckedException
- If marshalling failed.protected void writeToSocket(Socket sock, OutputStream out, org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryAbstractMessage msg, long timeout) throws IOException, IgniteCheckedException
sock
- Socket.out
- Stream to write to.msg
- Message.timeout
- Timeout.IOException
- If IO failed or write timed out.IgniteCheckedException
- If marshalling failed.protected void writeToSocket(org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryAbstractMessage msg, Socket sock, int res, long timeout) throws IOException
msg
- Received message.sock
- Socket.res
- Integer response.timeout
- Socket timeout.IOException
- If IO failed or write timed out.protected <T> T readMessage(Socket sock, @Nullable @Nullable InputStream in, long timeout) throws IOException, IgniteCheckedException
sock
- Socket.in
- Input stream (in case socket stream was wrapped).timeout
- Socket timeout for this operation.IOException
- If IO failed or read timed out.IgniteCheckedException
- If unmarshalling failed.protected int readReceipt(Socket sock, long timeout) throws IOException
sock
- Socket.timeout
- Socket timeout for this operation.IOException
- If IO failed or read timed out.protected Collection<InetSocketAddress> resolvedAddresses() throws IgniteSpiException
IgniteSpiException
- If an error occurs.protected Collection<InetSocketAddress> registeredAddresses() throws IgniteSpiException
DFLT_PORT
.IgniteSpiException
- If an error occurs.protected IgniteSpiException duplicateIdError(org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryDuplicateIdMessage msg)
msg
- Message.protected IgniteSpiException authenticationFailedError(org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryAuthFailedMessage msg)
msg
- Message.protected IgniteSpiException checkFailedError(org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryCheckFailedMessage msg)
msg
- Message.protected boolean ensured(org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryAbstractMessage msg)
msg
- Message.protected void onExchange(org.apache.ignite.spi.discovery.tcp.internal.DiscoveryDataPacket dataPacket, ClassLoader clsLdr)
dataPacket
- object holding discovery data collected during discovery process.clsLdr
- Class loader.public void spiStart(@Nullable @Nullable String igniteInstanceName) throws IgniteSpiException
spiStart
in interface IgniteSpi
igniteInstanceName
- Name of Ignite instance this SPI is being started for
(null
for default Ignite instance).IgniteSpiException
- Throws in case of any error during SPI start.public void spiStop() throws IgniteSpiException
Note that this method can be called at any point including during recovery of failed start. It should make no assumptions on what state SPI will be in when this method is called.
spiStop
in interface IgniteSpi
IgniteSpiException
- Thrown in case of any error during SPI stop.public void clientReconnect() throws IgniteSpiException
clientReconnect
in interface org.apache.ignite.internal.managers.discovery.IgniteDiscoverySpi
IgniteSpiException
public boolean allNodesSupport(org.apache.ignite.internal.IgniteFeatures feature)
allNodesSupport
in interface org.apache.ignite.internal.managers.discovery.IgniteDiscoverySpi
feature
- Feature to check.true
if all nodes support the given feature.public boolean allNodesSupport(org.apache.ignite.internal.IgniteFeatures feature, IgnitePredicate<ClusterNode> nodesPred)
allNodesSupport
in interface org.apache.ignite.internal.managers.discovery.IgniteDiscoverySpi
feature
- Feature to check.nodesPred
- Predicate to filter cluster nodes.true
if all nodes passed the filter support the given feature.public boolean knownNode(UUID nodeId)
knownNode
in interface org.apache.ignite.internal.managers.discovery.IgniteDiscoverySpi
nodeId
- Node ID.True
if node joining or already joined topology.public boolean clientReconnectSupported()
clientReconnectSupported
in interface org.apache.ignite.internal.managers.discovery.IgniteDiscoverySpi
True
if SPI supports client reconnect.public boolean supportsCommunicationFailureResolve()
supportsCommunicationFailureResolve
in interface org.apache.ignite.internal.managers.discovery.IgniteDiscoverySpi
True
if supports communication error resolve.public void resolveCommunicationFailure(ClusterNode node, Exception err)
resolveCommunicationFailure
in interface org.apache.ignite.internal.managers.discovery.IgniteDiscoverySpi
node
- Problem node.err
- Connection error.public int clientWorkerCount()
public void addSendMessageListener(IgniteInClosure<org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryAbstractMessage> lsnr)
public void setInternalListener(org.apache.ignite.internal.managers.discovery.IgniteDiscoverySpiInternalListener lsnr)
setInternalListener
in interface org.apache.ignite.internal.managers.discovery.IgniteDiscoverySpi
lsnr
- Listener.public void removeSendMessageListener(IgniteInClosure<org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryAbstractMessage> lsnr)
public void addIncomeConnectionListener(IgniteInClosure<Socket> lsnr)
public void removeIncomeConnectionListener(IgniteInClosure<Socket> lsnr)
public void waitForClientMessagePrecessed()
public void simulateNodeFailure()
Simulates this node failure by stopping service threads. So, node will become unresponsive.
This method is intended for test purposes only.
simulateNodeFailure
in interface org.apache.ignite.internal.managers.discovery.IgniteDiscoverySpi
public void brakeConnection()
public boolean isLocalNodeCoordinator()
true
if local node is coordinator.protected Marshaller marshaller()
public TcpDiscoverySpi setName(String name)
setName
in class IgniteSpiAdapter
name
- SPI name.this
for chaining.
GridGain In-Memory Computing Platform : ver. 8.9.15 Release Date : December 3 2024