@Override public void initialize(final int count) { Preconditions.checkArgument(latch == null, "Latch can be initialized only once at %s in %s.", desc, siteClass.getSimpleName()); Preconditions.checkArgument(count > 0, "Count has to be a positive integer at %s in %s.", desc, siteClass.getSimpleName()); latch = new ExtendedLatch(count); }
/** * Waits until it is safe to exit. Blocks until all currently running fragments have completed. * * <p>This is intended to be used by {@link com.dremio.exec.server.SabotNode#close()}.</p> */ public void waitToExit() { synchronized(this) { if (externalIdToForeman.isEmpty()) { return; } exitLatch = new ExtendedLatch(); } // Wait for at most 5 seconds or until the latch is released. exitLatch.awaitUninterruptibly(5000); }
/** * Waits until it is safe to exit. Blocks until all currently running fragments have completed. * * <p>This is intended to be used by {@link com.dremio.exec.server.SabotNode#close()}.</p> */ public void waitToExit() { synchronized(this) { if (fragmentExecutors == null || fragmentExecutors.size() == 0) { return; } exitLatch = new ExtendedLatch(); } // Wait for at most 5 seconds or until the latch is released. exitLatch.awaitUninterruptibly(5000); }
}else{ parallelism = Math.min(parallelism, runnables.size()); final ExtendedLatch latch = new ExtendedLatch(runnables.size()); final ExecutorService threadPool = Executors.newFixedThreadPool(parallelism); try{
final ExtendedLatch endpointLatch = new ExtendedLatch(numIntFragments); final FragmentSubmitFailures fragmentSubmitFailures = new FragmentSubmitFailures();
@Test public void pauseInjected() { final long expectedDuration = 1000L; final ExtendedLatch trigger = new ExtendedLatch(1); final Pointer<Exception> ex = new Pointer<>(); final String controls = Controls.newBuilder() .addPause(DummyClass.class, DummyClass.PAUSES) .build(); ControlsInjectionUtil.setControls(session, controls); final QueryContext queryContext = new QueryContext(session, nodes[0].getContext(), QueryId.getDefaultInstance()); (new ResumingThread(queryContext, trigger, ex, expectedDuration)).start(); // test that the pause happens final DummyClass dummyClass = new DummyClass(queryContext, trigger); final long actualDuration = dummyClass.pauses(); assertTrue(String.format("Test should stop for at least %d milliseconds.", expectedDuration), expectedDuration <= actualDuration); assertTrue("No exception should be thrown.", ex.value == null); try { queryContext.close(); } catch (final Exception e) { fail("Failed to close query context: " + e); } }
final ExtendedLatch trigger = new ExtendedLatch(1); final Pointer<Exception> ex = new Pointer<>(); final QueryContext queryContext = new QueryContext(session, nodeContext1, QueryId.getDefaultInstance()); final ExtendedLatch trigger = new ExtendedLatch(1); final QueryContext queryContext = new QueryContext(session, nodeContext2, QueryId.getDefaultInstance());
final ExtendedLatch trigger = new ExtendedLatch(1); final Pointer<Long> countingDownTime = new Pointer<>();