@IgniteSpiMultipleInstancesSupport(value=true) @DiscoverySpiOrderSupport(value=true) @DiscoverySpiHistorySupport(value=true) public class TcpDiscoverySpi extends IgniteSpiAdapter implements TcpDiscoverySpiMBean
Nodes are organized in ring. So almost all network exchange (except few cases) is done across it.
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.
setIpFinder(TcpDiscoveryIpFinder)
).
See the following IP finder implementations for details on configuration:
setLocalAddress(String)
)setLocalPort(int)
)setLocalPortRange(int)
)setHeartbeatFrequency(long)
)setMaxMissedHeartbeats(int)
)setReconnectCount(int)
)setNetworkTimeout(long)
)setSocketTimeout(long)
)setAckTimeout(long)
)setMaxAckTimeout(long)
)setJoinTimeout(long)
)setThreadPriority(int)
)setIpFinderCleanFrequency(long)
)setStatisticsPrintFrequency(long)
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 |
---|---|
protected long |
ackTimeout
Message acknowledgement timeout.
|
static String |
ATTR_EXT_ADDRS
Node attribute that is mapped to node's external addresses (value is disc.tcp.ext-addrs).
|
static long |
DFLT_ACK_TIMEOUT
Default timeout for receiving message acknowledgement in milliseconds (value is 200ms).
|
static long |
DFLT_HEARTBEAT_FREQ
Default heartbeat messages issuing frequency (value is 300ms).
|
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 int |
DFLT_MAX_MISSED_CLIENT_HEARTBEATS
Default max heartbeats count node can miss without failing client node (value is 5).
|
static int |
DFLT_MAX_MISSED_HEARTBEATS
Default max heartbeats count node can miss without initiating status check (value is 1).
|
static long |
DFLT_NETWORK_TIMEOUT
Default network timeout in milliseconds (value is 200ms).
|
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_SOCK_TIMEOUT
Default socket operations timeout in milliseconds (value is 200ms).
|
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_TOP_HISTORY_SIZE
Default size of topology snapshots history.
|
protected DiscoverySpiDataExchange |
exchange
Data exchange.
|
protected long |
gridStartTime
Start time of the very first grid node.
|
protected long |
hbFreq
Heartbeat messages issuing frequency.
|
protected TcpDiscoveryIpFinder |
ipFinder
IP finder.
|
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 IgniteLogger |
log
Logger.
|
protected DiscoverySpiListener |
lsnr
Grid discovery listener.
|
protected Marshaller |
marsh
Marshaller.
|
protected DiscoveryMetricsProvider |
metricsProvider
Metrics provider.
|
protected long |
netTimeout
Network timeout.
|
protected static int |
RES_CONTINUE_JOIN
Response CONTINUE JOIN.
|
protected static int |
RES_OK
Response OK.
|
protected static int |
RES_WAIT
Response WAIT.
|
protected long |
sockTimeout
Socket operations timeout.
|
protected org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpiAdapter.SocketTimeoutWorker |
sockTimeoutWorker
Socket timeout worker.
|
protected org.apache.ignite.spi.discovery.tcp.internal.TcpDiscoverySpiState |
spiState
Discovery state.
|
protected org.apache.ignite.spi.discovery.tcp.internal.TcpDiscoveryStatistics |
stats
Statistics.
|
protected int |
threadPri
Thread priority for all threads started by SPI.
|
protected int |
topHistSize
Size of topology snapshots history.
|
gridName, ignite, nodeId
Constructor and Description |
---|
TcpDiscoverySpi() |
Modifier and Type | Method and Description |
---|---|
protected IgniteSpiException |
authenticationFailedError(org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryAuthFailedMessage msg) |
protected IgniteSpiException |
checkFailedError(org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryCheckFailedMessage msg) |
void |
disconnect()
Tells discovery SPI to disconnect from topology.
|
void |
dumpDebugInfo()
Dumps debug info using configured logger.
|
void |
dumpDebugInfo(IgniteLogger log) |
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)
Initiates failure of provided node.
|
long |
getAckTimeout()
Gets message acknowledgement timeout.
|
AddressResolver |
getAddressResolver()
Gets address resolver.
|
long |
getAvgMessageProcessingTime()
Gets avg message processing time.
|
UUID |
getCoordinator()
Gets current coordinator.
|
long |
getCoordinatorSinceTimestamp()
Gets time local node has been coordinator since.
|
long |
getGridStartTime()
Gets start time of the very first node in the grid.
|
long |
getHeartbeatFrequency()
Gets delay between heartbeat messages sent by coordinator.
|
TcpDiscoveryIpFinder |
getIpFinder()
Gets IP finder for IP addresses sharing and storing.
|
long |
getIpFinderCleanFrequency()
Gets IP finder clean frequency.
|
String |
getIpFinderFormatted()
Gets
TcpDiscoveryIpFinder (string representation). |
long |
getJoinTimeout()
Gets join timeout.
|
String |
getLocalAddress()
Gets local address that was set to SPI with
setLocalAddress(String) method. |
ClusterNode |
getLocalNode()
Gets 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 |
getMaxMissedClientHeartbeats()
Gets max heartbeats count node can miss without failing client node.
|
int |
getMaxMissedHeartbeats()
Gets max heartbeats count node can miss without initiating status check.
|
int |
getMessageWorkerQueueSize()
Gets message worker queue current size.
|
long |
getNetworkTimeout()
Gets network timeout.
|
ClusterNode |
getNode(UUID nodeId)
Gets node by 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.
|
Collection<ClusterNode> |
getRemoteNodes()
Gets collection of remote nodes in grid or empty collection if no remote nodes found.
|
long |
getSocketTimeout()
Gets socket timeout.
|
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.
|
Collection<Object> |
injectables()
This method returns SPI internal instances that need to be injected as well.
|
void |
injectResources(Ignite ignite)
Inject resources
|
protected void |
onContextDestroyed0()
Method to be called in the beginning of onContextDestroyed() method.
|
void |
onContextInitialized0(IgniteSpiContext spiCtx)
Method to be called in the end of onContextInitialized method.
|
protected void |
onExchange(UUID joiningNodeID,
UUID nodeId,
Map<Integer,byte[]> data,
ClassLoader clsLdr) |
protected Socket |
openSocket(InetSocketAddress sockAddr) |
boolean |
pingNode(UUID nodeId)
Pings the remote node to see if it's alive.
|
protected <T> T |
readMessage(Socket sock,
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 . |
protected Collection<InetSocketAddress> |
resolvedAddresses()
Resolves addresses registered in the IP finder, removes duplicates and local host
address and returns the collection of.
|
void |
sendCustomEvent(Serializable evt)
Sends custom message across the ring.
|
void |
setAckTimeout(long ackTimeout)
Sets timeout for receiving acknowledgement for sent message.
|
void |
setAddressResolver(AddressResolver addrRslvr)
Sets address resolver.
|
void |
setAuthenticator(DiscoverySpiNodeAuthenticator nodeAuth)
Sets discovery SPI node authenticator.
|
void |
setDataExchange(DiscoverySpiDataExchange exchange)
Sets a handler for initial data exchange between Ignite nodes.
|
void |
setDebugMessageHistory(int debugMsgHist)
This method is intended for troubleshooting purposes only.
|
void |
setDebugMode(boolean debugMode)
This method is intended for troubleshooting purposes only.
|
void |
setHeartbeatFrequency(long hbFreq)
Sets delay between issuing of heartbeat messages.
|
void |
setIpFinder(TcpDiscoveryIpFinder ipFinder)
Sets IP finder for IP addresses sharing and storing.
|
void |
setIpFinderCleanFrequency(long ipFinderCleanFreq)
Sets IP finder clean frequency in milliseconds.
|
void |
setJoinTimeout(long joinTimeout)
Sets join timeout.
|
void |
setListener(DiscoverySpiListener lsnr)
Sets a listener for discovery events.
|
void |
setLocalAddress(String locAddr)
Sets local host IP address that discovery SPI uses.
|
void |
setLocalPort(int locPort)
Sets local port to listen to.
|
void |
setLocalPortRange(int locPortRange)
Range for local ports.
|
void |
setMaxAckTimeout(long maxAckTimeout)
Sets maximum timeout for receiving acknowledgement for sent message.
|
void |
setMaxMissedClientHeartbeats(int maxMissedClientHbs)
Sets max heartbeats count node can miss without failing client node.
|
void |
setMaxMissedHeartbeats(int maxMissedHbs)
Sets max heartbeats count node can miss without initiating status check.
|
void |
setMetricsProvider(DiscoveryMetricsProvider metricsProvider)
Sets discovery metrics provider.
|
void |
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.
|
void |
setReconnectCount(int reconCnt)
Number of times node tries to (re)establish connection to another node.
|
void |
setSocketTimeout(long sockTimeout)
Sets socket operations timeout.
|
void |
setStatisticsPrintFrequency(long statsPrintFreq)
Sets statistics print frequency.
|
void |
setThreadPriority(int threadPri)
Sets thread priority.
|
void |
setTopHistorySize(int topHistSize)
Sets size of topology snapshots history.
|
void |
spiStart(String gridName)
This method is called to start SPI.
|
void |
spiStop()
This method is called to stop SPI.
|
String |
toString() |
protected void |
writeToSocket(Socket sock,
byte[] data)
Writes message to the socket.
|
protected void |
writeToSocket(Socket sock,
int res)
Writes response to the socket.
|
protected void |
writeToSocket(Socket sock,
org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryAbstractMessage msg)
Writes message to the socket.
|
protected void |
writeToSocket(Socket sock,
org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryAbstractMessage msg,
org.apache.ignite.internal.util.io.GridByteArrayOutputStream bout)
Writes message to the socket.
|
assertParameter, checkConfigurationConsistency0, configInfo, createSpiAttributeName, getConsistentAttributeNames, getExceptionRegistry, getIgniteHome, getLocalNodeId, getName, getNodeAttributes, getStartTimestamp, getStartTimestampFormatted, getUpTime, getUpTimeFormatted, isNodeStopping, onContextDestroyed, onContextInitialized, registerMBean, setName, startInfo, startStopwatch, stopInfo, unregisterMBean
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getIgniteHome, getLocalNodeId, getName, getStartTimestamp, getStartTimestampFormatted, getUpTime, getUpTimeFormatted
getName, getNodeAttributes, onContextDestroyed, onContextInitialized
public static final int DFLT_PORT_RANGE
public static final long DFLT_JOIN_TIMEOUT
public static final int DFLT_RECONNECT_CNT
public static final int DFLT_MAX_MISSED_HEARTBEATS
public static final int DFLT_MAX_MISSED_CLIENT_HEARTBEATS
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 String ATTR_EXT_ADDRS
public static final int DFLT_PORT
public static final long DFLT_SOCK_TIMEOUT
public static final long DFLT_ACK_TIMEOUT
public static final long DFLT_NETWORK_TIMEOUT
public static final int DFLT_THREAD_PRI
public static final long DFLT_HEARTBEAT_FREQ
public static final int DFLT_TOP_HISTORY_SIZE
protected static final int RES_OK
protected static final int RES_CONTINUE_JOIN
protected static final int RES_WAIT
protected String locAddr
protected TcpDiscoveryIpFinder ipFinder
protected long sockTimeout
protected long ackTimeout
protected long netTimeout
protected int threadPri
protected long hbFreq
protected int topHistSize
protected volatile DiscoverySpiListener lsnr
protected DiscoverySpiDataExchange exchange
protected DiscoveryMetricsProvider metricsProvider
protected IgniteProductVersion locNodeVer
protected org.apache.ignite.spi.discovery.tcp.internal.TcpDiscoveryNode locNode
protected InetAddress locHost
protected Collection<InetSocketAddress> locNodeAddrs
protected org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpiAdapter.SocketTimeoutWorker sockTimeoutWorker
protected org.apache.ignite.spi.discovery.tcp.internal.TcpDiscoverySpiState spiState
protected volatile long gridStartTime
protected final Marshaller marsh
protected final org.apache.ignite.spi.discovery.tcp.internal.TcpDiscoveryStatistics stats
@LoggerResource protected IgniteLogger log
@IgniteInstanceResource public void injectResources(Ignite ignite)
ignite
- Ignite.@IgniteSpiConfiguration(optional=true) public void setAddressResolver(AddressResolver addrRslvr)
addrRslvr
- Address resolver.public AddressResolver getAddressResolver()
public int getReconnectCount()
getReconnectCount
in interface TcpDiscoverySpiMBean
@IgniteSpiConfiguration(optional=true) public void setReconnectCount(int reconCnt)
Note that SPI implementation will increase ackTimeout
by factor 2
on every retry.
If not specified, default is DFLT_RECONNECT_CNT
.
reconCnt
- Number of retries during message sending.setAckTimeout(long)
public long getMaxAckTimeout()
getMaxAckTimeout
in interface TcpDiscoverySpiMBean
@IgniteSpiConfiguration(optional=true) public void 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
.
maxAckTimeout
- Maximum acknowledgement timeout.public long getJoinTimeout()
getJoinTimeout
in interface TcpDiscoverySpiMBean
@IgniteSpiConfiguration(optional=true) public void 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).TcpDiscoveryIpFinder.isShared()
public int getLocalPort()
getLocalPort
in interface TcpDiscoverySpiMBean
@IgniteSpiConfiguration(optional=true) public void setLocalPort(int locPort)
If not specified, default is DFLT_PORT
.
locPort
- Local port to bind.public int getLocalPortRange()
getLocalPortRange
in interface TcpDiscoverySpiMBean
@IgniteSpiConfiguration(optional=true) public void setLocalPortRange(int locPortRange)
getLocalPort()
up until
getLocalPort()
+ locPortRange
.
If not specified, default is DFLT_PORT_RANGE
.
locPortRange
- Local port range to bind.public int getMaxMissedHeartbeats()
getMaxMissedHeartbeats
in interface TcpDiscoverySpiMBean
@IgniteSpiConfiguration(optional=true) public void setMaxMissedHeartbeats(int maxMissedHbs)
If not provided, default value is DFLT_MAX_MISSED_HEARTBEATS
.
maxMissedHbs
- Max missed heartbeats.public int getMaxMissedClientHeartbeats()
getMaxMissedClientHeartbeats
in interface TcpDiscoverySpiMBean
@IgniteSpiConfiguration(optional=true) public void setMaxMissedClientHeartbeats(int maxMissedClientHbs)
If not provided, default value is DFLT_MAX_MISSED_CLIENT_HEARTBEATS
.
maxMissedClientHbs
- Max missed client heartbeats.public long getStatisticsPrintFrequency()
getStatisticsPrintFrequency
in interface TcpDiscoverySpiMBean
@IgniteSpiConfiguration(optional=true) public void 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.public long getIpFinderCleanFrequency()
getIpFinderCleanFrequency
in interface TcpDiscoverySpiMBean
@IgniteSpiConfiguration(optional=true) public void setIpFinderCleanFrequency(long ipFinderCleanFreq)
If not provided, default value is DFLT_IP_FINDER_CLEAN_FREQ
ipFinderCleanFreq
- IP finder clean frequency.public void setDebugMode(boolean debugMode)
debugMode
- {code True} to start SPI in debug mode.public void setDebugMessageHistory(int debugMsgHist)
debugMsgHist
- Message history log size.public String getSpiState()
getSpiState
in interface TcpDiscoverySpiMBean
public long getSocketTimeout()
getSocketTimeout
in interface TcpDiscoverySpiMBean
public long getAckTimeout()
getAckTimeout
in interface TcpDiscoverySpiMBean
public long getNetworkTimeout()
getNetworkTimeout
in interface TcpDiscoverySpiMBean
public int getThreadPriority()
getThreadPriority
in interface TcpDiscoverySpiMBean
public long getHeartbeatFrequency()
getHeartbeatFrequency
in interface TcpDiscoverySpiMBean
public String getIpFinderFormatted()
TcpDiscoveryIpFinder
(string representation).getIpFinderFormatted
in interface TcpDiscoverySpiMBean
public int getMessageWorkerQueueSize()
getMessageWorkerQueueSize
in interface TcpDiscoverySpiMBean
public long getNodesJoined()
getNodesJoined
in interface TcpDiscoverySpiMBean
public long getNodesLeft()
getNodesLeft
in interface TcpDiscoverySpiMBean
public long getNodesFailed()
getNodesFailed
in interface TcpDiscoverySpiMBean
public long getPendingMessagesRegistered()
getPendingMessagesRegistered
in interface TcpDiscoverySpiMBean
public long getPendingMessagesDiscarded()
getPendingMessagesDiscarded
in interface TcpDiscoverySpiMBean
public long getAvgMessageProcessingTime()
getAvgMessageProcessingTime
in interface TcpDiscoverySpiMBean
public long getMaxMessageProcessingTime()
getMaxMessageProcessingTime
in interface TcpDiscoverySpiMBean
public int getTotalReceivedMessages()
getTotalReceivedMessages
in interface TcpDiscoverySpiMBean
public Map<String,Integer> getReceivedMessages()
getReceivedMessages
in interface TcpDiscoverySpiMBean
public int getTotalProcessedMessages()
getTotalProcessedMessages
in interface TcpDiscoverySpiMBean
public Map<String,Integer> getProcessedMessages()
getProcessedMessages
in interface TcpDiscoverySpiMBean
public long getCoordinatorSinceTimestamp()
getCoordinatorSinceTimestamp
in interface TcpDiscoverySpiMBean
@Nullable public UUID getCoordinator()
getCoordinator
in interface TcpDiscoverySpiMBean
@Nullable public ClusterNode getNode(UUID nodeId)
getNode
in interface DiscoverySpi
nodeId
- Node ID.null
if node is not found.public Collection<ClusterNode> getRemoteNodes()
getRemoteNodes
in interface DiscoverySpi
public Collection<Object> injectables()
injectables
in class IgniteSpiAdapter
public void spiStart(String gridName) throws IgniteSpiException
spiStart
in interface IgniteSpi
gridName
- Name of grid instance this SPI is being started for
(null
for default grid).IgniteSpiException
- Throws in case of any error during SPI start.public void onContextInitialized0(IgniteSpiContext spiCtx) throws IgniteSpiException
spiCtx
- SPI context.IgniteSpiException
- In case of errors.public IgniteSpiContext getSpiContext()
getSpiContext
in class IgniteSpiAdapter
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.protected void onContextDestroyed0()
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 nodeAuth)
setAuthenticator
in interface DiscoverySpi
nodeAuth
- Discovery SPI authenticator.public void sendCustomEvent(Serializable evt)
sendCustomEvent
in interface DiscoverySpi
evt
- Event.public void failNode(UUID nodeId)
failNode
in interface DiscoverySpi
nodeId
- Node ID.public void dumpDebugInfo()
dumpDebugInfo
in interface TcpDiscoverySpiMBean
public void dumpDebugInfo(IgniteLogger log)
log
- Logger.@IgniteSpiConfiguration(optional=true) public void 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.public String getLocalAddress()
setLocalAddress(String)
method.public TcpDiscoveryIpFinder getIpFinder()
@IgniteSpiConfiguration(optional=true) public void setIpFinder(TcpDiscoveryIpFinder ipFinder)
If not provided TcpDiscoveryMulticastIpFinder
will be used by default.
ipFinder
- IP finder.@IgniteSpiConfiguration(optional=true) public void 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
.
sockTimeout
- Socket connection timeout.@IgniteSpiConfiguration(optional=true) public void 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
.
ackTimeout
- Acknowledgement timeout.@IgniteSpiConfiguration(optional=true) public void setNetworkTimeout(long netTimeout)
If not specified, default is DFLT_NETWORK_TIMEOUT
.
netTimeout
- Network timeout.@IgniteSpiConfiguration(optional=true) public void setThreadPriority(int threadPri)
If not provided, default value is DFLT_THREAD_PRI
threadPri
- Thread priority.@IgniteSpiConfiguration(optional=true) public void setHeartbeatFrequency(long hbFreq)
If not provided, default value is DFLT_HEARTBEAT_FREQ
.
hbFreq
- Heartbeat frequency in milliseconds.public long getTopHistorySize()
@IgniteSpiConfiguration(optional=true) public void setTopHistorySize(int topHistSize)
DFLT_TOP_HISTORY_SIZE
.topHistSize
- Size of topology snapshots history.public void setNodeAttributes(Map<String,Object> attrs, IgniteProductVersion ver)
setNodeAttributes
in interface DiscoverySpi
attrs
- Map of node attributes.ver
- Product version.public ClusterNode getLocalNode()
getLocalNode
in interface DiscoverySpi
public void setListener(@Nullable DiscoverySpiListener lsnr)
DiscoveryEvent
for a set of all possible
discovery events.
Note that as of Ignite 3.0.2 this method is called before
method IgniteSpi.spiStart(String)
is called. This is done to
avoid potential window when SPI is started but the listener is
not registered yet.
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.protected Socket openSocket(InetSocketAddress sockAddr) throws IOException
sockAddr
- Remote address.IOException
- If failed.protected void writeToSocket(Socket sock, byte[] data) throws IOException
sock
- Socket.data
- Raw data to write.IOException
- If IO failed or write timed out.protected void writeToSocket(Socket sock, org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryAbstractMessage msg) throws IOException, IgniteCheckedException
sock
- Socket.msg
- Message.IOException
- If IO failed or write timed out.IgniteCheckedException
- If marshalling failed.protected void writeToSocket(Socket sock, org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryAbstractMessage msg, org.apache.ignite.internal.util.io.GridByteArrayOutputStream bout) throws IOException, IgniteCheckedException
sock
- Socket.msg
- Message.bout
- Byte array output stream.IOException
- If IO failed or write timed out.IgniteCheckedException
- If marshalling failed.protected void writeToSocket(Socket sock, int res) throws IOException
sock
- Socket.res
- Integer response.IOException
- If IO failed or write timed out.protected <T> T readMessage(Socket sock, @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(UUID joiningNodeID, UUID nodeId, Map<Integer,byte[]> data, ClassLoader clsLdr)
joiningNodeID
- Joining node ID.nodeId
- Remote node ID for which data is provided.data
- Collection of marshalled discovery data objects from different components.clsLdr
- Class loader for discovery data unmarshalling.
Follow @ApacheIgnite
Ignite Fabric : ver. 1.1.0-incubating Release Date : May 20 2015