/** * @return Context. */ @Override public GridCacheContext<K, V> context() { return getContextSafe(); }
/** {@inheritDoc} */ @Override public <T> T unwrap(Class<T> clazz) { if (clazz.isAssignableFrom(getClass())) return (T)this; else if (clazz.isAssignableFrom(IgniteEx.class)) { GridCacheContext<K, V> ctx = getContextSafe(); return (T)ctx.grid(); } throw new IllegalArgumentException("Unwrapping to class is not supported: " + clazz); }
/** {@inheritDoc} */ @Override public CacheMetrics metrics() { GridCacheContext<K, V> ctx = getContextSafe(); return ctx.cache().clusterMetrics(); }
/** {@inheritDoc} */ @Override public CacheMetrics localMetrics() { GridCacheContext<K, V> ctx = getContextSafe(); return ctx.cache().localMetrics(); }
/** {@inheritDoc} */ @Override public CacheMetrics metrics(ClusterGroup grp) { GridCacheContext<K, V> ctx = getContextSafe(); return ctx.cache().clusterMetrics(grp); }
/** {@inheritDoc} */ @Override public CacheMetricsMXBean mxBean() { GridCacheContext<K, V> ctx = getContextSafe(); return ctx.cache().clusterMxBean(); }
/** {@inheritDoc} */ @Override public CacheMetricsMXBean localMxBean() { GridCacheContext<K, V> ctx = getContextSafe(); return ctx.cache().localMxBean(); }
/** {@inheritDoc} */ @Override public void deregisterCacheEntryListener(CacheEntryListenerConfiguration<K, V> lsnrCfg) { GridCacheContext<K, V> ctx = getContextSafe(); try { ctx.continuousQueries().cancelJCacheQuery(lsnrCfg); } catch (IgniteCheckedException | IgniteException e) { throw cacheException(e); } }
/** * @return Internal proxy. */ @Override public GridCacheProxyImpl<K, V> internalProxy() { GridCacheContext<K, V> ctx = getContextSafe(); IgniteInternalCache<K, V> delegate = getDelegateSafe(); return new GridCacheProxyImpl<>(ctx, delegate, ctx.operationContextPerCall()); }
/** {@inheritDoc} */ @Override public IgniteFuture<Boolean> rebalance() { GridCacheContext<K, V> ctx = getContextSafe(); return new IgniteFutureImpl<>(ctx.preloader().forceRebalance()); }
/** * Converts query arguments to BinaryObjects if binary marshaller used. * * @param args Arguments. */ private void convertToBinary(final Object[] args) { if (args == null) return; GridCacheContext<K, V> ctx = getContextSafe(); for (int i = 0; i < args.length; i++) args[i] = ctx.cacheObjects().binary().toBinary(args[i]); }
/** {@inheritDoc} */ @Override public void clearStatistics() { GridCacheContext<K, V> ctx = getContextSafe(); try { ctx.kernalContext().cache().clearStatistics(Collections.singleton(getName())); } catch (IgniteCheckedException e) { throw cacheException(e); } }
/** {@inheritDoc} */ @Override public void enableStatistics(boolean enabled) { GridCacheContext<K, V> ctx = getContextSafe(); try { ctx.kernalContext().cache().enableStatistics(Collections.singleton(getName()), enabled); } catch (IgniteCheckedException e) { throw cacheException(e); } }
/** {@inheritDoc} */ @Override public IgniteFuture<?> closeAsync() { GridCacheContext<K, V> ctx = getContextSafe(); return new IgniteFutureImpl<>(ctx.kernalContext().cache().dynamicCloseCache(cacheName)); }
/** {@inheritDoc} */ @Override public IgniteFuture<?> destroyAsync() { GridCacheContext<K, V> ctx = getContextSafe(); return new IgniteFutureImpl<>(ctx.kernalContext().cache().dynamicDestroyCache(cacheName, false, true, false, null)); }
/** {@inheritDoc} */ @Override public boolean isClosed() { GridCacheContext<K, V> ctx = getContextSafe(); return ctx.kernalContext().cache().context().closed(ctx); }
/** {@inheritDoc} */ @Override public Lock lockAll(final Collection<? extends K> keys) { IgniteInternalCache<K, V> delegate = getDelegateSafe(); GridCacheContext<K, V> ctx = getContextSafe(); //TODO: IGNITE-9324: add explicit locks support. MvccUtils.verifyMvccOperationSupport(ctx, "Lock"); return new CacheLockImpl<>(ctx.gate(), delegate, ctx.operationContextPerCall(), keys); }
/** {@inheritDoc} */ @Override public void registerCacheEntryListener(CacheEntryListenerConfiguration<K, V> lsnrCfg) { GridCacheContext<K, V> ctx = getContextSafe(); try { CacheOperationContext opCtx = ctx.operationContextPerCall(); ctx.continuousQueries().executeJCacheQuery(lsnrCfg, false, opCtx != null && opCtx.isKeepBinary()); } catch (IgniteCheckedException | IgniteException e) { throw cacheException(e); } }
/** {@inheritDoc} */ @Override public IgniteFuture<?> indexReadyFuture() { GridCacheContext<K, V> ctx = getContextSafe(); IgniteInternalFuture fut = ctx.shared().database().indexRebuildFuture(ctx.cacheId()); if (fut == null) return new IgniteFinishedFutureImpl<>(); return new IgniteFutureImpl<>(fut); }
/** * @param loc Enforce local. * @return Local node cluster group. */ private ClusterGroup projection(boolean loc) { GridCacheContext<K, V> ctx = getContextSafe(); if (loc || ctx.isLocal() || ctx.isReplicatedAffinityNode()) return ctx.kernalContext().grid().cluster().forLocal(); if (ctx.isReplicated()) return ctx.kernalContext().grid().cluster().forDataNodes(cacheName).forRandom(); return null; }