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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <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. 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.<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.GridClientFuture<?>changeState(ClusterState state, UUID destNodeId)Changes grid global state.GridClientFuture<?>changeState(ClusterState state, UUID destNodeId, boolean forceDeactivation)Changes grid global state.GridClientFuture<String>clusterName(UUID destNodeId)Get a cluster name.<R> GridClientFutureAdapter<R>execute(String taskName, Object arg, UUID destNodeId, boolean keepBinaries)Execute task in the grid.GridClientFutureAdapter<GridRouterRequest>forwardMessage(Object msg)Forwards a message in raw form to the connected node.GridClientFutureAdapter<?>messageBeforeStart(Object msg)Sending messages before node starts and getting a response to it.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<ClusterState>state(UUID destNodeId)Gets current grid global state.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, getCloseReasonAsException, getCloseReasonMessage, isClosed, metricsMapToMetrics, safeDouble, safeLong, serverAddress, sslContext
-
-
-
-
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:
cachePutAllin classGridClientConnection- Parameters:
cacheName- Cache name.entries- Entries.flags- Cache flags to be enabled.destNodeId- Destination node ID.- Returns:
Trueif map contained more then one entry or if put succeeded in case of one entry,falseotherwise- 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:
cacheGetAllin classGridClientConnection- 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:
cacheRemovein classGridClientConnection- 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:
cacheRemoveAllin classGridClientConnection- 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:
cacheReplacein classGridClientConnection- 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:
cacheCompareAndSetin classGridClientConnection- 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:
cacheMetricsin classGridClientConnection- 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:
cacheAppendin classGridClientConnection- 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:
cachePrependin classGridClientConnection- 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 keepBinaries) throws GridClientConnectionResetException, GridClientClosedException
Execute task in the grid.- Specified by:
executein classGridClientConnection- Parameters:
taskName- Task name.arg- Task argument.destNodeId- Destination node ID.keepBinaries- Keep binary flag.- Returns:
- Task execution result.
- Throws:
GridClientConnectionResetException- In case of error.GridClientClosedException- If client was manually closed before request was sent over network.
-
changeState
public GridClientFuture<?> changeState(ClusterState state, UUID destNodeId, boolean forceDeactivation) throws GridClientClosedException, GridClientConnectionResetException
Changes grid global state.- Specified by:
changeStatein classGridClientConnection- Parameters:
state- New cluster state.destNodeId- Destination node id.forceDeactivation- Iftrue, cluster deactivation will be forced.- Throws:
GridClientClosedException- If client was manually closed before request was sent over network.GridClientConnectionResetException- In case of error.
-
changeState
public GridClientFuture<?> changeState(ClusterState state, UUID destNodeId) throws GridClientClosedException, GridClientConnectionResetException
Changes grid global state.- Specified by:
changeStatein classGridClientConnection- Parameters:
state- New cluster state.destNodeId- Destination node id.- Throws:
GridClientClosedException- If client was manually closed before request was sent over network.GridClientConnectionResetException- In case of error.
-
state
public GridClientFuture<ClusterState> state(UUID destNodeId) throws GridClientClosedException, GridClientConnectionResetException
Gets current grid global state.- Specified by:
statein classGridClientConnection- Parameters:
destNodeId- Destination node id.- Throws:
GridClientClosedException- If client was manually closed before request was sent over network.GridClientConnectionResetException- In case of error.
-
node
public GridClientFuture<GridClientNode> node(UUID id, boolean inclAttrs, boolean inclMetrics, UUID destNodeId) throws GridClientConnectionResetException, GridClientClosedException
Gets node by node ID.- Specified by:
nodein classGridClientConnection- 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:
nodein classGridClientConnection- 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:
topologyin classGridClientConnection- 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:
forwardMessagein classGridClientConnection- Parameters:
msg- A raw message to send.- Returns:
- Future holding server's response.
- Throws:
GridClientException- If message forwarding failed.
-
clusterName
public GridClientFuture<String> clusterName(UUID destNodeId) throws GridClientClosedException, GridClientConnectionResetException
Get a cluster name.- Specified by:
clusterNamein classGridClientConnection- Parameters:
destNodeId- Destination node id.- Returns:
- Future to get the cluster name.
- Throws:
GridClientClosedException- If client was manually closed before request was sent over network.GridClientConnectionResetException- In case of error.
-
messageBeforeStart
public GridClientFutureAdapter<?> messageBeforeStart(Object msg) throws GridClientException
Sending messages before node starts and getting a response to it.- Specified by:
messageBeforeStartin classGridClientConnection- Parameters:
msg- A raw message to send.- Returns:
- Future holding server's response.
- Throws:
GridClientException- In case of error.
-
-