@IgniteSpiMultipleInstancesSupport(value=true) @DiscoverySpiOrderSupport(value=true) @DiscoverySpiHistorySupport(value=true) public class TcpDiscoverySpi extends IgniteSpiAdapter implements DiscoverySpi, TcpDiscoverySpiMBean
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.
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)
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 |
---|---|
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 50ms).
|
static long |
DFLT_ACK_TIMEOUT_CLIENT
Default timeout for receiving message acknowledgement in milliseconds (value is 700ms).
|
static long |
DFLT_HEARTBEAT_FREQ
Default heartbeat messages issuing frequency (value is 100ms).
|
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 5000ms).
|
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_SOCK_TIMEOUT_CLIENT
Default socket operations timeout in milliseconds (value is 700ms).
|
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 org.apache.ignite.spi.discovery.tcp.TcpDiscoveryImpl |
impl |
protected CopyOnWriteArrayList<IgniteInClosure<Socket>> |
incomeConnLsnrs |
protected TcpDiscoveryIpFinder |
ipFinder
IP finder.
|
protected long |
ipFinderCleanFreq
IP finder clean frequency.
|
protected long |
joinTimeout
Join timeout.
|
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 Marshaller |
marsh
Marshaller.
|
protected long |
maxAckTimeout
Maximum message acknowledgement timeout.
|
protected int |
maxMissedClientHbs
Max heartbeats count node can miss without failing client node.
|
protected int |
maxMissedHbs
Max heartbeats count node can miss without initiating status check.
|
protected DiscoveryMetricsProvider |
metricsProvider
Metrics provider.
|
protected long |
netTimeout
Network timeout.
|
protected DiscoverySpiNodeAuthenticator |
nodeAuth
Node authenticator.
|
protected int |
reconCnt
Reconnect attempts count.
|
protected CopyOnWriteArrayList<IgniteInClosure<org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryAbstractMessage>> |
sendMsgLsnrs |
protected long |
sockTimeout
Socket operations timeout.
|
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.
|
gridName, ignite, nodeId
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!!!
|
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) |
int |
clientWorkerCount()
FOR TEST ONLY!!!
|
protected Map<Integer,byte[]> |
collectExchangeData(UUID nodeId) |
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)
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.
|
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 |
isForceServerMode()
If
true TcpDiscoverySpi will started in server mode regardless
of IgniteConfiguration.isClientMode() |
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 . |
void |
removeIncomeConnectionListener(IgniteInClosure<Socket> lsnr)
FOR TEST ONLY!!!
|
void |
removeSendMessageListener(IgniteInClosure<org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryAbstractMessage> lsnr)
FOR TEST ONLY!!!
|
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.
|
TcpDiscoverySpi |
setDataExchange(DiscoverySpiDataExchange exchange)
Sets a handler for initial data exchange between Ignite nodes.
|
TcpDiscoverySpi |
setForceServerMode(boolean forceSrvMode)
Sets force server mode flag.
|
TcpDiscoverySpi |
setHeartbeatFrequency(long hbFreq)
Sets delay between issuing of heartbeat messages.
|
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(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.
|
TcpDiscoverySpi |
setMaxMissedClientHeartbeats(int maxMissedClientHbs)
Sets max heartbeats count node can miss without failing client node.
|
TcpDiscoverySpi |
setMaxMissedHeartbeats(int maxMissedHbs)
Sets max heartbeats count node can miss without initiating status check.
|
TcpDiscoverySpi |
setMetricsProvider(DiscoveryMetricsProvider metricsProvider)
Sets discovery metrics provider.
|
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 |
setSocketTimeout(long sockTimeout)
Sets socket operations timeout.
|
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 |
spiStart(String gridName)
This method is called to start SPI.
|
void |
spiStop()
This method is called to stop SPI.
|
void |
waitForClientMessagePrecessed()
FOR TEST PURPOSE ONLY!
|
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.
|
addTimeoutObject, assertParameter, checkConfigurationConsistency0, configInfo, createSpiAttributeName, getConsistentAttributeNames, getExceptionRegistry, getIgniteHome, getLocalNodeId, getName, getNodeAttributes, getStartTimestamp, getStartTimestampFormatted, getUpTime, getUpTimeFormatted, isNodeStopping, onContextDestroyed, onContextInitialized, registerMBean, removeTimeoutObject, setName, startInfo, startStopwatch, stopInfo, unregisterMBean
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getName, getNodeAttributes, onContextDestroyed, onContextInitialized
getIgniteHome, getLocalNodeId, getName, getStartTimestamp, getStartTimestampFormatted, getUpTime, getUpTimeFormatted
public static final String ATTR_EXT_ADDRS
public static final int DFLT_PORT_RANGE
public static final int DFLT_PORT
public static final long DFLT_JOIN_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
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 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
protected String locAddr
protected TcpDiscoveryIpFinder ipFinder
protected long sockTimeout
protected long ackTimeout
protected long netTimeout
protected long joinTimeout
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 volatile long gridStartTime
protected final Marshaller marsh
protected final org.apache.ignite.spi.discovery.tcp.internal.TcpDiscoveryStatistics stats
protected int locPort
protected int locPortRange
protected int reconCnt
protected long statsPrintFreq
protected long maxAckTimeout
protected int maxMissedHbs
protected int maxMissedClientHbs
protected long ipFinderCleanFreq
protected DiscoverySpiNodeAuthenticator nodeAuth
protected final CopyOnWriteArrayList<IgniteInClosure<org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryAbstractMessage>> sendMsgLsnrs
protected final CopyOnWriteArrayList<IgniteInClosure<Socket>> incomeConnLsnrs
@LoggerResource protected IgniteLogger log
protected org.apache.ignite.spi.discovery.tcp.TcpDiscoveryImpl impl
public String getSpiState()
getSpiState
in interface TcpDiscoverySpiMBean
public int getMessageWorkerQueueSize()
getMessageWorkerQueueSize
in interface TcpDiscoverySpiMBean
@Nullable public UUID getCoordinator()
getCoordinator
in interface TcpDiscoverySpiMBean
public Collection<ClusterNode> getRemoteNodes()
getRemoteNodes
in interface DiscoverySpi
@Nullable public ClusterNode getNode(UUID nodeId)
getNode
in interface DiscoverySpi
nodeId
- Node ID.null
if node is not found.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 marshal evt.public void failNode(UUID nodeId)
failNode
in interface DiscoverySpi
nodeId
- Node ID.public void dumpDebugInfo()
dumpDebugInfo
in interface TcpDiscoverySpiMBean
public boolean isClientMode()
isClientMode
in interface DiscoverySpi
isClientMode
in interface TcpDiscoverySpiMBean
true
if node is in client mode.public boolean isForceServerMode()
true
TcpDiscoverySpi will started in server mode regardless
of IgniteConfiguration.isClientMode()
@IgniteSpiConfiguration(optional=true) public TcpDiscoverySpi setForceServerMode(boolean forceSrvMode)
If true
TcpDiscoverySpi is started in server mode regardless
of IgniteConfiguration.isClientMode()
.
forceSrvMode
- forceServerMode flag.this
for chaining.@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.public String getLocalAddress()
setLocalAddress(String)
method.@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 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
.
reconCnt
- Number of retries during message sending.setAckTimeout(long)
public long getMaxAckTimeout()
getMaxAckTimeout
in interface TcpDiscoverySpiMBean
@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.
maxAckTimeout
- Maximum acknowledgement timeout.public int getLocalPort()
getLocalPort
in interface TcpDiscoverySpiMBean
@IgniteSpiConfiguration(optional=true) public TcpDiscoverySpi setLocalPort(int locPort)
If not specified, default is DFLT_PORT
.
Affected server nodes only.
locPort
- Local port to bind.public int getLocalPortRange()
getLocalPortRange
in interface TcpDiscoverySpiMBean
@IgniteSpiConfiguration(optional=true) public TcpDiscoverySpi setLocalPortRange(int locPortRange)
getLocalPort()
up until
getLocalPort()
+ locPortRange
.
If not specified, default is DFLT_PORT_RANGE
.
Affected server nodes only.
locPortRange
- Local port range to bind.public int getMaxMissedHeartbeats()
getMaxMissedHeartbeats
in interface TcpDiscoverySpiMBean
@IgniteSpiConfiguration(optional=true) public TcpDiscoverySpi setMaxMissedHeartbeats(int maxMissedHbs)
If not provided, default value is DFLT_MAX_MISSED_HEARTBEATS
.
Affected server nodes only.
maxMissedHbs
- Max missed heartbeats.public int getMaxMissedClientHeartbeats()
getMaxMissedClientHeartbeats
in interface TcpDiscoverySpiMBean
@IgniteSpiConfiguration(optional=true) public TcpDiscoverySpi 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 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.public long getIpFinderCleanFrequency()
getIpFinderCleanFrequency
in interface TcpDiscoverySpiMBean
@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.public TcpDiscoveryIpFinder getIpFinder()
@IgniteSpiConfiguration(optional=true) public TcpDiscoverySpi setIpFinder(TcpDiscoveryIpFinder ipFinder)
If not provided TcpDiscoveryMulticastIpFinder
will be used by default.
ipFinder
- IP finder.@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
.
sockTimeout
- Socket connection timeout.@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
.
ackTimeout
- Acknowledgement timeout.@IgniteSpiConfiguration(optional=true) public TcpDiscoverySpi setNetworkTimeout(long netTimeout)
If not specified, default is DFLT_NETWORK_TIMEOUT
.
netTimeout
- Network timeout.public long getJoinTimeout()
getJoinTimeout
in interface TcpDiscoverySpiMBean
@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).TcpDiscoveryIpFinder.isShared()
@IgniteSpiConfiguration(optional=true) public TcpDiscoverySpi setThreadPriority(int threadPri)
If not provided, default value is DFLT_THREAD_PRI
threadPri
- Thread priority.@IgniteSpiConfiguration(optional=true) public TcpDiscoverySpi setHeartbeatFrequency(long hbFreq)
If not provided, default value is DFLT_HEARTBEAT_FREQ
.
hbFreq
- Heartbeat frequency in milliseconds.public long getTopHistorySize()
@IgniteSpiConfiguration(optional=true) public TcpDiscoverySpi 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.protected void initLocalNode(int srvPort, boolean addExtAddrAttr)
srvPort
- Server port.public Collection<Object> injectables()
injectables
in class IgniteSpiAdapter
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 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
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
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 TcpDiscoverySpi setDataExchange(DiscoverySpiDataExchange exchange)
setDataExchange
in interface DiscoverySpi
exchange
- Discovery data exchange handler.public TcpDiscoverySpi 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 Map<Integer,byte[]> collectExchangeData(UUID nodeId)
nodeId
- Node ID.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.public void spiStart(@Nullable 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 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 int clientWorkerCount()
public void addSendMessageListener(IgniteInClosure<org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryAbstractMessage> lsnr)
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 brakeConnection()
Follow @ApacheIgnite
Ignite Fabric : ver. 1.2.0-incubating Release Date : June 16 2015