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

How to use
CountdownTimer
in
brooklyn.util.time

Best Java code snippets using brooklyn.util.time.CountdownTimer (Showing top 4 results out of 315)

origin: io.brooklyn/brooklyn-utils-common

public static CountdownTimer newInstancePaused(Duration duration) {
  return new CountdownTimer(duration).pause();
}
origin: io.brooklyn/brooklyn-utils-common

/** returns a new started {@link CountdownTimer} with this duration */
public CountdownTimer countdownTimer() {
  return CountdownTimer.newInstanceStarted(this);
}
origin: io.brooklyn/brooklyn-utils-common

public static CountdownTimer newInstanceStarted(Duration duration) {
  return new CountdownTimer(duration).start();
}
origin: io.brooklyn/brooklyn-software-base

public void waitForEntityStart() {
  if (log.isDebugEnabled()) log.debug("waiting to ensure {} doesn't abort prematurely", this);
  Duration startTimeout = Duration.seconds(getConfig(START_TIMEOUT));
  CountdownTimer timer = startTimeout.countdownTimer();
  boolean isRunningResult = false;
  long delay = 100;
  while (!isRunningResult && !timer.isExpired()) {
    Time.sleep(delay);
    try {
      isRunningResult = driver.isRunning();
    } catch (Exception  e) {
      setAttribute(SERVICE_STATE, Lifecycle.ON_FIRE);
      // provide extra context info, as we're seeing this happen in strange circumstances
      if (driver==null) throw new IllegalStateException(this+" concurrent start and shutdown detected");
      throw new IllegalStateException("Error detecting whether "+this+" is running: "+e, e);
    }
    if (log.isDebugEnabled()) log.debug("checked {}, is running returned: {}", this, isRunningResult);
    // slow exponential delay -- 1.1^N means after 40 tries and 50s elapsed, it reaches the max of 5s intervals  
    delay = Math.min(delay*11/10, 5000);
  }
  if (!isRunningResult) {
    String msg = "Software process entity "+this+" did not pass is-running check within "+
        "the required "+startTimeout+" limit ("+timer.getDurationElapsed()+" elapsed)";
    log.warn(msg+" (throwing)");
    setAttribute(SERVICE_STATE, Lifecycle.ON_FIRE);
    throw new IllegalStateException(msg);
  }
}
brooklyn.util.timeCountdownTimer

Most used methods

  • <init>
  • getDurationElapsed
    return how long the timer has been running (longer than limit if #isExpired())
  • isExpired
    true iff the timer has been running for the given time
  • newInstanceStarted
  • pause
    pauses the timer, if running; no-op if not running
  • start
    starts the timer, either initially or if #pause()d; no-op if already running

Popular in Java

  • Reading from database using SQL prepared statement
  • getResourceAsStream (ClassLoader)
  • onCreateOptionsMenu (Activity)
  • startActivity (Activity)
  • ObjectMapper (com.fasterxml.jackson.databind)
    ObjectMapper provides functionality for reading and writing JSON, either to and from basic POJOs (Pl
  • BufferedInputStream (java.io)
    A BufferedInputStream adds functionality to another input stream-namely, the ability to buffer the i
  • FileInputStream (java.io)
    An input stream that reads bytes from a file. File file = ...finally if (in != null) in.clos
  • Hashtable (java.util)
    A plug-in replacement for JDK1.5 java.util.Hashtable. This version is based on org.cliffc.high_scale
  • TimeUnit (java.util.concurrent)
    A TimeUnit represents time durations at a given unit of granularity and provides utility methods to
  • Table (org.hibernate.mapping)
    A relational table
  • Top 12 Jupyter Notebook extensions
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