Class ClientClusterImpl
- java.lang.Object
-
- org.apache.ignite.internal.client.thin.ClientClusterImpl
-
- All Implemented Interfaces:
ClientCluster,ClientClusterGroup
public class ClientClusterImpl extends Object implements ClientCluster
Implementation ofClientCluster.
-
-
Field Summary
Fields Modifier and Type Field Description protected org.apache.ignite.internal.client.thin.ReliableChannelchChannel.protected ClientUtilsutilsMarshaller utils.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleandisableWal(String cacheName)Disables write-ahead logging for specified cache.booleanenableWal(String cacheName)Enables write-ahead logging for specified cache.ClientClusterGroupforAttribute(String name, @Nullable Object val)Creates a new cluster group for nodes containing given name and value specified in user attributes.ClientClusterGroupforClients()Creates a cluster group of nodes started in client mode.ClientClusterGroupforHost(String host, String... hosts)Gets cluster group consisting from the nodes running on the hosts specified.ClientClusterGroupforHost(ClusterNode node)Gets cluster group consisting from the nodes in this cluster group residing on the same host (with the same MAC address) as the given node.ClientClusterGroupforNode(ClusterNode node, ClusterNode... nodes)Creates a cluster group for the given node.ClientClusterGroupforNodeId(UUID id, UUID... ids)Creates a cluster group for a node with the specified ID.ClientClusterGroupforNodeIds(Collection<UUID> ids)Creates a cluster group over nodes with specified node IDs.ClientClusterGroupforNodes(Collection<? extends ClusterNode> nodes)Creates a cluster group over a given set of nodes.ClientClusterGroupforOldest()Creates a cluster group with one oldest node from the current cluster group.ClientClusterGroupforOthers(ClientClusterGroup prj)Creates a cluster group for nodes not included into the given cluster group.ClientClusterGroupforOthers(ClusterNode node, ClusterNode... nodes)Creates a cluster group for nodes other than the given nodes.ClientClusterGroupforPredicate(Predicate<ClusterNode> p)Creates a new cluster group which includes all nodes that pass the given predicate filter.ClientClusterGroupforRandom()Creates a cluster group with one random node from the current cluster group.ClientClusterGroupforServers()Creates a cluster group of nodes started in server mode.ClientClusterGroupforYoungest()Creates a cluster group with one youngest node in the current cluster group.booleanisWalEnabled(String cacheName)Checks if write-ahead logging is enabled for specified cache.ClusterNodenode()Gets first node from the list of nodes in this cluster group.ClusterNodenode(UUID nid)Gets a node for given ID from this cluster group.Collection<UUID>nodeIds()Gets node id's.Collection<ClusterNode>nodes()Gets the read-only collection of nodes in this cluster group.ClusterStatestate()Gets current cluster state.voidstate(ClusterState newState)Changes current cluster state to givennewStatecluster state.voidstate(ClusterState newState, boolean forceDeactivation)Changes current cluster state to givennewStatecluster state.-
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.client.ClientClusterGroup
forAttribute, forClients, forHost, forHost, forNode, forNodeId, forNodeIds, forNodes, forOldest, forOthers, forOthers, forPredicate, forRandom, forServers, forYoungest, node, node, nodes
-
-
-
-
Field Detail
-
ch
protected final org.apache.ignite.internal.client.thin.ReliableChannel ch
Channel.
-
utils
protected final ClientUtils utils
Marshaller utils.
-
-
Method Detail
-
state
public ClusterState state()
Gets current cluster state.- Specified by:
statein interfaceClientCluster- Returns:
- Current cluster state.
-
state
public void state(ClusterState newState) throws ClientException
Changes current cluster state to givennewStatecluster state.NOTE: Deactivation clears in-memory caches (without persistence) including the system caches.
- Specified by:
statein interfaceClientCluster- Parameters:
newState- New cluster state.- Throws:
ClientException- If change state operation failed.
-
state
public void state(ClusterState newState, boolean forceDeactivation) throws ClientException
Changes current cluster state to givennewStatecluster state.NOTE: Deactivation clears in-memory caches (without persistence) including the system caches.
- Parameters:
newState- New cluster state.forceDeactivation- Iftrue, cluster deactivation will be forced.- Throws:
ClientException- If change state operation failed.
-
disableWal
public boolean disableWal(String cacheName) throws ClientException
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.
- Specified by:
disableWalin interfaceClientCluster- Parameters:
cacheName- Cache name.- Returns:
- Whether WAL disabled by this call.
- Throws:
ClientException- If error occurs.- See Also:
ClientCluster.enableWal(String),ClientCluster.isWalEnabled(String)
-
enableWal
public boolean enableWal(String cacheName) throws ClientException
Enables write-ahead logging for specified cache. Restoring crash-recovery guarantees of a previous call toClientCluster.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.
- Specified by:
enableWalin interfaceClientCluster- Parameters:
cacheName- Cache name.- Returns:
- Whether WAL enabled by this call.
- Throws:
ClientException- If error occurs.- See Also:
ClientCluster.disableWal(String),ClientCluster.isWalEnabled(String)
-
isWalEnabled
public boolean isWalEnabled(String cacheName)
Checks if write-ahead logging is enabled for specified cache.- Specified by:
isWalEnabledin interfaceClientCluster- Parameters:
cacheName- Cache name.- Returns:
Trueif WAL is enabled for cache.- See Also:
ClientCluster.disableWal(String),ClientCluster.enableWal(String)
-
forNodes
public ClientClusterGroup forNodes(Collection<? extends ClusterNode> nodes)
Creates a cluster group over a given set of nodes.- Specified by:
forNodesin interfaceClientClusterGroup- Parameters:
nodes- Collection of nodes to create the cluster group from.- Returns:
- Cluster group for the provided grid nodes.
-
forNode
public ClientClusterGroup forNode(ClusterNode node, ClusterNode... nodes)
Creates a cluster group for the given node.- Specified by:
forNodein interfaceClientClusterGroup- 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 ClientClusterGroup forOthers(ClusterNode node, ClusterNode... nodes)
Creates a cluster group for nodes other than the given nodes.- Specified by:
forOthersin interfaceClientClusterGroup- 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 ClientClusterGroup forOthers(ClientClusterGroup prj)
Creates a cluster group for nodes not included into the given cluster group.- Specified by:
forOthersin interfaceClientClusterGroup- 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 ClientClusterGroup forNodeIds(Collection<UUID> ids)
Creates a cluster group over nodes with specified node IDs.- Specified by:
forNodeIdsin interfaceClientClusterGroup- Parameters:
ids- Collection of node IDs.- Returns:
- Cluster group over nodes with the specified node IDs.
-
forNodeId
public ClientClusterGroup forNodeId(UUID id, UUID... ids)
Creates a cluster group for a node with the specified ID.- Specified by:
forNodeIdin interfaceClientClusterGroup- 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 ClientClusterGroup forPredicate(Predicate<ClusterNode> p)
Creates a new cluster group which includes all nodes that pass the given predicate filter.- Specified by:
forPredicatein interfaceClientClusterGroup- Parameters:
p- Predicate filter for nodes to include into the cluster group.- Returns:
- Cluster group for nodes that passed the predicate filter.
-
forAttribute
public ClientClusterGroup 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 interfaceClientClusterGroup- Parameters:
name- Name of the attribute.val- Optional attribute value to match (if null, just check if attribute exists).- Returns:
- Cluster group for nodes containing specified attribute.
-
forServers
public ClientClusterGroup forServers()
Creates a cluster group of nodes started in server mode.- Specified by:
forServersin interfaceClientClusterGroup- Returns:
- Cluster group of nodes started in server mode.
- See Also:
Ignition.setClientMode(boolean),IgniteConfiguration.setClientMode(boolean)
-
forClients
public ClientClusterGroup forClients()
Creates a cluster group of nodes started in client mode.- Specified by:
forClientsin interfaceClientClusterGroup- Returns:
- Cluster group of nodes started in client mode.
- See Also:
Ignition.setClientMode(boolean),IgniteConfiguration.setClientMode(boolean)
-
forRandom
public ClientClusterGroup forRandom()
Creates a cluster group with one random node from the current cluster group.- Specified by:
forRandomin interfaceClientClusterGroup- Returns:
- Cluster group containing one random node from the current cluster group.
-
forOldest
public ClientClusterGroup 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
ClientClusterGroup.node()method to get the oldest node.- Specified by:
forOldestin interfaceClientClusterGroup- Returns:
- Cluster group containing one oldest node from the current cluster group.
-
forYoungest
public ClientClusterGroup 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 interfaceClientClusterGroup- Returns:
- Cluster group containing one youngest node from the current cluster group.
-
forHost
public ClientClusterGroup forHost(ClusterNode node)
Gets cluster group consisting from the nodes in this cluster group residing on the same host (with the same MAC address) as the given node.- Specified by:
forHostin interfaceClientClusterGroup- Parameters:
node- Node to select the host for.- Returns:
- Cluster group for nodes residing on the same host as the specified node.
-
forHost
public ClientClusterGroup forHost(String host, String... hosts)
Gets cluster group consisting from the nodes running on the hosts specified.- Specified by:
forHostin interfaceClientClusterGroup- 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.
-
nodes
public Collection<ClusterNode> nodes()
Gets the read-only collection of nodes in this cluster group.- Specified by:
nodesin interfaceClientClusterGroup- Returns:
- All nodes in this cluster group.
-
node
public ClusterNode node(UUID nid)
Gets a node for given ID from this cluster group.- Specified by:
nodein interfaceClientClusterGroup- Parameters:
nid- Node ID.- Returns:
- Node with given ID from this cluster group or
null, if such node does not exist.
-
node
public 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 interfaceClientClusterGroup- Returns:
- First node from the list of nodes in this cluster group or
nullif the cluster group is empty.
-
nodeIds
public Collection<UUID> nodeIds()
Gets node id's. Note: This method is for internal use only. For optimization purposes it can return not existing node IDs if only filter by node IDs was explicitly set. Method also returns null for default projection (for server nodes).
-
-