org.apache.ignite.internal.client.router.impl

## 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

A `GridClient` router implementation.

### Method Summary

Methods
`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.
`void` `stop(boolean wait)` Closes client.
`Collection<GridClientTopologyListener>` `topologyListeners()` Gets an unmodifiable snapshot of topology listeners list.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Method Detail

#### stop

    public void stop(boolean wait)

Closes client.

Parameters:
  `wait` - If `true` will 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:
  `id` in interface `GridClient`
Returns:
  Generated client id.

#### data

    public GridClientData data()
                        throws GridClientException

Gets a data projection for a default grid cache with `null` name.

Specified by:
  `data` in interface `GridClient`
Returns:
  Data projection for grid cache with `null` name.
Throws:
  `GridClientException` - If client was closed.

#### 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:
  `data` in interface `GridClient`
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 to `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.

Specified by:
  `compute` in interface `GridClient`
Returns:
  Default compute projection.
See Also:
  `GridClientCompute`

#### addTopologyListener

    public void addTopologyListener(GridClientTopologyListener lsnr)

Adds topology listener. Remote grid topology is refreshed every `GridClientConfiguration.getTopologyRefreshFrequency()` milliseconds. If any node was added or removed, a listener will be notified.

Specified by:
  `addTopologyListener` in interface `GridClient`
Parameters:
  `lsnr` - Listener to add.

#### removeTopologyListener

    public void removeTopologyListener(GridClientTopologyListener lsnr)

Removes previously added topology listener.

Specified by:
  `removeTopologyListener` in interface `GridClient`
Parameters:
  `lsnr` - Listener to remove.

#### topologyListeners

    public Collection<GridClientTopologyListener> topologyListeners()

Gets an unmodifiable snapshot of topology listeners list.

Specified by:
  `topologyListeners` in interface `GridClient`
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 throw `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.

Specified by:
  `connected` in interface `GridClient`
Returns:
  Whether client is connected to remote Grid.

#### close

    public void close()

Closes client instance. This method is identical to `GridClientFactory.stop(clientId)`.

The method is invoked automatically on objects managed by the `try-with-resources` statement.

Specified by:
  `close` in interface `AutoCloseable`
Specified by:
  `close` in interface `GridClient`

2015 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 1.7.0
Release Date | : August 1 2016