Package org.apache.ignite.spi.discovery
Interface DiscoverySpi
-
- All Superinterfaces:
IgniteSpi
- All Known Implementing Classes:
IsolatedDiscoverySpi,TcpDiscoverySpi,ZookeeperDiscoverySpi
public interface DiscoverySpi extends IgniteSpi
Grid discovery SPI allows to discover remote nodes in grid.The default discovery SPI is
TcpDiscoverySpiwith default configuration which allows all nodes in local network (with enabled multicast) to discover each other.Ignite provides the following
NOTE: this SPI (i.e. methods in this interface) should never be used directly. SPIs provide internal view on the subsystem and is used internally by Ignite kernal. In rare use cases when access to a specific implementation of this SPI is required - an instance of this SPI can be obtained viaGridDeploymentSpiimplementation:Ignite.configuration()method to check its configuration properties or call other non-SPI methods. Note again that calling methods from this interface on the obtained instance can lead to undefined behavior and explicitly not supported.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description @Nullable SerializableconsistentId()Gets consistent ID.voiddisconnect()Tells discovery SPI to disconnect from topology.voidfailNode(UUID nodeId, @Nullable String warning)Initiates failure of provided node.longgetGridStartTime()Gets start time of the very first node in the grid.ClusterNodegetLocalNode()Gets local node.@Nullable ClusterNodegetNode(UUID nodeId)Gets node by ID.Collection<ClusterNode>getRemoteNodes()Gets collection of remote nodes in grid or empty collection if no remote nodes found.booleanisClientMode()Whether or not discovery is started in client mode.booleanpingNode(UUID nodeId)Pings the remote node to see if it's alive.voidsendCustomEvent(DiscoverySpiCustomMessage msg)Sends custom message across the ring.voidsetAuthenticator(DiscoverySpiNodeAuthenticator auth)Sets discovery SPI node authenticator.voidsetDataExchange(DiscoverySpiDataExchange exchange)Sets a handler for initial data exchange between Ignite nodes.voidsetListener(@Nullable DiscoverySpiListener lsnr)Deprecated.voidsetMetricsProvider(DiscoveryMetricsProvider metricsProvider)Sets discovery metrics provider.voidsetNodeAttributes(Map<String,Object> attrs, IgniteProductVersion ver)Sets node attributes and node version which will be distributed in grid during join process.-
Methods inherited from interface org.apache.ignite.spi.IgniteSpi
getName, getNodeAttributes, onClientDisconnected, onClientReconnected, onContextDestroyed, onContextInitialized, spiStart, spiStop
-
-
-
-
Method Detail
-
consistentId
@Nullable @Nullable Serializable consistentId() throws IgniteSpiException
Gets consistent ID.- Returns:
- Consistent ID of this Ignite instance or
nullif not applicable. - Throws:
IgniteSpiException- If failed.
-
getRemoteNodes
Collection<ClusterNode> getRemoteNodes()
Gets collection of remote nodes in grid or empty collection if no remote nodes found.- Returns:
- Collection of remote nodes.
-
getLocalNode
ClusterNode getLocalNode()
Gets local node.- Returns:
- Local node.
-
getNode
@Nullable @Nullable ClusterNode getNode(UUID nodeId)
Gets node by ID.- Parameters:
nodeId- Node ID.- Returns:
- Node with given ID or
nullif node is not found.
-
pingNode
boolean pingNode(UUID nodeId)
Pings the remote node to see if it's alive.- Parameters:
nodeId- Node Id.- Returns:
trueif node alive,falseotherwise.
-
setNodeAttributes
void setNodeAttributes(Map<String,Object> attrs, IgniteProductVersion ver)
Sets node attributes and node version which will be distributed in grid during join process. Note that these attributes cannot be changed and set only once. set- Parameters:
attrs- Map of node attributes.ver- Product version.
-
setListener
@Deprecated void setListener(@Nullable @Nullable DiscoverySpiListener lsnr)
Deprecated.Sets a listener for discovery events. Refer toDiscoveryEventfor a set of all possible discovery events.TODO: This method should be removed from public API in Apache Ignite 3.0
- Parameters:
lsnr- Listener to discovery events ornullto unset the listener.
-
setDataExchange
void setDataExchange(DiscoverySpiDataExchange exchange)
Sets a handler for initial data exchange between Ignite nodes.- Parameters:
exchange- Discovery data exchange handler.
-
setMetricsProvider
void setMetricsProvider(DiscoveryMetricsProvider metricsProvider)
Sets discovery metrics provider. Use metrics provided byDiscoveryMetricsProvider.metrics()method to exchange dynamic metrics between nodes.- Parameters:
metricsProvider- Provider of metrics data.
-
disconnect
void disconnect() throws IgniteSpiExceptionTells discovery SPI to disconnect from topology. This is very close to callingIgniteSpi.spiStop()with accounting that it is not a full stop, but disconnect due to segmentation.- Throws:
IgniteSpiException- If any error occurs.
-
setAuthenticator
void setAuthenticator(DiscoverySpiNodeAuthenticator auth)
Sets discovery SPI node authenticator. This method is called before SPI start() method.- Parameters:
auth- Discovery SPI authenticator.
-
getGridStartTime
long getGridStartTime()
Gets start time of the very first node in the grid. This value should be the same on all nodes in the grid and it should not change even if very first node fails of leaves grid.- Returns:
- Start time of the first node in grid or
0if SPI implementation does not support this method.
-
sendCustomEvent
void sendCustomEvent(DiscoverySpiCustomMessage msg) throws IgniteException
Sends custom message across the ring.- Parameters:
msg- Custom message.- Throws:
IgniteException- if failed to sent the event message.
-
failNode
void failNode(UUID nodeId, @Nullable @Nullable String warning)
Initiates failure of provided node.- Parameters:
nodeId- Node ID.warning- Warning to be shown on all cluster nodes.
-
isClientMode
boolean isClientMode() throws IllegalStateExceptionWhether or not discovery is started in client mode.- Returns:
trueif node is in client mode.- Throws:
IllegalStateException- If discovery SPI has not started.
-
-