Tabnine Logo
ExtendedLatch
Code IndexAdd Tabnine to your IDE (free)

How to use
ExtendedLatch
in
com.dremio.common.concurrent

Best Java code snippets using com.dremio.common.concurrent.ExtendedLatch (Showing top 20 results out of 315)

origin: dremio/dremio-oss

/**
 * 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);
}
origin: dremio/dremio-oss

 /**
  * Await without interruption. In the case of interruption, log a warning and continue to wait.
  */
 public void awaitUninterruptibly() {
  while (true) {
   try {
    await();
    return;
   } catch (final InterruptedException e) {
    // if we're still not ready, the while loop will cause us to wait again
    logger.warn("Interrupted while waiting for event latch.", e);
   }
  }
 }
}
origin: dremio/dremio-oss

@Override
public void countDown() {
 Preconditions.checkNotNull(latch, "Latch not initialized in %s at %s.", siteClass.getSimpleName(), desc);
 Preconditions.checkArgument(latch.getCount() > 0, "Counting down on latch more than intended.");
 latch.countDown();
}
origin: dremio/dremio-oss

final ExtendedLatch endpointLatch = new ExtendedLatch(numIntFragments);
final FragmentSubmitFailures fragmentSubmitFailures = new FragmentSubmitFailures();
if(numIntFragments > 0 && !endpointLatch.awaitUninterruptibly(timeout)){
 long numberRemaining = endpointLatch.getCount();
 throw UserException.connectionError()
   .message(
origin: dremio/dremio-oss

@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);
}
origin: dremio/dremio-oss

@Override
public void awaitUninterruptibly() {
 Preconditions.checkNotNull(latch, "Latch not initialized in %s at %s.", siteClass.getSimpleName(), desc);
 latch.awaitUninterruptibly();
}
origin: dremio/dremio-oss

 public void unpause() {
  latch.countDown();
 }
}
origin: dremio/dremio-oss

@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);
 }
}
origin: dremio/dremio-oss

public void pause() {
 if (!injectNow()) {
  return;
 }
 latch.awaitUninterruptibly();
}
origin: dremio/dremio-oss

/**
 * If it is safe to exit, and the exitLatch is in use, signals it so that waitToExit() will
 * unblock.
 */
private void indicateIfSafeToExit() {
 synchronized(this) {
  if (exitLatch != null) {
   if (externalIdToForeman.isEmpty()) {
    exitLatch.countDown();
   }
  }
 }
}
origin: dremio/dremio-oss

/**
 * 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);
}
origin: dremio/dremio-oss

@Override
public void await() throws InterruptedException {
 Preconditions.checkNotNull(latch, "Latch not initialized in %s at %s.", siteClass.getSimpleName(), desc);
 try {
  latch.await();
 } catch (final InterruptedException e) {
  logger.warn("Interrupted while awaiting in {} at {}.", siteClass.getSimpleName(), desc);
  throw e;
 }
}
origin: dremio/dremio-oss

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());
origin: dremio/dremio-oss

 @Override
 public void run() {
  latch.awaitUninterruptibly();
  final long startTime = System.currentTimeMillis();
  for (int i = 0; i < count; i++) {
   (new Thread() {
    @Override
    public void run() {
     dummyClass.countDown();
    }
   }).start();
  }
  final long endTime = System.currentTimeMillis();
  countingDownTime.value = (endTime - startTime);
 }
}
origin: dremio/dremio-oss

/**
 * If it is safe to exit, and the exitLatch is in use, signals it so that waitToExit() will
 * unblock.
 */
private void indicateIfSafeToExit() {
 synchronized(this) {
  if (exitLatch != null) {
   if (fragmentExecutors.size() == 0) {
    exitLatch.countDown();
   }
  }
 }
}
origin: dremio/dremio-oss

}else{
 parallelism = Math.min(parallelism,  runnables.size());
 final ExtendedLatch latch = new ExtendedLatch(runnables.size());
 final ExecutorService threadPool = Executors.newFixedThreadPool(parallelism);
 try{
  if (!latch.awaitUninterruptibly(timeout)) {
origin: dremio/dremio-oss

/**
 * Await without interruption for a given time.
 * @param waitMillis
 *          Time in milliseconds to wait
 * @return Whether the countdown reached zero or not.
 */
public boolean awaitUninterruptibly(long waitMillis) {
 final long targetMillis = System.currentTimeMillis() + waitMillis;
 while (System.currentTimeMillis() < targetMillis) {
  final long wait = targetMillis - System.currentTimeMillis();
  if (wait < 1) {
   return false;
  }
  try {
   return await(wait, TimeUnit.MILLISECONDS);
  } catch (final InterruptedException e) {
   // if we weren't ready, the while loop will continue to wait
  }
 }
 return false;
}
origin: dremio/dremio-oss

final ExtendedLatch trigger = new ExtendedLatch(1);
final Pointer<Long> countingDownTime = new Pointer<>();
origin: dremio/dremio-oss

 @Override
 public void run() {
  latch.awaitUninterruptibly();
  try {
   Thread.sleep(millis);
  } catch (final InterruptedException ex) {
   this.ex.value = ex;
  }
  context.getExecutionControls().unpauseAll();
 }
}
origin: dremio/dremio-oss

public void interruptiblePause() throws InterruptedException {
 if (!injectNow()) {
  return;
 }
 latch.await();
}
com.dremio.common.concurrentExtendedLatch

Javadoc

An extended CountDownLatch which allows us to await uninterruptibly.

Most used methods

  • <init>
  • await
  • awaitUninterruptibly
    Await without interruption for a given time.
  • countDown
  • getCount

Popular in Java

  • Start an intent from android
  • getResourceAsStream (ClassLoader)
  • getSystemService (Context)
  • onRequestPermissionsResult (Fragment)
  • FileOutputStream (java.io)
    An output stream that writes bytes to a file. If the output file exists, it can be replaced or appen
  • BitSet (java.util)
    The BitSet class implements abit array [http://en.wikipedia.org/wiki/Bit_array]. Each element is eit
  • Scanner (java.util)
    A parser that parses a text string of primitive types and strings with the help of regular expressio
  • Notification (javax.management)
  • JList (javax.swing)
  • IsNull (org.hamcrest.core)
    Is the value null?
  • CodeWhisperer alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now