public class GridClientDataImpl extends Object implements GridClientData
| Modifier and Type | Class and Description |
|---|---|
protected static interface |
GridClientAbstractProjection.ClientProjectionClosure<R>
Closure to execute reconnect-handling code.
|
protected static interface |
GridClientAbstractProjection.ProjectionFactory<X extends org.apache.ignite.internal.client.impl.GridClientAbstractProjection>
Factory for new projection creation.
|
| Modifier and Type | Field and Description |
|---|---|
protected GridClientLoadBalancer |
balancer
Balancer to be used in this projection.
|
protected GridClientImpl |
client
Client instance.
|
protected GridClientPredicate<? super GridClientNode> |
filter
Node filter to be applied for this projection.
|
protected Collection<GridClientNode> |
nodes
List of nodes included in this projection.
|
| Modifier and Type | Method and Description |
|---|---|
<K> UUID |
affinity(K key)
Gets affinity node ID for provided key.
|
<K,V> boolean |
append(K key,
V val)
Append requested value to already cached one.
|
<K,V> GridClientFuture<Boolean> |
appendAsync(K key,
V val)
Append requested value to already cached one.
|
GridClientDataMetrics |
cachedMetrics()
Tries to get metrics from local cache.
|
String |
cacheName()
Gets name of the remote cache.
|
<K,V> boolean |
cas(K key,
V val1,
V val2)
Sets entry value to
val1 if current value is val2 with
following conditions:
If val1 is null and val2 is equal to current value,
entry is removed from cache. |
<K,V> GridClientFuture<Boolean> |
casAsync(K key,
V val1,
V val2)
Asynchronously sets entry value to
val1 if current value is val2
with following conditions:
If val1 is null and val2 is equal to current value,
entry is removed from cache. |
protected boolean |
checkNodeAlive(UUID nodeId)
Tries to refresh node on every possible connection in topology.
|
protected T |
createProjection(Collection<GridClientNode> nodes,
GridClientPredicate<? super GridClientNode> filter,
GridClientLoadBalancer balancer,
GridClientAbstractProjection.ProjectionFactory<T> factory)
Creates a sub-projection for current projection.
|
Set<GridClientCacheFlag> |
flags()
Gets cache flags enabled on this data projection.
|
GridClientData |
flagsOff(GridClientCacheFlag... flags)
Creates new client data object with disabled cache flags.
|
GridClientData |
flagsOn(GridClientCacheFlag... flags)
Creates new client data object with enabled cache flags.
|
<K,V> V |
get(K key)
Gets value from cache on remote node.
|
<K,V> Map<K,V> |
getAll(Collection<K> keys)
Gets entries from cache on remote grid.
|
<K,V> GridClientFuture<Map<K,V>> |
getAllAsync(Collection<K> keys)
Asynchronously gets entries from cache on remote grid.
|
<K,V> GridClientFuture<V> |
getAsync(K key)
Asynchronously gets value from cache on remote grid.
|
GridClientDataMetrics |
metrics()
Fetches metrics for cache from remote grid.
|
GridClientFuture<GridClientDataMetrics> |
metricsAsync()
Asynchronously fetches metrics for cache from remote grid.
|
Collection<GridClientNode> |
pinnedNodes()
Gets pinned node or
null if no nodes were pinned. |
GridClientData |
pinNodes(GridClientNode node,
GridClientNode... nodes)
Gets client data projection which will only contact specified remote grid node.
|
<K,V> boolean |
prepend(K key,
V val)
Prepend requested value to already cached one.
|
<K,V> GridClientFuture<Boolean> |
prependAsync(K key,
V val)
Prepend requested value to already cached one.
|
Collection<? extends GridClientNode> |
projectionNodes()
Gets most recently refreshed topology.
|
protected Collection<? extends GridClientNode> |
projectionNodes(GridClientPredicate<GridClientNode> pred)
Gets most recently refreshed topology.
|
<K,V> boolean |
put(K key,
V val)
Puts value to cache on remote grid.
|
<K,V> void |
putAll(Map<K,V> entries)
Puts entries to cache on remote grid.
|
<K,V> GridClientFuture<?> |
putAllAsync(Map<K,V> entries)
Asynchronously puts entries to cache on remote grid.
|
<K,V> GridClientFuture<Boolean> |
putAsync(K key,
V val)
Asynchronously puts value to cache on remote node.
|
<K> boolean |
remove(K key)
Removes value from cache on remote node.
|
<K> void |
removeAll(Collection<K> keys)
Removes entries from cache on remote node.
|
<K> GridClientFuture<?> |
removeAllAsync(Collection<K> keys)
Asynchronously removes entries from cache on remote grid.
|
<K> GridClientFuture<Boolean> |
removeAsync(K key)
Asynchronously removes value from cache on remote grid.
|
<K,V> boolean |
replace(K key,
V val)
Replaces value in cache on remote grid only if there was a
non-null
value associated with this key. |
<K,V> GridClientFuture<Boolean> |
replaceAsync(K key,
V val)
Asynchronously replaces value in cache on remote grid only if there was a
non-null
value associated with this key. |
protected <R> GridClientFuture<R> |
withReconnectHandling(GridClientAbstractProjection.ClientProjectionClosure<R> c)
This method executes request to a communication layer and handles connection error, if it occurs.
|
protected <R> GridClientFuture<R> |
withReconnectHandling(GridClientAbstractProjection.ClientProjectionClosure<R> c,
String cacheName,
Object affKey)
This method executes request to a communication layer and handles connection error, if it occurs.
|
protected Collection<GridClientNode> nodes
protected GridClientPredicate<? super GridClientNode> filter
protected GridClientLoadBalancer balancer
protected GridClientImpl client
public String cacheName()
GridClient.data(String) method at the time of creation.cacheName in interface GridClientDatapublic GridClientData pinNodes(GridClientNode node, GridClientNode... nodes) throws GridClientException
GridClientDataAffinity provided - this method allows
to override default behavior and use only specified server for all cache operations.
Use this method when there are other than key-affinity reasons why a certain
node should be contacted.
pinNodes in interface GridClientDatanode - Node to be contacted (optional).nodes - Additional nodes (optional).GridClientException - If resulting projection is empty.public Collection<GridClientNode> pinnedNodes()
null if no nodes were pinned.pinnedNodes in interface GridClientDatapublic <K,V> boolean put(K key,
V val)
throws GridClientException
Note that this operation is affinity-aware and will immediately contact
exactly the remote node on which this key is supposed to be cached (unless
some nodes were pinned).
put in interface GridClientDatakey - Key to put in cache.val - Value to put in cache.GridClientException - In case of error.GridServerUnreachableException - If none of the servers can be reached.GridClientClosedException - If client was closed manually.public <K,V> GridClientFuture<Boolean> putAsync(K key, V val)
Note that this operation is affinity-aware and will immediately contact
exactly the remote node on which this key is supposed to be cached (unless
some nodes were pinned).
putAsync in interface GridClientDatakey - Key to put in cache.val - Value to put in cache.public <K,V> void putAll(Map<K,V> entries) throws GridClientException
Note that this operation is affinity-aware and will immediately contact
exactly the remote nodes on which these keys are supposed to be cached (unless
some nodes were pinned). If entries do not map to one node, then the node
which has most mapped entries will be contacted.
putAll in interface GridClientDataentries - Entries to put in cache.GridClientException - In case of error.GridServerUnreachableException - If none of the servers can be reached.GridClientClosedException - If client was closed manually.public <K,V> GridClientFuture<?> putAllAsync(Map<K,V> entries)
Note that this operation is affinity-aware and will immediately contact
exactly the remote nodes on which these keys are supposed to be cached (unless
some nodes were pinned). If entries do not map to one node, then the node
which has most mapped entries will be contacted.
putAllAsync in interface GridClientDataentries - Entries to put in cache.public <K,V> V get(K key)
throws GridClientException
Note that this operation is affinity-aware and will immediately contact
exactly the remote node on which this key is supposed to be cached (unless
some nodes were pinned).
get in interface GridClientDatakey - Key to get from cache.null if no value was cached.GridClientException - In case of error.GridServerUnreachableException - If none of the servers can be reached.GridClientClosedException - If client was closed manually.public <K,V> GridClientFuture<V> getAsync(K key)
Note that this operation is affinity-aware and will immediately contact
exactly the remote node on which this key is supposed to be cached (unless
some nodes were pinned).
getAsync in interface GridClientDatakey - Key to get from cache.null if no value was cached.public <K,V> Map<K,V> getAll(Collection<K> keys) throws GridClientException
Note that this operation is affinity-aware and will immediately contact
exactly the remote nodes on which these keys are supposed to be cached (unless
some nodes were pinned). If entries do not map to one node, then the node
which has most mapped entries will be contacted.
getAll in interface GridClientDatakeys - Keys to get.GridClientException - In case of error.GridServerUnreachableException - If none of the servers can be reached.GridClientClosedException - If client was closed manually.public <K,V> GridClientFuture<Map<K,V>> getAllAsync(Collection<K> keys)
Note that this operation is affinity-aware and will immediately contact
exactly the remote nodes on which these keys are supposed to be cached (unless
some nodes were pinned). If entries do not map to one node, then the node
which has most mapped entries will be contacted.
getAllAsync in interface GridClientDatakeys - Keys to get.public <K> boolean remove(K key)
throws GridClientException
Note that this operation is affinity-aware and will immediately contact
exactly the remote node on which this key is supposed to be cached (unless
some nodes were pinned).
remove in interface GridClientDatakey - Key to remove.GridClientException - In case of error.GridServerUnreachableException - If none of the servers can be reached.GridClientClosedException - If client was closed manually.public <K> GridClientFuture<Boolean> removeAsync(K key)
Note that this operation is affinity-aware and will immediately contact
exactly the remote node on which this key is supposed to be cached (unless
some nodes were pinned).
removeAsync in interface GridClientDatakey - Key to remove.public <K> void removeAll(Collection<K> keys) throws GridClientException
Note that this operation is affinity-aware and will immediately contact
exactly the remote nodes on which these keys are supposed to be cached (unless
some nodes were pinned). If entries do not map to one node, then the node
which has most mapped entries will be contacted.
removeAll in interface GridClientDatakeys - Keys to remove.GridClientException - In case of error.GridServerUnreachableException - If none of the servers can be reached.GridClientClosedException - If client was closed manually.public <K> GridClientFuture<?> removeAllAsync(Collection<K> keys)
Note that this operation is affinity-aware and will immediately contact
exactly the remote nodes on which these keys are supposed to be cached (unless
some nodes were pinned). If entries do not map to one node, then the node
which has most mapped entries will be contacted.
removeAllAsync in interface GridClientDatakeys - Keys to remove.public <K,V> boolean replace(K key,
V val)
throws GridClientException
non-null
value associated with this key.
Note that this operation is affinity-aware and will immediately contact
exactly the remote node on which this key is supposed to be cached (unless
some nodes were pinned).
replace in interface GridClientDatakey - Key to replace.val - Value to replace.GridClientException - In case of error.GridServerUnreachableException - If none of the servers can be reached.GridClientClosedException - If client was closed manually.public <K,V> GridClientFuture<Boolean> replaceAsync(K key, V val)
non-null
value associated with this key.
Note that this operation is affinity-aware and will immediately contact
exactly the remote node on which this key is supposed to be cached (unless
some nodes were pinned).
replaceAsync in interface GridClientDatakey - Key to replace.val - Value to replace.public <K,V> boolean cas(K key,
V val1,
V val2)
throws GridClientException
val1 if current value is val2 with
following conditions:
val1 is null and val2 is equal to current value,
entry is removed from cache.
val2 is null, entry is created if it doesn't exist.
val1 and val2 are null, entry is removed.
pinned).cas in interface GridClientDatakey - Key to set.val1 - Value to set.val2 - Check value.GridClientException - In case of error.GridServerUnreachableException - If none of the servers can be reached.GridClientClosedException - If client was closed manually.public <K,V> GridClientFuture<Boolean> casAsync(K key, V val1, V val2)
val1 if current value is val2
with following conditions:
val1 is null and val2 is equal to current value,
entry is removed from cache.
val2 is null, entry is created if it doesn't exist.
val1 and val2 are null, entry is removed.
pinned).casAsync in interface GridClientDatakey - Key to set.val1 - Value to set.val2 - Check value.public <K> UUID affinity(K key) throws GridClientException
null if no
affinity was configured for the given cache for this client or there are no nodes in topology with
cache enabled.affinity in interface GridClientDatakey - Key.GridClientException - In case of error.public GridClientDataMetrics metrics() throws GridClientException
metrics in interface GridClientDataGridClientException - In case of error.GridServerUnreachableException - If none of the servers can be reached.GridClientClosedException - If client was closed manually.public GridClientFuture<GridClientDataMetrics> metricsAsync()
metricsAsync in interface GridClientDatapublic GridClientDataMetrics cachedMetrics() throws GridClientException
Local cache is updated on every GridClientData.metrics() or GridClientData.metricsAsync() call
if GridClientConfiguration.isEnableMetricsCache() is enabled. If it is
disabled then this method will always return null.
cachedMetrics in interface GridClientDatanull if no cached metrics available.GridClientException - In case of error.GridServerUnreachableException - If none of the servers can be reached.GridClientClosedException - If client was closed manually.public <K,V> boolean append(K key,
V val)
throws GridClientException
Note that this operation is affinity-aware and will immediately contact
exactly the remote node on which this key is supposed to be cached (unless
some nodes were pinned).
append in interface GridClientDatakey - Key to manipulate cache value for.val - Value to append to the cached one.GridClientException - In case of error.public <K,V> GridClientFuture<Boolean> appendAsync(K key, V val) throws GridClientException
Note that this operation is affinity-aware and will immediately contact
exactly the remote node on which this key is supposed to be cached (unless
some nodes were pinned).
appendAsync in interface GridClientDatakey - Key to manipulate cache value for.val - Value to append to the cached one.GridClientException - In case of error.public <K,V> boolean prepend(K key,
V val)
throws GridClientException
Note that this operation is affinity-aware and will immediately contact
exactly the remote node on which this key is supposed to be cached (unless
some nodes were pinned).
prepend in interface GridClientDatakey - Key to manipulate cache value for.val - Value to prepend to the cached one.GridClientException - In case of error.public <K,V> GridClientFuture<Boolean> prependAsync(K key, V val) throws GridClientException
Note that this operation is affinity-aware and will immediately contact
exactly the remote node on which this key is supposed to be cached (unless
some nodes were pinned).
prependAsync in interface GridClientDatakey - Key to manipulate cache value for.val - Value to prepend to the cached one.GridClientException - In case of error.public Set<GridClientCacheFlag> flags()
flags in interface GridClientDatapublic GridClientData flagsOn(GridClientCacheFlag... flags) throws GridClientException
flagsOn in interface GridClientDataflags - Optional cache flags to be enabled.GridClientException - In case of error.public GridClientData flagsOff(GridClientCacheFlag... flags) throws GridClientException
flagsOff in interface GridClientDataflags - Cache flags to be disabled.GridClientException - In case of error.protected <R> GridClientFuture<R> withReconnectHandling(GridClientAbstractProjection.ClientProjectionClosure<R> c)
R - Result future type.c - Closure to be executed.protected <R> GridClientFuture<R> withReconnectHandling(GridClientAbstractProjection.ClientProjectionClosure<R> c, String cacheName, @Nullable Object affKey)
R - Type of result in future.c - Closure to be executed.cacheName - Cache name for which mapped node will be calculated.affKey - Affinity key.protected boolean checkNodeAlive(UUID nodeId) throws GridClientException, InterruptedException
nodeId - Node id to check.True if response was received, false if either null response received or
no nodes can be contacted at all.GridClientException - If failed to refresh topology or if client was closed manually.InterruptedException - If interrupted.public Collection<? extends GridClientNode> projectionNodes() throws GridClientException
GridClientException - If failed to refresh topology.protected Collection<? extends GridClientNode> projectionNodes(@Nullable GridClientPredicate<GridClientNode> pred) throws GridClientException
pred - Predicate to additionally filter projection nodes,
if null just return projection.GridClientException - If failed to refresh topology.protected T createProjection(@Nullable
Collection<GridClientNode> nodes,
@Nullable
GridClientPredicate<? super GridClientNode> filter,
@Nullable
GridClientLoadBalancer balancer,
GridClientAbstractProjection.ProjectionFactory<T> factory)
throws GridClientException
nodes - Collection of nodes that sub-projection will be restricted to. If null,
created projection is dynamic and will take nodes from topology.filter - Filter to be applied to nodes in projection. If null - no filter applied.balancer - Balancer to use in projection. If null - inherit balancer from the current projection.factory - Factory to create new projection.GridClientException - If resulting projection is empty. Note that this exception may
only be thrown on case of static projections, i.e. where collection of nodes is not null.
Follow @ApacheIgnite
Ignite Fabric : ver. 1.7.0 Release Date : August 1 2016