/** see {@link Time#sleep(long)} */ public static void sleep(Duration duration) { Time.sleep(duration); }
/** as {@link #sleep(long)} */ public static void sleep(Duration duration) { Time.sleep(duration.toMillisecondsRoundingUp()); }
protected boolean tryCheckStartWindowsService() { if (windowsServiceName==null) return false; // if it's still up after 5s assume we are good (default behaviour) Time.sleep(Duration.FIVE_SECONDS); if (!((Integer)0).equals(DynamicTasks.queue(SshEffectorTasks.ssh("sc query \""+windowsServiceName+"\" | find \"RUNNING\"").runAsCommand()).get())) { throw new IllegalStateException("The process for "+entity()+" appears not to be running (windowsService "+windowsServiceName+")"); } return true; }
protected boolean tryCheckStartService() { if (serviceName==null) return false; // if it's still up after 5s assume we are good (default behaviour) Time.sleep(Duration.FIVE_SECONDS); if (!((Integer)0).equals(DynamicTasks.queue(SshEffectorTasks.ssh("/etc/init.d/"+serviceName+" status").runAsRoot()).get())) { throw new IllegalStateException("The process for "+entity()+" appears not to be running (service "+serviceName+")"); } return true; }
@Override protected void postStart() { super.postStart(); // stupid to do this here, but there appears to be a race where sometimes the // broker throws a BrokerStopped exception, even though the sensor indicates it is up Time.sleep(Duration.FIVE_SECONDS); for (String name : queueNames) { addQueue(name); } for (String name : topicNames) { addTopic(name); } }
Time.sleep(period);
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); } }
@Override public void start(Collection<? extends Location> locations) { super.start(locations); connectSensors(); // TODO wait until all nodes which we think are up are consistent // i.e. all known nodes use the same schema, as reported by // SshEffectorTasks.ssh("echo \"describe cluster;\" | /bin/cassandra-cli"); // once we've done that we can revert to using 2 seed nodes. // see CassandraCluster.DEFAULT_SEED_QUORUM Time.sleep(getConfig(CassandraCluster.DELAY_BEFORE_ADVERTISING_CLUSTER)); update(); }
protected boolean tryCheckStartPid() { if (pidFile==null) return false; // if it's still up after 5s assume we are good (default behaviour) Time.sleep(Duration.FIVE_SECONDS); if (!DynamicTasks.queue(SshEffectorTasks.isPidFromFileRunning(pidFile).runAsRoot()).get()) { throw new IllegalStateException("The process for "+entity()+" appears not to be running (pid file "+pidFile+")"); } // and set the PID entity().setAttribute(Attributes.PID, Integer.parseInt(DynamicTasks.queue(SshEffectorTasks.ssh("cat "+pidFile).runAsRoot()).block().getStdout().trim())); return true; }
@Override public void start(Collection<? extends Location> locations) { Machines.warnIfLocalhost(locations, "CassandraCluster does not support multiple nodes on localhost, " + "due to assumptions Cassandra makes about the use of the same port numbers used across the cluster."); super.start(locations); connectSensors(); // TODO wait until all nodes which we think are up are consistent // i.e. all known nodes use the same schema, as reported by // SshEffectorTasks.ssh("echo \"describe cluster;\" | /bin/cassandra-cli"); // once we've done that we can revert to using 2 seed nodes. // see CassandraCluster.DEFAULT_SEED_QUORUM Time.sleep(getConfig(DELAY_BEFORE_ADVERTISING_CLUSTER)); update(); }
log.info("Launching " + entity + ": delaying launch of non-first node by "+toWait+" to prevent schema disagreements"); Tasks.setBlockingDetails("Pausing to ensure first node has time to start"); Time.sleep(toWait); Tasks.resetBlockingDetails();
" (and Java not detected); invalid result "+result+". " + "Will retry."); Time.sleep(Duration.TEN_SECONDS);