public interface GridClient extends AutoCloseable
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 GridClient
through
GridClientFactory.start(GridClientConfiguration)
. Note that you
can have multiple instances of GridClient
running in the same VM. For
information on how to start or stop Grid please refer to GridClientFactory
class.
Use following methods to get access to remote cache functionality:
Use following methods to get access to remote compute functionality:
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.
GridClientCompute
,
GridClientData
Modifier and Type | Method and Description |
---|---|
void |
addTopologyListener(GridClientTopologyListener lsnr)
Adds topology listener.
|
void |
close()
Closes client instance.
|
GridClientCompute |
compute()
Gets a default compute projection.
|
boolean |
connected()
Indicates whether client is connected to remote Grid.
|
GridClientData |
data()
Gets a data projection for a default grid cache with
null name. |
GridClientData |
data(String cacheName)
Gets a data projection for grid cache with name cacheName.
|
UUID |
id()
Gets a unique client identifier.
|
void |
removeTopologyListener(GridClientTopologyListener lsnr)
Removes previously added topology listener.
|
GridClientClusterState |
state()
Get client cluster state projection, for perform activate/deactivate operation on cluster.
|
Collection<GridClientTopologyListener> |
topologyListeners()
Gets an unmodifiable snapshot of topology listeners list.
|
UUID id()
GridClientData data() throws GridClientException
null
name.null
name.GridClientException
- If client was closed.GridClientData data(String cacheName) throws GridClientException
cacheName
- Grid cache name for which data projection should be obtained.GridClientException
- If client was closed or no configuration with given name was provided.GridClientCompute compute()
GridClientLoadBalancer
provided in client configuration or
according to affinity if projection call involves affinity key.
More restricted projection configurations may be created with GridClientCompute
methods.
GridClientCompute
GridClientClusterState state()
GridClientClusterState
void addTopologyListener(GridClientTopologyListener lsnr)
GridClientConfiguration.getTopologyRefreshFrequency()
milliseconds. If any node was added or removed,
a listener will be notified.lsnr
- Listener to add.void removeTopologyListener(GridClientTopologyListener lsnr)
lsnr
- Listener to remove.Collection<GridClientTopologyListener> topologyListeners()
boolean connected()
GridClientDisconnectedException
.
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.
void close()
GridClientFactory.stop(clientId)
.
The method is invoked automatically on objects managed by the
try-with-resources
statement.
close
in interface AutoCloseable
Follow @ApacheIgnite
Ignite Fabric : ver. 2.0.0 Release Date : April 30 2017