Class GridRouterClientImpl
- java.lang.Object
-
- org.apache.ignite.internal.client.router.impl.GridRouterClientImpl
-
- All Implemented Interfaces:
AutoCloseable,GridClient
public class GridRouterClientImpl extends Object implements GridClient
AGridClientrouter implementation.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddTopologyListener(GridClientTopologyListener lsnr)Adds topology listener.GridClientExceptioncheckLastError()Check for last topology errors.voidclose()Closes client instance.GridClientComputecompute()Gets a default compute projection.booleanconnected()Indicates whether client is connected to remote Grid.GridClientDatadata(String cacheName)Gets a data projection for grid cache with name cacheName.UUIDid()Gets a unique client identifier.voidremoveTopologyListener(GridClientTopologyListener lsnr)Removes previously added topology listener.GridClientClusterStatestate()Get client cluster state projection, for perform activate/deactivate operation on cluster.voidstop(boolean wait)Closes client.Collection<GridClientTopologyListener>topologyListeners()Gets an unmodifiable snapshot of topology listeners list.
-
-
-
Method Detail
-
stop
public void stop(boolean wait)
Closes client.- Parameters:
wait- Iftruewill wait for all pending requests to be proceeded.
-
id
public UUID id()
Gets a unique client identifier. This identifier is generated by factory on client creation and used in identification and authentication procedure on server node.- Specified by:
idin interfaceGridClient- Returns:
- Generated client id.
-
data
public GridClientData data(String cacheName) throws GridClientException
Gets a data projection for grid cache with name cacheName. If no data configuration with given name was provided at client startup, an exception will be thrown.- Specified by:
datain interfaceGridClient- Parameters:
cacheName- Grid cache name for which data projection should be obtained.- Returns:
- Data projection for grid cache with name cacheName.
- Throws:
GridClientException- If client was closed or no configuration with given name was provided.
-
compute
public GridClientCompute compute()
Gets a default compute projection. Default compute projection will include all nodes in remote grid. Selection of node that will be connected to perform operations will be done according toGridClientLoadBalancerprovided in client configuration or according to affinity if projection call involves affinity key.More restricted projection configurations may be created with
GridClientComputemethods.- Specified by:
computein interfaceGridClient- Returns:
- Default compute projection.
- See Also:
GridClientCompute
-
state
public GridClientClusterState state()
Get client cluster state projection, for perform activate/deactivate operation on cluster.- Specified by:
statein interfaceGridClient- Returns:
- Cluster state projection.
- See Also:
GridClientClusterState
-
addTopologyListener
public void addTopologyListener(GridClientTopologyListener lsnr)
Adds topology listener. Remote grid topology is refreshed everyGridClientConfiguration.getTopologyRefreshFrequency()milliseconds. If any node was added or removed, a listener will be notified.- Specified by:
addTopologyListenerin interfaceGridClient- Parameters:
lsnr- Listener to add.
-
removeTopologyListener
public void removeTopologyListener(GridClientTopologyListener lsnr)
Removes previously added topology listener.- Specified by:
removeTopologyListenerin interfaceGridClient- Parameters:
lsnr- Listener to remove.
-
topologyListeners
public Collection<GridClientTopologyListener> topologyListeners()
Gets an unmodifiable snapshot of topology listeners list.- Specified by:
topologyListenersin interfaceGridClient- Returns:
- List of topology listeners.
-
connected
public boolean connected()
Indicates whether client is connected to remote Grid. In other words it allow to determine if client is able to communicate with Grid right now. If it can't all methods on Compute and Data projections throwGridClientDisconnectedException.Connection status is updated in background together with topology update. See
GridClientConfiguration.getTopologyRefreshFrequency()for more details on how background topology update works.Note that due to asynchronous nature of topology update and connectivity detection this method gives no guarantees for subsequent calls for projections methods. It can be used only fo diagnostic and monitoring purposes.
- Specified by:
connectedin interfaceGridClient- Returns:
- Whether client is connected to remote Grid.
-
close
public void close()
Closes client instance. This method is identical toGridClientFactory.stop(clientId).The method is invoked automatically on objects managed by the
try-with-resourcesstatement.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceGridClient
-
checkLastError
public GridClientException checkLastError()
Check for last topology errors.- Specified by:
checkLastErrorin interfaceGridClient- Returns:
Exceptionif client was not connected.
-
-