@IgniteSpiMultipleInstancesSupport(value=true) @DiscoverySpiOrderSupport(value=true) @DiscoverySpiHistorySupport(value=true) public class TcpClientDiscoverySpi extends IgniteSpiAdapter implements TcpClientDiscoverySpiMBean
This discovery SPI requires at least on server node configured with
TcpDiscoverySpi. It will try to connect to random IP taken from
TcpDiscoveryIpFinder which should point to one of these server
nodes and will maintain connection only with this node (will not enter the ring).
If this connection is broken, it will try to reconnect using addresses from
the same IP finder.
| Modifier and Type | Field and Description |
|---|---|
protected long |
ackTimeout
Message acknowledgement timeout.
|
static long |
DFLT_ACK_TIMEOUT
Default timeout for receiving message acknowledgement in milliseconds (value is 200ms).
|
static long |
DFLT_DISCONNECT_CHECK_INT
Default disconnect check interval.
|
static long |
DFLT_HEARTBEAT_FREQ
Default heartbeat messages issuing frequency (value is 300ms).
|
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 long |
DFLT_SOCK_TIMEOUT
Default socket operations timeout in milliseconds (value is 200ms).
|
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 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 TcpDiscoverySpiState |
spiState
Discovery state.
|
protected 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 |
|---|
TcpClientDiscoverySpi() |
| Modifier and Type | Method and Description |
|---|---|
protected IgniteSpiException |
authenticationFailedError(TcpDiscoveryAuthFailedMessage msg) |
protected IgniteSpiException |
checkFailedError(TcpDiscoveryCheckFailedMessage msg) |
void |
disconnect()
Tells discovery SPI to disconnect from topology.
|
protected IgniteSpiException |
duplicateIdError(TcpDiscoveryDuplicateIdMessage msg) |
protected boolean |
ensured(TcpDiscoveryAbstractMessage msg) |
void |
failNode(UUID nodeId)
Initiates failure of provided node.
|
long |
getAckTimeout()
Gets message acknowledgement timeout.
|
long |
getAvgMessageProcessingTime()
Gets avg message processing time.
|
long |
getDisconnectCheckInterval()
Gets disconnect check interval.
|
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.
|
String |
getIpFinderFormatted()
Gets
TcpDiscoveryIpFinder (string representation). |
String |
getLocalAddress()
Gets local address that was set to SPI with
setLocalAddress(String) method. |
ClusterNode |
getLocalNode()
Gets local node.
|
long |
getMaxMessageProcessingTime()
Gets max message processing time.
|
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.
|
Map<String,Integer> |
getProcessedMessages()
Gets processed messages counts (grouped by type).
|
Map<String,Integer> |
getReceivedMessages()
Gets received messages counts (grouped by type).
|
Collection<ClusterNode> |
getRemoteNodes()
Gets collection of remote nodes in grid or empty collection if no remote nodes found.
|
long |
getSocketTimeout()
Gets socket timeout.
|
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.
|
protected void |
injectResources(Ignite ignite)
Inject resources
|
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(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 |
setAuthenticator(DiscoverySpiNodeAuthenticator auth)
Sets discovery SPI node authenticator.
|
void |
setDataExchange(DiscoverySpiDataExchange exchange)
Sets a handler for initial data exchange between Ignite nodes.
|
void |
setDisconnectCheckInterval(long disconnectCheckInt)
Sets disconnect check interval.
|
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 |
setListener(DiscoverySpiListener lsnr)
Sets a listener for discovery events.
|
void |
setLocalAddress(String locAddr)
Sets local host IP address that discovery SPI uses.
|
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 |
setSocketTimeout(long sockTimeout)
Sets socket operations timeout.
|
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.
|
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,
TcpDiscoveryAbstractMessage msg)
Writes message to the socket.
|
protected void |
writeToSocket(Socket sock,
TcpDiscoveryAbstractMessage msg,
GridByteArrayOutputStream bout)
Writes message to the socket.
|
assertParameter, checkConfigurationConsistency0, configInfo, createSpiAttributeName, getConsistentAttributeNames, getExceptionRegistry, getIgniteHome, getLocalNodeId, getName, getNodeAttributes, getSpiContext, getStartTimestamp, getStartTimestampFormatted, getUpTime, getUpTimeFormatted, isNodeStopping, onContextDestroyed, onContextInitialized, registerMBean, setName, startInfo, startStopwatch, stopInfo, unregisterMBeanclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetIgniteHome, getLocalNodeId, getName, getStartTimestamp, getStartTimestampFormatted, getUpTime, getUpTimeFormattedgetName, getNodeAttributes, onContextDestroyed, onContextInitializedpublic static final long DFLT_DISCONNECT_CHECK_INT
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 TcpDiscoveryNode locNode
protected InetAddress locHost
protected Collection<InetSocketAddress> locNodeAddrs
protected org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpiAdapter.SocketTimeoutWorker sockTimeoutWorker
protected TcpDiscoverySpiState spiState
protected volatile long gridStartTime
protected final Marshaller marsh
protected final TcpDiscoveryStatistics stats
@LoggerResource protected IgniteLogger log
public long getDisconnectCheckInterval()
getDisconnectCheckInterval in interface TcpClientDiscoverySpiMBean@IgniteSpiConfiguration(optional=true) public void setDisconnectCheckInterval(long disconnectCheckInt)
disconnectCheckInt - Disconnect check interval.public long getSocketTimeout()
getSocketTimeout in interface TcpClientDiscoverySpiMBeanpublic long getAckTimeout()
getAckTimeout in interface TcpClientDiscoverySpiMBeanpublic long getNetworkTimeout()
getNetworkTimeout in interface TcpClientDiscoverySpiMBeanpublic int getThreadPriority()
getThreadPriority in interface TcpClientDiscoverySpiMBeanpublic long getHeartbeatFrequency()
getHeartbeatFrequency in interface TcpClientDiscoverySpiMBeanpublic String getIpFinderFormatted()
TcpDiscoveryIpFinder (string representation).getIpFinderFormatted in interface TcpClientDiscoverySpiMBeanpublic int getMessageWorkerQueueSize()
getMessageWorkerQueueSize in interface TcpClientDiscoverySpiMBeanpublic long getNodesJoined()
getNodesJoined in interface TcpClientDiscoverySpiMBeanpublic long getNodesLeft()
getNodesLeft in interface TcpClientDiscoverySpiMBeanpublic long getNodesFailed()
getNodesFailed in interface TcpClientDiscoverySpiMBeanpublic long getAvgMessageProcessingTime()
getAvgMessageProcessingTime in interface TcpClientDiscoverySpiMBeanpublic long getMaxMessageProcessingTime()
getMaxMessageProcessingTime in interface TcpClientDiscoverySpiMBeanpublic int getTotalReceivedMessages()
getTotalReceivedMessages in interface TcpClientDiscoverySpiMBeanpublic Map<String,Integer> getReceivedMessages()
getReceivedMessages in interface TcpClientDiscoverySpiMBeanpublic int getTotalProcessedMessages()
getTotalProcessedMessages in interface TcpClientDiscoverySpiMBeanpublic Map<String,Integer> getProcessedMessages()
getProcessedMessages in interface TcpClientDiscoverySpiMBeanpublic void spiStart(@Nullable String gridName) throws IgniteSpiException
spiStart in interface IgniteSpigridName - 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 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 IgniteSpiIgniteSpiException - Thrown in case of any error during SPI stop.public Collection<Object> injectables()
injectables in class IgniteSpiAdapterpublic Collection<ClusterNode> getRemoteNodes()
getRemoteNodes in interface DiscoverySpi@Nullable public ClusterNode getNode(UUID nodeId)
getNode in interface DiscoverySpinodeId - Node ID.null if node is not found.public boolean pingNode(UUID nodeId)
pingNode in interface DiscoverySpinodeId - 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 DiscoverySpiIgniteSpiException - If any error occurs.public void setAuthenticator(DiscoverySpiNodeAuthenticator auth)
setAuthenticator in interface DiscoverySpiauth - Discovery SPI authenticator.public void sendCustomEvent(Serializable evt)
sendCustomEvent in interface DiscoverySpievt - Event.public void failNode(UUID nodeId)
failNode in interface DiscoverySpinodeId - Node ID.@IgniteInstanceResource protected void injectResources(Ignite ignite)
injectResources in class IgniteSpiAdapterignite - Ignite.@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 DiscoverySpiattrs - Map of node attributes.ver - Product version.protected void onContextInitialized0(IgniteSpiContext spiCtx) throws IgniteSpiException
onContextInitialized0 in class IgniteSpiAdapterspiCtx - SPI context.IgniteSpiException - In case of errors.protected void onContextDestroyed0()
onContextDestroyed0 in class IgniteSpiAdapterpublic ClusterNode getLocalNode()
getLocalNode in interface DiscoverySpipublic 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 DiscoverySpilsnr - Listener to discovery events or null to unset the listener.public void setDataExchange(DiscoverySpiDataExchange exchange)
setDataExchange in interface DiscoverySpiexchange - Discovery data exchange handler.public void setMetricsProvider(DiscoveryMetricsProvider metricsProvider)
DiscoveryMetricsProvider.metrics() method to exchange
dynamic metrics between nodes.setMetricsProvider in interface DiscoverySpimetricsProvider - Provider of metrics data.public long getGridStartTime()
getGridStartTime in interface DiscoverySpi0 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, 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, TcpDiscoveryAbstractMessage msg, 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(TcpDiscoveryDuplicateIdMessage msg)
msg - Message.protected IgniteSpiException authenticationFailedError(TcpDiscoveryAuthFailedMessage msg)
msg - Message.protected IgniteSpiException checkFailedError(TcpDiscoveryCheckFailedMessage msg)
msg - Message.protected boolean ensured(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