Class GridClientClusterStateImpl
- java.lang.Object
-
- org.apache.ignite.internal.client.impl.GridClientClusterStateImpl
-
- All Implemented Interfaces:
GridClientClusterState
public class GridClientClusterStateImpl extends Object implements GridClientClusterState
-
-
Field Summary
Fields Modifier and Type Field Description protected GridClientLoadBalancerbalancerBalancer to be used in this projection.protected GridClientImplclientClient instance.protected GridClientPredicate<? super GridClientNode>filterNode filter to be applied for this projection.protected Collection<GridClientNode>nodesList of nodes included in this projection.
-
Constructor Summary
Constructors Constructor Description GridClientClusterStateImpl(GridClientImpl client, Collection<GridClientNode> nodes, GridClientPredicate<? super GridClientNode> filter, GridClientLoadBalancer balancer)Creates projection with specified client.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected booleancheckNodeAlive(UUID nodeId)Tries to refresh node on every possible connection in topology.StringclusterName()Get the cluster name.protected TcreateProjection(@Nullable Collection<GridClientNode> nodes, @Nullable GridClientPredicate<? super GridClientNode> filter, @Nullable GridClientLoadBalancer balancer, org.apache.ignite.internal.client.impl.GridClientAbstractProjection.ProjectionFactory<T> factory)Creates a sub-projection for current projection.UUIDid()Unique identifier of cluster STATE command was sent to.Collection<? extends GridClientNode>projectionNodes()Gets most recently refreshed topology.protected Collection<? extends GridClientNode>projectionNodes(@Nullable GridClientPredicate<GridClientNode> pred)Gets most recently refreshed topology.ClusterStatestate()voidstate(ClusterState newState, boolean forceDeactivation)Changes cluster state tonewState.Stringtag()User-defined tag of cluster STATE command was sent to.protected <R> GridClientFuture<R>withReconnectHandling(org.apache.ignite.internal.client.impl.GridClientAbstractProjection.ClientProjectionClosure<R> c)This method executes request to a communication layer and handles connection error, if it occurs.protected <R> GridClientFuture<R>withReconnectHandling(org.apache.ignite.internal.client.impl.GridClientAbstractProjection.ClientProjectionClosure<R> c, String cacheName, @Nullable Object affKey)This method executes request to a communication layer and handles connection error, if it occurs.
-
-
-
Field Detail
-
nodes
protected Collection<GridClientNode> nodes
List of nodes included in this projection. If null, all nodes in topology are included.
-
filter
protected GridClientPredicate<? super GridClientNode> filter
Node filter to be applied for this projection.
-
balancer
protected GridClientLoadBalancer balancer
Balancer to be used in this projection.
-
client
protected GridClientImpl client
Client instance.
-
-
Constructor Detail
-
GridClientClusterStateImpl
public GridClientClusterStateImpl(GridClientImpl client, Collection<GridClientNode> nodes, GridClientPredicate<? super GridClientNode> filter, GridClientLoadBalancer balancer)
Creates projection with specified client.- Parameters:
client- Client instance to use.nodes- Collections of nodes included in this projection.filter- Node filter to be applied.balancer- Balancer to use.
-
-
Method Detail
-
state
public ClusterState state() throws GridClientException
- Specified by:
statein interfaceGridClientClusterState- Returns:
- Current cluster state.
- Throws:
GridClientException- If the request to get the cluster state failed.
-
state
public void state(ClusterState newState, boolean forceDeactivation) throws GridClientException
Changes cluster state tonewState.- Specified by:
statein interfaceGridClientClusterState- Parameters:
newState- New cluster state.forceDeactivation- Iftrue, cluster deactivation will be forced.- Throws:
GridClientException- If the request to change the cluster state failed.- See Also:
ClusterState.INACTIVE
-
id
public UUID id() throws Exception
Unique identifier of cluster STATE command was sent to.- Specified by:
idin interfaceGridClientClusterState- Returns:
- ID of the cluster.
- Throws:
Exception
-
tag
public String tag() throws Exception
User-defined tag of cluster STATE command was sent to.- Specified by:
tagin interfaceGridClientClusterState- Returns:
- Tag of the cluster.
- Throws:
Exception
-
clusterName
public String clusterName() throws GridClientException
Get the cluster name.- Specified by:
clusterNamein interfaceGridClientClusterState- Returns:
- The name of the cluster.
- Throws:
GridClientException- If the request to get the cluster name failed.
-
withReconnectHandling
protected <R> GridClientFuture<R> withReconnectHandling(org.apache.ignite.internal.client.impl.GridClientAbstractProjection.ClientProjectionClosure<R> c)
This method executes request to a communication layer and handles connection error, if it occurs. In case of communication exception client instance is notified and new instance of client is created. If none of the grid servers can be reached, an exception is thrown.- Type Parameters:
R- Result future type.- Parameters:
c- Closure to be executed.- Returns:
- Future returned by closure.
-
withReconnectHandling
protected <R> GridClientFuture<R> withReconnectHandling(org.apache.ignite.internal.client.impl.GridClientAbstractProjection.ClientProjectionClosure<R> c, String cacheName, @Nullable @Nullable Object affKey)
This method executes request to a communication layer and handles connection error, if it occurs. Server is picked up according to the projection affinity and key given. Connection will be made with the node on which key is cached. In case of communication exception client instance is notified and new instance of client is created. If none of servers can be reached, an exception is thrown.- Type Parameters:
R- Type of result in future.- Parameters:
c- Closure to be executed.cacheName- Cache name for which mapped node will be calculated.affKey- Affinity key.- Returns:
- Operation future.
-
checkNodeAlive
protected boolean checkNodeAlive(UUID nodeId) throws GridClientException, InterruptedException
Tries to refresh node on every possible connection in topology.- Parameters:
nodeId- Node id to check.- Returns:
Trueif response was received,falseif eithernullresponse received or no nodes can be contacted at all.- Throws:
GridClientException- If failed to refresh topology or if client was closed manually.InterruptedException- If interrupted.
-
projectionNodes
public Collection<? extends GridClientNode> projectionNodes() throws GridClientException
Gets most recently refreshed topology. If this compute instance is a projection, then only nodes that satisfy projection criteria will be returned.- Returns:
- Most recently refreshed topology.
- Throws:
GridClientException- If failed to refresh topology.
-
projectionNodes
protected Collection<? extends GridClientNode> projectionNodes(@Nullable @Nullable GridClientPredicate<GridClientNode> pred) throws GridClientException
Gets most recently refreshed topology. If this compute instance is a projection, then only nodes that satisfy projection criteria will be returned.- Parameters:
pred- Predicate to additionally filter projection nodes, ifnulljust return projection.- Returns:
- Most recently refreshed topology.
- Throws:
GridClientException- If failed to refresh topology.
-
createProjection
protected T createProjection(@Nullable @Nullable Collection<GridClientNode> nodes, @Nullable @Nullable GridClientPredicate<? super GridClientNode> filter, @Nullable @Nullable GridClientLoadBalancer balancer, org.apache.ignite.internal.client.impl.GridClientAbstractProjection.ProjectionFactory<T> factory) throws GridClientExceptionCreates a sub-projection for current projection.- Parameters:
nodes- Collection of nodes that sub-projection will be restricted to. Ifnull, created projection is dynamic and will take nodes from topology.filter- Filter to be applied to nodes in projection. Ifnull- no filter applied.balancer- Balancer to use in projection. Ifnull- inherit balancer from the current projection.factory- Factory to create new projection.- Returns:
- Created projection.
- Throws:
GridClientException- If resulting projection is empty. Note that this exception may only be thrown on case of static projections, i.e. where collection of nodes is not null.
-
-