Search in sources :

Example 1 with TestTransformer

use of org.apache.ignite.internal.metric.SystemViewSelfTest.TestTransformer in project ignite by apache.

the class JmxExporterSpiTest method testScanQuery.

/**
 */
@Test
public void testScanQuery() throws Exception {
    try (IgniteEx client1 = startClientGrid("client-1");
        IgniteEx client2 = startClientGrid("client-2")) {
        IgniteCache<Integer, Integer> cache1 = client1.createCache(new CacheConfiguration<Integer, Integer>("cache1").setGroupName("group1"));
        IgniteCache<Integer, Integer> cache2 = client2.createCache("cache2");
        awaitPartitionMapExchange();
        for (int i = 0; i < 100; i++) {
            cache1.put(i, i);
            cache2.put(i, i);
        }
        TabularDataSupport qrySysView0 = systemView(ignite, SCAN_QRY_SYS_VIEW);
        assertNotNull(qrySysView0);
        assertEquals(0, qrySysView0.size());
        QueryCursor<Integer> qryRes1 = cache1.query(new ScanQuery<Integer, Integer>().setFilter(new TestPredicate()).setPageSize(10), new TestTransformer());
        QueryCursor<?> qryRes2 = cache2.withKeepBinary().query(new ScanQuery<>().setPageSize(20));
        assertTrue(qryRes1.iterator().hasNext());
        assertTrue(qryRes2.iterator().hasNext());
        checkScanQueryView(client1, client2, ignite);
        qryRes1.close();
        qryRes2.close();
        boolean res = waitForCondition(() -> systemView(ignite, SCAN_QRY_SYS_VIEW).isEmpty(), 5_000);
        assertTrue(res);
    }
}
Also used : ScanQuery(org.apache.ignite.cache.query.ScanQuery) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) TestTransformer(org.apache.ignite.internal.metric.SystemViewSelfTest.TestTransformer) TestPredicate(org.apache.ignite.internal.metric.SystemViewSelfTest.TestPredicate) TabularDataSupport(javax.management.openmbean.TabularDataSupport) IgniteEx(org.apache.ignite.internal.IgniteEx) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) Test(org.junit.Test)

Example 2 with TestTransformer

use of org.apache.ignite.internal.metric.SystemViewSelfTest.TestTransformer in project ignite by apache.

the class SystemViewCommandTest method testLocalScanQuery.

/**
 */
@Test
public void testLocalScanQuery() throws Exception {
    IgniteCache<Integer, Integer> cache1 = ignite0.createCache(new CacheConfiguration<Integer, Integer>("cache1").setGroupName("group1"));
    int part = ignite0.affinity("cache1").primaryPartitions(ignite0.localNode())[0];
    List<Integer> partKeys = partitionKeys(cache1, part, 11, 0);
    partKeys.forEach(key -> cache1.put(key, key));
    assertTrue(systemView(ignite0, SCAN_QRY_SYS_VIEW).isEmpty());
    try (QueryCursor<Integer> qryRes1 = cache1.query(new ScanQuery<Integer, Integer>().setFilter(new TestPredicate()).setLocal(true).setPartition(part).setPageSize(10), new TestTransformer())) {
        assertTrue(qryRes1.iterator().hasNext());
        assertTrue(waitForCondition(() -> !systemView(ignite0, SCAN_QRY_SYS_VIEW).isEmpty(), getTestTimeout()));
        List<String> view = systemView(ignite0, SCAN_QRY_SYS_VIEW).get(0);
        // originNodeId
        assertEquals(ignite0.localNode().id().toString(), view.get(0));
        // queryId
        assertEquals("0", view.get(1));
        // cacheName
        assertEquals("cache1", view.get(2));
        // cacheId
        assertEquals(Integer.toString(cacheId("cache1")), view.get(3));
        // cacheGroupId
        assertEquals(Integer.toString(cacheGroupId("cache1", "group1")), view.get(4));
        // cacheGroupName
        assertEquals("group1", view.get(5));
        // startTime
        assertTrue(Long.parseLong(view.get(6)) <= System.currentTimeMillis());
        // duration
        assertTrue(Long.parseLong(view.get(7)) >= 0);
        // canceled
        assertFalse(Boolean.parseBoolean(view.get(8)));
        // filter
        assertEquals(TEST_PREDICATE, view.get(9));
        // local
        assertTrue(Boolean.parseBoolean(view.get(11)));
        // partition
        assertEquals(part, Integer.parseInt(view.get(13)));
        // topology
        assertEquals(toStringSafe(ignite0.context().discovery().topologyVersionEx()), view.get(16));
        // transformer
        assertEquals(TEST_TRANSFORMER, view.get(17));
        // keepBinary
        assertFalse(Boolean.parseBoolean(view.get(10)));
        // subjectId
        assertEquals("null", view.get(14));
        // taskName
        assertEquals("null", view.get(15));
    }
    assertTrue(waitForCondition(() -> systemView(ignite0, SCAN_QRY_SYS_VIEW).isEmpty(), getTestTimeout()));
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) TestTransformer(org.apache.ignite.internal.metric.SystemViewSelfTest.TestTransformer) TestPredicate(org.apache.ignite.internal.metric.SystemViewSelfTest.TestPredicate) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) Test(org.junit.Test)

Example 3 with TestTransformer

use of org.apache.ignite.internal.metric.SystemViewSelfTest.TestTransformer in project ignite by apache.

the class SqlViewExporterSpiTest method testLocalScanQuery.

/**
 */
@Test
public void testLocalScanQuery() throws Exception {
    IgniteCache<Integer, Integer> cache1 = ignite0.createCache(new CacheConfiguration<Integer, Integer>("cache1").setGroupName("group1"));
    int part = ignite0.affinity("cache1").primaryPartitions(ignite0.localNode())[0];
    List<Integer> partKeys = partitionKeys(cache1, part, 11, 0);
    for (Integer key : partKeys) cache1.put(key, key);
    assertEquals(0, execute(ignite0, SCAN_QRY_SELECT).size());
    QueryCursor<Integer> qryRes1 = cache1.query(new ScanQuery<Integer, Integer>().setFilter(new TestPredicate()).setLocal(true).setPartition(part).setPageSize(10), new TestTransformer());
    assertTrue(qryRes1.iterator().hasNext());
    boolean res = waitForCondition(() -> !execute(ignite0, SCAN_QRY_SELECT).isEmpty(), 5_000);
    assertTrue(res);
    List<?> view = execute(ignite0, SCAN_QRY_SELECT).get(0);
    assertEquals(ignite0.localNode().id(), view.get(0));
    assertEquals(0L, view.get(1));
    assertEquals("cache1", view.get(2));
    assertEquals(cacheId("cache1"), view.get(3));
    assertEquals(cacheGroupId("cache1", "group1"), view.get(4));
    assertEquals("group1", view.get(5));
    assertTrue((Long) view.get(6) <= System.currentTimeMillis());
    assertTrue((Long) view.get(7) >= 0);
    assertFalse((Boolean) view.get(8));
    assertEquals(TEST_PREDICATE, view.get(9));
    assertTrue((Boolean) view.get(10));
    assertEquals(part, view.get(11));
    assertEquals(toStringSafe(ignite0.context().discovery().topologyVersionEx()), view.get(12));
    assertEquals(TEST_TRANSFORMER, view.get(13));
    assertFalse((Boolean) view.get(14));
    assertNull(view.get(15));
    assertNull(view.get(16));
    qryRes1.close();
    res = waitForCondition(() -> execute(ignite0, SCAN_QRY_SELECT).isEmpty(), 5_000);
    assertTrue(res);
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) TestTransformer(org.apache.ignite.internal.metric.SystemViewSelfTest.TestTransformer) TestPredicate(org.apache.ignite.internal.metric.SystemViewSelfTest.TestPredicate) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) AbstractExporterSpiTest(org.apache.ignite.internal.metric.AbstractExporterSpiTest) Test(org.junit.Test)

Example 4 with TestTransformer

use of org.apache.ignite.internal.metric.SystemViewSelfTest.TestTransformer in project ignite by apache.

the class SqlViewExporterSpiTest method testScanQuery.

/**
 */
@Test
public void testScanQuery() throws Exception {
    try (IgniteEx client1 = startClientGrid("client-1");
        IgniteEx client2 = startClientGrid("client-2")) {
        IgniteCache<Integer, Integer> cache1 = client1.createCache(new CacheConfiguration<Integer, Integer>("cache1").setGroupName("group1"));
        IgniteCache<Integer, Integer> cache2 = client2.createCache("cache2");
        for (int i = 0; i < 100; i++) {
            cache1.put(i, i);
            cache2.put(i, i);
        }
        assertEquals(0, execute(ignite0, SCAN_QRY_SELECT).size());
        assertEquals(0, execute(ignite1, SCAN_QRY_SELECT).size());
        QueryCursor<Integer> qryRes1 = cache1.query(new ScanQuery<Integer, Integer>().setFilter(new TestPredicate()).setPageSize(10), new TestTransformer());
        QueryCursor<?> qryRes2 = cache2.withKeepBinary().query(new ScanQuery<>().setPageSize(20));
        assertTrue(qryRes1.iterator().hasNext());
        assertTrue(qryRes2.iterator().hasNext());
        checkScanQueryView(client1, client2, ignite0);
        checkScanQueryView(client1, client2, ignite1);
        qryRes1.close();
        qryRes2.close();
        boolean res = waitForCondition(() -> execute(ignite0, SCAN_QRY_SELECT).size() + execute(ignite1, SCAN_QRY_SELECT).size() == 0, 5_000);
        assertTrue(res);
    }
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) TestTransformer(org.apache.ignite.internal.metric.SystemViewSelfTest.TestTransformer) TestPredicate(org.apache.ignite.internal.metric.SystemViewSelfTest.TestPredicate) IgniteEx(org.apache.ignite.internal.IgniteEx) ScanQuery(org.apache.ignite.cache.query.ScanQuery) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) AbstractExporterSpiTest(org.apache.ignite.internal.metric.AbstractExporterSpiTest) Test(org.junit.Test)

Example 5 with TestTransformer

use of org.apache.ignite.internal.metric.SystemViewSelfTest.TestTransformer in project ignite by apache.

the class SystemViewCommandTest method testScanQuery.

/**
 */
@Test
public void testScanQuery() throws Exception {
    try (IgniteEx client1 = startClientGrid("client-1");
        IgniteEx client2 = startClientGrid("client-2")) {
        IgniteCache<Integer, Integer> cache1 = client1.createCache(new CacheConfiguration<Integer, Integer>("cache1").setGroupName("group1"));
        IgniteCache<Integer, Integer> cache2 = client2.createCache("cache2");
        for (int i = 0; i < 100; i++) {
            cache1.put(i, i);
            cache2.put(i, i);
        }
        assertTrue(systemView(ignite0, SCAN_QRY_SYS_VIEW).isEmpty());
        assertTrue(systemView(ignite1, SCAN_QRY_SYS_VIEW).isEmpty());
        try (QueryCursor<Integer> qryRes1 = cache1.query(new ScanQuery<Integer, Integer>().setFilter(new TestPredicate()).setPageSize(10), new TestTransformer());
            QueryCursor<?> qryRes2 = cache2.withKeepBinary().query(new ScanQuery<>().setPageSize(20))) {
            assertTrue(qryRes1.iterator().hasNext());
            assertTrue(qryRes2.iterator().hasNext());
            checkScanQueryView(client1, client2, ignite0);
            checkScanQueryView(client1, client2, ignite1);
        }
        assertTrue(waitForCondition(() -> systemView(ignite0, SCAN_QRY_SYS_VIEW).isEmpty() && systemView(ignite1, SCAN_QRY_SYS_VIEW).isEmpty(), getTestTimeout()));
    }
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) TestTransformer(org.apache.ignite.internal.metric.SystemViewSelfTest.TestTransformer) TestPredicate(org.apache.ignite.internal.metric.SystemViewSelfTest.TestPredicate) IgniteEx(org.apache.ignite.internal.IgniteEx) ScanQuery(org.apache.ignite.cache.query.ScanQuery) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) Test(org.junit.Test)

Aggregations

AtomicInteger (java.util.concurrent.atomic.AtomicInteger)6 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)6 TestPredicate (org.apache.ignite.internal.metric.SystemViewSelfTest.TestPredicate)6 TestTransformer (org.apache.ignite.internal.metric.SystemViewSelfTest.TestTransformer)6 Test (org.junit.Test)6 ScanQuery (org.apache.ignite.cache.query.ScanQuery)3 IgniteEx (org.apache.ignite.internal.IgniteEx)3 TabularDataSupport (javax.management.openmbean.TabularDataSupport)2 AbstractExporterSpiTest (org.apache.ignite.internal.metric.AbstractExporterSpiTest)2 CompositeData (javax.management.openmbean.CompositeData)1