/** * @throws Exception If failed. */ @Test public void testCompletedTasks() throws Exception { stripedExecSvc.execute(0, new TestRunnable()); stripedExecSvc.execute(1, new TestRunnable()); sleepASec(); assertEquals(2, stripedExecSvc.completedTasks()); }
/** * @throws Exception If failed. */ @Test public void testActiveStripesCount() throws Exception { stripedExecSvc.execute(0, new TestRunnable()); stripedExecSvc.execute(1, new TestRunnable(true)); sleepASec(); assertEquals(1, stripedExecSvc.activeStripesCount()); }
/** * @throws Exception If failed. */ @Test public void testQueueSize() throws Exception { stripedExecSvc.execute(1, new TestRunnable()); stripedExecSvc.execute(1, new TestRunnable(true)); stripedExecSvc.execute(1, new TestRunnable(true)); sleepASec(); assertEquals(1, stripedExecSvc.queueSize()); }
/** * @throws Exception If failed. */ @Test public void testStripesCompletedTasks() throws Exception { stripedExecSvc.execute(0, new TestRunnable()); stripedExecSvc.execute(1, new TestRunnable()); sleepASec(); long[] completedTaks = stripedExecSvc.stripesCompletedTasks(); assertEquals(1, completedTaks[0]); assertEquals(1, completedTaks[1]); assertEquals(0, completedTaks[2]); }
/** * @throws Exception If failed. */ @Test public void testStripesActiveStatuses() throws Exception { stripedExecSvc.execute(0, new TestRunnable()); stripedExecSvc.execute(1, new TestRunnable(true)); sleepASec(); boolean[] statuses = stripedExecSvc.stripesActiveStatuses(); assertFalse(statuses[0]); assertTrue(statuses[1]); assertFalse(statuses[0]); }
/** * @throws Exception If failed. */ @Test public void testStarvationDetected() throws Exception { final int stripeIdx = 0; stripedExecSvc.execute(stripeIdx, new TestRunnable(true)); sleepASec(); assertFalse(GridTestUtils.waitForCondition(() -> stripedExecSvc.activeStripesCount() == 0, 2000)); stripedExecSvc.execute(stripeIdx, new TestRunnable()); assertTrue(GridTestUtils.waitForCondition(() -> stripedExecSvc.activeStripesCount() == 1, 10000)); assertTrue(stripedExecSvc.detectStarvation()); }
/** * @throws Exception If failed. */ @Test public void testStripesQueueSizes() throws Exception { stripedExecSvc.execute(0, new TestRunnable()); stripedExecSvc.execute(0, new TestRunnable(true)); stripedExecSvc.execute(0, new TestRunnable(true)); stripedExecSvc.execute(1, new TestRunnable(true)); stripedExecSvc.execute(1, new TestRunnable(true)); stripedExecSvc.execute(1, new TestRunnable(true)); sleepASec(); int[] queueSizes = stripedExecSvc.stripesQueueSizes(); assertEquals(1, queueSizes[0]); assertEquals(2, queueSizes[1]); assertEquals(0, queueSizes[2]); }