Class IsolatedDiscoverySpi
- java.lang.Object
-
- org.apache.ignite.spi.IgniteSpiAdapter
-
- org.apache.ignite.spi.discovery.isolated.IsolatedDiscoverySpi
-
- All Implemented Interfaces:
org.apache.ignite.internal.managers.discovery.IgniteDiscoverySpi,DiscoverySpi,IgniteSpi
@IgniteSpiMultipleInstancesSupport(true) @DiscoverySpiHistorySupport(true) @DiscoverySpiOrderSupport(true) public class IsolatedDiscoverySpi extends IgniteSpiAdapter implements org.apache.ignite.internal.managers.discovery.IgniteDiscoverySpi
Special discovery SPI implementation to start a single-node cluster in "isolated" mode. When used, node doesn't try to seek or communicate to other nodes that may be up and running even in the same JVM. At the same time all functions like sending discovery messages are functional with only note that no messages are sent to network but are processed by local node immediately when they are created.
-
-
Field Summary
-
Fields inherited from class org.apache.ignite.spi.IgniteSpiAdapter
ignite, igniteInstanceName, log
-
-
Constructor Summary
Constructors Constructor Description IsolatedDiscoverySpi()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanallNodesSupport(org.apache.ignite.internal.IgniteFeatures feature)voidclientReconnect()booleanclientReconnectSupported()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.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.protected voidinjectResources(Ignite ignite)Inject ignite instance.booleanisClientMode()Whether or not discovery is started in client mode.booleanknownNode(UUID nodeId)protected voidonContextInitialized0(IgniteSpiContext spiCtx)Method to be called in the end of onContextInitialized method.booleanpingNode(UUID nodeId)Pings the remote node to see if it's alive.voidresolveCommunicationFailure(ClusterNode node, Exception err)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.voidsetInternalListener(org.apache.ignite.internal.managers.discovery.IgniteDiscoverySpiInternalListener lsnr)For TESTING only.voidsetListener(@Nullable DiscoverySpiListener lsnr)Sets a listener for discovery events.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.voidsimulateNodeFailure()For TESTING only.voidspiStart(@Nullable String igniteInstanceName)This method is called to start SPI.voidspiStop()This method is called to stop SPI.booleansupportsCommunicationFailureResolve()-
Methods inherited from class org.apache.ignite.spi.IgniteSpiAdapter
addTimeoutObject, assertParameter, checkConfigurationConsistency0, clientFailureDetectionTimeout, configInfo, createSpiAttributeName, failureDetectionTimeout, failureDetectionTimeoutEnabled, failureDetectionTimeoutEnabled, getConsistentAttributeNames, getExceptionRegistry, getName, getNodeAttributes, getSpiContext, ignite, initFailureDetectionTimeout, injectables, isNodeStopping, onBeforeStart, onClientDisconnected, onClientReconnected, onContextDestroyed, onContextDestroyed0, onContextInitialized, registerMBean, removeTimeoutObject, setName, started, startInfo, startStopwatch, stopInfo, unregisterMBean
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.ignite.spi.IgniteSpi
getName, getNodeAttributes, onClientDisconnected, onClientReconnected, onContextDestroyed, onContextInitialized
-
-
-
-
Method Detail
-
consistentId
public Serializable consistentId() throws IgniteSpiException
Gets consistent ID.- Specified by:
consistentIdin interfaceDiscoverySpi- Returns:
- Consistent ID of this Ignite instance or
nullif not applicable. - Throws:
IgniteSpiException- If failed.
-
getRemoteNodes
public Collection<ClusterNode> getRemoteNodes()
Gets collection of remote nodes in grid or empty collection if no remote nodes found.- Specified by:
getRemoteNodesin interfaceDiscoverySpi- Returns:
- Collection of remote nodes.
-
getLocalNode
public ClusterNode getLocalNode()
Gets local node.- Specified by:
getLocalNodein interfaceDiscoverySpi- Overrides:
getLocalNodein classIgniteSpiAdapter- Returns:
- Local node.
-
getNode
public ClusterNode getNode(UUID nodeId)
Gets node by ID.- Specified by:
getNodein interfaceDiscoverySpi- Parameters:
nodeId- Node ID.- Returns:
- Node with given ID or
nullif node is not found.
-
pingNode
public boolean pingNode(UUID nodeId)
Pings the remote node to see if it's alive.- Specified by:
pingNodein interfaceDiscoverySpi- Parameters:
nodeId- Node Id.- Returns:
trueif node alive,falseotherwise.
-
setNodeAttributes
public 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- Specified by:
setNodeAttributesin interfaceDiscoverySpi- Parameters:
attrs- Map of node attributes.ver- Product version.
-
setListener
public void setListener(@Nullable @Nullable DiscoverySpiListener lsnr)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
- Specified by:
setListenerin interfaceDiscoverySpi- Parameters:
lsnr- Listener to discovery events ornullto unset the listener.
-
setDataExchange
public void setDataExchange(DiscoverySpiDataExchange exchange)
Sets a handler for initial data exchange between Ignite nodes.- Specified by:
setDataExchangein interfaceDiscoverySpi- Parameters:
exchange- Discovery data exchange handler.
-
setMetricsProvider
public void setMetricsProvider(DiscoveryMetricsProvider metricsProvider)
Sets discovery metrics provider. Use metrics provided byDiscoveryMetricsProvider.metrics()method to exchange dynamic metrics between nodes.- Specified by:
setMetricsProviderin interfaceDiscoverySpi- Parameters:
metricsProvider- Provider of metrics data.
-
disconnect
public 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.- Specified by:
disconnectin interfaceDiscoverySpi- Throws:
IgniteSpiException- If any error occurs.
-
setAuthenticator
public void setAuthenticator(DiscoverySpiNodeAuthenticator auth)
Sets discovery SPI node authenticator. This method is called before SPI start() method.- Specified by:
setAuthenticatorin interfaceDiscoverySpi- Parameters:
auth- Discovery SPI authenticator.
-
getGridStartTime
public 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.- Specified by:
getGridStartTimein interfaceDiscoverySpi- Returns:
- Start time of the first node in grid or
0if SPI implementation does not support this method.
-
sendCustomEvent
public void sendCustomEvent(DiscoverySpiCustomMessage msg) throws IgniteException
Sends custom message across the ring.- Specified by:
sendCustomEventin interfaceDiscoverySpi- Parameters:
msg- Custom message.- Throws:
IgniteException- if failed to sent the event message.
-
failNode
public void failNode(UUID nodeId, @Nullable @Nullable String warning)
Initiates failure of provided node.- Specified by:
failNodein interfaceDiscoverySpi- Parameters:
nodeId- Node ID.warning- Warning to be shown on all cluster nodes.
-
isClientMode
public boolean isClientMode() throws IllegalStateExceptionWhether or not discovery is started in client mode.- Specified by:
isClientModein interfaceDiscoverySpi- Returns:
trueif node is in client mode.- Throws:
IllegalStateException- If discovery SPI has not started.
-
spiStart
public void spiStart(@Nullable @Nullable String igniteInstanceName) throws IgniteSpiExceptionThis method is called to start SPI. After this method returns successfully kernel assumes that SPI is fully operational.- Specified by:
spiStartin interfaceIgniteSpi- Parameters:
igniteInstanceName- Name of Ignite instance this SPI is being started for (nullfor default Ignite instance).- Throws:
IgniteSpiException- Throws in case of any error during SPI start.
-
spiStop
public void spiStop() throws IgniteSpiExceptionThis method is called to stop SPI. After this method returns kernel assumes that this SPI is finished and all resources acquired by it are released.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.
- Specified by:
spiStopin interfaceIgniteSpi- Throws:
IgniteSpiException- Thrown in case of any error during SPI stop.
-
onContextInitialized0
protected void onContextInitialized0(IgniteSpiContext spiCtx) throws IgniteSpiException
Method to be called in the end of onContextInitialized method.- Overrides:
onContextInitialized0in classIgniteSpiAdapter- Parameters:
spiCtx- SPI context.- Throws:
IgniteSpiException- In case of errors.
-
knownNode
public boolean knownNode(UUID nodeId)
- Specified by:
knownNodein interfaceorg.apache.ignite.internal.managers.discovery.IgniteDiscoverySpi- Parameters:
nodeId- Node ID.- Returns:
Trueif node joining or already joined topology.
-
clientReconnectSupported
public boolean clientReconnectSupported()
- Specified by:
clientReconnectSupportedin interfaceorg.apache.ignite.internal.managers.discovery.IgniteDiscoverySpi- Returns:
Trueif SPI supports client reconnect.
-
clientReconnect
public void clientReconnect()
- Specified by:
clientReconnectin interfaceorg.apache.ignite.internal.managers.discovery.IgniteDiscoverySpi
-
injectResources
protected void injectResources(Ignite ignite)
Inject ignite instance.- Overrides:
injectResourcesin classIgniteSpiAdapter- Parameters:
ignite- Ignite instance.
-
allNodesSupport
public boolean allNodesSupport(org.apache.ignite.internal.IgniteFeatures feature)
- Specified by:
allNodesSupportin interfaceorg.apache.ignite.internal.managers.discovery.IgniteDiscoverySpi- Parameters:
feature- Feature to check.- Returns:
trueif all nodes support the given feature.
-
simulateNodeFailure
public void simulateNodeFailure()
For TESTING only.- Specified by:
simulateNodeFailurein interfaceorg.apache.ignite.internal.managers.discovery.IgniteDiscoverySpi
-
setInternalListener
public void setInternalListener(org.apache.ignite.internal.managers.discovery.IgniteDiscoverySpiInternalListener lsnr)
For TESTING only.- Specified by:
setInternalListenerin interfaceorg.apache.ignite.internal.managers.discovery.IgniteDiscoverySpi- Parameters:
lsnr- Listener.
-
supportsCommunicationFailureResolve
public boolean supportsCommunicationFailureResolve()
- Specified by:
supportsCommunicationFailureResolvein interfaceorg.apache.ignite.internal.managers.discovery.IgniteDiscoverySpi- Returns:
Trueif supports communication error resolve.
-
resolveCommunicationFailure
public void resolveCommunicationFailure(ClusterNode node, Exception err)
- Specified by:
resolveCommunicationFailurein interfaceorg.apache.ignite.internal.managers.discovery.IgniteDiscoverySpi- Parameters:
node- Problem node.err- Connection error.
-
-