/** * Close all cursors. */ public void closeAll() { for (FieldsQueryCursor<List<?>> cursor : cursors) cursor.close(); }
fldQryCursor.close();
/** * Check cluster wide query id generation. * * @throws Exception Exception in case of failure. */ @Test public void testClusterWideQueryIdGeneration() throws Exception { newBarrier(1); IgniteCache<Object, Object> cache = ignite.cache(DEFAULT_CACHE_NAME); for (int i = 0; i < 100; i++) { FieldsQueryCursor<List<?>> cursor = cache.query(new SqlFieldsQuery("SELECT * FROM Integer WHERE 1 = 1")); Collection<GridRunningQueryInfo> runningQueries = ignite.context().query().runningQueries(-1); assertEquals(1, runningQueries.size()); GridRunningQueryInfo r = runningQueries.iterator().next(); assertEquals(ignite.context().localNodeId() + "_" + r.id(), r.globalQueryId()); cursor.close(); } }
/** * Lazy query release partitions on cursor close test. * * @throws Exception If failed. */ @Test public void testLazyQueryPartitionsReleaseOnClose() throws Exception { Ignite node1 = startGrid(0); IgniteCache<Integer, Person> cache = node1.cache(PERSON_CACHE); cache.clear(); Affinity<Integer> aff = node1.affinity(PERSON_CACHE); int partsFilled = fillAllPartitions(cache, aff); SqlFieldsQuery qry = new SqlFieldsQuery("select name, age from person") .setLazy(true) .setPageSize(1); FieldsQueryCursor<List<?>> qryCursor = cache.query(qry); Iterator<List<?>> it = qryCursor.iterator(); if (it.hasNext()) it.next(); else fail("No query results."); startGrid(1); // Close cursor. Partitions should be released now. qryCursor.close(); for (Ignite ig : G.allGrids()) ig.cache(PERSON_CACHE).rebalance().get(); assertEquals("Wrong result set size", partsFilled, cache.query(qry).getAll().size()); }
cursor.close();
/** * Close all cursors. */ public void closeAll() { for (FieldsQueryCursor<List<?>> cursor : cursors) cursor.close(); }
fldQryCursor.close();