Class 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.
    • Constructor Detail

      • IsolatedDiscoverySpi

        public IsolatedDiscoverySpi()
    • Method Detail

      • getRemoteNodes

        public Collection<ClusterNode> getRemoteNodes()
        Gets collection of remote nodes in grid or empty collection if no remote nodes found.
        Specified by:
        getRemoteNodes in interface DiscoverySpi
        Returns:
        Collection of remote nodes.
      • getNode

        public ClusterNode getNode​(UUID nodeId)
        Gets node by ID.
        Specified by:
        getNode in interface DiscoverySpi
        Parameters:
        nodeId - Node ID.
        Returns:
        Node with given ID or null if node is not found.
      • pingNode

        public boolean pingNode​(UUID nodeId)
        Pings the remote node to see if it's alive.
        Specified by:
        pingNode in interface DiscoverySpi
        Parameters:
        nodeId - Node Id.
        Returns:
        true if node alive, false otherwise.
      • 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:
        setNodeAttributes in interface DiscoverySpi
        Parameters:
        attrs - Map of node attributes.
        ver - Product version.
      • setListener

        public void setListener​(@Nullable
                                @Nullable DiscoverySpiListener lsnr)
        Sets a listener for discovery events. Refer to DiscoveryEvent for a set of all possible discovery events.

        TODO: This method should be removed from public API in Apache Ignite 3.0

        Specified by:
        setListener in interface DiscoverySpi
        Parameters:
        lsnr - Listener to discovery events or null to unset the listener.
      • setDataExchange

        public void setDataExchange​(DiscoverySpiDataExchange exchange)
        Sets a handler for initial data exchange between Ignite nodes.
        Specified by:
        setDataExchange in interface DiscoverySpi
        Parameters:
        exchange - Discovery data exchange handler.
      • 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:
        getGridStartTime in interface DiscoverySpi
        Returns:
        Start time of the first node in grid or 0 if SPI implementation does not support this method.
      • failNode

        public void failNode​(UUID nodeId,
                             @Nullable
                             @Nullable String warning)
        Initiates failure of provided node.
        Specified by:
        failNode in interface DiscoverySpi
        Parameters:
        nodeId - Node ID.
        warning - Warning to be shown on all cluster nodes.
      • spiStart

        public void spiStart​(@Nullable
                             @Nullable String igniteInstanceName)
                      throws IgniteSpiException
        This method is called to start SPI. After this method returns successfully kernel assumes that SPI is fully operational.
        Specified by:
        spiStart in interface IgniteSpi
        Parameters:
        igniteInstanceName - Name of Ignite instance this SPI is being started for (null for default Ignite instance).
        Throws:
        IgniteSpiException - Throws in case of any error during SPI start.
      • spiStop

        public void spiStop()
                     throws IgniteSpiException
        This 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:
        spiStop in interface IgniteSpi
        Throws:
        IgniteSpiException - Thrown in case of any error during SPI stop.
      • knownNode

        public boolean knownNode​(UUID nodeId)
        Specified by:
        knownNode in interface org.apache.ignite.internal.managers.discovery.IgniteDiscoverySpi
        Parameters:
        nodeId - Node ID.
        Returns:
        True if node joining or already joined topology.
      • clientReconnectSupported

        public boolean clientReconnectSupported()
        Specified by:
        clientReconnectSupported in interface org.apache.ignite.internal.managers.discovery.IgniteDiscoverySpi
        Returns:
        True if SPI supports client reconnect.
      • clientReconnect

        public void clientReconnect()
        Specified by:
        clientReconnect in interface org.apache.ignite.internal.managers.discovery.IgniteDiscoverySpi
      • injectResources

        protected void injectResources​(Ignite ignite)
        Inject ignite instance.
        Overrides:
        injectResources in class IgniteSpiAdapter
        Parameters:
        ignite - Ignite instance.
      • allNodesSupport

        public boolean allNodesSupport​(org.apache.ignite.internal.IgniteFeatures feature)
        Specified by:
        allNodesSupport in interface org.apache.ignite.internal.managers.discovery.IgniteDiscoverySpi
        Parameters:
        feature - Feature to check.
        Returns:
        true if all nodes support the given feature.
      • simulateNodeFailure

        public void simulateNodeFailure()
        For TESTING only.
        Specified by:
        simulateNodeFailure in interface org.apache.ignite.internal.managers.discovery.IgniteDiscoverySpi
      • setInternalListener

        public void setInternalListener​(org.apache.ignite.internal.managers.discovery.IgniteDiscoverySpiInternalListener lsnr)
        For TESTING only.
        Specified by:
        setInternalListener in interface org.apache.ignite.internal.managers.discovery.IgniteDiscoverySpi
        Parameters:
        lsnr - Listener.
      • supportsCommunicationFailureResolve

        public boolean supportsCommunicationFailureResolve()
        Specified by:
        supportsCommunicationFailureResolve in interface org.apache.ignite.internal.managers.discovery.IgniteDiscoverySpi
        Returns:
        True if supports communication error resolve.
      • resolveCommunicationFailure

        public void resolveCommunicationFailure​(ClusterNode node,
                                                Exception err)
        Specified by:
        resolveCommunicationFailure in interface org.apache.ignite.internal.managers.discovery.IgniteDiscoverySpi
        Parameters:
        node - Problem node.
        err - Connection error.