Class IgniteSpiAdapter

    • Constructor Detail

      • IgniteSpiAdapter

        protected IgniteSpiAdapter()
        Creates new adapter and initializes it from the current (this) class. SPI name will be initialized to the simple name of the class (see Class.getSimpleName()).
    • Method Detail

      • startStopwatch

        protected void startStopwatch()
        Starts startup stopwatch.
      • onBeforeStart

        public final void onBeforeStart()
        This method is called by built-in managers implementation to avoid repeating SPI start attempts.
      • started

        public final boolean started()
        Checks if onBeforeStart() has been called on this SPI instance.
        Returns:
        True if onBeforeStart() has already been called.
      • getLocalNode

        protected ClusterNode getLocalNode()
        Returns:
        Local node.
      • getName

        public String getName()
        Gets SPI name.
        Specified by:
        getName in interface IgniteSpi
        Returns:
        SPI name.
      • ignite

        public Ignite ignite()
        Gets ignite instance.
        Returns:
        Ignite instance.
      • onContextInitialized

        public final void onContextInitialized​(IgniteSpiContext spiCtx)
                                        throws IgniteSpiException
        Callback invoked when SPI context is initialized. SPI implementation may store SPI context for future access.

        This method is invoked after IgniteSpi.spiStart(String) method is completed, so SPI should be fully functional at this point. Use this method for post-start initialization, such as subscribing a discovery listener, sending a message to remote node, etc...

        Specified by:
        onContextInitialized in interface IgniteSpi
        Parameters:
        spiCtx - Spi context.
        Throws:
        IgniteSpiException - If context initialization failed (grid will be stopped).
      • onContextInitialized0

        protected void onContextInitialized0​(IgniteSpiContext spiCtx)
                                      throws IgniteSpiException
        Method to be called in the end of onContextInitialized method.
        Parameters:
        spiCtx - SPI context.
        Throws:
        IgniteSpiException - In case of errors.
      • onContextDestroyed

        public final void onContextDestroyed()
        Callback invoked prior to stopping grid before SPI context is destroyed. Once this method is complete, grid will begin shutdown sequence. Use this callback for de-initialization logic that may involve SPI context. Note that invoking SPI context after this callback is complete is considered illegal and may produce unknown results.

        If IgniteSpiAdapter is used for SPI implementation, then it will replace actual context with dummy no-op context which is usually good-enough since grid is about to shut down.

        Specified by:
        onContextDestroyed in interface IgniteSpi
      • onClientDisconnected

        public void onClientDisconnected​(IgniteFuture<?> reconnectFut)
        Client node disconnected callback.
        Specified by:
        onClientDisconnected in interface IgniteSpi
        Parameters:
        reconnectFut - Future that will be completed when client reconnected.
      • onClientReconnected

        public void onClientReconnected​(boolean clusterRestarted)
        Client node reconnected callback.
        Specified by:
        onClientReconnected in interface IgniteSpi
        Parameters:
        clusterRestarted - True if all cluster nodes restarted while client was disconnected.
      • injectResources

        @IgniteInstanceResource
        protected void injectResources​(Ignite ignite)
        Inject ignite instance.
        Parameters:
        ignite - Ignite instance.
      • onContextDestroyed0

        protected void onContextDestroyed0()
        Method to be called in the beginning of onContextDestroyed() method.
      • injectables

        public Collection<Object> injectables()
        This method returns SPI internal instances that need to be injected as well. Usually these will be instances provided to SPI externally by user, e.g. during SPI configuration.
        Returns:
        Internal SPI objects that also need to be injected.
      • getSpiContext

        public IgniteSpiContext getSpiContext()
        Gets SPI context.
        Returns:
        SPI context.
      • getExceptionRegistry

        public org.apache.ignite.internal.util.IgniteExceptionRegistry getExceptionRegistry()
        Gets Exception registry.
        Returns:
        Exception registry.
      • getNodeAttributes

        public Map<String,​Object> getNodeAttributes()
                                                   throws IgniteSpiException
        This method is called before SPI starts (before method IgniteSpi.spiStart(String) is called). It allows SPI implementation to add attributes to a local node. Kernal collects these attributes from all SPI implementations loaded up and then passes it to discovery SPI so that they can be exchanged with other nodes.
        Specified by:
        getNodeAttributes in interface IgniteSpi
        Returns:
        Map of local node attributes this SPI wants to add.
        Throws:
        IgniteSpiException - Throws in case of any error.
      • assertParameter

        protected final void assertParameter​(boolean cond,
                                             String condDesc)
                                      throws IgniteSpiException
        Throws exception with uniform error message if given parameter's assertion condition is false.
        Parameters:
        cond - Assertion condition to check.
        condDesc - Description of failed condition. Note that this description should include JavaBean name of the property (not a variable name) as well condition in Java syntax like, for example:
              ...
              assertParameter(dirPath != null, "dirPath != null");
              ...
              
        Note that in case when variable name is the same as JavaBean property you can just copy Java condition expression into description as a string.
        Throws:
        IgniteSpiException - Thrown if given condition is false
      • startInfo

        protected final String startInfo()
        Gets uniformly formatted message for SPI start.
        Returns:
        Uniformly formatted message for SPI start.
      • stopInfo

        protected final String stopInfo()
        Gets uniformly format message for SPI stop.
        Returns:
        Uniformly format message for SPI stop.
      • configInfo

        protected final String configInfo​(String name,
                                          Object val)
        Gets uniformed string for configuration parameter.
        Parameters:
        name - Parameter name.
        val - Parameter value.
        Returns:
        Uniformed string for configuration parameter.
      • registerMBean

        protected final <T extends IgniteSpiManagementMBean> void registerMBean​(String igniteInstanceName,
                                                                                T impl,
                                                                                Class<T> mbeanItf)
                                                                         throws IgniteSpiException
        Registers SPI MBean. Note that SPI can only register one MBean.
        Type Parameters:
        T - Type of the MBean
        Parameters:
        igniteInstanceName - Ignite instance name. If null, then name will be empty.
        impl - MBean implementation.
        mbeanItf - MBean interface (if null, then standard JMX naming conventions are used.
        Throws:
        IgniteSpiException - If registration failed.
      • isNodeStopping

        protected final boolean isNodeStopping()
        Returns:
        True if node is stopping.
      • checkConfigurationConsistency0

        protected void checkConfigurationConsistency0​(IgniteSpiContext spiCtx,
                                                      ClusterNode node,
                                                      boolean starting)
                                               throws IgniteSpiException
        Method which is called in the end of checkConfigurationConsistency() method. May be overriden in SPIs.
        Parameters:
        spiCtx - SPI context.
        node - Remote node.
        starting - If this node is starting or not.
        Throws:
        IgniteSpiException - in case of errors.
      • getConsistentAttributeNames

        protected List<String> getConsistentAttributeNames()
        Returns back a list of attributes that should be consistent for this SPI. Consistency means that remote node has to have the same attribute with the same value.
        Returns:
        List or attribute names.
      • createSpiAttributeName

        protected String createSpiAttributeName​(String attrName)
        Creates new name for the given attribute. Name contains SPI name prefix.
        Parameters:
        attrName - SPI attribute name.
        Returns:
        New name with SPI name prefix.
      • initFailureDetectionTimeout

        protected void initFailureDetectionTimeout()
        Initiates and checks failure detection timeout value.
      • failureDetectionTimeoutEnabled

        public void failureDetectionTimeoutEnabled​(boolean enabled)
        Enables or disables failure detection timeout.
        Parameters:
        enabled - true if enable, false otherwise.
      • failureDetectionTimeoutEnabled

        public boolean failureDetectionTimeoutEnabled()
        Checks whether failure detection timeout is enabled for this IgniteSpi.
        Returns:
        true if enabled, false otherwise.
      • clientFailureDetectionTimeout

        public long clientFailureDetectionTimeout()
        Returns client failure detection timeout set to use for network related operations.
        Returns:
        client failure detection timeout in milliseconds or 0 if the timeout is disabled.
      • failureDetectionTimeout

        public long failureDetectionTimeout()
        Returns failure detection timeout set to use for network related operations.
        Returns:
        failure detection timeout in milliseconds or 0 if the timeout is disabled.