Interface GridClient
-
- All Superinterfaces:
AutoCloseable
- All Known Implementing Classes:
GridClientImpl,GridRouterClientImpl
public interface GridClient extends AutoCloseable
Ignite Java client API.Contains functionality to get projections for accessing remote data and compute functionality, as well as provide listeners on topology changes.
You can obtain an instance of
GridClientthroughGridClientFactory.start(GridClientConfiguration). Note that you can have multiple instances ofGridClientrunning in the same VM. For information on how to start or stop Grid please refer toGridClientFactoryclass.Use the following method to get access to remote cache functionality:
Use following methods to get access to remote compute functionality:Partition awareness
One of the unique properties of the Ignite remote clients is that they are affinity aware. In other words, both compute and data APIs will optionally contact exactly the node where the data is cached based on some affinity key. This allows for collocation of computations and data and avoids extra network hops that would be necessary if non-affinity nodes were contacted.If client can't access some of grid nodes directly (for example due to security restrictions) either dedicated Router component could be used or some of Grid nodes could act as routers. See
GridClientConfiguration.getRouters()for more details.- See Also:
GridClientCompute,GridClientData
-
-
Method Summary
All Methods Instance Methods Abstract 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.Collection<GridClientTopologyListener>topologyListeners()Gets an unmodifiable snapshot of topology listeners list.
-
-
-
Method Detail
-
id
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.- Returns:
- Generated client id.
-
data
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.- 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
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.- Returns:
- Default compute projection.
- See Also:
GridClientCompute
-
state
GridClientClusterState state()
Get client cluster state projection, for perform activate/deactivate operation on cluster.- Returns:
- Cluster state projection.
- See Also:
GridClientClusterState
-
addTopologyListener
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.- Parameters:
lsnr- Listener to add.
-
removeTopologyListener
void removeTopologyListener(GridClientTopologyListener lsnr)
Removes previously added topology listener.- Parameters:
lsnr- Listener to remove.
-
topologyListeners
Collection<GridClientTopologyListener> topologyListeners()
Gets an unmodifiable snapshot of topology listeners list.- Returns:
- List of topology listeners.
-
connected
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.
- Returns:
- Whether client is connected to remote Grid.
-
close
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
-
checkLastError
GridClientException checkLastError()
Check for last topology errors.- Returns:
Exceptionif client was not connected.
-
-