public class GridClientImpl extends Object implements GridClient
Modifier and Type | Field and Description |
---|---|
protected GridClientConfiguration |
cfg
Client configuration.
|
protected GridClientConnectionManager |
connMgr
Connection manager.
|
protected GridClientTopology |
top
Topology.
|
Constructor and Description |
---|
GridClientImpl(UUID id,
GridClientConfiguration cfg0,
boolean routerClient)
Creates a new client based on a given configuration.
|
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.
|
GridClientConnectionManager |
connectionManager() |
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.
|
GridClientConnectionManager |
newConnectionManager(Byte marshId,
boolean routerClient) |
void |
removeTopologyListener(GridClientTopologyListener lsnr)
Removes previously added topology listener.
|
GridClientClusterState |
state()
Get client cluster state projection, for perform activate/deactivate operation on cluster.
|
void |
stop(boolean waitCompletion)
Closes client.
|
GridClientTopology |
topology()
Gets topology instance.
|
Collection<GridClientTopologyListener> |
topologyListeners()
Gets an unmodifiable snapshot of topology listeners list.
|
String |
toString() |
protected final GridClientConfiguration cfg
protected GridClientTopology top
protected GridClientConnectionManager connMgr
public GridClientImpl(UUID id, GridClientConfiguration cfg0, boolean routerClient) throws GridClientException
id
- Client identifier.cfg0
- Client configuration.routerClient
- Router client flag.GridClientException
- If client configuration is incorrect.GridServerUnreachableException
- If none of the servers specified in configuration can
be reached.public UUID id()
id
in interface GridClient
public void stop(boolean waitCompletion)
waitCompletion
- If true
will wait for all pending requests to be proceeded.public GridClientData data() throws GridClientException
null
name.data
in interface GridClient
null
name.GridClientException
- If client was closed.public GridClientData data(@Nullable String cacheName) throws GridClientException
data
in interface GridClient
cacheName
- Grid cache name for which data projection should be obtained.GridClientException
- If client was closed or no configuration with given name was provided.public 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.
compute
in interface GridClient
GridClientCompute
public GridClientClusterState state()
state
in interface GridClient
GridClientClusterState
public void addTopologyListener(GridClientTopologyListener lsnr)
GridClientConfiguration.getTopologyRefreshFrequency()
milliseconds. If any node was added or removed,
a listener will be notified.addTopologyListener
in interface GridClient
lsnr
- Listener to add.public void removeTopologyListener(GridClientTopologyListener lsnr)
removeTopologyListener
in interface GridClient
lsnr
- Listener to remove.public Collection<GridClientTopologyListener> topologyListeners()
topologyListeners
in interface GridClient
public 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.
connected
in interface GridClient
public void close()
GridClientFactory.stop(clientId)
.
The method is invoked automatically on objects managed by the
try-with-resources
statement.
close
in interface AutoCloseable
close
in interface GridClient
public GridClientTopology topology()
public GridClientConnectionManager connectionManager()
public GridClientConnectionManager newConnectionManager(@Nullable Byte marshId, boolean routerClient) throws GridClientException
GridClientException
- If failed to start connection server.
Follow @ApacheIgnite
Ignite Fabric : ver. 2.0.0 Release Date : April 30 2017