/** {@inheritDoc} */ @Override public String toString() { return S.toString(GridCacheAdapter.class, this, "name", name(), "size", size()); }
/** {@inheritDoc} */ @Override public void clear() { try { cache.context().shared().cache().clearStatistics(Collections.singleton(cache.name())); } catch (Exception e) { throw new RuntimeException(e.getMessage()); } }
/** {@inheritDoc} */ @Override public void enableStatistics() { try { cache.context().shared().cache().enableStatistics(Collections.singleton(cache.name()), true); } catch (Exception e) { throw new RuntimeException(e.getMessage()); } }
/** {@inheritDoc} */ @Override public void disableStatistics() { try { cache.context().shared().cache().enableStatistics(Collections.singleton(cache.name()), false); } catch (Exception e) { throw new RuntimeException(e.getMessage()); } } }
/** * @param cancel Cancel. */ public void stopCaches(boolean cancel) { for (String cacheName : stopSeq) { GridCacheAdapter<?, ?> cache = stoppedCaches.remove(cacheName); if (cache != null) stopCache(cache, cancel, false); } for (GridCacheAdapter<?, ?> cache : stoppedCaches.values()) { if (cache == stoppedCaches.remove(cache.name())) stopCache(cache, cancel, false); } for (CacheGroupContext grp : cacheGrps.values()) stopCacheGroup(grp.groupId()); }
/** {@inheritDoc} */ @Override public void disableStatistics() { try { cache.context().shared().cache().enableStatistics(Collections.singleton(cache.name()), false); } catch (IgniteCheckedException e) { throw new RuntimeException(e.getMessage()); } } }
/** {@inheritDoc} */ @Override public <R> R affinityCall(IgniteCallable<R> job) { if (!collocated) throw new IgniteException("Failed to execute affinityCall() for non-collocated queue: " + name() + ". This operation is supported only for collocated queues."); return compute.affinityCall(cache.name(), queueKey, job); }
/** * Reconstructs object on unmarshalling. * * @return Reconstructed object. * @throws ObjectStreamException Thrown in case of unmarshalling error. */ private Object readResolve() throws ObjectStreamException { return cctx.grid().affinity(cctx.cache().name()); } }
/** {@inheritDoc} */ @Override public void enableStatistics() { try { cache.context().shared().cache().enableStatistics(Collections.singleton(cache.name()), true); } catch (IgniteCheckedException e) { throw new RuntimeException(e.getMessage()); } }
/** {@inheritDoc} */ @Override public void affinityRun(IgniteRunnable job) { if (!collocated) throw new IgniteException("Failed to execute affinityRun() for non-collocated queue: " + name() + ". This operation is supported only for collocated queues."); compute.affinityRun(cache.name(), queueKey, job); }
/** {@inheritDoc} */ @Override public void printMemoryStats() { X.println(">>> "); for (GridCacheAdapter c : caches.values()) { X.println(">>> Cache memory stats [igniteInstanceName=" + ctx.igniteInstanceName() + ", cache=" + c.name() + ']'); c.context().printMemoryStats(); } }
/** * Constructor. * * @param parts Partitions. * @param clo Closure. * @param remainder Remainder. * @param fut Future. */ @SuppressWarnings("unchecked") public AsyncWorker(List<GridDhtLocalPartition> parts, SchemaIndexCacheVisitorClosure clo, int remainder, GridFutureAdapter<Void> fut) { super(cctx.igniteInstanceName(), "parallel-idx-worker-" + cctx.cache().name() + "-" + remainder, cctx.logger(AsyncWorker.class)); this.parts = parts; this.clo = clo; this.remainder = remainder; this.fut = fut; }
/** * @throws IgniteCheckedException If query is invalid. */ public void validate() throws IgniteCheckedException { if ((type != SCAN && type != SET && type != SPI) && !QueryUtils.isEnabled(cctx.config())) throw new IgniteCheckedException("Indexing is disabled for cache: " + cctx.cache().name()); }
/** {@inheritDoc} */ @Override public IgniteInternalFuture<Long> sizeLongAsync(final CachePeekMode[] peekModes) { assert peekModes != null; PeekModes modes = parsePeekModes(peekModes, true); IgniteClusterEx cluster = ctx.grid().cluster(); ClusterGroup grp = modes.near ? cluster.forCacheNodes(name(), true, true, false) : cluster.forDataNodes(name()); Collection<ClusterNode> nodes = new ArrayList<>(grp.nodes()); if (nodes.isEmpty()) return new GridFinishedFuture<>(0L); ctx.kernalContext().task().setThreadContext(TC_SUBGRID, nodes); return ctx.kernalContext().task().execute( new SizeLongTask(ctx.name(), ctx.affinity().affinityTopologyVersion(), peekModes), null); }
/** {@inheritDoc} */ @Override public IgniteInternalFuture<Integer> sizeAsync(final CachePeekMode[] peekModes) { assert peekModes != null; PeekModes modes = parsePeekModes(peekModes, true); IgniteClusterEx cluster = ctx.grid().cluster(); ClusterGroup grp = modes.near ? cluster.forCacheNodes(name(), true, true, false) : cluster.forDataNodes(name()); Collection<ClusterNode> nodes = new ArrayList<>(grp.nodes()); if (nodes.isEmpty()) return new GridFinishedFuture<>(0); ctx.kernalContext().task().setThreadContext(TC_SUBGRID, nodes); return ctx.kernalContext().task().execute( new SizeTask(ctx.name(), ctx.affinity().affinityTopologyVersion(), peekModes), null); }
/** * Run load keys callable on appropriate nodes. * * @param keys Keys. * @param plc Expiry policy. * @param keepBinary Keep binary flag. * @return Operation future. */ private IgniteInternalFuture<?> runLoadKeysCallable(final Set<? extends K> keys, final ExpiryPolicy plc, final boolean keepBinary, final boolean update) { Collection<ClusterNode> nodes = ctx.grid().cluster().forDataNodes(name()).nodes(); if (nodes.isEmpty()) return new GridFinishedFuture<>(); return ctx.closures().callAsyncNoFailover(BROADCAST, new LoadKeysCallable<>(ctx.name(), keys, update, plc, keepBinary), nodes, true, 0, false); }
@Override public void run() { assertTrue(ignite.cachex(cctx(queue2).cache().name()).affinity().isPrimaryOrBackup( ignite.cluster().localNode(), "Queue2")); assertEquals(100, queue2.take().intValue()); } });
/** * @param keys Keys to clear. * @param near Near cache flag. * @return Future. */ private IgniteInternalFuture<?> executeClearTask(@Nullable Set<? extends K> keys, boolean near) { Collection<ClusterNode> srvNodes = ctx.grid().cluster().forCacheNodes(name(), !near, near, false).nodes(); if (!srvNodes.isEmpty()) { ctx.kernalContext().task().setThreadContext(TC_SUBGRID, srvNodes); return ctx.kernalContext().task().execute( new ClearTask(ctx.name(), ctx.affinity().affinityTopologyVersion(), keys, near), null); } else return new GridFinishedFuture<>(); }
@Override public Integer call() { assertTrue(ignite.cachex(cctx(queue2).cache().name()).affinity().isPrimaryOrBackup( ignite.cluster().localNode(), "Queue2")); return queue2.take(); } });
/** {@inheritDoc} */ @Override public void close() { IgniteFuture<Boolean> destroyFut = null; gate.enter(); try { delegate.close(); if (delegate.separated()) { IgniteInternalFuture<Boolean> fut = cctx.kernalContext().cache().dynamicDestroyCache( cctx.cache().name(), false, true, false, null); ((GridFutureAdapter)fut).ignoreInterrupts(); destroyFut = new IgniteFutureImpl<>(fut); } } finally { gate.leave(); } if (destroyFut != null) destroyFut.get(); }