/** * @return {@code True} if cache is local. */ public boolean isLocal() { return cache != null && cache.isLocal(); }
/** {@inheritDoc} */ @Override public Collection<Integer> lostPartitions() { if (isLocal()) return Collections.emptyList(); return ctx.topology().lostPartitions(); }
/** {@inheritDoc} */ @Override public int size(CachePeekMode[] peekModes) throws IgniteCheckedException { if (isLocal()) return localSize(peekModes); return sizeAsync(peekModes).get(); }
/** {@inheritDoc} */ @Override public long sizeLong(CachePeekMode[] peekModes) throws IgniteCheckedException { if (isLocal()) return localSizeLong(peekModes); return sizeLongAsync(peekModes).get(); }
/** {@inheritDoc} */ @Override public long sizeLong(int partition, CachePeekMode[] peekModes) throws IgniteCheckedException { if (isLocal()) return localSizeLong(partition, peekModes); return sizeLongAsync(partition, peekModes).get(); }
/** {@inheritDoc} */ @Override public void preloadPartition(int part) throws IgniteCheckedException { if (isLocal()) ctx.offheap().preloadPartition(part); else executePreloadTask(part).get(); }
/** * @param keys Keys to clear or {@code null} if all cache should be cleared. * @return Future. */ private IgniteInternalFuture<?> clearAsync(@Nullable final Set<? extends K> keys) { //TODO IGNITE-7952 MvccUtils.verifyMvccOperationSupport(ctx, "Clear"); if (isLocal()) return clearLocallyAsync(keys); else return executeClearTask(keys, false).chain(new CX1<IgniteInternalFuture<?>, Object>() { @Override public Object applyx(IgniteInternalFuture<?> fut) throws IgniteCheckedException { executeClearTask(keys, true).get(); return null; } }); }
/** {@inheritDoc} */ @Override public IgniteFuture<Void> loadCacheAsync(@Nullable IgniteBiPredicate<K, V> p, @Nullable Object... args) throws CacheException { GridCacheContext<K, V> ctx = getContextSafe(); try { if (ctx.cache().isLocal()) return (IgniteFuture<Void>)createFuture(ctx.cache().localLoadCacheAsync(p, args)); return (IgniteFuture<Void>)createFuture(ctx.cache().globalLoadCacheAsync(p, args)); } catch (IgniteCheckedException | IgniteException e) { throw cacheException(e); } }
/** * @param keys Keys to clear. * @throws IgniteCheckedException In case of error. */ private void clear(@Nullable Set<? extends K> keys) throws IgniteCheckedException { //TODO IGNITE-7952 MvccUtils.verifyMvccOperationSupport(ctx, "Clear"); if (isLocal()) { if (keys == null) clearLocally(true, false, false); else clearLocallyAll(keys, true, false, false); } else { executeClearTask(keys, false).get(); executeClearTask(keys, true).get(); } }
/** {@inheritDoc} */ @Override public void loadCache(@Nullable IgniteBiPredicate<K, V> p, @Nullable Object... args) { GridCacheContext<K, V> ctx = getContextSafe(); try { if (isAsync()) { if (ctx.cache().isLocal()) setFuture(ctx.cache().localLoadCacheAsync(p, args)); else setFuture(ctx.cache().globalLoadCacheAsync(p, args)); } else { if (ctx.cache().isLocal()) ctx.cache().localLoadCache(p, args); else ctx.cache().globalLoadCache(p, args); } } catch (IgniteCheckedException | IgniteException e) { throw cacheException(e); } }
/** {@inheritDoc} */ @Override public IgniteInternalFuture<?> preloadPartitionAsync(int part) throws IgniteCheckedException { if (isLocal()) { return ctx.kernalContext().closure().runLocalSafe(() -> { try { ctx.offheap().preloadPartition(part); } catch (IgniteCheckedException e) { throw new IgniteException(e); } }); } else return executePreloadTask(part); }
GridCacheAdapter cache = ctx.cache().internalCache(hnd0.cacheName()); if (cache != null && !cache.isLocal() && cache.context().userCache()) req.addUpdateCounters(ctx.localNodeId(), toCountersMap(cache.context().topology().localUpdateCounters(false)));
GridCacheAdapter cache = ctx.cache().internalCache(hnd0.cacheName()); if (cache != null && !cache.isLocal() && cache.context().userCache()) { CachePartitionPartialCountersMap cntrsMap = cache.context().topology().localUpdateCounters(false);
/** * @return {@code True} if cache is local. */ public boolean isLocal() { return cache != null && cache.isLocal(); }
GridCacheAdapter internalCache = internalCache(srvNodeCache); if (internalCache.isLocal()) return;
GridCacheAdapter internalCache = internalCache(fullCache); if (internalCache.isLocal()) return;
/** {@inheritDoc} */ @Override public Collection<Integer> lostPartitions() { if (isLocal()) return Collections.emptyList(); return ctx.topology().lostPartitions(); }
/** {@inheritDoc} */ @Override public int size(CachePeekMode[] peekModes) throws IgniteCheckedException { if (isLocal()) return localSize(peekModes); return sizeAsync(peekModes).get(); }
/** {@inheritDoc} */ @Override public long sizeLong(CachePeekMode[] peekModes) throws IgniteCheckedException { if (isLocal()) return localSizeLong(peekModes); return sizeLongAsync(peekModes).get(); }
/** {@inheritDoc} */ @Override public long sizeLong(int partition, CachePeekMode[] peekModes) throws IgniteCheckedException { if (isLocal()) return localSizeLong(partition, peekModes); return sizeLongAsync(partition, peekModes).get(); }