public abstract class GridClientConnection extends Object
| Modifier and Type | Field and Description |
|---|---|
protected UUID |
clientId
Client id.
|
protected org.gridgain.client.impl.connection.GridClientConnectionCloseReason |
closeReason
Reason why connection was closed.
|
protected GridClientTopology |
top
Topology
|
| Modifier | Constructor and Description |
|---|---|
protected |
GridClientConnection(UUID clientId,
InetSocketAddress srvAddr,
SSLContext sslCtx,
GridClientTopology top,
Object cred)
Creates a facade.
|
| Modifier and Type | Method and Description |
|---|---|
abstract <K,V> GridClientFutureAdapter<Boolean> |
cacheAppend(String cacheName,
K key,
V val,
Set<GridClientCacheFlag> flags,
UUID destNodeId)
Append requested value to already cached one.
|
abstract <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<V> |
cacheGet(String cacheName,
K key,
Set<GridClientCacheFlag> flags,
UUID destNodeId)
Gets entry from the cache for specified key.
|
abstract <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.
|
abstract <K> GridClientFutureAdapter<GridClientDataMetrics> |
cacheMetrics(String cacheName,
UUID destNodeId)
Gets cache metrics for the key.
|
abstract <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> |
cachePut(String cacheName,
K key,
V val,
Set<GridClientCacheFlag> flags,
UUID destNodeId)
Puts key-value pair into cache.
|
abstract <K,V> GridClientFutureAdapter<Boolean> |
cachePutAll(String cacheName,
Map<K,V> entries,
Set<GridClientCacheFlag> flags,
UUID destNodeId)
Puts bundle of entries into cache.
|
abstract <K> GridClientFutureAdapter<Boolean> |
cacheRemove(String cacheName,
K key,
Set<GridClientCacheFlag> flags,
UUID destNodeId)
Removes entry from the cache for specified key.
|
abstract <K> GridClientFutureAdapter<Boolean> |
cacheRemoveAll(String cacheName,
Collection<K> keys,
Set<GridClientCacheFlag> flags,
UUID destNodeId)
Removes bundle of entries for specified keys from the cache.
|
abstract <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.
|
protected void |
checkClosed(org.gridgain.client.impl.connection.GridClientConnectionCloseReason reason)
Check if this connection was closed and throws appropriate exception.
|
protected Object |
credentials()
Returns credentials for this client connection.
|
static int |
encodeCacheFlags(Collection<GridClientCacheFlag> flagSet)
Encodes cache flags to bit map.
|
abstract <R> GridClientFutureAdapter<R> |
execute(String taskName,
Object arg,
UUID destNodeId)
Execute task in the grid.
|
abstract GridClientFutureAdapter<?> |
forwardMessage(Object body)
Forwards a message in raw form to the connected node.
|
protected GridClientException |
getCloseReasonAsException(org.gridgain.client.impl.connection.GridClientConnectionCloseReason reason,
Throwable cause)
Build appropriate exception from the given close reason.
|
protected String |
getCloseReasonMessage(org.gridgain.client.impl.connection.GridClientConnectionCloseReason reason,
Throwable cause) |
boolean |
isClosed() |
abstract GridClientFuture<List<String>> |
log(String path,
int fromLine,
int toLine,
UUID destNodeId)
Gets log entries.
|
protected GridClientDataMetrics |
metricsMapToMetrics(Map<String,Number> metricsMap)
Converts metrics map to metrics object.
|
abstract GridClientFuture<GridClientNode> |
node(String ipAddr,
boolean inclAttrs,
boolean includeMetrics,
UUID destNodeId)
Gets node by node IP.
|
abstract GridClientFuture<GridClientNode> |
node(UUID id,
boolean inclAttrs,
boolean inclMetrics,
UUID destNodeId)
Gets node by node ID.
|
protected double |
safeDouble(Map<String,Number> map,
String key)
Safely gets double value by given key.
|
protected long |
safeLong(Map<String,Number> map,
String key)
Safely gets long value by given key.
|
InetSocketAddress |
serverAddress()
Gets server address this connection connected to.
|
protected SSLContext |
sslContext()
Gets SSLContext of this client connection.
|
abstract GridClientFuture<List<GridClientNode>> |
topology(boolean inclAttrs,
boolean inclMetrics,
UUID destNodeId)
Gets grid topology nodes.
|
protected GridClientTopology top
protected final UUID clientId
protected volatile org.gridgain.client.impl.connection.GridClientConnectionCloseReason closeReason
null means connection is still alive.protected GridClientConnection(UUID clientId, InetSocketAddress srvAddr, SSLContext sslCtx, GridClientTopology top, Object cred)
clientId - Client identifier.srvAddr - Server address this connection connected to.sslCtx - SSL context to use if SSL is enabled, null otherwise.top - Topology.cred - Client credentials.public InetSocketAddress serverAddress()
public static int encodeCacheFlags(Collection<GridClientCacheFlag> flagSet)
flagSet - Set of flags to be encoded.public <K,V> GridClientFutureAdapter<Boolean> cachePut(String cacheName, K key, V val, Set<GridClientCacheFlag> flags, UUID destNodeId) throws GridClientConnectionResetException, GridClientClosedException
cacheName - Cache name.key - Key.val - Value.flags - Cache flags to be enabled.destNodeId - Destination node ID.GridClientConnectionResetException - In case of error.GridClientClosedException - If client was manually closed before request was sent over network.public <K,V> GridClientFutureAdapter<V> cacheGet(String cacheName, K key, Set<GridClientCacheFlag> flags, UUID destNodeId) throws GridClientConnectionResetException, GridClientClosedException
cacheName - Cache name.key - Key.flags - Cache flags to be enabled.destNodeId - Destination node ID.GridClientConnectionResetException - In case of error.GridClientClosedException - If client was manually closed before request was sent over network.public abstract <K> GridClientFutureAdapter<Boolean> cacheRemove(String cacheName, K key, Set<GridClientCacheFlag> flags, UUID destNodeId) throws GridClientConnectionResetException, GridClientClosedException
cacheName - Cache name.key - Key.flags - Cache flags to be enabled.destNodeId - Destination node ID.GridClientConnectionResetException - In case of error.GridClientClosedException - If client was manually closed before request was sent over network.public abstract <K,V> GridClientFutureAdapter<Boolean> cachePutAll(String cacheName, Map<K,V> entries, Set<GridClientCacheFlag> flags, UUID destNodeId) throws GridClientConnectionResetException, GridClientClosedException
cacheName - Cache name.entries - Entries.flags - Cache flags to be enabled.destNodeId - Destination node ID.True if map contained more then one entry or if put succeeded in case of one entry,
false otherwiseGridClientConnectionResetException - In case of error.GridClientClosedException - If client was manually closed before request was sent over network.public abstract <K,V> GridClientFutureAdapter<Map<K,V>> cacheGetAll(String cacheName, Collection<K> keys, Set<GridClientCacheFlag> flags, UUID destNodeId) throws GridClientConnectionResetException, GridClientClosedException
cacheName - Cache name.keys - Keys.flags - Cache flags to be enabled.destNodeId - Destination node ID.GridClientConnectionResetException - In case of error.GridClientClosedException - If client was manually closed before request was sent over network.public abstract <K> GridClientFutureAdapter<Boolean> cacheRemoveAll(String cacheName, Collection<K> keys, Set<GridClientCacheFlag> flags, UUID destNodeId) throws GridClientConnectionResetException, GridClientClosedException
cacheName - Cache name.keys - Keys.flags - Cache flags to be enabled.destNodeId - Destination node ID.GridClientConnectionResetException - In case of error.GridClientClosedException - If client was manually closed before request was sent over network.public abstract <K,V> GridClientFutureAdapter<Boolean> cacheReplace(String cacheName, K key, V val, Set<GridClientCacheFlag> flags, UUID destNodeId) throws GridClientConnectionResetException, GridClientClosedException
cacheName - Cache name.key - Key.val - Value.flags - Cache flags to be enabled.destNodeId - Destination node ID.GridClientConnectionResetException - In case of error.GridClientClosedException - If client was manually closed before request was sent over network.public abstract <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. |
cacheName - Cache name.key - Key.newVal - Value 1.oldVal - Value 2.flags - Cache flags to be enabled.destNodeId - Destination node ID.GridClientConnectionResetException - In case of error.GridClientClosedException - If client was manually closed before request was sent over network.public abstract <K> GridClientFutureAdapter<GridClientDataMetrics> cacheMetrics(String cacheName, UUID destNodeId) throws GridClientConnectionResetException, GridClientClosedException
cacheName - Cache name.destNodeId - Destination node ID.GridClientConnectionResetException - In case of error.GridClientClosedException - If client was manually closed before request was sent over network.public abstract <K,V> GridClientFutureAdapter<Boolean> cacheAppend(String cacheName, K key, V val, Set<GridClientCacheFlag> flags, UUID destNodeId) throws GridClientConnectionResetException, GridClientClosedException
cacheName - Cache name.key - Key.val - Value to append to the cached one.flags - Cache flags to be enabled.destNodeId - Destination node ID.GridClientConnectionResetException - In case of error.GridClientClosedException - If client was manually closed before request was sent over network.public abstract <K,V> GridClientFutureAdapter<Boolean> cachePrepend(String cacheName, K key, V val, Set<GridClientCacheFlag> flags, UUID destNodeId) throws GridClientConnectionResetException, GridClientClosedException
cacheName - Cache name.key - Key.val - Value to prepend to the cached one.flags - Cache flags to be enabled.destNodeId - Destination node ID.GridClientConnectionResetException - In case of error.GridClientClosedException - If client was manually closed before request was sent over network.public abstract <R> GridClientFutureAdapter<R> execute(String taskName, Object arg, UUID destNodeId) throws GridClientConnectionResetException, GridClientClosedException
taskName - Task name.arg - Task argument.destNodeId - Destination node ID.GridClientConnectionResetException - In case of error.GridClientClosedException - If client was manually closed before request was sent over network.public abstract GridClientFuture<GridClientNode> node(UUID id, boolean inclAttrs, boolean inclMetrics, UUID destNodeId) throws GridClientConnectionResetException, GridClientClosedException
id - Node ID.inclAttrs - Whether to include attributes.inclMetrics - Whether to include metrics.destNodeId - Destination node ID.GridClientConnectionResetException - In case of error.GridClientClosedException - If client was manually closed before request was sent over network.public abstract GridClientFuture<GridClientNode> node(String ipAddr, boolean inclAttrs, boolean includeMetrics, UUID destNodeId) throws GridClientConnectionResetException, GridClientClosedException
ipAddr - IP address.inclAttrs - Whether to include attributes.includeMetrics - Whether to include metrics.destNodeId - Destination node ID.GridClientConnectionResetException - In case of error.GridClientClosedException - If client was manually closed before request was sent over network.public abstract GridClientFuture<List<GridClientNode>> topology(boolean inclAttrs, boolean inclMetrics, @Nullable UUID destNodeId) throws GridClientConnectionResetException, GridClientClosedException
inclAttrs - Whether to include attributes.inclMetrics - Whether to include metrics.destNodeId - Destination node ID.GridClientConnectionResetException - In case of error.GridClientClosedException - If client was manually closed before request was sent over network.public abstract GridClientFuture<List<String>> log(@Nullable String path, int fromLine, int toLine, UUID destNodeId) throws GridClientConnectionResetException, GridClientClosedException
path - Log file path. If null, then default path will be used.fromLine - Index of start line that should be retrieved.toLine - Index of end line that should be retrieved.destNodeId - Destination node ID.GridClientConnectionResetException - In case of error.GridClientClosedException - If client was manually closed before request was sent over network.public abstract GridClientFutureAdapter<?> forwardMessage(Object body) throws GridClientException
body - A raw message to send.GridClientException - If message forwarding failed.public boolean isClosed()
True if connection is closed.protected SSLContext sslContext()
SSLContext instance.protected Object credentials()
protected long safeLong(Map<String,Number> map, String key)
map - Map to get value from.key - Metrics name.protected double safeDouble(Map<String,Number> map, String key)
map - Map to get value from.key - Metrics name.protected GridClientDataMetrics metricsMapToMetrics(Map<String,Number> metricsMap)
metricsMap - Map to convert.protected void checkClosed(org.gridgain.client.impl.connection.GridClientConnectionCloseReason reason)
throws GridConnectionIdleClosedException,
GridClientConnectionResetException,
GridClientClosedException
reason - Close reason.GridConnectionIdleClosedException - If connection was closed as idle.GridClientClosedException - If client was closed by by external call.GridClientConnectionResetException - If connection was closed because of failure.protected GridClientException getCloseReasonAsException(org.gridgain.client.impl.connection.GridClientConnectionCloseReason reason, @Nullable Throwable cause)
reason - Close reason.cause - Cause of connection close, or null in case of regular close.protected String getCloseReasonMessage(org.gridgain.client.impl.connection.GridClientConnectionCloseReason reason, @Nullable Throwable cause)
reason - Close reason.cause - Cause of connection close, or null in case of regular close.Copyright © 2014. All rights reserved.