Class IgniteClusterImpl

    • Constructor Detail

      • IgniteClusterImpl

        public IgniteClusterImpl()
        Required by Externalizable.
      • IgniteClusterImpl

        public IgniteClusterImpl​(GridKernalContext ctx)
        Parameters:
        ctx - Kernal context.
    • Method Detail

      • start

        public void start()
        Invoke when metastorage ready to start component.
      • forLocal

        public ClusterGroup forLocal()
        Gets a cluster group consisting from the local node.
        Specified by:
        forLocal in interface IgniteCluster
        Returns:
        Cluster group consisting from the local node.
      • nodeLocalMap

        public <K,​V> ConcurrentMap<K,​V> nodeLocalMap()
        Gets node-local storage instance.

        Node-local values are similar to thread locals in a way that these values are not distributed and kept only on local node (similar like thread local values are attached to the current thread only). Node-local values are used primarily by closures executed from the remote nodes to keep intermediate state on the local node between executions.

        There's only one instance of node local storage per local node. Node local storage is based on ConcurrentMap and is safe for multi-threaded access.

        Specified by:
        nodeLocalMap in interface IgniteCluster
        Type Parameters:
        K - Type of keys in the node local map.
        V - Type of mapped values in the node local map.
        Returns:
        Node local storage instance for the local node.
      • pingNode

        public boolean pingNode​(UUID nodeId)
        Pings a remote node.

        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 IgniteCluster
        Parameters:
        nodeId - ID of a node to ping.
        Returns:
        true if node for a given ID is alive, false otherwise.
        See Also:
        DiscoverySpi
      • topologyVersion

        public long topologyVersion()
        Gets current topology version. In case of TCP discovery (see TcpDiscoverySpi) topology versions are sequential - they start from '1' and get incremented every time whenever a node joins or leaves. For other discovery SPIs topology versions may not be (and likely are not) sequential.
        Specified by:
        topologyVersion in interface IgniteCluster
        Returns:
        Current topology version.
      • topology

        public Collection<ClusterNode> topology​(long topVer)
                                         throws UnsupportedOperationException
        Gets a topology by version. Returns null if topology history storage doesn't contain specified topology version (history currently keeps last 1000 snapshots).
        Specified by:
        topology in interface IgniteCluster
        Parameters:
        topVer - Topology version.
        Returns:
        Collection of grid nodes which represented by specified topology version, if it is present in history storage, null otherwise.
        Throws:
        UnsupportedOperationException - If underlying SPI implementation does not support topology history. Currently only TcpDiscoverySpi supports topology history.
      • startNodes

        public Collection<ClusterStartNodeResult> startNodes​(File file,
                                                             boolean restart,
                                                             int timeout,
                                                             int maxConn)
                                                      throws IgniteException
        Starts one or more nodes on remote host(s).

        This method takes INI file which defines all startup parameters. It can contain one or more sections, each for a host or for range of hosts (note that they must have different names) and a special 'defaults' section with default values. They are applied to undefined parameters in host's sections.

        Returned result is collection of tuples. Each tuple corresponds to one node start attempt and contains hostname, success flag and error message if attempt was not successful. Note that successful attempt doesn't mean that node was actually started and joined topology. For large topologies (> 100s nodes) it can take over 10 minutes for all nodes to start. See individual node logs for details.

        Supports asynchronous execution (see IgniteAsyncSupport).

        Specified by:
        startNodes in interface IgniteCluster
        Parameters:
        file - Configuration file.
        restart - Whether to stop existing nodes. If true, all existing nodes on the host will be stopped before starting new ones. If false, nodes will be started only if there are less nodes on the host than expected.
        timeout - Connection timeout.
        maxConn - Number of parallel SSH connections to one host.
        Returns:
        Collection of start node results, each containing host name, result (success or failure) and error message (if any).
        Throws:
        IgniteException - In case of error.
      • startNodesAsync

        public IgniteFuture<Collection<ClusterStartNodeResult>> startNodesAsync​(File file,
                                                                                boolean restart,
                                                                                int timeout,
                                                                                int maxConn)
                                                                         throws IgniteException
        Starts one or more nodes on remote host(s) asynchronously.

        This method takes INI file which defines all startup parameters. It can contain one or more sections, each for a host or for range of hosts (note that they must have different names) and a special 'defaults' section with default values. They are applied to undefined parameters in host's sections.

        Completed future contains collection of tuples. Each tuple corresponds to one node start attempt and contains hostname, success flag and error message if attempt was not successful. Note that successful attempt doesn't mean that node was actually started and joined topology. For large topologies (> 100s nodes) it can take over 10 minutes for all nodes to start. See individual node logs for details.

        Specified by:
        startNodesAsync in interface IgniteCluster
        Parameters:
        file - Configuration file.
        restart - Whether to stop existing nodes. If true, all existing nodes on the host will be stopped before starting new ones. If false, nodes will be started only if there are less nodes on the host than expected.
        timeout - Connection timeout.
        maxConn - Number of parallel SSH connections to one host.
        Returns:
        a Future representing pending completion of the starting nodes.
        Throws:
        IgniteException - In case of error.
      • startNodes

        public Collection<ClusterStartNodeResult> startNodes​(Collection<Map<String,​Object>> hosts,
                                                             @Nullable
                                                             @Nullable Map<String,​Object> dflts,
                                                             boolean restart,
                                                             int timeout,
                                                             int maxConn)
                                                      throws IgniteException
        Starts one or more nodes on remote host(s).

        Each map in hosts collection defines startup parameters for one host or for a range of hosts. The following parameters are supported:

        Name Type Description
        host String Hostname (required). Can define several hosts if their IPs are sequential. E.g., 10.0.0.1~5 defines range of five IP addresses. Other parameters are applied to all hosts equally.
        port Integer Port number (default is 22).
        uname String Username (if not defined, current local username will be used).
        passwd String Password (if not defined, private key file must be defined).
        key File Private key file (if not defined, password must be defined).
        nodes Integer Expected number of nodes on the host. If some nodes are started already, then only remaining nodes will be started. If current count of nodes is equal to this number, and restart flag is false, then nothing will happen.
        igniteHome String Path to Ignite installation folder. If not defined, IGNITE_HOME environment variable must be set on remote hosts.
        cfg String Path to configuration file (relative to igniteHome).
        script String Custom startup script file name and path (relative to igniteHome). You can also specify a space-separated list of parameters in the same string (for example: "bin/my-custom-script.sh -v").

        dflts map defines default values. They are applied to undefined parameters in hosts collection.

        Returned result is collection of tuples. Each tuple corresponds to one node start attempt and contains hostname, success flag and error message if attempt was not successful. Note that successful attempt doesn't mean that node was actually started and joined topology. For large topologies (> 100s nodes) it can take over 10 minutes for all nodes to start. See individual node logs for details.

        Supports asynchronous execution (see IgniteAsyncSupport).

        Specified by:
        startNodes in interface IgniteCluster
        Parameters:
        hosts - Startup parameters.
        dflts - Default values.
        restart - Whether to stop existing nodes. If true, all existing nodes on the host will be stopped before starting new ones. If false, nodes will be started only if there are less nodes on the host than expected.
        timeout - Connection timeout in milliseconds.
        maxConn - Number of parallel SSH connections to one host.
        Returns:
        Collection of start node results, each containing host name, result (success or failure) and error message (if any).
        Throws:
        IgniteException - In case of error.
      • startNodesAsync

        public IgniteFuture<Collection<ClusterStartNodeResult>> startNodesAsync​(Collection<Map<String,​Object>> hosts,
                                                                                @Nullable
                                                                                @Nullable Map<String,​Object> dflts,
                                                                                boolean restart,
                                                                                int timeout,
                                                                                int maxConn)
                                                                         throws IgniteException
        Starts one or more nodes on remote host(s) asynchronously.

        Each map in hosts collection defines startup parameters for one host or for a range of hosts. The following parameters are supported:

        Name Type Description
        host String Hostname (required). Can define several hosts if their IPs are sequential. E.g., 10.0.0.1~5 defines range of five IP addresses. Other parameters are applied to all hosts equally.
        port Integer Port number (default is 22).
        uname String Username (if not defined, current local username will be used).
        passwd String Password (if not defined, private key file must be defined).
        key File Private key file (if not defined, password must be defined).
        nodes Integer Expected number of nodes on the host. If some nodes are started already, then only remaining nodes will be started. If current count of nodes is equal to this number, and restart flag is false, then nothing will happen.
        igniteHome String Path to Ignite installation folder. If not defined, IGNITE_HOME environment variable must be set on remote hosts.
        cfg String Path to configuration file (relative to igniteHome).
        script String Custom startup script file name and path (relative to igniteHome). You can also specify a space-separated list of parameters in the same string (for example: "bin/my-custom-script.sh -v").

        dflts map defines default values. They are applied to undefined parameters in hosts collection.

        Completed future contains collection of tuples. Each tuple corresponds to one node start attempt and contains hostname, success flag and error message if attempt was not successful. Note that successful attempt doesn't mean that node was actually started and joined topology. For large topologies (> 100s nodes) it can take over 10 minutes for all nodes to start. See individual node logs for details.

        Specified by:
        startNodesAsync in interface IgniteCluster
        Parameters:
        hosts - Startup parameters.
        dflts - Default values.
        restart - Whether to stop existing nodes. If true, all existing nodes on the host will be stopped before starting new ones. If false, nodes will be started only if there are less nodes on the host than expected.
        timeout - Connection timeout in milliseconds.
        maxConn - Number of parallel SSH connections to one host.
        Returns:
        a Future representing pending completion of the starting nodes.
        Throws:
        IgniteException - In case of error.
      • stopNodes

        public void stopNodes()
                       throws IgniteException
        Stops nodes satisfying optional set of predicates.

        NOTE: System.exit(Ignition.KILL_EXIT_CODE) will be executed on each stopping node. If you have other applications running in the same JVM along with Ignition, those applications will be stopped as well.

        Specified by:
        stopNodes in interface IgniteCluster
        Throws:
        IgniteException - In case of error.
      • stopNodes

        public void stopNodes​(Collection<UUID> ids)
                       throws IgniteException
        Stops nodes defined by provided IDs.

        NOTE: System.exit(Ignition.KILL_EXIT_CODE) will be executed on each stopping node. If you have other applications running in the same JVM along with Ignition, those applications will be stopped as well.

        Specified by:
        stopNodes in interface IgniteCluster
        Parameters:
        ids - IDs defining nodes to stop.
        Throws:
        IgniteException - In case of error.
      • restartNodes

        public void restartNodes()
                          throws IgniteException
        Restarts nodes satisfying optional set of predicates.

        NOTE: this command only works for grid nodes started with Ignition ignite.sh or ignite.bat scripts.

        Specified by:
        restartNodes in interface IgniteCluster
        Throws:
        IgniteException - In case of error.
      • restartNodes

        public void restartNodes​(Collection<UUID> ids)
                          throws IgniteException
        Restarts nodes defined by provided IDs.

        NOTE: this command only works for grid nodes started with Ignition ignite.sh or ignite.bat scripts.

        Specified by:
        restartNodes in interface IgniteCluster
        Parameters:
        ids - IDs defining nodes to restart.
        Throws:
        IgniteException - In case of error.
      • resetMetrics

        public void resetMetrics()
        Resets local I/O, job, and task execution metrics.
        Specified by:
        resetMetrics in interface IgniteCluster
      • active

        public boolean active()
        Checks Ignite grid is active or not active.
        Specified by:
        active in interface IgniteCluster
        Returns:
        True if grid is active. False If grid is not active.
      • active

        public void active​(boolean active)
        Changes Ignite grid state to active or inactive.

        NOTE: Deactivation clears in-memory caches (without persistence) including the system caches.

        Specified by:
        active in interface IgniteCluster
        Parameters:
        active - If True start activation process. If False start deactivation process.
      • state

        public void state​(ClusterState newState)
                   throws IgniteException
        Changes current cluster state to given newState cluster state.

        NOTE: Deactivation clears in-memory caches (without persistence) including the system caches.

        Specified by:
        state in interface IgniteCluster
        Parameters:
        newState - New cluster state.
        Throws:
        IgniteException - If there is an already started transaction or lock in the same thread.
      • state

        public void state​(ClusterState newState,
                          boolean force)
                   throws IgniteException
        Changes current cluster state to given newState cluster state.

        NOTE: Deactivation clears in-memory caches (without persistence) including the system caches.

        Specified by:
        state in interface IgniteClusterEx
        Parameters:
        newState - New cluster state.
        force - Force deactivation.
        Throws:
        IgniteException - If there is an already started transaction or lock in the same thread.
      • currentBaselineTopology

        @Nullable
        public @Nullable Collection<BaselineNode> currentBaselineTopology()
        Gets current baseline topology. If baseline topology was not set, will return null.
        Specified by:
        currentBaselineTopology in interface IgniteCluster
        Returns:
        Collection of nodes included to the current baseline topology.
      • setBaselineTopology

        public void setBaselineTopology​(Collection<? extends BaselineNode> baselineTop)
        Sets baseline topology. The cluster must be activated for this method to be called.
        Specified by:
        setBaselineTopology in interface IgniteCluster
        Parameters:
        baselineTop - A collection of nodes to be included to the baseline topology.
      • triggerBaselineAutoAdjust

        public void triggerBaselineAutoAdjust​(long topVer)
        Sets baseline topology constructed from the cluster topology of the given version (the method succeeds only if the cluster topology has not changed). All client nodes will be filtered out of the resulting baseline.
        Parameters:
        topVer - Topology version to set.
      • setBaselineTopology

        public void setBaselineTopology​(long topVer)
        Sets baseline topology constructed from the cluster topology of the given version (the method succeeds only if the cluster topology has not changed). All client nodes will be filtered out of the resulting baseline.
        Specified by:
        setBaselineTopology in interface IgniteCluster
        Parameters:
        topVer - Topology version to set.
      • shutdownPolicy

        public ShutdownPolicy shutdownPolicy()
        Returns a policy of shutdown or default value IgniteConfiguration.DFLT_SHUTDOWN_POLICY if the property is not set.
        Specified by:
        shutdownPolicy in interface IgniteCluster
        Returns:
        Shutdown policy.
      • enableStatistics

        public void enableStatistics​(Collection<String> caches,
                                     boolean enabled)
        Enables/disables statistics for caches cluster wide.
        Specified by:
        enableStatistics in interface IgniteCluster
        Parameters:
        caches - Collection of cache names.
        enabled - Statistics enabled flag.
      • clearStatistics

        public void clearStatistics​(Collection<String> caches)
        Clear statistics for caches cluster wide.
        Specified by:
        clearStatistics in interface IgniteCluster
        Parameters:
        caches - Collection of cache names.
      • setTxTimeoutOnPartitionMapExchange

        public void setTxTimeoutOnPartitionMapExchange​(long timeout)
        Sets transaction timeout on partition map exchange.
        Specified by:
        setTxTimeoutOnPartitionMapExchange in interface IgniteCluster
        Parameters:
        timeout - Transaction timeout on partition map exchange in milliseconds.
      • enableWal

        public boolean enableWal​(String cacheName)
                          throws IgniteException
        Enables write-ahead logging for specified cache. Restoring crash-recovery guarantees of a previous call to IgniteCluster.disableWal(String).

        Internally this method will wait for all current cache operations to finish and prevent new cache operations from being executed. Then checkpoint is initiated to flush all data to disk. Control is returned to the callee when all data is persisted to disk.

        WAL state can be changed only for persistent caches.

        NOTE: Currently, this method should only be called on a stable topology when no nodes are leaving or joining cluster, and all baseline nodes are present. Cache may be stuck in inconsistent state due to violation of these conditions. It is advised to destroy such cache.

        Specified by:
        enableWal in interface IgniteCluster
        Parameters:
        cacheName - Cache name.
        Returns:
        Whether WAL enabled by this call.
        Throws:
        IgniteException - If error occurs.
        See Also:
        IgniteCluster.disableWal(String), IgniteCluster.isWalEnabled(String)
      • disableWal

        public boolean disableWal​(String cacheName)
                           throws IgniteException
        Disables write-ahead logging for specified cache. When WAL is disabled, changes are not logged to disk. This significantly improves cache update speed. The drawback is absence of local crash-recovery guarantees. If node is crashed, local content of WAL-disabled cache will be cleared on restart to avoid data corruption.

        Internally this method will wait for all current cache operations to finish and prevent new cache operations from being executed. Then checkpoint is initiated to flush all data to disk. Control is returned to the callee when all dirty pages are prepared for checkpoint, but not necessarily flushed to disk.

        WAL state can be changed only for persistent caches.

        NOTE: Currently, this method should only be called on a stable topology when no nodes are leaving or joining cluster, and all baseline nodes are present. Cache may be stuck in inconsistent state due to violation of these conditions. It is advised to destroy such cache.

        Specified by:
        disableWal in interface IgniteCluster
        Parameters:
        cacheName - Cache name.
        Returns:
        Whether WAL disabled by this call.
        Throws:
        IgniteException - If error occurs.
        See Also:
        IgniteCluster.enableWal(String), IgniteCluster.isWalEnabled(String)
      • id

        public UUID id()
        Cluster ID is a unique identifier automatically generated when cluster starts up for the very first time. It is a cluster-wide property so all nodes of the cluster (including client nodes) return the same value. In in-memory clusters ID is generated again upon each cluster restart. In clusters running in persistent mode cluster ID is stored to disk and is used even after full cluster restart.
        Specified by:
        id in interface IgniteCluster
        Returns:
        Unique cluster ID.
      • setId

        public void setId​(UUID id)
        Not part of public API. Enables ClusterProcessor to set ID in the following cases:
        1. For the first time on node startup.
        2. Set to null on client disconnect.
        3. Set to some not-null value on client reconnect.
        Parameters:
        id - ID to set.
      • tag

        public String tag()
        User-defined tag describing the cluster.
        Specified by:
        tag in interface IgniteCluster
        Returns:
        Current tag value same across all nodes of the cluster.
      • tag

        public void tag​(String tag)
                 throws IgniteCheckedException
        Enables user to add a specific label to the cluster e.g. to describe purpose of the cluster or any its characteristics. Tag is set cluster-wide, value set on one node will be distributed across all nodes (including client nodes) in the cluster. Maximum tag length is limited by IgniteCluster.MAX_TAG_LENGTH value.
        Specified by:
        tag in interface IgniteCluster
        Parameters:
        tag - New tag to be set.
        Throws:
        IgniteCheckedException - In case tag change is requested on inactive cluster or concurrent tag change request was completed before the current one. Also provided tag is checked for max length.
      • setTag

        public void setTag​(@Nullable
                           @Nullable String tag)
        Not part of public API. Enables ClusterProcessor to set tag in the following cases:
        1. For the first time on node startup.
        2. Set to null on client disconnect.
        3. Set to some not-null value on client reconnect.
        Parameters:
        tag - Tag to set.
      • isBaselineAutoAdjustEnabled

        public boolean isBaselineAutoAdjustEnabled()
        Specified by:
        isBaselineAutoAdjustEnabled in interface IgniteCluster
        Returns:
        Value of manual baseline control or auto adjusting baseline. True If cluster in auto-adjust. False If cluster in manual.
      • baselineAutoAdjustEnabled

        public void baselineAutoAdjustEnabled​(boolean baselineAutoAdjustEnabled)
        Specified by:
        baselineAutoAdjustEnabled in interface IgniteCluster
        Parameters:
        baselineAutoAdjustEnabled - Value of manual baseline control or auto adjusting baseline. True If cluster in auto-adjust. False If cluster in manuale.
      • baselineAutoAdjustEnabledAsync

        public IgniteFuture<?> baselineAutoAdjustEnabledAsync​(boolean baselineAutoAdjustEnabled)
        Parameters:
        baselineAutoAdjustEnabled - Value of manual baseline control or auto adjusting baseline. True If cluster in auto-adjust. False If cluster in manuale.
        Returns:
        Future for await operation completion.
      • baselineAutoAdjustTimeout

        public long baselineAutoAdjustTimeout()
        Specified by:
        baselineAutoAdjustTimeout in interface IgniteCluster
        Returns:
        Number of milliseconds to wait before the actual topology change since last server topology change (node join/left/fail).
      • baselineAutoAdjustTimeout

        public void baselineAutoAdjustTimeout​(long baselineAutoAdjustTimeout)
        Specified by:
        baselineAutoAdjustTimeout in interface IgniteCluster
        Parameters:
        baselineAutoAdjustTimeout - Number of milliseconds to wait before the actual topology change since last server topology change (node join/left/fail).
      • baselineAutoAdjustTimeoutAsync

        public IgniteFuture<?> baselineAutoAdjustTimeoutAsync​(long baselineAutoAdjustTimeout)
        Parameters:
        baselineAutoAdjustTimeout - Value of time which we would wait before the actual topology change since last server topology change (node join/left/fail).
        Returns:
        Future for await operation completion.
      • isAsync

        public boolean isAsync()
        Specified by:
        isAsync in interface IgniteAsyncSupport
        Returns:
        True if asynchronous mode is enabled.
      • future

        public <R> IgniteFuture<R> future()
        Gets and resets future for previous asynchronous operation.
        Specified by:
        future in interface IgniteAsyncSupport
        Type Parameters:
        R - Type of the future result.
        Returns:
        Future for previous asynchronous operation.
      • clearNodeMap

        public void clearNodeMap()
        Clears node local map.
      • clientReconnectFuture

        public void clientReconnectFuture​(IgniteFuture<?> reconnecFut)
        Parameters:
        reconnecFut - Reconnect future.
      • clientReconnectFuture

        @Nullable
        public @Nullable IgniteFuture<?> clientReconnectFuture()
        If local client node disconnected from cluster returns future that will be completed when client reconnected.
        Specified by:
        clientReconnectFuture in interface IgniteCluster
        Returns:
        Future that will be completed when client reconnected.