Java Code Examples for org.apache.ignite.cache.query.QueryCursor#close()

The following examples show how to use org.apache.ignite.cache.query.QueryCursor#close() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IgniteQueryDedicatedPoolTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/**
 * Tests that Scan queries are executed in dedicated pool
 * @throws Exception If failed.
 */
@Test
public void testScanQueryUsesDedicatedThreadPool() throws Exception {
    startGrid("server");

    try (Ignite client = startClientGrid("client")) {
        IgniteCache<Integer, Integer> cache = client.cache(CACHE_NAME);

        cache.put(0, 0);

        QueryCursor<Cache.Entry<Object, Object>> cursor = cache.query(
            new ScanQuery<>(new IgniteBiPredicate<Object, Object>() {
                @Override public boolean apply(Object o, Object o2) {
                    return F.eq(GridIoManager.currentPolicy(), GridIoPolicy.QUERY_POOL);
                }
            }));

        assertEquals(1, cursor.getAll().size());

        cursor.close();
    }
}
 
Example 2
Source File: IgniteQueryDedicatedPoolTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/**
 * Tests that SPI queries are executed in dedicated pool
 * @throws Exception If failed.
 */
@Test
public void testSpiQueryUsesDedicatedThreadPool() throws Exception {
    startGrid("server");

    try (Ignite client = startClientGrid("client")) {
        IgniteCache<Byte, Byte> cache = client.cache(CACHE_NAME);

        for (byte b = 0; b < Byte.MAX_VALUE; ++b)
            cache.put(b, b);

        QueryCursor<Cache.Entry<Byte, Byte>> cursor = cache.query(new SpiQuery<Byte, Byte>());

        List<Cache.Entry<Byte, Byte>> all = cursor.getAll();

        assertEquals(1, all.size());
        assertEquals(GridIoPolicy.QUERY_POOL, (byte)all.get(0).getValue());

        cursor.close();
    }
}
 
Example 3
Source File: IgniteCacheRandomOperationBenchmark.java    From ignite with Apache License 2.0 6 votes vote down vote up
/**
 * @param cache Ignite cache.
 * @param map Parameters map.
 * @throws Exception If failed.
 */
private void doContinuousQuery(IgniteCache<Object, Object> cache, Map<Object, Object> map) throws Exception {
    List<QueryCursor> cursors = (ArrayList<QueryCursor>)map.get(cache.getName());

    if (cursors == null) {
        cursors = new ArrayList<>(CONTINUOUS_QUERY_PER_CACHE);
        map.put(cache.getName(), cursors);
    }

    if (cursors.size() == CONTINUOUS_QUERY_PER_CACHE) {
        QueryCursor cursor = cursors.get(nextRandom(cursors.size()));
        cursor.close();
        cursors.remove(cursor);
    }

    ContinuousQuery qry = new ContinuousQuery();

    qry.setLocalListener(new ContinuousQueryUpdater());

    qry.setRemoteFilterFactory(FactoryBuilder.factoryOf(new ContinuousQueryFilter()));

    cursors.add(cache.query(qry));
}
 
Example 4
Source File: CacheContinuousWithTransformerFailoverTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/**
 * @param cur Cur.
 */
private void tryClose(QueryCursor<?> cur) {
    try {
        cur.close();
    }
    catch (Throwable e) {
        if (e instanceof IgniteClientDisconnectedException) {
            IgniteClientDisconnectedException ex = (IgniteClientDisconnectedException)e;

            ex.reconnectFuture().get();

            cur.close();
        }
        else
            throw e;
    }
}
 
Example 5
Source File: IgniteQueryDedicatedPoolTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * Tests that SQL queries involving actual network IO are executed in dedicated pool.
 * @throws Exception If failed.
 */
@Test
public void testSqlQueryUsesDedicatedThreadPool() throws Exception {
    startGrid("server");

    try (Ignite client = startClientGrid("client")) {
        IgniteCache<Integer, Integer> cache = client.cache(CACHE_NAME);

        // We do this in order to have 1 row in results of select - function is called once per each row of result.
        cache.put(1, 1);

        // We have to refer to a cache explicitly in the query in order for it to be executed
        // in non local distributed manner (yes, there's a "local distributed" manner too - see link above...)
        QueryCursor<List<?>> cursor = cache.query(new SqlFieldsQuery("select currentPolicy() from Integer"));

        List<List<?>> result = cursor.getAll();

        cursor.close();

        assertEquals(1, result.size());

        Byte plc = (Byte)result.get(0).get(0);

        assertNotNull(plc);
        assertEquals(GridIoPolicy.QUERY_POOL, (byte)plc);
    }
}
 
Example 6
Source File: IgniteCacheConfigVariationsQueryTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * @param expMap Expected map.
 * @param cursor Query cursor.
 */
private void checkQueryResults(Map<Object, Object> expMap, QueryCursor<Cache.Entry<Object, Object>> cursor)
    throws InterruptedException {
    Iterator<Cache.Entry<Object, Object>> iter = cursor.iterator();

    try {
        assertNotNull(iter);

        int cnt = 0;

        while (iter.hasNext()) {
            Cache.Entry<Object, Object> e = iter.next();

            assertNotNull(e.getKey());
            assertNotNull(e.getValue());

            Object expVal = expMap.get(e.getKey());

            assertNotNull("Failed to resolve expected value for key: " + e.getKey(), expVal);

            assertEquals(expVal, e.getValue());

            cnt++;
        }

        assertEquals(expMap.size(), cnt);
    }
    finally {
        cursor.close();
    }

    checkEvents();
}
 
Example 7
Source File: GridCacheContinuousQueryAbstractSelfTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * @throws Exception If failed.
 */
@SuppressWarnings("TryFinallyCanBeTryWithResources")
@Test
public void testNodeJoinWithoutCache() throws Exception {
    IgniteCache<Integer, Integer> cache = grid(0).cache(DEFAULT_CACHE_NAME);

    ContinuousQuery<Integer, Integer> qry = new ContinuousQuery<>();

    final CountDownLatch latch = new CountDownLatch(1);

    qry.setLocalListener(new CacheEntryUpdatedListener<Integer, Integer>() {
        @Override public void onUpdated(Iterable<CacheEntryEvent<? extends Integer, ? extends Integer>> evts) {
            latch.countDown();
        }
    });

    QueryCursor<Cache.Entry<Integer, Integer>> cur = cache.query(qry);

    try {
        try (Ignite ignite = startClientGrid(NO_CACHE_IGNITE_INSTANCE_NAME)) {
            log.info("Started node without cache: " + ignite);
        }

        cachePut(cache, 1, 1);

        assertTrue(latch.await(5000, MILLISECONDS));
    }
    finally {
        cur.close();
    }
}
 
Example 8
Source File: CacheContinuousBatchAckTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * @param ccfg Cache configuration.
 * @throws Exception If failed.
 */
private void checkBackupAcknowledgeMessage(CacheConfiguration<Object, Object> ccfg) throws Exception {
    QueryCursor qry = null;

    IgniteCache<Object, Object> cache = null;

    try {
        ContinuousQuery q = new ContinuousQuery();

        q.setLocalListener(new CacheEntryUpdatedListener() {
            @Override public void onUpdated(Iterable iterable) throws CacheEntryListenerException {
                // No-op.
            }
        });

        cache = grid(SERVER).getOrCreateCache(ccfg);

        qry = cache.query(q);

        for (int i = 0; i < GridTestUtils.SF.applyLB(10000, 1000); i++)
            cache.put(i, i);

        assertFalse(GridTestUtils.waitForCondition(fail::get, 1300L));
    }
    finally {
        if (qry != null)
            qry.close();

        if (cache != null)
            grid(SERVER).destroyCache(cache.getName());
    }
}
 
Example 9
Source File: H2ResultSetIteratorNullifyOnEndSelfTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
/**
 * Local SQL Fields check nullification after close
 */
@Test
public void testSqlFieldsQueryLocalClose() {
    SqlFieldsQuery qry = new SqlFieldsQuery(SELECT_MAX_SAL_SQLF);

    qry.setLocal(true);

    QueryCursor<List<?>> qryCurs = cache().query(qry);

    qryCurs.iterator();

    qryCurs.close();

    H2ResultSetIterator h2It = extractGridIteratorInnerH2ResultSetIterator(qryCurs);

    checkIterator(h2It);
}
 
Example 10
Source File: H2ResultSetIteratorNullifyOnEndSelfTest.java    From ignite with Apache License 2.0 3 votes vote down vote up
/**
 * Non local SQL Fields check nullification after close
 */
@Test
public void testSqlFieldsQueryClose() {
    SqlFieldsQuery qry = new SqlFieldsQuery(SELECT_MAX_SAL_SQLF);

    QueryCursor<List<?>> qryCurs = cache().query(qry);

    qryCurs.iterator();

    qryCurs.close();

    H2ResultSetIterator h2It = extractGridIteratorInnerH2ResultSetIterator(qryCurs);

    checkIterator(h2It);
}
 
Example 11
Source File: CacheQueryMemoryLeakTest.java    From ignite with Apache License 2.0 3 votes vote down vote up
/**
 * Check, that query results are not accumulated, when result set size is a multiple of a {@link Query#pageSize}.
 *
 * @throws Exception If failed.
 */
@Test
public void testResultIsMultipleOfPage() throws Exception {
    IgniteEx srv = startGrid("server");
    Ignite client = startClientGrid("client");

    IgniteCache<Integer, Person> cache = startPeopleCache(client);

    int pages = 3;
    int pageSize = 1024;

    for (int i = 0; i < pages * pageSize; i++) {
        Person p = new Person("Person #" + i, 25);

        cache.put(i, p);
    }

    for (int i = 0; i < 100; i++) {
        Query<List<?>> qry = new SqlFieldsQuery("select * from people");

        qry.setPageSize(pageSize);

        QueryCursor<List<?>> cursor = cache.query(qry);

        cursor.getAll();

        cursor.close();
    }

    assertTrue("MapNodeResults is not cleared on the map node.", isMapNodeResultsEmpty(srv));
}
 
Example 12
Source File: TextQueryExample.java    From ignite-book-code-samples with GNU General Public License v3.0 3 votes vote down vote up
private static void scanQuery() {
    IgniteCache<Long, Company> companyCache = Ignition.ignite().cache(COMPANY_CACHE_NAME);

    //  Query for all companies which the city 'NEW YORK' - NewYork.
    QueryCursor cursor = companyCache.query(new ScanQuery<Long, Company>((k, p) -> p.getCity().equalsIgnoreCase("NEW YORK") ));

    for (Iterator ite = cursor.iterator(); ite.hasNext(); ) {
        CacheEntryImpl company = (CacheEntryImpl) ite.next();

        log(((Company) company.getValue()).getCompanyName());
    }

    cursor.close();

}
 
Example 13
Source File: IgniteClientReconnectContinuousProcessorTest.java    From ignite with Apache License 2.0 3 votes vote down vote up
/**
 * @throws Exception If failed.
 */
@Test
public void testCacheContinuousQueryReconnect() throws Exception {
    Ignite client = grid(serverCount());

    assertTrue(client.cluster().localNode().isClient());

    IgniteCache<Object, Object> clientCache = client.getOrCreateCache(new CacheConfiguration<>(DEFAULT_CACHE_NAME));

    CacheEventListener lsnr = new CacheEventListener();

    ContinuousQuery<Object, Object> qry = new ContinuousQuery<>();

    qry.setAutoUnsubscribe(true);

    qry.setLocalListener(lsnr);

    QueryCursor<?> cur = clientCache.query(qry);

    for (int i = 0; i < 5; i++) {
        log.info("Iteration: " + i);

        continuousQueryReconnect(client, clientCache, lsnr);
    }

    log.info("Close cursor, should not get cache events anymore.");

    cur.close();

    lsnr.latch = new CountDownLatch(1);

    clientCache.put(3, 3);

    assertFalse(lsnr.latch.await(3000, MILLISECONDS));
}
 
Example 14
Source File: CacheContinuousQueryFailoverAbstractSelfTest.java    From ignite with Apache License 2.0 2 votes vote down vote up
/**
 * @throws Exception If failed.
 */
@Test
public void testStartStop() throws Exception {
    this.backups = 2;

    final int SRV_NODES = 4;

    startGridsMultiThreaded(SRV_NODES);

    Ignite qryClient = startClientGrid(SRV_NODES);

    IgniteCache<Object, Object> qryClnCache = qryClient.cache(DEFAULT_CACHE_NAME);

    Affinity<Object> aff = qryClient.affinity(DEFAULT_CACHE_NAME);

    final CacheEventListener2 lsnr = new CacheEventListener2();

    ContinuousQuery<Object, Object> qry = new ContinuousQuery<>();

    qry.setLocalListener(lsnr);

    qry.setRemoteFilter(new CacheEventFilter());

    QueryCursor<?> cur = qryClnCache.query(qry);

    for (int i = 0; i < 10; i++) {
        final int idx = i % (SRV_NODES - 1);

        log.info("Stop node: " + idx);

        stopGrid(idx);

        awaitPartitionMapExchange();

        List<T3<Object, Object, Object>> afterRestEvts = new ArrayList<>();

        for (int j = 0; j < aff.partitions(); j++) {
            Integer oldVal = (Integer)qryClnCache.get(j);

            qryClnCache.put(j, i);

            afterRestEvts.add(new T3<>((Object)j, (Object)i, (Object)oldVal));
        }

        checkEvents(new ArrayList<>(afterRestEvts), lsnr, false);

        log.info("Start node: " + idx);

        startGrid(idx);
    }

    cur.close();
}
 
Example 15
Source File: CacheContinuousQueryFailoverAbstractSelfTest.java    From ignite with Apache License 2.0 2 votes vote down vote up
/**
 * @throws Exception If failed.
 */
@Test
public void testBackupQueueCleanupServerQuery() throws Exception {
    Ignite qryClient = startGridsMultiThreaded(2);

    CacheEventListener1 lsnr = new CacheEventListener1(false);

    ContinuousQuery<Object, Object> qry = new ContinuousQuery<>();

    qry.setLocalListener(lsnr);

    IgniteCache<Object, Object> cache = qryClient.cache(DEFAULT_CACHE_NAME);

    QueryCursor<?> cur = cache.query(qry);

    assertEquals(0, backupQueue(ignite(1)).size());

    List<Integer> keys = primaryKeys(cache, BACKUP_ACK_THRESHOLD);

    CountDownLatch latch = new CountDownLatch(keys.size());

    lsnr.latch = latch;

    for (Integer key : keys) {
        log.info("Put: " + key);

        cache.put(key, key);
    }

    GridTestUtils.waitForCondition(new GridAbsPredicate() {
        @Override public boolean apply() {
            return backupQueue(ignite(1)).isEmpty();
        }
    }, 5000);

    assertTrue("Backup queue is not cleared: " + backupQueue(ignite(1)),
        backupQueue(ignite(1)).size() < BACKUP_ACK_THRESHOLD);

    if (!latch.await(5, SECONDS))
        fail("Failed to wait for notifications [exp=" + keys.size() + ", left=" + lsnr.latch.getCount() + ']');

    cur.close();
}
 
Example 16
Source File: IgniteCacheContinuousQueryClientTest.java    From ignite with Apache License 2.0 2 votes vote down vote up
/**
 * @throws Exception If failed.
 */
@Test
public void testNodeJoinsRestartQuery() throws Exception {
    startGrids(2);

    final int CLIENT_ID = 3;

    Ignite clientNode = startClientGrid(CLIENT_ID);

    for (int i = 0; i < 10; i++) {
        log.info("Start iteration: " + i);

        final CacheEventListener lsnr = new CacheEventListener();

        ContinuousQuery<Object, Object> qry = new ContinuousQuery<>();

        qry.setLocalListener(lsnr);

        QueryCursor<?> cur = clientNode.cache(DEFAULT_CACHE_NAME).query(qry);

        lsnr.latch = new CountDownLatch(1);

        Ignite joined1 = startGrid(4);

        awaitPartitionMapExchange();

        IgniteCache<Object, Object> joinedCache1 = joined1.cache(DEFAULT_CACHE_NAME);

        joinedCache1.put(primaryKey(joinedCache1), 1);

        assertTrue("Failed to wait for event.", lsnr.latch.await(5, SECONDS));

        cur.close();

        lsnr.latch = new CountDownLatch(1);

        Ignite joined2 = startGrid(5);

        IgniteCache<Object, Object> joinedCache2 = joined2.cache(DEFAULT_CACHE_NAME);

        joinedCache2.put(primaryKey(joinedCache2), 2);

        assertFalse("Unexpected event received.", GridTestUtils.waitForCondition(new GridAbsPredicate() {
            @Override public boolean apply() {
                return 1 != lsnr.latch.getCount();
            }
        }, 1000));

        stopGrid(4);

        stopGrid(5);
    }
}
 
Example 17
Source File: IgniteCacheContinuousQueryClientTest.java    From ignite with Apache License 2.0 2 votes vote down vote up
/**
 * @throws Exception If failed.
 */
@Test
public void testNodeJoins() throws Exception {
    startGrids(2);

    final int CLIENT_ID = 3;

    Ignite clientNode = startClientGrid(CLIENT_ID);

    final CacheEventListener lsnr = new CacheEventListener();

    ContinuousQuery<Object, Object> qry = new ContinuousQuery<>();

    qry.setLocalListener(lsnr);

    QueryCursor<?> cur = clientNode.cache(DEFAULT_CACHE_NAME).query(qry);

    for (int i = 0; i < 10; i++) {
        log.info("Start iteration: " + i);

        lsnr.latch = new CountDownLatch(1);

        Ignite joined1 = startGrid(4);

        awaitPartitionMapExchange();

        IgniteCache<Object, Object> joinedCache1 = joined1.cache(DEFAULT_CACHE_NAME);

        joinedCache1.put(primaryKey(joinedCache1), 1);

        assertTrue("Failed to wait for event.", lsnr.latch.await(5, SECONDS));

        lsnr.latch = new CountDownLatch(1);

        Ignite joined2 = startGrid(5);

        awaitPartitionMapExchange();

        IgniteCache<Object, Object> joinedCache2 = joined2.cache(DEFAULT_CACHE_NAME);

        joinedCache2.put(primaryKey(joinedCache2), 2);

        assertTrue("Failed to wait for event.", lsnr.latch.await(5, SECONDS));

        stopGrid(4);

        stopGrid(5);
    }

    cur.close();
}
 
Example 18
Source File: IgniteCacheContinuousQueryClientReconnectTest.java    From ignite with Apache License 2.0 2 votes vote down vote up
/**
 * @throws Exception If failed.
 */
@Test
public void testReconnectClientAndLeftRouter() throws Exception {
    if (!tcpDiscovery())
        return;

    Ignite client = grid(serverCount());

    final Ignite srv = clientRouter(client);

    final String clnRouterName = srv.name();

    assertTrue(client.cluster().localNode().isClient());

    final CacheEventListener lsnr = new CacheEventListener();

    ContinuousQuery<Object, Object> qry = new ContinuousQuery<>();

    qry.setLocalListener(lsnr);

    IgniteCache<Object, Object> clnCache = client.cache(DEFAULT_CACHE_NAME);

    QueryCursor<?> cur = clnCache.query(qry);

    int keyCnt = 100;

    lsnr.latch = new CountDownLatch(keyCnt);

    for (int key = 0; key < keyCnt; key++)
        clnCache.put(key, key);

    assertTrue("Failed to wait for event.", lsnr.latch.await(5, SECONDS));

    reconnectClientNode(client, srv, new Runnable() {
        @Override public void run() {
            stopGrid(clnRouterName);
        }
    });

    assertFalse("Client connected to the same server node.", clnRouterName.equals(clientRouter(client).name()));

    lsnr.latch = new CountDownLatch(keyCnt);

    for (int key = 0; key < keyCnt; key++)
        clnCache.put(key, key);

    assertTrue("Failed to wait for event.", lsnr.latch.await(5, SECONDS));

    cur.close();
}
 
Example 19
Source File: IgniteCacheContinuousQueryClientReconnectTest.java    From ignite with Apache License 2.0 2 votes vote down vote up
/**
 * @throws Exception If failed.
 */
@Test
public void testReconnectClient() throws Exception {
    Ignite client = grid(serverCount());

    Ignite srv = clientRouter(client);

    assertTrue(client.cluster().localNode().isClient());

    final CacheEventListener lsnr = new CacheEventListener();

    ContinuousQuery<Object, Object> qry = new ContinuousQuery<>();

    qry.setLocalListener(lsnr);

    IgniteCache<Object, Object> clnCache = client.cache(DEFAULT_CACHE_NAME);

    QueryCursor<?> cur = clnCache.query(qry);

    int keyCnt = 100;

    for (int i = 0; i < 10; i++) {
        lsnr.latch = new CountDownLatch(keyCnt);

        for (int key = 0; key < keyCnt; key++)
            clnCache.put(key, key);

        assertTrue("Failed to wait for event.", lsnr.latch.await(5, SECONDS));

        reconnectClientNode(client, srv, null);

        lsnr.latch = new CountDownLatch(keyCnt);

        for (int key = 0; key < keyCnt; key++)
            clnCache.put(key, key);

        assertTrue("Failed to wait for event.", lsnr.latch.await(5, SECONDS));
    }

    cur.close();
}
 
Example 20
Source File: SqlSystemViewsSelfTest.java    From ignite with Apache License 2.0 2 votes vote down vote up
/**
 * Test running queries system view.
 */
@Test
public void testRunningQueriesView() throws Exception {
    IgniteEx ignite = startGrid(0);

    IgniteCache cache = ignite.createCache(
        new CacheConfiguration<>(DEFAULT_CACHE_NAME).setIndexedTypes(Integer.class, String.class)
    );

    cache.put(100,"200");

    String sql = "SELECT SQL, QUERY_ID, SCHEMA_NAME, LOCAL, START_TIME, DURATION FROM " +
        systemSchemaName() + ".SQL_QUERIES";

    FieldsQueryCursor notClosedFieldQryCursor = cache.query(new SqlFieldsQuery(sql).setLocal(true));

    List<?> cur = cache.query(new SqlFieldsQuery(sql).setLocal(true)).getAll();

    assertEquals(2, cur.size());

    List<?> res0 = (List<?>)cur.get(0);
    List<?> res1 = (List<?>)cur.get(1);

    Timestamp ts = (Timestamp)res0.get(4);

    Instant now = Instant.now();

    long diffInMillis = now.minusMillis(ts.getTime()).toEpochMilli();

    assertTrue(diffInMillis < 3000);

    assertEquals(sql, res0.get(0));

    assertEquals(sql, res1.get(0));

    assertTrue((Boolean)res0.get(3));

    String id0 = (String)res0.get(1);
    String id1 = (String)res1.get(1);

    assertNotEquals(id0, id1);

    String qryPrefix = ignite.localNode().id() + "_";

    String qryId1 = qryPrefix + "1";
    String qryId2 = qryPrefix + "2";

    assertTrue(id0.equals(qryId1) || id1.equals(qryId1));

    assertTrue(id0.equals(qryId2) || id1.equals(qryId2));

    assertEquals(2, cache.query(new SqlFieldsQuery(sql)).getAll().size());

    notClosedFieldQryCursor.close();

    assertEquals(1, cache.query(new SqlFieldsQuery(sql)).getAll().size());

    cache.put(100,"200");

    QueryCursor notClosedQryCursor = cache.query(new SqlQuery<>(String.class, "_key=100"));

    String expSqlQry = "SELECT \"default\".\"STRING\"._KEY, \"default\".\"STRING\"._VAL FROM " +
        "\"default\".\"STRING\" WHERE _key=100";

    cur = cache.query(new SqlFieldsQuery(sql)).getAll();

    assertEquals(2, cur.size());

    res0 = (List<?>)cur.get(0);
    res1 = (List<?>)cur.get(1);

    assertTrue(expSqlQry, res0.get(0).equals(expSqlQry) || res1.get(0).equals(expSqlQry));

    assertFalse((Boolean)res0.get(3));

    assertFalse((Boolean)res1.get(3));

    notClosedQryCursor.close();

    sql = "SELECT SQL, QUERY_ID FROM " + systemSchemaName() + ".SQL_QUERIES WHERE QUERY_ID='" + qryPrefix + "7'";

    assertEquals(qryPrefix + "7", ((List<?>)cache.query(new SqlFieldsQuery(sql)).getAll().get(0)).get(1));

    sql = "SELECT SQL FROM " + systemSchemaName() + ".SQL_QUERIES WHERE DURATION > 100000";

    assertTrue(cache.query(new SqlFieldsQuery(sql)).getAll().isEmpty());

    sql = "SELECT SQL FROM " + systemSchemaName() + ".SQL_QUERIES WHERE QUERY_ID='UNKNOWN'";

    assertTrue(cache.query(new SqlFieldsQuery(sql)).getAll().isEmpty());
}