/** * Register local classes. * * @param objs Objects to register. * @throws GridException If registration failed. */ public void registerClasses(Object... objs) throws GridException { registerClasses(F.asList(objs)); }
/** * Adds futures to this compound future. * * @param futs Futures to add. */ public void addAll(@Nullable GridFuture<T>... futs) { addAll(F.asList(futs)); }
/** {@inheritDoc} */ @Override public Set<GridCacheFlag> flags() { GridCacheFlag[] forced = cctx.forcedFlags(); if (F.isEmpty(forced)) return flags; // We don't expect too many flags, so default size is fine. Set<GridCacheFlag> ret = new HashSet<>(); ret.addAll(flags); ret.addAll(F.asList(forced)); return Collections.unmodifiableSet(ret); }
/** * Maps single key to a node. * * @param cacheName Cache name. * @param key Key to map. * @return Picked node. * @throws GridException If failed. */ @Nullable public <K> GridNode mapKeyToNode(@Nullable String cacheName, K key, long topVer) throws GridException { Map<GridNode, Collection<K>> map = keysToNodes(cacheName, F.asList(key), topVer); return map != null ? F.first(map.keySet()) : null; }
/** * Maps single key to a node. * * @param cacheName Cache name. * @param key Key to map. * @return Picked node. * @throws GridException If failed. */ @Nullable public <K> GridNode mapKeyToNode(@Nullable String cacheName, K key) throws GridException { Map<GridNode, Collection<K>> map = keysToNodes(cacheName, F.asList(key)); return map != null ? F.first(map.keySet()) : null; }
/** * @param key Key. * @param filter Filter to evaluate. * @return Cached value. * @throws GridException If failed. */ @Nullable public V get(K key, boolean deserializePortable, @Nullable GridPredicate<GridCacheEntry<K, V>> filter) throws GridException { return getAllAsync(F.asList(key), deserializePortable, filter).get().get(key); }
/** {@inheritDoc} */ @Override public Map<? extends GridComputeJob, GridNode> map(List<GridNode> subgrid, @Nullable Void arg) throws GridException { return outMap(t.get1(), F.asList(t.get2()), subgrid, lb); }
/** {@inheritDoc} */ @Override public Map<? extends GridComputeJob, GridNode> map(List<GridNode> subgrid, @Nullable Void arg) throws GridException { return absMap(t.get1(), F.asList(t.get2()), subgrid, lb); } }
/** {@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 GridCacheProjection<K, V> flagsOn(@Nullable GridCacheFlag[] flags) { if (F.isEmpty(flags)) return this; GridCacheProjectionImpl<K, V> prj = new GridCacheProjectionImpl<>(this, ctx, null, null, EnumSet.copyOf(F.asList(flags)), null, false); return new GridCacheProxyImpl<>(ctx, prj, prj); }
/** {@inheritDoc} */ @Override public GridCacheProjection<K, V> flagsOff(@Nullable GridCacheFlag[] flags) { if (F.isEmpty(flags)) return new GridCacheProxyImpl<>(cctx, this, this); Set<GridCacheFlag> res = EnumSet.noneOf(GridCacheFlag.class); if (!F.isEmpty(this.flags)) res.addAll(this.flags); res.removeAll(EnumSet.copyOf(F.asList(flags))); GridCacheProjectionImpl<K, V> prj = new GridCacheProjectionImpl<>(this, cctx, noNullKvFilter.kvFilter, noNullEntryFilter.entryFilter, res, subjId, keepPortable); return new GridCacheProxyImpl<>(cctx, prj, prj); }
/** {@inheritDoc} */ @Override protected V readThrough(GridCacheTxEx<K, V> tx, K key, boolean reload, GridPredicate<GridCacheEntry<K, V>>[] filter, UUID subjId, String taskName) throws GridException { return cctx.near().loadAsync(tx, F.asList(key), reload, /*force primary*/false, filter, subjId, taskName, true). get().get(key); }
/** {@inheritDoc} */ @Override public V promote(K key) throws GridException { ctx.denyOnFlags(F.asList(READ, SKIP_SWAP)); // Unswap only from dht(). Near cache does not have swap storage. return dht().promote(key); }
/** {@inheritDoc} */ @Override public V promote(K key, boolean deserializePortable) throws GridException { ctx.denyOnFlags(F.asList(READ, SKIP_SWAP)); // Unswap only from dht(). Near cache does not have swap storage. return dht().promote(key, deserializePortable); }
/** {@inheritDoc} */ @Override public Iterator<Map.Entry<K, V>> swapIterator() throws GridException { ctx.denyOnFlags(F.asList(SKIP_SWAP)); return dht().swapIterator(); }
/** {@inheritDoc} */ @Override public V get(K key, @Nullable GridCacheEntryEx<K, V> entry, boolean deserializePortable, @Nullable GridPredicate<GridCacheEntry<K, V>>... filter) throws GridException { String taskName = ctx.kernalContext().job().currentTaskName(); return getAllAsync(F.asList(key), ctx.hasFlag(GET_PRIMARY), /*skip tx*/false, entry, null, taskName, deserializePortable, filter).get().get(key); }
/** {@inheritDoc} */ @Override public void reloadAll() throws GridException { ctx.denyOnFlags(F.asList(LOCAL, READ)); reloadAll(keySet(), (GridPredicate<GridCacheEntry<K, V>>[])null); }
/** {@inheritDoc} */ @Override public void promoteAll(@Nullable Collection<? extends K> keys) throws GridException { ctx.denyOnFlags(F.asList(READ, SKIP_SWAP)); // Unswap only from dht(). Near cache does not have swap storage. // In near-only cache this is a no-op. if (isAffinityNode(ctx.config())) dht().promoteAll(keys); }
/** * @param ctx Context. * @return Managers present in both, DHT and Near caches. */ @SuppressWarnings("IfMayBeConditional") private Collection<GridCacheManager> dhtExcludes(GridCacheContext ctx) { if (ctx.config().getCacheMode() == LOCAL || !isNearEnabled(ctx)) return Collections.emptyList(); else return F.asList((GridCacheManager)ctx.dgc(), ctx.queries(), ctx.continuousQueries()); }
/** {@inheritDoc} */ @Override public V getForcePrimary(K key) throws GridException { ctx.denyOnFlag(LOCAL); String taskName = ctx.kernalContext().job().currentTaskName(); return getAllAsync(F.asList(key), /*force primary*/true, /*skip tx*/false, null, null, taskName, true) .get().get(key); }