Class IgniteClusterAsyncImpl
- java.lang.Object
-
- org.apache.ignite.internal.AsyncSupportAdapter<IgniteCluster>
-
- org.apache.ignite.internal.cluster.IgniteClusterAsyncImpl
-
- All Implemented Interfaces:
Externalizable,Serializable,ClusterGroup,IgniteCluster,IgniteAsyncSupport
public class IgniteClusterAsyncImpl extends AsyncSupportAdapter<IgniteCluster> implements IgniteCluster, Externalizable
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class org.apache.ignite.internal.AsyncSupportAdapter
curFut
-
Fields inherited from interface org.apache.ignite.IgniteCluster
MAX_TAG_LENGTH
-
-
Constructor Summary
Constructors Constructor Description IgniteClusterAsyncImpl()Required byExternalizable.IgniteClusterAsyncImpl(IgniteClusterImpl cluster)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanactive()Checks Ignite grid is active or not active.voidactive(boolean active)Changes Ignite grid state to active or inactive.voidbaselineAutoAdjustEnabled(boolean baselineAutoAdjustEnabled)IgniteFuture<?>baselineAutoAdjustEnabledAsync(boolean baselineAutoAdjustEnabled)BaselineAutoAdjustStatusbaselineAutoAdjustStatus()longbaselineAutoAdjustTimeout()voidbaselineAutoAdjustTimeout(long baselineAutoAdjustTimeout)IgniteFuture<?>baselineAutoAdjustTimeoutAsync(long baselineAutoAdjustTimeout)voidclearStatistics(Collection<String> caches)Clear statistics for caches cluster wide.@Nullable IgniteFuture<?>clientReconnectFuture()If local client node disconnected from cluster returns future that will be completed when client reconnected.@Nullable Collection<BaselineNode>currentBaselineTopology()Gets current baseline topology.booleandisableWal(String cacheName)Disables write-ahead logging for specified cache.voidenableStatistics(Collection<String> caches, boolean enabled)Enables/disables statistics for caches cluster wide.booleanenableWal(String cacheName)Enables write-ahead logging for specified cache.ClusterGroupforAttribute(String name, @Nullable Object val)Creates a new cluster group for nodes containing given name and value specified in user attributes.ClusterGroupforCacheNodes(String cacheName)Creates a cluster group for all nodes that have cache with specified name, either in client or server modes.ClusterGroupforClientNodes(String cacheName)Creates a cluster group for all client nodes that access cache with the specified name.ClusterGroupforClients()Creates a cluster group of nodes started in client mode.ClusterGroupforDataNodes(String cacheName)Creates a cluster group for all data nodes that have the cache with the specified name running.ClusterGroupforHost(String host, String... hosts)Gets cluster group consisting from the nodes running on the hosts specified.ClusterGroupforHost(ClusterNode node)Gets cluster group consisting from the nodes in this cluster group residing on the same host as the given node.ClusterGroupforLocal()Gets a cluster group consisting from the local node.ClusterGroupforNode(ClusterNode node, ClusterNode... nodes)Creates a cluster group for the given node.ClusterGroupforNodeId(UUID id, UUID... ids)Creates a cluster group for a node with the specified ID.ClusterGroupforNodeIds(Collection<UUID> ids)Creates a cluster group over nodes with specified node IDs.ClusterGroupforNodes(Collection<? extends ClusterNode> nodes)Creates a cluster group over a given set of nodes.ClusterGroupforOldest()Creates a cluster group with one oldest node from the current cluster group.ClusterGroupforOthers(ClusterGroup prj)Creates a cluster group for nodes not included into the given cluster group.ClusterGroupforOthers(ClusterNode node, ClusterNode... nodes)Creates a cluster group for nodes other than the given nodes.ClusterGroupforPredicate(IgnitePredicate<ClusterNode> p)Creates a new cluster group which includes all nodes that pass the given predicate filter.ClusterGroupforRandom()Creates a cluster group with one random node from the current cluster group.ClusterGroupforRemotes()Gets cluster group consisting from the nodes in this cluster group excluding the local node.ClusterGroupforServers()Creates a cluster group of nodes started in server mode.ClusterGroupforYoungest()Creates a cluster group with one youngest node in the current cluster group.Collection<String>hostNames()Gets the read-only collection of hostnames in this cluster group.UUIDid()Cluster ID is a unique identifier automatically generated when cluster starts up for the very first time.Igniteignite()Gets instance of grid.booleanisBaselineAutoAdjustEnabled()booleanisWalEnabled(String cacheName)Checks if write-ahead logging is enabled for specified cache.ClusterNodelocalNode()Gets local grid node.ClusterMetricsmetrics()Gets a metrics snapshot for this cluster group.@Nullable ClusterNodenode()Gets first node from the list of nodes in this cluster group.@Nullable ClusterNodenode(UUID id)Gets a node for given ID from this cluster group.<K,V>
ConcurrentMap<K,V>nodeLocalMap()Gets node-local storage instance.Collection<ClusterNode>nodes()Gets the read-only collection of nodes in this cluster group.booleanpingNode(UUID nodeId)Pings a remote node.IgnitePredicate<ClusterNode>predicate()Gets predicate that defines a subset of nodes for this cluster group.voidreadExternal(ObjectInput in)voidresetMetrics()Resets local I/O, job, and task execution metrics.voidrestartNodes()Restarts nodes satisfying optional set of predicates.voidrestartNodes(Collection<UUID> ids)Restarts nodes defined by provided IDs.voidsetBaselineTopology(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).voidsetBaselineTopology(Collection<? extends BaselineNode> baselineTop)Sets baseline topology.voidsetTxTimeoutOnPartitionMapExchange(long timeout)Sets transaction timeout on partition map exchange.ShutdownPolicyshutdownPolicy()Returns a policy of shutdown or default valueIgniteConfiguration.DFLT_SHUTDOWN_POLICYif the property is not set.voidshutdownPolicy(ShutdownPolicy policy)Sets a shutdown policy on a cluster.Collection<ClusterStartNodeResult>startNodes(File file, boolean restart, int timeout, int maxConn)Starts one or more nodes on remote host(s).Collection<ClusterStartNodeResult>startNodes(Collection<Map<String,Object>> hosts, @Nullable Map<String,Object> dflts, boolean restart, int timeout, int maxConn)Starts one or more nodes on remote host(s).IgniteFuture<Collection<ClusterStartNodeResult>>startNodesAsync(File file, boolean restart, int timeout, int maxConn)Starts one or more nodes on remote host(s) asynchronously.IgniteFuture<Collection<ClusterStartNodeResult>>startNodesAsync(Collection<Map<String,Object>> hosts, @Nullable Map<String,Object> dflts, boolean restart, int timeout, int maxConn)Starts one or more nodes on remote host(s) asynchronously.ClusterStatestate()Gets current cluster state.voidstate(ClusterState newState)Changes current cluster state to givennewStatecluster state.voidstopNodes()Stops nodes satisfying optional set of predicates.voidstopNodes(Collection<UUID> ids)Stops nodes defined by provided IDs.Stringtag()User-defined tag describing the cluster.voidtag(String tag)Enables user to add a specific label to the cluster e.g. to describe purpose of the cluster or any its characteristics.@Nullable Collection<ClusterNode>topology(long topVer)Gets a topology by version.longtopologyVersion()Gets current topology version.voidwriteExternal(ObjectOutput out)-
Methods inherited from class org.apache.ignite.internal.AsyncSupportAdapter
createAsyncInstance, createFuture, future, future, isAsync, saveOrGet, withAsync
-
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.lang.IgniteAsyncSupport
future, isAsync
-
Methods inherited from interface org.apache.ignite.IgniteCluster
withAsync
-
-
-
-
Constructor Detail
-
IgniteClusterAsyncImpl
public IgniteClusterAsyncImpl()
Required byExternalizable.
-
IgniteClusterAsyncImpl
public IgniteClusterAsyncImpl(IgniteClusterImpl cluster)
- Parameters:
cluster- Cluster.
-
-
Method Detail
-
localNode
public ClusterNode localNode()
Gets local grid node.- Specified by:
localNodein interfaceIgniteCluster- Returns:
- Local grid node.
-
forLocal
public ClusterGroup forLocal()
Gets a cluster group consisting from the local node.- Specified by:
forLocalin interfaceIgniteCluster- 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
ConcurrentMapand is safe for multi-threaded access.- Specified by:
nodeLocalMapin interfaceIgniteCluster- 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:
pingNodein interfaceIgniteCluster- Parameters:
nodeId- ID of a node to ping.- Returns:
trueif node for a given ID is alive,falseotherwise.- See Also:
DiscoverySpi
-
topologyVersion
public long topologyVersion()
Gets current topology version. In case of TCP discovery (seeTcpDiscoverySpi) 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:
topologyVersionin interfaceIgniteCluster- Returns:
- Current topology version.
-
topology
@Nullable public @Nullable Collection<ClusterNode> topology(long topVer)
Gets a topology by version. Returnsnullif topology history storage doesn't contain specified topology version (history currently keeps last1000snapshots).- Specified by:
topologyin interfaceIgniteCluster- Parameters:
topVer- Topology version.- Returns:
- Collection of grid nodes which represented by specified topology version,
if it is present in history storage,
nullotherwise.
-
startNodes
public Collection<ClusterStartNodeResult> startNodes(File file, boolean restart, int timeout, int maxConn)
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:
startNodesin interfaceIgniteCluster- Parameters:
file- Configuration file.restart- Whether to stop existing nodes. Iftrue, all existing nodes on the host will be stopped before starting new ones. Iffalse, 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).
-
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:
startNodesAsyncin interfaceIgniteCluster- Parameters:
file- Configuration file.restart- Whether to stop existing nodes. Iftrue, all existing nodes on the host will be stopped before starting new ones. Iffalse, 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)
Starts one or more nodes on remote host(s).Each map in
hostscollection 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~5defines 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 restartflag isfalse, 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").dfltsmap defines default values. They are applied to undefined parameters inhostscollection.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:
startNodesin interfaceIgniteCluster- Parameters:
hosts- Startup parameters.dflts- Default values.restart- Whether to stop existing nodes. Iftrue, all existing nodes on the host will be stopped before starting new ones. Iffalse, 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).
-
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
hostscollection 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~5defines 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 restartflag isfalse, 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").dfltsmap defines default values. They are applied to undefined parameters inhostscollection.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:
startNodesAsyncin interfaceIgniteCluster- Parameters:
hosts- Startup parameters.dflts- Default values.restart- Whether to stop existing nodes. Iftrue, all existing nodes on the host will be stopped before starting new ones. Iffalse, 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()
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:
stopNodesin interfaceIgniteCluster
-
stopNodes
public void stopNodes(Collection<UUID> ids)
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:
stopNodesin interfaceIgniteCluster- Parameters:
ids- IDs defining nodes to stop.
-
restartNodes
public void restartNodes()
Restarts nodes satisfying optional set of predicates.NOTE: this command only works for grid nodes started with Ignition
ignite.shorignite.batscripts.- Specified by:
restartNodesin interfaceIgniteCluster
-
restartNodes
public void restartNodes(Collection<UUID> ids)
Restarts nodes defined by provided IDs.NOTE: this command only works for grid nodes started with Ignition
ignite.shorignite.batscripts.- Specified by:
restartNodesin interfaceIgniteCluster- Parameters:
ids- IDs defining nodes to restart.
-
resetMetrics
public void resetMetrics()
Resets local I/O, job, and task execution metrics.- Specified by:
resetMetricsin interfaceIgniteCluster
-
enableStatistics
public void enableStatistics(Collection<String> caches, boolean enabled)
Enables/disables statistics for caches cluster wide.- Specified by:
enableStatisticsin interfaceIgniteCluster- 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:
clearStatisticsin interfaceIgniteCluster- Parameters:
caches- Collection of cache names.
-
setTxTimeoutOnPartitionMapExchange
public void setTxTimeoutOnPartitionMapExchange(long timeout)
Sets transaction timeout on partition map exchange.- Specified by:
setTxTimeoutOnPartitionMapExchangein interfaceIgniteCluster- Parameters:
timeout- Transaction timeout on partition map exchange in milliseconds.
-
ignite
public Ignite ignite()
Gets instance of grid.- Specified by:
ignitein interfaceClusterGroup- Returns:
- Grid instance.
-
forNodes
public ClusterGroup forNodes(Collection<? extends ClusterNode> nodes)
Creates a cluster group over a given set of nodes.- Specified by:
forNodesin interfaceClusterGroup- Parameters:
nodes- Collection of nodes to create the cluster group from.- Returns:
- Cluster group for the provided grid nodes.
-
forNode
public ClusterGroup forNode(ClusterNode node, ClusterNode... nodes)
Creates a cluster group for the given node.- Specified by:
forNodein interfaceClusterGroup- Parameters:
node- Node to create cluster group for.nodes- Optional additional nodes to include into the cluster group.- Returns:
- Cluster group for the given nodes.
-
forOthers
public ClusterGroup forOthers(ClusterNode node, ClusterNode... nodes)
Creates a cluster group for nodes other than the given nodes.- Specified by:
forOthersin interfaceClusterGroup- Parameters:
node- Node to exclude from the new cluster group.nodes- Optional additional nodes to exclude from the cluster group.- Returns:
- Cluster group that will contain all nodes from the original cluster group excluding the given nodes.
-
forOthers
public ClusterGroup forOthers(ClusterGroup prj)
Creates a cluster group for nodes not included into the given cluster group.- Specified by:
forOthersin interfaceClusterGroup- Parameters:
prj- Cluster group to exclude from the new cluster group.- Returns:
- Cluster group for nodes not included into the given cluster group.
-
forNodeIds
public ClusterGroup forNodeIds(Collection<UUID> ids)
Creates a cluster group over nodes with specified node IDs.- Specified by:
forNodeIdsin interfaceClusterGroup- Parameters:
ids- Collection of node IDs.- Returns:
- Cluster group over nodes with the specified node IDs.
-
forNodeId
public ClusterGroup forNodeId(UUID id, UUID... ids)
Creates a cluster group for a node with the specified ID.- Specified by:
forNodeIdin interfaceClusterGroup- Parameters:
id- Node ID to get the cluster group for.ids- Optional additional node IDs to include into the cluster group.- Returns:
- Cluster group over the node with the specified node IDs.
-
forPredicate
public ClusterGroup forPredicate(IgnitePredicate<ClusterNode> p)
Creates a new cluster group which includes all nodes that pass the given predicate filter.- Specified by:
forPredicatein interfaceClusterGroup- Parameters:
p- Predicate filter for nodes to include into the cluster group.- Returns:
- Cluster group for nodes that passed the predicate filter.
-
forAttribute
public ClusterGroup forAttribute(String name, @Nullable @Nullable Object val)
Creates a new cluster group for nodes containing given name and value specified in user attributes.User attributes for every node are optional and can be specified in grid node configuration. See
IgniteConfiguration.getUserAttributes()for more information.- Specified by:
forAttributein interfaceClusterGroup- Parameters:
name- Name of the attribute.val- Optional attribute value to match.- Returns:
- Cluster group for nodes containing specified attribute.
-
forServers
public ClusterGroup forServers()
Creates a cluster group of nodes started in server mode.- Specified by:
forServersin interfaceClusterGroup- Returns:
- Cluster group of nodes started in server mode.
- See Also:
Ignition.setClientMode(boolean),IgniteConfiguration.setClientMode(boolean)
-
forClients
public ClusterGroup forClients()
Creates a cluster group of nodes started in client mode.- Specified by:
forClientsin interfaceClusterGroup- Returns:
- Cluster group of nodes started in client mode.
- See Also:
Ignition.setClientMode(boolean),IgniteConfiguration.setClientMode(boolean)
-
forCacheNodes
public ClusterGroup forCacheNodes(String cacheName)
Creates a cluster group for all nodes that have cache with specified name, either in client or server modes.- Specified by:
forCacheNodesin interfaceClusterGroup- Parameters:
cacheName- Cache name.- Returns:
- Cluster group over nodes that have specified cache running.
-
forDataNodes
public ClusterGroup forDataNodes(String cacheName)
Creates a cluster group for all data nodes that have the cache with the specified name running.- Specified by:
forDataNodesin interfaceClusterGroup- Parameters:
cacheName- Cache name.- Returns:
- Cluster group over nodes that have the cache with the specified name running.
-
forClientNodes
public ClusterGroup forClientNodes(String cacheName)
Creates a cluster group for all client nodes that access cache with the specified name.- Specified by:
forClientNodesin interfaceClusterGroup- Parameters:
cacheName- Cache name.- Returns:
- Cluster group over nodes that have the specified cache running.
-
forRemotes
public ClusterGroup forRemotes()
Gets cluster group consisting from the nodes in this cluster group excluding the local node.- Specified by:
forRemotesin interfaceClusterGroup- Returns:
- Cluster group consisting from the nodes in this cluster group excluding the local node.
-
forHost
public ClusterGroup forHost(ClusterNode node)
Gets cluster group consisting from the nodes in this cluster group residing on the same host as the given node.- Specified by:
forHostin interfaceClusterGroup- Parameters:
node- Node to select the host for.- Returns:
- Cluster group for nodes residing on the same host as the specified node.
-
forHost
public ClusterGroup forHost(String host, String... hosts)
Gets cluster group consisting from the nodes running on the hosts specified.- Specified by:
forHostin interfaceClusterGroup- Parameters:
host- Host name to get nodes to put in clusterhosts- Host names to get nodes to put in cluster.- Returns:
- Cluster group for nodes residing on the hosts specified.
-
forRandom
public ClusterGroup forRandom()
Creates a cluster group with one random node from the current cluster group.- Specified by:
forRandomin interfaceClusterGroup- Returns:
- Cluster group containing one random node from the current cluster group.
-
forOldest
public ClusterGroup forOldest()
Creates a cluster group with one oldest node from the current cluster group. The resulting cluster group is dynamic and will always pick the next oldest node if the previous one leaves topology even after the cluster group has been created.Use
ClusterGroup.node()method to get the oldest node.- Specified by:
forOldestin interfaceClusterGroup- Returns:
- Cluster group containing one oldest node from the current cluster group.
-
forYoungest
public ClusterGroup forYoungest()
Creates a cluster group with one youngest node in the current cluster group. The resulting cluster group is dynamic and will always pick the newest node in the topology, even if more nodes entered after the cluster group has been created.- Specified by:
forYoungestin interfaceClusterGroup- Returns:
- Cluster group containing one youngest node from the current cluster group.
-
nodes
public Collection<ClusterNode> nodes()
Gets the read-only collection of nodes in this cluster group.- Specified by:
nodesin interfaceClusterGroup- Returns:
- All nodes in this cluster group.
-
node
@Nullable public @Nullable ClusterNode node(UUID id)
Gets a node for given ID from this cluster group.- Specified by:
nodein interfaceClusterGroup- Parameters:
id- Node ID.- Returns:
- Node with given ID from this cluster group or
null, if such node does not exist.
-
hostNames
public Collection<String> hostNames()
Gets the read-only collection of hostnames in this cluster group.- Specified by:
hostNamesin interfaceClusterGroup- Returns:
- All hostnames in this cluster group.
-
node
@Nullable public @Nullable ClusterNode node()
Gets first node from the list of nodes in this cluster group. This method is specifically useful for cluster groups with one node only.- Specified by:
nodein interfaceClusterGroup- Returns:
- First node from the list of nodes in this cluster group or
nullif the cluster group is empty.
-
predicate
public IgnitePredicate<ClusterNode> predicate()
Gets predicate that defines a subset of nodes for this cluster group.- Specified by:
predicatein interfaceClusterGroup- Returns:
- Predicate that defines a subset of nodes for this cluster group.
-
metrics
public ClusterMetrics metrics()
Gets a metrics snapshot for this cluster group.- Specified by:
metricsin interfaceClusterGroup- Returns:
- Metrics snapshot.
-
active
public boolean active()
Checks Ignite grid is active or not active.- Specified by:
activein interfaceIgniteCluster- Returns:
Trueif grid is active.FalseIf 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:
activein interfaceIgniteCluster- Parameters:
active- IfTruestart activation process. IfFalsestart deactivation process.
-
currentBaselineTopology
@Nullable public @Nullable Collection<BaselineNode> currentBaselineTopology()
Gets current baseline topology. If baseline topology was not set, will returnnull.- Specified by:
currentBaselineTopologyin interfaceIgniteCluster- 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:
setBaselineTopologyin interfaceIgniteCluster- Parameters:
baselineTop- A collection of nodes to be included to the baseline topology.
-
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:
setBaselineTopologyin interfaceIgniteCluster- Parameters:
topVer- Topology version to set.
-
clientReconnectFuture
@Nullable public @Nullable IgniteFuture<?> clientReconnectFuture()
If local client node disconnected from cluster returns future that will be completed when client reconnected.- Specified by:
clientReconnectFuturein interfaceIgniteCluster- Returns:
- Future that will be completed when client reconnected.
-
enableWal
public boolean enableWal(String cacheName) throws IgniteException
Enables write-ahead logging for specified cache. Restoring crash-recovery guarantees of a previous call toIgniteCluster.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:
enableWalin interfaceIgniteCluster- 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:
disableWalin interfaceIgniteCluster- Parameters:
cacheName- Cache name.- Returns:
- Whether WAL disabled by this call.
- Throws:
IgniteException- If error occurs.- See Also:
IgniteCluster.enableWal(String),IgniteCluster.isWalEnabled(String)
-
isWalEnabled
public boolean isWalEnabled(String cacheName)
Checks if write-ahead logging is enabled for specified cache.- Specified by:
isWalEnabledin interfaceIgniteCluster- Parameters:
cacheName- Cache name.- Returns:
Trueif WAL is enabled for cache.- See Also:
IgniteCluster.disableWal(String),IgniteCluster.enableWal(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:
idin interfaceIgniteCluster- Returns:
- Unique cluster ID.
-
tag
public String tag()
User-defined tag describing the cluster.- Specified by:
tagin interfaceIgniteCluster- 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 byIgniteCluster.MAX_TAG_LENGTHvalue.- Specified by:
tagin interfaceIgniteCluster- 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.
-
isBaselineAutoAdjustEnabled
public boolean isBaselineAutoAdjustEnabled()
- Specified by:
isBaselineAutoAdjustEnabledin interfaceIgniteCluster- Returns:
- Value of manual baseline control or auto adjusting baseline.
TrueIf cluster in auto-adjust.FalseIf cluster in manual.
-
baselineAutoAdjustEnabled
public void baselineAutoAdjustEnabled(boolean baselineAutoAdjustEnabled) throws IgniteException- Specified by:
baselineAutoAdjustEnabledin interfaceIgniteCluster- Parameters:
baselineAutoAdjustEnabled- Value of manual baseline control or auto adjusting baseline.TrueIf cluster in auto-adjust.FalseIf cluster in manuale.- Throws:
IgniteException- If operation failed.
-
baselineAutoAdjustEnabledAsync
public IgniteFuture<?> baselineAutoAdjustEnabledAsync(boolean baselineAutoAdjustEnabled)
- Parameters:
baselineAutoAdjustEnabled- Value of manual baseline control or auto adjusting baseline.TrueIf cluster in auto-adjust.FalseIf cluster in manuale.- Returns:
- Future for await operation completion.
-
baselineAutoAdjustTimeout
public long baselineAutoAdjustTimeout()
- Specified by:
baselineAutoAdjustTimeoutin interfaceIgniteCluster- 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) throws IgniteException- Specified by:
baselineAutoAdjustTimeoutin interfaceIgniteCluster- Parameters:
baselineAutoAdjustTimeout- Number of milliseconds to wait before the actual topology change since last server topology change (node join/left/fail).- Throws:
IgniteException- If failed.
-
baselineAutoAdjustStatus
public BaselineAutoAdjustStatus baselineAutoAdjustStatus()
- Specified by:
baselineAutoAdjustStatusin interfaceIgniteCluster- Returns:
- Status of baseline auto-adjust.
-
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.
-
shutdownPolicy
public ShutdownPolicy shutdownPolicy()
Returns a policy of shutdown or default valueIgniteConfiguration.DFLT_SHUTDOWN_POLICYif the property is not set.- Specified by:
shutdownPolicyin interfaceIgniteCluster- Returns:
- Shutdown policy.
-
shutdownPolicy
public void shutdownPolicy(ShutdownPolicy policy)
Sets a shutdown policy on a cluster. If a policy is specified here the value will override static configuration onIgniteConfiguration.setShutdownPolicy(ShutdownPolicy)and persists to cluster meta storage.- Specified by:
shutdownPolicyin interfaceIgniteCluster- Parameters:
policy- Shutdown policy.
-
readExternal
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
- Specified by:
readExternalin interfaceExternalizable- Throws:
IOExceptionClassNotFoundException
-
writeExternal
public void writeExternal(ObjectOutput out) throws IOException
- Specified by:
writeExternalin interfaceExternalizable- Throws:
IOException
-
state
public ClusterState state()
Gets current cluster state.- Specified by:
statein interfaceIgniteCluster- Returns:
- Current cluster state.
-
state
public void state(ClusterState newState) throws IgniteException
Changes current cluster state to givennewStatecluster state.NOTE: Deactivation clears in-memory caches (without persistence) including the system caches.
- Specified by:
statein interfaceIgniteCluster- Parameters:
newState- New cluster state.- Throws:
IgniteException- If there is an already started transaction or lock in the same thread.
-
-