Class StandaloneSpiContext

    • Constructor Detail

      • StandaloneSpiContext

        public StandaloneSpiContext()
    • Method Detail

      • addLocalEventListener

        public void addLocalEventListener​(GridLocalEventListener lsnr,
                                          int... types)
        Adds an event listener for local events.
        Specified by:
        addLocalEventListener in interface IgniteSpiContext
        Parameters:
        lsnr - Event listener for local events.
        types - Optional types for which this listener will be notified. If no types are provided this listener will be notified for all local events.
        See Also:
        Event
      • addLocalMessageListener

        public void addLocalMessageListener​(Object topic,
                                            IgniteBiPredicate<UUID,​?> p)
        Register an local message listener to receive messages sent by remote nodes. The underlying communication mechanism is defined by CommunicationSpi implementation used.
        Specified by:
        addLocalMessageListener in interface IgniteSpiContext
        Parameters:
        topic - Topic to subscribe to.
        p - Message predicate.
      • recordEvent

        public void recordEvent​(Event evt)
        Records local event.
        Specified by:
        recordEvent in interface IgniteSpiContext
        Parameters:
        evt - Local grid event to record.
      • get

        public <K,​V> V get​(String cacheName,
                                 K key)
        Gets object from cache.
        Specified by:
        get in interface IgniteSpiContext
        Type Parameters:
        K - Key type.
        V - Value type.
        Parameters:
        cacheName - Cache name.
        key - Object key.
        Returns:
        Cached object.
      • put

        public <K,​V> V put​(String cacheName,
                                 K key,
                                 V val,
                                 long ttl)
        Puts object in cache.
        Specified by:
        put in interface IgniteSpiContext
        Type Parameters:
        K - Key type.
        V - Value type.
        Parameters:
        cacheName - Cache name.
        key - Object key.
        val - Cached object.
        ttl - Time to live, 0 means the entry will never expire.
        Returns:
        Previous value associated with specified key, possibly null.
      • putIfAbsent

        public <K,​V> V putIfAbsent​(String cacheName,
                                         K key,
                                         V val,
                                         long ttl)
        Puts object into cache if there was no previous object associated with given key.
        Specified by:
        putIfAbsent in interface IgniteSpiContext
        Type Parameters:
        K - Cache key type.
        V - Cache value type.
        Parameters:
        cacheName - Cache name.
        key - Cache key.
        val - Cache value.
        ttl - Time to live.
        Returns:
        Either existing value or null if there was no value for given key.
      • remove

        public <K,​V> V remove​(String cacheName,
                                    K key)
        Removes object from cache.
        Specified by:
        remove in interface IgniteSpiContext
        Type Parameters:
        K - Key type.
        V - Value type.
        Parameters:
        cacheName - Cache name.
        key - Object key.
        Returns:
        Previous value associated with specified key, possibly null.
      • containsKey

        public <K> boolean containsKey​(String cacheName,
                                       K key)
        Returns true if this cache contains a mapping for the specified key.
        Specified by:
        containsKey in interface IgniteSpiContext
        Type Parameters:
        K - Key type.
        Parameters:
        cacheName - Cache name.
        key - Object key.
        Returns:
        true if this cache contains a mapping for the specified key.
      • partition

        public int partition​(String cacheName,
                             Object key)
        Calculates partition number for given key.
        Specified by:
        partition in interface IgniteSpiContext
        Parameters:
        cacheName - Cache name.
        key - Key.
        Returns:
        Partition.
      • node

        @Nullable
        public @Nullable ClusterNode node​(UUID nodeId)
        Gets a node instance based on its ID.
        Specified by:
        node in interface IgniteSpiContext
        Parameters:
        nodeId - ID of a node to get.
        Returns:
        Node for a given ID or null is such not has not been discovered.
        See Also:
        DiscoverySpi
      • pingNode

        public boolean pingNode​(UUID nodeId)
        Pings a remote node. The underlying communication is provided via DiscoverySpi.pingNode(UUID) implementation.

        Discovery SPIs usually have some latency in discovering failed nodes. Hence, communication to remote nodes may fail at times if an attempt was made to establish communication with a failed node. This method can be used to check if communication has failed due to node failure or due to some other reason.

        Specified by:
        pingNode in interface IgniteSpiContext
        Parameters:
        nodeId - ID of a node to ping.
        Returns:
        true if node for a given ID is alive, false otherwise.
        See Also:
        DiscoverySpi
      • isEventRecordable

        public boolean isEventRecordable​(int... types)
        Checks whether all provided event types are recordable.
        Specified by:
        isEventRecordable in interface IgniteSpiContext
        Parameters:
        types - Event types to check.
        Returns:
        Whether or not all provided event types are recordable..
      • removeMessageListener

        public boolean removeMessageListener​(GridMessageListener lsnr,
                                             String topic)
        Removes a previously registered message listener.
        Specified by:
        removeMessageListener in interface IgniteSpiContext
        Parameters:
        lsnr - Message listener to remove.
        topic - Topic to unregister listener for.
        Returns:
        true of message listener was removed, false if it was not previously registered.
      • send

        public void send​(ClusterNode node,
                         Serializable msg,
                         String topic)
        Sends a message to a remote node. The underlying communication mechanism is defined by CommunicationSpi implementation used.
        Specified by:
        send in interface IgniteSpiContext
        Parameters:
        node - Node to send a message to.
        msg - Message to send.
        topic - Topic to send message to.
      • validateNode

        @Nullable
        public @Nullable IgniteNodeValidationResult validateNode​(ClusterNode node)
        Validates that new node can join grid topology, this method is called on coordinator node before new node joins topology.
        Specified by:
        validateNode in interface IgniteSpiContext
        Parameters:
        node - Joining node.
        Returns:
        Validation result or null in case of success.
      • isStopping

        public boolean isStopping()
        Specified by:
        isStopping in interface IgniteSpiContext
        Returns:
        True if node started shutdown sequence.
      • tryFailNode

        public boolean tryFailNode​(UUID nodeId,
                                   @Nullable
                                   @Nullable String warning)
        Specified by:
        tryFailNode in interface IgniteSpiContext
        Parameters:
        nodeId - Node ID.
        warning - Warning to be shown on all cluster nodes.
        Returns:
        If node was failed.
      • failNode

        public void failNode​(UUID nodeId,
                             @Nullable
                             @Nullable String warning)
        Specified by:
        failNode in interface IgniteSpiContext
        Parameters:
        nodeId - Node ID.
        warning - Warning to be shown on all cluster nodes.
      • getOrCreateMetricRegistry

        public ReadOnlyMetricRegistry getOrCreateMetricRegistry​(String name)
        Returns existing or newly created instance of metric registry with given name.
        Specified by:
        getOrCreateMetricRegistry in interface IgniteSpiContext
        Parameters:
        name - Metric registry name.
        Returns:
        Existing or newly created instance of metric registry.
      • removeMetricRegistry

        public void removeMetricRegistry​(String name)
        Removes metric registry with given name.
        Specified by:
        removeMetricRegistry in interface IgniteSpiContext
        Parameters:
        name - Metric registry name.