Search in sources :

Example 6 with TestTransformer

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

the class JmxExporterSpiTest method testLocalScanQuery.

/**
 */
@Test
public void testLocalScanQuery() throws Exception {
    IgniteCache<Integer, Integer> cache1 = ignite.createCache(new CacheConfiguration<Integer, Integer>("cache1").setGroupName("group1"));
    int part = ignite.affinity("cache1").primaryPartitions(ignite.localNode())[0];
    List<Integer> partKeys = partitionKeys(cache1, part, 11, 0);
    for (Integer key : partKeys) cache1.put(key, key);
    TabularDataSupport qrySysView0 = systemView(SCAN_QRY_SYS_VIEW);
    assertNotNull(qrySysView0);
    assertEquals(0, qrySysView0.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(() -> !systemView(SCAN_QRY_SYS_VIEW).isEmpty(), 5_000);
    assertTrue(res);
    CompositeData view = systemView(SCAN_QRY_SYS_VIEW).get(new Object[] { 0 });
    assertEquals(ignite.localNode().id().toString(), view.get("originNodeId"));
    assertEquals(0L, view.get("queryId"));
    assertEquals("cache1", view.get("cacheName"));
    assertEquals(cacheId("cache1"), view.get("cacheId"));
    assertEquals(cacheGroupId("cache1", "group1"), view.get("cacheGroupId"));
    assertEquals("group1", view.get("cacheGroupName"));
    assertTrue((Long) view.get("startTime") <= System.currentTimeMillis());
    assertTrue((Long) view.get("duration") >= 0);
    assertFalse((Boolean) view.get("canceled"));
    assertEquals(TEST_PREDICATE, view.get("filter"));
    assertTrue((Boolean) view.get("local"));
    assertEquals(part, view.get("partition"));
    assertEquals(toStringSafe(ignite.context().discovery().topologyVersionEx()), view.get("topology"));
    assertEquals(TEST_TRANSFORMER, view.get("transformer"));
    assertFalse((Boolean) view.get("keepBinary"));
    assertNull(view.get("subjectId"));
    assertNull(view.get("taskName"));
    qryRes1.close();
    res = waitForCondition(() -> systemView(SCAN_QRY_SYS_VIEW).isEmpty(), 5_000);
    assertTrue(res);
}
Also used : CompositeData(javax.management.openmbean.CompositeData) 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) 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