/** * @param ctx Cache context. * @param reqId Request ID. * @param qry Query. * @param nodes Nodes. */ protected GridCacheDistributedQueryFuture(GridCacheContext<K, V> ctx, long reqId, GridCacheQueryBean qry, Iterable<ClusterNode> nodes) { super(ctx, qry, false); assert reqId > 0; this.reqId = reqId; GridCacheQueryManager<K, V> mgr = ctx.queries(); assert mgr != null; synchronized (this) { for (ClusterNode node : nodes) subgrid.add(node.id()); } }
/** {@inheritDoc} */ @Override void clear() { assert isDone() : this; GridCacheDistributedQueryManager<K, V> qryMgr = (GridCacheDistributedQueryManager<K, V>)cctx.queries(); if (qryMgr != null) qryMgr.removeQueryFuture(reqId); } }
/** {@inheritDoc} */ @Override protected void loadPage() { assert !Thread.holdsLock(this); Collection<ClusterNode> nodes = null; synchronized (this) { if (!isDone() && rcvd.containsAll(subgrid)) { rcvd.clear(); nodes = nodes(); } } if (nodes != null) cctx.queries().loadPage(reqId, qry.query(), nodes, false); }
/** {@inheritDoc} */ @Override public void resetQueryDetailMetrics() { IgniteInternalCache<K, V> delegate = getDelegateSafe(); delegate.context().queries().resetDetailMetrics(); }
/** {@inheritDoc} */ @Override protected void loadAllPages() throws IgniteInterruptedCheckedException { assert !Thread.holdsLock(this); U.await(firstPageLatch); Collection<ClusterNode> nodes = null; synchronized (this) { if (!isDone() && !subgrid.isEmpty()) nodes = nodes(); } if (nodes != null) cctx.queries().loadPage(reqId, qry.query(), nodes, true); }
/** {@inheritDoc} */ @SuppressWarnings("unchecked") @Override public Collection<GridCacheSqlMetadata> call() throws Exception { IgniteCache cache = ignite.cache(cacheName); return ((IgniteCacheProxy)cache).context().queries().sqlMetadataV2(); } }
/** {@inheritDoc} */ @Override public void resetQueryMetrics() { IgniteInternalCache<K, V> delegate = getDelegateSafe(); delegate.context().queries().resetMetrics(); }
/** {@inheritDoc} */ @Override public QueryMetrics queryMetrics() { IgniteInternalCache<K, V> delegate = getDelegateSafe(); return delegate.context().queries().metrics(); }
/** {@inheritDoc} */ @Override public Collection<? extends QueryDetailMetrics> queryDetailMetrics() { IgniteInternalCache<K, V> delegate = getDelegateSafe(); return delegate.context().queries().detailMetrics(); }
@Override public void run() { for (GridCacheContext ctxs : ctx.cache().context().cacheContexts()) ctxs.queries().evictDetailMetrics(); } }, QRY_DETAIL_METRICS_EVICTION_FREQ, QRY_DETAIL_METRICS_EVICTION_FREQ);
/** * @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(ctx.queries(), ctx.continuousQueries(), ctx.store()); }
/** * @param idx Index. */ @Override public Void call(int idx) throws Exception { GridCacheContext<String, Integer> ctx = ((IgniteKernal)ignite).<String, Integer>internalCache(cacheName).context(); GridCacheQueryManager queries = ctx.queries(); Map map = GridTestUtils.getFieldValue(queries, GridCacheQueryManager.class, "qryIters"); for (Object obj : map.values()) assertEquals("Iterators not removed for grid " + idx, 0, ((Map)obj).size()); return null; } }
/** * @param idx Index. */ @Override public Void call(int idx) throws Exception { GridCacheContext<String, Integer> ctx = ((IgniteKernal)ignite).<String, Integer>internalCache(DEFAULT_CACHE_NAME).context(); GridCacheQueryManager queries = ctx.queries(); ConcurrentMap<UUID, Map<Long, GridFutureAdapter<?>>> map = GridTestUtils.getFieldValue(queries, GridCacheQueryManager.class, "qryIters"); for (Map<Long, GridFutureAdapter<?>> map1 : map.values()) assertTrue("Iterators not removed for grid " + idx, map1.isEmpty()); return null; } }
/** * @param ctx Context. * @return DHT managers. */ private List<GridCacheManager> dhtManagers(GridCacheContext ctx) { return F.asList(ctx.store(), ctx.events(), ctx.evicts(), ctx.queries(), ctx.continuousQueries(), ctx.dr()); }
@Override public void applyx() throws IgniteCheckedException { int iter = 0; while (!done.get() && !Thread.currentThread().isInterrupted()) { iter++; List<List<?>> entries = c.query(new SqlFieldsQuery("SELECT * from TestValue").setPageSize(100)).getAll(); assert entries != null; assertEquals("Entries count is not as expected on iteration: " + iter, keyCnt, entries.size()); if (cnt.incrementAndGet() % logMod == 0) { GridCacheQueryManager<Object, Object> qryMgr = ((IgniteKernal)g).internalCache(DEFAULT_CACHE_NAME).context().queries(); assert qryMgr != null; qryMgr.printMemoryStats(); } } } }, threadCnt);
@Override public void applyx() throws IgniteCheckedException { int iter = 0; while (!done.get() && !Thread.currentThread().isInterrupted()) { iter++; Collection<Cache.Entry<Integer, Integer>> entries = c.query(new SqlQuery(Integer.class, "_val >= 0")).getAll(); assert entries != null; assertEquals("Entries count is not as expected on iteration: " + iter, keyCnt, entries.size()); if (cnt.incrementAndGet() % logMod == 0) { GridCacheQueryManager<Object, Object> qryMgr = ((IgniteKernal)g).internalCache(c.getName()).context().queries(); assert qryMgr != null; qryMgr.printMemoryStats(); } } } }, threadCnt);
@Override public void applyx() throws IgniteCheckedException { int iter = 0; while (!done.get() && !Thread.currentThread().isInterrupted()) { iter++; // Scan query. Collection<Cache.Entry<Integer, Integer>> entries = c.query(new ScanQuery<Integer, Integer>()).getAll(); assert entries != null; assertEquals("Entries count is not as expected on iteration: " + iter, keyCnt, entries.size()); if (cnt.incrementAndGet() % logMod == 0) { GridCacheQueryManager<Object, Object> qryMgr = ((IgniteKernal)g).internalCache(c.getName()).context().queries(); assert qryMgr != null; qryMgr.printMemoryStats(); } } } }, threadCnt);
/** * @param cctx Cache context. * @param key Key. * @param oldRow Removed row. * @throws IgniteCheckedException If failed. */ private void finishRemove(GridCacheContext cctx, KeyCacheObject key, @Nullable CacheDataRow oldRow) throws IgniteCheckedException { if (oldRow != null) { clearPendingEntries(cctx, oldRow); decrementSize(cctx.cacheId()); } GridCacheQueryManager qryMgr = cctx.queries(); if (qryMgr.enabled()) qryMgr.remove(key, oldRow); if (oldRow != null) rowStore.removeRow(oldRow.link(), grp.statisticsHolderData()); updateIgfsMetrics(cctx, key, (oldRow != null ? oldRow.value() : null), null); }
/** * Checks internal iterators maps are cleared. */ private void assertSetIteratorsCleared() { for (int i = 0; i < gridCount(); i++) { IgniteKernal grid = (IgniteKernal) grid(i); for (IgniteCache cache : grid.caches()) { GridCacheQueryManager queries = grid.internalCache(cache.getName()).context().queries(); Map map = GridTestUtils.getFieldValue(queries, GridCacheQueryManager.class, "qryIters"); for (Object obj : map.values()) assertEquals("Iterators not removed for grid " + i, 0, ((Map) obj).size()); } } }
/** {@inheritDoc} */ @Override protected VisorCacheSqlMetadata run(VisorCacheMetadataTaskArg arg) { try { IgniteInternalCache<Object, Object> cache = ignite.cachex(arg.getCacheName()); if (cache != null) { GridCacheSqlMetadata meta = F.first(cache.context().queries().sqlMetadata()); if (meta != null) return new VisorCacheSqlMetadata(meta); return null; } throw new IgniteException("Cache not found: " + escapeName(arg.getCacheName())); } catch (IgniteCheckedException e) { throw U.convertException(e); } }