org.apache.ignite.internal.client.impl.connection

## Class GridClientNioTcpConnection

- java.lang.Object
- - org.apache.ignite.internal.client.impl.connection.GridClientConnection
  - - org.apache.ignite.internal.client.impl.connection.GridClientNioTcpConnection

    public class GridClientNioTcpConnection
    extends GridClientConnection

This class performs request to grid over tcp protocol. Serialization is performed with marshaller provided.

### Field Summary

### Fields inherited from class org.apache.ignite.internal.client.impl.connection.GridClientConnection

`clientId, closeReason, top`

### Method Summary

Methods
`<K,V> GridClientFutureAdapter<Boolean>` `cacheAppend(String cacheName, K key, V val, Set<GridClientCacheFlag> flags, UUID destNodeId)` Append requested value to already cached one.
`<K,V> GridClientFutureAdapter<Boolean>` `cacheCompareAndSet(String cacheName, K key, V newVal, V oldVal, Set<GridClientCacheFlag> flags, UUID destNodeId)` New valueActual/old valueBehaviour null null Remove entry for key.
`<K,V> GridClientFutureAdapter<Map<K,V>>` `cacheGetAll(String cacheName, Collection<K> keys, Set<GridClientCacheFlag> flags, UUID destNodeId)` Gets bundle of entries for specified keys from the cache.
`<K> GridClientFutureAdapter<GridClientDataMetrics>` `cacheMetrics(String cacheName, UUID destNodeId)` Gets cache metrics for the key.
`<K,V> GridClientFutureAdapter<Boolean>` `cachePrepend(String cacheName, K key, V val, Set<GridClientCacheFlag> flags, UUID destNodeId)` Prepend requested value to already cached one.
`<K,V> GridClientFutureAdapter<Boolean>` `cachePutAll(String cacheName, Map<K,V> entries, Set<GridClientCacheFlag> flags, UUID destNodeId)` Puts bundle of entries into cache.
`<K> GridClientFutureAdapter<Boolean>` `cacheRemove(String cacheName, K key, Set<GridClientCacheFlag> flags, UUID destNodeId)` Removes entry from the cache for specified key.
`<K> GridClientFutureAdapter<Boolean>` `cacheRemoveAll(String cacheName, Collection<K> keys, Set<GridClientCacheFlag> flags, UUID destNodeId)` Removes bundle of entries for specified keys from the cache.
`<K,V> GridClientFutureAdapter<Boolean>` `cacheReplace(String cacheName, K key, V val, Set<GridClientCacheFlag> flags, UUID destNodeId)` Replace key-value pair in cache if already exist.
`<R> GridClientFutureAdapter<R>` `execute(String taskName, Object arg, UUID destNodeId, boolean keepPortables)` Execute task in the grid.
`GridClientFutureAdapter<GridRouterRequest>` `forwardMessage(Object msg)` Forwards a message in raw form to the connected node.
`GridClientFuture<GridClientNode>` `node(String ipAddr, boolean inclAttrs, boolean includeMetrics, UUID destNodeId)` Gets node by node IP.
`GridClientFuture<GridClientNode>` `node(UUID id, boolean inclAttrs, boolean inclMetrics, UUID destNodeId)` Gets node by node ID.
`GridClientFuture<List<GridClientNode>>` `topology(boolean inclAttrs, boolean inclMetrics, UUID destNodeId)` Gets grid topology nodes.

### Methods inherited from class org.apache.ignite.internal.client.impl.connection.GridClientConnection

`cacheGet, cachePut, checkClosed, credentials, encodeCacheFlags, getCloseReasonAsException, getCloseReasonMessage, isClosed, metricsMapToMetrics, safeDouble, safeLong, serverAddress, sslContext`

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

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

### Method Detail

#### cachePutAll

    public <K,V> GridClientFutureAdapter<Boolean> cachePutAll(String cacheName,
                                                     Map<K,V> entries,
                                                     Set<GridClientCacheFlag> flags,
                                                     UUID destNodeId)
                                                 throws GridClientConnectionResetException,
                                                        GridClientClosedException

Puts bundle of entries into cache.

Specified by:
  `cachePutAll` in class `GridClientConnection`
Parameters:
  `cacheName` - Cache name.
  `entries` - Entries.
  `flags` - Cache flags to be enabled.
  `destNodeId` - Destination node ID.
Returns:
  `True` if map contained more then one entry or if put succeeded in case of one entry, `false` otherwise
Throws:
  `GridClientConnectionResetException` - In case of error.
  `GridClientClosedException` - If client was manually closed before request was sent over network.

#### cacheGetAll

    public <K,V> GridClientFutureAdapter<Map<K,V>> cacheGetAll(String cacheName,
                                                      Collection<K> keys,
                                                      Set<GridClientCacheFlag> flags,
                                                      UUID destNodeId)
                                                  throws GridClientConnectionResetException,
                                                         GridClientClosedException

Gets bundle of entries for specified keys from the cache.

Specified by:
  `cacheGetAll` in class `GridClientConnection`
Parameters:
  `cacheName` - Cache name.
  `keys` - Keys.
  `flags` - Cache flags to be enabled.
  `destNodeId` - Destination node ID.
Returns:
  Entries.
Throws:
  `GridClientConnectionResetException` - In case of error.
  `GridClientClosedException` - If client was manually closed before request was sent over network.

#### cacheRemove

    public <K> GridClientFutureAdapter<Boolean> cacheRemove(String cacheName,
                                                   K key,
                                                   Set<GridClientCacheFlag> flags,
                                                   UUID destNodeId)
                                                 throws GridClientConnectionResetException,
                                                        GridClientClosedException

Removes entry from the cache for specified key.

Specified by:
  `cacheRemove` in class `GridClientConnection`
Parameters:
  `cacheName` - Cache name.
  `key` - Key.
  `flags` - Cache flags to be enabled.
  `destNodeId` - Destination node ID.
Returns:
  Whether entry was actually removed.
Throws:
  `GridClientConnectionResetException` - In case of error.
  `GridClientClosedException` - If client was manually closed before request was sent over network.

#### cacheRemoveAll

    public <K> GridClientFutureAdapter<Boolean> cacheRemoveAll(String cacheName,
                                                      Collection<K> keys,
                                                      Set<GridClientCacheFlag> flags,
                                                      UUID destNodeId)
                                                    throws GridClientConnectionResetException,
                                                           GridClientClosedException

Removes bundle of entries for specified keys from the cache.

Specified by:
  `cacheRemoveAll` in class `GridClientConnection`
Parameters:
  `cacheName` - Cache name.
  `keys` - Keys.
  `flags` - Cache flags to be enabled.
  `destNodeId` - Destination node ID.
Returns:
  Whether entries were actually removed
Throws:
  `GridClientConnectionResetException` - In case of error.
  `GridClientClosedException` - If client was manually closed before request was sent over network.

#### cacheReplace

    public <K,V> GridClientFutureAdapter<Boolean> cacheReplace(String cacheName,
                                                      K key,
                                                      V val,
                                                      Set<GridClientCacheFlag> flags,
                                                      UUID destNodeId)
                                                  throws GridClientConnectionResetException,
                                                         GridClientClosedException

Replace key-value pair in cache if already exist.

Specified by:
  `cacheReplace` in class `GridClientConnection`
Parameters:
  `cacheName` - Cache name.
  `key` - Key.
  `val` - Value.
  `flags` - Cache flags to be enabled.
  `destNodeId` - Destination node ID.
Returns:
  Whether value was actually replaced.
Throws:
  `GridClientConnectionResetException` - In case of error.
  `GridClientClosedException` - If client was manually closed before request was sent over network.

#### cacheCompareAndSet

    public <K,V> GridClientFutureAdapter<Boolean> cacheCompareAndSet(String cacheName,
                                                            K key,
                                                            V newVal,
                                                            V oldVal,
                                                            Set<GridClientCacheFlag> flags,
                                                            UUID destNodeId)
                                                        throws GridClientConnectionResetException,
                                                               GridClientClosedException

New value | Actual/old value | Behaviour
--- | --- | ---
null | null | Remove entry for key.
newVal | null | Put newVal into cache if such key doesn't exist.
null | oldVal | Remove if actual value oldVal is equals to value in cache.
newVal | oldVal | Replace if actual value oldVal is equals to value in cache.

Specified by:
  `cacheCompareAndSet` in class `GridClientConnection`
Parameters:
  `cacheName` - Cache name.
  `key` - Key.
  `newVal` - Value 1.
  `oldVal` - Value 2.
  `flags` - Cache flags to be enabled.
  `destNodeId` - Destination node ID.
Returns:
  Whether new value was actually set.
Throws:
  `GridClientConnectionResetException` - In case of error.
  `GridClientClosedException` - If client was manually closed before request was sent over network.

#### cacheMetrics

    public <K> GridClientFutureAdapter<GridClientDataMetrics> cacheMetrics(String cacheName,
                                                                  UUID destNodeId)
                                                                throws GridClientConnectionResetException,
                                                                       GridClientClosedException

Gets cache metrics for the key.

Specified by:
  `cacheMetrics` in class `GridClientConnection`
Parameters:
  `cacheName` - Cache name.
  `destNodeId` - Destination node ID.
Returns:
  Metrics.
Throws:
  `GridClientConnectionResetException` - In case of error.
  `GridClientClosedException` - If client was manually closed before request was sent over network.

#### cacheAppend

    public <K,V> GridClientFutureAdapter<Boolean> cacheAppend(String cacheName,
                                                     K key,
                                                     V val,
                                                     Set<GridClientCacheFlag> flags,
                                                     UUID destNodeId)
                                                 throws GridClientConnectionResetException,
                                                        GridClientClosedException

Append requested value to already cached one.

Specified by:
  `cacheAppend` in class `GridClientConnection`
Parameters:
  `cacheName` - Cache name.
  `key` - Key.
  `val` - Value to append to the cached one.
  `flags` - Cache flags to be enabled.
  `destNodeId` - Destination node ID.
Returns:
  Whether new value was actually set.
Throws:
  `GridClientConnectionResetException` - In case of error.
  `GridClientClosedException` - If client was manually closed before request was sent over network.

#### cachePrepend

    public <K,V> GridClientFutureAdapter<Boolean> cachePrepend(String cacheName,
                                                      K key,
                                                      V val,
                                                      Set<GridClientCacheFlag> flags,
                                                      UUID destNodeId)
                                                  throws GridClientConnectionResetException,
                                                         GridClientClosedException

Prepend requested value to already cached one.

Specified by:
  `cachePrepend` in class `GridClientConnection`
Parameters:
  `cacheName` - Cache name.
  `key` - Key.
  `val` - Value to prepend to the cached one.
  `flags` - Cache flags to be enabled.
  `destNodeId` - Destination node ID.
Returns:
  Whether new value was actually set.
Throws:
  `GridClientConnectionResetException` - In case of error.
  `GridClientClosedException` - If client was manually closed before request was sent over network.

#### execute

    public <R> GridClientFutureAdapter<R> execute(String taskName,
                                         Object arg,
                                         UUID destNodeId,
                                         boolean keepPortables)
                                       throws GridClientConnectionResetException,
                                              GridClientClosedException

Execute task in the grid.

Specified by:
  `execute` in class `GridClientConnection`
Parameters:
  `taskName` - Task name.
  `arg` - Task argument.
  `destNodeId` - Destination node ID.
  `keepPortables` - Keep portables flag.
Returns:
  Task execution result.
Throws:
  `GridClientConnectionResetException` - In case of error.
  `GridClientClosedException` - If client was manually closed before request was sent over network.

#### node

    public GridClientFuture<GridClientNode> node(UUID id,
                                        boolean inclAttrs,
                                        boolean inclMetrics,
                                        UUID destNodeId)
                                          throws GridClientConnectionResetException,
                                                 GridClientClosedException

Gets node by node ID.

Specified by:
  `node` in class `GridClientConnection`
Parameters:
  `id` - Node ID.
  `inclAttrs` - Whether to include attributes.
  `inclMetrics` - Whether to include metrics.
  `destNodeId` - Destination node ID.
Returns:
  Node.
Throws:
  `GridClientConnectionResetException` - In case of error.
  `GridClientClosedException` - If client was manually closed before request was sent over network.

#### node

    public GridClientFuture<GridClientNode> node(String ipAddr,
                                        boolean inclAttrs,
                                        boolean includeMetrics,
                                        UUID destNodeId)
                                          throws GridClientConnectionResetException,
                                                 GridClientClosedException

Gets node by node IP.

Specified by:
  `node` in class `GridClientConnection`
Parameters:
  `ipAddr` - IP address.
  `inclAttrs` - Whether to include attributes.
  `includeMetrics` - Whether to include metrics.
  `destNodeId` - Destination node ID.
Returns:
  Node.
Throws:
  `GridClientConnectionResetException` - In case of error.
  `GridClientClosedException` - If client was manually closed before request was sent over network.

#### topology

    public GridClientFuture<List<GridClientNode>> topology(boolean inclAttrs,
                                                  boolean inclMetrics,
                                                  UUID destNodeId)
                                                    throws GridClientConnectionResetException,
                                                           GridClientClosedException

Gets grid topology nodes.

Specified by:
  `topology` in class `GridClientConnection`
Parameters:
  `inclAttrs` - Whether to include attributes.
  `inclMetrics` - Whether to include metrics.
  `destNodeId` - Destination node ID.
Returns:
  Nodes.
Throws:
  `GridClientConnectionResetException` - In case of error.
  `GridClientClosedException` - If client was manually closed before request was sent over network.

#### forwardMessage

    public GridClientFutureAdapter<GridRouterRequest> forwardMessage(Object msg)
                                                              throws GridClientException

Forwards a message in raw form to the connected node. This method supposed to be used only inside router. The exact types of acceptable arguments and return values depend on connection implementation.

Specified by:
  `forwardMessage` in class `GridClientConnection`
Parameters:
  `msg` - A raw message to send.
Returns:
  Future holding server's response.
Throws:
  `GridClientException` - If message forwarding failed.

2015 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 1.1.0-incubating
Release Date | : May 20 2015