/** {@inheritDoc} */ @Override public GridCacheContext<K, V> context() { return delegate.context(); }
/** {@inheritDoc} */ @Override protected Collection<VisorCacheMetrics> run(final VisorCacheMetricsCollectorTaskArg arg) { assert arg != null; boolean showSysCaches = arg.isShowSystemCaches(); Collection<String> cacheNames = arg.getCacheNames(); assert cacheNames != null; GridCacheProcessor cacheProcessor = ignite.context().cache(); Collection<IgniteCacheProxy<?, ?>> caches = cacheProcessor.jcaches(); Collection<VisorCacheMetrics> res = new ArrayList<>(caches.size()); boolean allCaches = cacheNames.isEmpty(); for (IgniteCacheProxy ca : caches) { String cacheName = ca.getName(); if (!VisorTaskUtils.isRestartingCache(ignite, cacheName)) { GridCacheContext ctx = ca.context(); if (ctx.started() && (ctx.affinityNode() || ctx.isNear())) { VisorCacheMetrics cm = new VisorCacheMetrics(ignite, cacheName); if ((allCaches || cacheNames.contains(cacheName)) && (showSysCaches || !cm.isSystem())) res.add(cm); } } } return res; }
/** {@inheritDoc} */ @Override protected Map<String, VisorCacheConfiguration> run(VisorCacheConfigurationCollectorTaskArg arg) { Collection<IgniteCacheProxy<?, ?>> caches = ignite.context().cache().jcaches(); Pattern ptrn = arg.getRegex() != null ? Pattern.compile(arg.getRegex()) : null; boolean all = F.isEmpty(arg.getCacheNames()); boolean hasPtrn = ptrn != null; Map<String, VisorCacheConfiguration> res = U.newHashMap(caches.size()); for (IgniteCacheProxy<?, ?> cache : caches) { String cacheName = cache.getName(); boolean matched = hasPtrn ? ptrn.matcher(cacheName).find() : all || arg.getCacheNames().contains(cacheName); if (!VisorTaskUtils.isRestartingCache(ignite, cacheName) && matched) { VisorCacheConfiguration cfg = config(cache.getConfiguration(CacheConfiguration.class), cache.context().dynamicDeploymentId()); res.put(cacheName, cfg); } } return res; }
/** * @param cacheName Cache name to close. * @return Future that will be completed when cache is closed. */ IgniteInternalFuture<?> dynamicCloseCache(String cacheName) { assert cacheName != null; IgniteCacheProxy<?, ?> proxy = jcacheProxy(cacheName, false); if (proxy == null || proxy.isProxyClosed()) return new GridFinishedFuture<>(); // No-op. checkEmptyTransactions(); if (proxy.context().isLocal()) return dynamicDestroyCache(cacheName, false, true, false, null); return startClientCacheChange(null, Collections.singleton(cacheName)); }
switch (type) { case OP_GET_NAME: writer.writeObject(cache.getName()); CacheMetrics metrics = cache.localMetrics(); CacheMetrics metrics = cache.metrics(); Collection<Integer> parts = cache.lostPartitions(); QueryMetrics metrics = cache.queryMetrics();
switch (type) { case OP_PUT: cache.put(reader.readObjectDetached(), reader.readObjectDetached()); return writeResult(mem, cache.get(reader.readObjectDetached())); return cache.remove(reader.readObjectDetached(), reader.readObjectDetached()) ? TRUE : FALSE; cache.removeAll(PlatformUtils.readSet(reader)); cache.putAll(PlatformUtils.readMap(reader)); cache.localEvict(PlatformUtils.readCollection(reader)); return cache.containsKey(reader.readObjectDetached()) ? TRUE : FALSE; return cache.containsKeys(PlatformUtils.readSet(reader)) ? TRUE : FALSE; return cache.replace(reader.readObjectDetached(), reader.readObjectDetached(), reader.readObjectDetached()) ? TRUE : FALSE; cache.clear(reader.readObjectDetached()); cache.clearAll(PlatformUtils.readSet(reader)); cache.localClear(reader.readObjectDetached()); cache.localClearAll(PlatformUtils.readSet(reader));
log.debug("Running put job [nodeId=" + ctx.localNodeId() + ", size=" + col.size() + ']'); IgniteCacheProxy cache = ctx.cache().jcache(cacheName).cacheNoGate(); cache.context().awaitStarted(); cache = (IgniteCacheProxy<?, ?>)cache.withSkipStore(); cache = (IgniteCacheProxy<?, ?>)cache.withKeepBinary(); cache.context().deploy().ignoreOwnership(true); final GridCacheContext cctx = cache.context(); cache.context().deploy().ignoreOwnership(false);
/** * Scan (with explicit {@code setLocal(true)}) should perform on the local node. * * @throws Exception If failed. */ @Test public void testScanLocalExplicit() throws Exception { cacheMode = CacheMode.PARTITIONED; backups = 0; commSpiFactory = new TestLocalCommunicationSpiFactory(); try { Ignite ignite = startGrids(GRID_CNT); IgniteCacheProxy<Integer, Integer> cache = fillCache(ignite); int part = anyLocalPartition(cache.context()); QueryCursor<Cache.Entry<Integer, Integer>> qry = cache.query(new ScanQuery<Integer, Integer>().setPartition(part).setLocal(true)); doTestScanQuery(qry, part); GridTestUtils.assertThrows(log, (Callable<Void>)() -> { int remPart = remotePartition(cache.context()).getKey(); cache.query(new ScanQuery<Integer, Integer>().setPartition(remPart).setLocal(true)); return null; }, IgniteCheckedException.class, null); } finally { stopAllGrids(); } }
/** * @param ignite Ignite. * @return Cache. */ protected IgniteCacheProxy<Integer, Integer> fillCache(Ignite ignite) { IgniteCacheProxy<Integer, Integer> cache = (IgniteCacheProxy<Integer, Integer>)ignite.<Integer, Integer>cache(DEFAULT_CACHE_NAME); for (int i = 0; i < KEYS_CNT; i++) { cache.put(i, i); int part = cache.context().affinity().partition(i); Map<Integer, Integer> partEntries = entries.get(part); if (partEntries == null) entries.put(part, partEntries = new HashMap<>()); partEntries.put(i, i); } return cache; }
/** {@inheritDoc} */ @Override public String getName() { return delegate.getName(); }
/** {@inheritDoc} */ @Override public GridCacheProxyImpl<K, V> internalProxy() { return delegate.internalProxy(); }
for (Ignite node : G.allGrids()) { for (IgniteCacheProxy cache : ((IgniteKernal)node).caches()) { GridCacheContext cctx = cache.context(); try (GridCloseableIterator it = (GridCloseableIterator)cache.withKeepBinary().iterator()) { while (it.hasNext()) { IgniteBiTuple entry = (IgniteBiTuple)it.next();
GridCacheAdapter ca = (GridCacheAdapter)((IgniteCacheProxy)cache).internalProxy().delegate(); assertEquals(expVal, U.<Value>field(obj, "val").i); else assertEquals(expVal, CU.<Value>value(obj, ((IgniteCacheProxy)cache).context(), false).i);
/** {@inheritDoc} */ @Override public PlatformTarget processOutObject(int type) throws IgniteCheckedException { switch (type) { case OP_WITH_PARTITION_RECOVER: { return copy(rawCache.withPartitionRecover(), keepBinary); } case OP_WITH_KEEP_BINARY: { if (keepBinary) return this; return copy(rawCache.withKeepBinary(), true); } case OP_WITH_NO_RETRIES: { CacheOperationContext opCtx = cache.context().operationContextPerCall(); if (opCtx != null && opCtx.noRetries()) return this; return copy(rawCache.withNoRetries(), keepBinary); } case OP_WITH_SKIP_STORE: { CacheOperationContext opCtx = cache.context().operationContextPerCall(); if (opCtx != null && opCtx.skipStore()) return this; return copy(rawCache.withSkipStore(), keepBinary); } case OP_ITERATOR: { Iterator<Cache.Entry> iter = cache.iterator(); return new PlatformCacheIterator(platformCtx, iter); } } return super.processOutObject(type); }
/** {@inheritDoc} */ @Override public FieldsQueryCursor<List<?>> query(SqlFieldsQuery qry) { CacheOperationGate opGate = onEnter(); try { return delegate.query(qry); } finally { onLeave(opGate); } }
/** * @param name Cache name. * @return Cache. */ private <K, V> IgniteInternalCache<K, V> internalCacheEx(String name) { if (ctx.discovery().localNode().isClient()) { IgniteCacheProxy<K, V> proxy = (IgniteCacheProxy<K, V>)jcacheProxy(name, true); if (proxy == null) { GridCacheAdapter<?, ?> cacheAdapter = caches.get(name); if (cacheAdapter != null) { proxy = new IgniteCacheProxyImpl(cacheAdapter.context(), cacheAdapter, false); IgniteCacheProxyImpl<?, ?> prev = addjCacheProxy(name, (IgniteCacheProxyImpl<?, ?>)proxy); if (prev != null) proxy = (IgniteCacheProxy<K, V>)prev; completeProxyInitialize(proxy.getName()); } } assert proxy != null : name; return proxy.internalProxy(); } return internalCache(name); }
/** {@inheritDoc} */ @Override public <C extends Configuration<K, V>> C getConfiguration(Class<C> clazz) { return delegate.getConfiguration(clazz); }
/** {@inheritDoc} */ @Override public void put(K key, V val) throws TransactionException { CacheOperationGate opGate = onEnter(); try { delegate.put(key, val); } finally { onLeave(opGate); } }
switch (type) { case OP_PUT: cache.put(reader.readObjectDetached(), reader.readObjectDetached()); return writeResult(mem, cache.get(reader.readObjectDetached())); return cache.remove(reader.readObjectDetached(), reader.readObjectDetached()) ? TRUE : FALSE; cache.removeAll(PlatformUtils.readSet(reader)); cache.putAll(PlatformUtils.readMap(reader)); cache.localEvict(PlatformUtils.readCollection(reader)); return cache.containsKey(reader.readObjectDetached()) ? TRUE : FALSE; return cache.containsKeys(PlatformUtils.readSet(reader)) ? TRUE : FALSE; return cache.replace(reader.readObjectDetached(), reader.readObjectDetached(), reader.readObjectDetached()) ? TRUE : FALSE; cache.clear(reader.readObjectDetached()); cache.clearAll(PlatformUtils.readSet(reader)); cache.localClear(reader.readObjectDetached()); cache.localClearAll(PlatformUtils.readSet(reader));
log.debug("Running put job [nodeId=" + ctx.localNodeId() + ", size=" + col.size() + ']'); IgniteCacheProxy cache = ctx.cache().jcache(cacheName).cacheNoGate(); cache.context().awaitStarted(); cache = (IgniteCacheProxy<?, ?>)cache.withSkipStore(); cache = (IgniteCacheProxy<?, ?>)cache.withKeepBinary(); cache.context().deploy().ignoreOwnership(true); final GridCacheContext cctx = cache.context(); cache.context().deploy().ignoreOwnership(false);