/** {@inheritDoc} */ @Override public GridClientFuture<GridClientNode> refreshNodeAsync(final UUID id, final boolean includeAttrs, final boolean includeMetrics) { A.notNull(id, "id"); return withReconnectHandling(new ClientProjectionClosure<GridClientNode>() { @Override public GridClientFuture<GridClientNode> apply(GridClientConnection conn, UUID destNodeId) throws GridClientConnectionResetException, GridClientClosedException { return conn.node(id, includeAttrs, includeMetrics, destNodeId); } }); }
/** {@inheritDoc} */ @Nullable @Override public V get(Object key) { A.notNull(key, "key"); return map != null ? map.get(key) : null; }
/** * Converts given iterator into instance of {@link Iterable} interface. * * @param iter Iterator to convert. * @param <T> Type of the iterator. * @return Iterable over given iterator. */ public static <T> GridIterable<T> as(Iterator<T> iter) { A.notNull(iter, "iter"); return new GridIterableAdapter<>(iter); }
/** {@inheritDoc} */ @Override public void transform(K key, GridClosure<V, V> transformer) throws GridException { A.notNull(key, "key", transformer, "valTransform"); cache.transform(key, transformer); }
/** {@inheritDoc} */ @Override public <R> GridFuture<R> transformAndComputeAsync(K key, GridClosure<V, GridBiTuple<V, R>> transformer) { A.notNull(key, "key", transformer, "transformer"); return cache.transformAndComputeAsync(key, transformer); }
/** {@inheritDoc} */ @Override public <K> GridClientFuture<Boolean> removeAsync(final K key) { A.notNull(key, "key"); return withReconnectHandling(new ClientProjectionClosure<Boolean>() { @Override public GridClientFuture<Boolean> apply(GridClientConnection conn, UUID destNodeId) throws GridClientConnectionResetException, GridClientClosedException { return conn.cacheRemove(cacheName, key, flags, destNodeId); } }, cacheName, key); }
/** {@inheritDoc} */ @SuppressWarnings({"unchecked"}) @Nullable @Override public <V> V meta(String name) { A.notNull(name, "name"); synchronized (mux) { return data == null ? null : (V)data.get(name); } }
/** {@inheritDoc} */ @Nullable @Override public V put(K k, V v) { A.notNull(k, "k", v, "v"); V ret = super.put(k, v); onPut(); return ret; }
/** {@inheritDoc} */ @Override public Map<Integer, GridNode> mapPartitionsToNodes(Collection<Integer> parts) { A.notNull(parts, "parts"); Map<Integer, GridNode> map = new HashMap<>(); if (!F.isEmpty(parts)) { for (int p : parts) map.put(p, mapPartitionToNode(p)); } return map; }
/** {@inheritDoc} */ @SuppressWarnings({"unchecked"}) @Nullable @Override public <V> V putMetaIfAbsent(String name, V val) { A.notNull(name, "name", val, "val"); synchronized (mux) { V v = (V) meta(name); if (v == null) return addMeta(name, val); return v; } }
/** {@inheritDoc} */ @Nullable @Override public V putIfAbsent(K k, V v) { A.notNull(k, "k", v, "v"); V ret = super.putIfAbsent(k, v); // Handle size only if put succeeded. if (ret == null) onPut(); return ret; }
/** {@inheritDoc} */ @Override public GridFuture<?> addData(Map.Entry<K, V> entry) throws GridException, IllegalStateException { A.notNull(entry, "entry"); return addData(F.asList(entry)); }
/** {@inheritDoc} */ @Override public void forEach(GridInClosure<GridCacheEntry<K, V>> vis) { A.notNull(vis, "vis"); for (GridCacheEntry<K, V> e : entrySet()) vis.apply(e); }
/** {@inheritDoc} */ @Override public int partition(K key) { A.notNull(key, "key"); return cctx.affinity().partition(key); }
/** {@inheritDoc} */ @Override public boolean contains(Object o) { A.notNull(o, "o"); for (GridCacheEntry<K, V> e : map.values()) if (F.isAll(e, filter) && F.eq(e.getValue(), o)) return true; return false; } }
/** {@inheritDoc} */ @Override public GridFuture<Boolean> putxAsync(K key, V val, @Nullable GridCacheEntryEx<K, V> entry, long ttl, @Nullable GridPredicate<GridCacheEntry<K, V>>[] filter) { A.notNull(key, "key", val, "val"); // Check k-v predicate first. if (!isAll(key, val, true)) return new GridFinishedFuture<>(cctx.kernalContext(), false); return cache.putxAsync(key, val, entry, ttl, and(filter, false)); }
/** {@inheritDoc} */ @Override public boolean isPrimary(GridNode n, K key) { A.notNull(n, "n", key, "key"); return cctx.affinity().primary(n, key, topologyVersion()); }
/** {@inheritDoc} */ @Override public GridCacheQuery<List<?>> createSqlFieldsQuery(String qry) { A.notNull(qry, "qry"); return new GridCacheQueryAdapter<>(ctx, SQL_FIELDS, filter(), null, qry, null, false, prj != null && prj.isKeepPortable()); }
/** {@inheritDoc} */ @Override public void copyMeta(GridMetadataAware from) { A.notNull(from, "from"); synchronized (this) { Map m = from.allMeta(); ensureData(m.size()); attributeDataExtras().putAll(from.allMeta()); } }
/** {@inheritDoc} */ @Override public GridFuture<GridCacheReturn<V>> replacexAsync(K key, V oldVal, V newVal) { A.notNull(key, "key", oldVal, "oldVal", newVal, "newVal"); // Check k-v predicate first. if (!isAll(key, newVal, true)) return new GridFinishedFuture<>(cctx.kernalContext(), new GridCacheReturn<V>(false)); return cache.replacexAsync(key, oldVal, newVal); }