Search in sources :

Example 1 with TestRunnable

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

the class JmxExporterSpiTest method checkStripeExecutorView.

/**
 * Checks striped executor system view.
 *
 * @param execSvc Striped executor.
 * @param viewName System view.
 * @param poolName Executor name.
 */
private void checkStripeExecutorView(StripedExecutor execSvc, String viewName, String poolName) throws Exception {
    CountDownLatch latch = new CountDownLatch(1);
    execSvc.execute(0, new TestRunnable(latch, 0));
    execSvc.execute(0, new TestRunnable(latch, 1));
    execSvc.execute(1, new TestRunnable(latch, 2));
    execSvc.execute(1, new TestRunnable(latch, 3));
    try {
        boolean res = waitForCondition(() -> systemView(viewName).size() == 2, 5_000);
        assertTrue(res);
        TabularDataSupport view = systemView(viewName);
        CompositeData row0 = view.get(new Object[] { 0 });
        assertEquals(0, row0.get("stripeIndex"));
        assertEquals(TestRunnable.class.getSimpleName() + '1', row0.get("description"));
        assertEquals(poolName + "-stripe-0", row0.get("threadName"));
        assertEquals(TestRunnable.class.getName(), row0.get("taskName"));
        CompositeData row1 = view.get(new Object[] { 1 });
        assertEquals(1, row1.get("stripeIndex"));
        assertEquals(TestRunnable.class.getSimpleName() + '3', row1.get("description"));
        assertEquals(poolName + "-stripe-1", row1.get("threadName"));
        assertEquals(TestRunnable.class.getName(), row1.get("taskName"));
    } finally {
        latch.countDown();
    }
}
Also used : TestRunnable(org.apache.ignite.internal.metric.SystemViewSelfTest.TestRunnable) TabularDataSupport(javax.management.openmbean.TabularDataSupport) CompositeData(javax.management.openmbean.CompositeData) CountDownLatch(java.util.concurrent.CountDownLatch)

Example 2 with TestRunnable

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

the class SqlViewExporterSpiTest method checkStripeExecutorView.

/**
 * Checks striped executor system view.
 *
 * @param execSvc Striped executor.
 * @param view System view name.
 * @param poolName Executor name.
 */
private void checkStripeExecutorView(StripedExecutor execSvc, String view, String poolName) throws Exception {
    CountDownLatch latch = new CountDownLatch(1);
    execSvc.execute(0, new TestRunnable(latch, 0));
    execSvc.execute(0, new TestRunnable(latch, 1));
    execSvc.execute(1, new TestRunnable(latch, 2));
    execSvc.execute(1, new TestRunnable(latch, 3));
    try {
        boolean res = waitForCondition(() -> execute(ignite0, "SELECT * FROM SYS." + view).size() == 2, 5_000);
        assertTrue(res);
        List<List<?>> stripedQueue = execute(ignite0, "SELECT * FROM SYS." + view);
        List<?> row0 = stripedQueue.get(0);
        assertEquals(0, row0.get(0));
        assertEquals(TestRunnable.class.getSimpleName() + '1', row0.get(1));
        assertEquals(poolName + "-stripe-0", row0.get(2));
        assertEquals(TestRunnable.class.getName(), row0.get(3));
        List<?> row1 = stripedQueue.get(1);
        assertEquals(1, row1.get(0));
        assertEquals(TestRunnable.class.getSimpleName() + '3', row1.get(1));
        assertEquals(poolName + "-stripe-1", row1.get(2));
        assertEquals(TestRunnable.class.getName(), row1.get(3));
    } finally {
        latch.countDown();
    }
}
Also used : TestRunnable(org.apache.ignite.internal.metric.SystemViewSelfTest.TestRunnable) Arrays.asList(java.util.Arrays.asList) List(java.util.List) ArrayList(java.util.ArrayList) CountDownLatch(java.util.concurrent.CountDownLatch)

Example 3 with TestRunnable

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

the class SystemViewCommandTest method checkStripeExecutorView.

/**
 * Checks striped executor system view.
 *
 * @param execSvc Striped executor.
 * @param view System view name.
 * @param poolName Executor name.
 */
private void checkStripeExecutorView(StripedExecutor execSvc, String view, String poolName) throws Exception {
    CountDownLatch latch = new CountDownLatch(1);
    execSvc.execute(0, new TestRunnable(latch, 0));
    execSvc.execute(0, new TestRunnable(latch, 1));
    execSvc.execute(1, new TestRunnable(latch, 2));
    execSvc.execute(1, new TestRunnable(latch, 3));
    try {
        assertTrue(waitForCondition(() -> systemView(ignite0, view).size() == 2, getTestTimeout()));
        List<List<String>> stripedQueue = systemView(ignite0, view);
        List<String> row0 = stripedQueue.get(0);
        assertEquals("0", row0.get(0));
        assertEquals(TestRunnable.class.getSimpleName() + '1', row0.get(1));
        assertEquals(poolName + "-stripe-0", row0.get(2));
        assertEquals(TestRunnable.class.getName(), row0.get(3));
        List<String> row1 = stripedQueue.get(1);
        assertEquals("1", row1.get(0));
        assertEquals(TestRunnable.class.getSimpleName() + '3', row1.get(1));
        assertEquals(poolName + "-stripe-1", row1.get(2));
        assertEquals(TestRunnable.class.getName(), row1.get(3));
    } finally {
        latch.countDown();
    }
}
Also used : TestRunnable(org.apache.ignite.internal.metric.SystemViewSelfTest.TestRunnable) Arrays.asList(java.util.Arrays.asList) ArrayList(java.util.ArrayList) CommandList(org.apache.ignite.internal.commandline.CommandList) List(java.util.List) CountDownLatch(java.util.concurrent.CountDownLatch)

Aggregations

CountDownLatch (java.util.concurrent.CountDownLatch)3 TestRunnable (org.apache.ignite.internal.metric.SystemViewSelfTest.TestRunnable)3 ArrayList (java.util.ArrayList)2 Arrays.asList (java.util.Arrays.asList)2 List (java.util.List)2 CompositeData (javax.management.openmbean.CompositeData)1 TabularDataSupport (javax.management.openmbean.TabularDataSupport)1 CommandList (org.apache.ignite.internal.commandline.CommandList)1