public static void sleepSecs(long secs) throws InterruptedException { if (secs > 0) { sleep(secs * 1000); } }
public static void sleep(long millis) { try { Time.sleep(millis); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new RuntimeException(e); } }
/** * Get an assignments from the target queue with the specific index. * @param queueIndex index of the queue * @return an {@link NodeAssignments} * @throws InterruptedException */ public NodeAssignments nextAssignments(Integer queueIndex) throws InterruptedException { NodeAssignments target = null; while (true) { target = getQueueById(queueIndex).poll(); if (target != null) { return target; } Time.sleep(100L); } }
public void run() { try { final Callable<Long> fn = isFactory ? (Callable<Long>) afn.call() : afn; while (true) { if (Thread.interrupted()) { throw new InterruptedException(); } final Long s = fn.call(); if (s == null) { // then stop running it break; } if (s > 0) { Time.sleep(s); } } } catch (Throwable t) { if (Utils.exceptionCauseIsInstanceOf( InterruptedException.class, t)) { LOG.info("Async loop interrupted!"); return; } LOG.error("Async loop died!", t); throw new RuntimeException(t); } } });
public void run() { try { while (true) { Map<K, V> dead = null; Time.sleep(sleepTime); synchronized (_lock) { dead = _rotatingMap.rotate(); } if (_callback != null) { for (Entry<K, V> entry : dead.entrySet()) { _callback.expire(entry.getKey(), entry.getValue()); } } } } catch (InterruptedException ex) { } } });
private void inactiveExecute() throws InterruptedException { if (lastActive.get()) { lastActive.set(false); deactivateSpouts(); } long start = Time.currentTimeMillis(); Time.sleep(100); spoutThrottlingMetrics.skippedInactiveMs(Time.currentTimeMillis() - start); }
static DynamicState handleEmpty(DynamicState dynamicState, StaticState staticState) throws InterruptedException, IOException { assert dynamicState.changingBlobs.isEmpty(); assert dynamicState.pendingChangingBlobsAssignment == null; if (!equivalent(dynamicState.newAssignment, dynamicState.currentAssignment)) { return prepareForNewAssignmentNoWorkersRunning(dynamicState, staticState); } dynamicState = updateAssignmentIfNeeded(dynamicState); //Both assignments are null, just wait if (dynamicState.profileActions != null && !dynamicState.profileActions.isEmpty()) { //Nothing is scheduled here so throw away all of the profileActions LOG.warn("Dropping {} no topology is running", dynamicState.profileActions); dynamicState = dynamicState.withProfileActions(Collections.emptySet(), Collections.emptySet()); } //Drop the change notifications we are not running anything right now dynamicState = drainAllChangingBlobs(dynamicState); Time.sleep(1000); return dynamicState; }
/** * State Transitions for KILL state. * PRECONDITION: container.kill() was called * PRECONDITION: container != null && currentAssignment != null * @param dynamicState current state * @param staticState static data * @return the next state * @throws Exception on any error */ private static DynamicState handleKill(DynamicState dynamicState, StaticState staticState) throws Exception { assert (dynamicState.container != null); assert (dynamicState.currentAssignment != null); if (dynamicState.container.areAllProcessesDead()) { LOG.info("SLOT {} all processes are dead...", staticState.port); return cleanupCurrentContainer(dynamicState, staticState, dynamicState.pendingLocalization == null ? MachineState.EMPTY : MachineState.WAITING_FOR_BLOB_LOCALIZATION); } LOG.warn("SLOT {} force kill and wait...", staticState.port); dynamicState.container.forceKill(); Time.sleep(staticState.killSleepMs); return dynamicState; }
/** * Used by {@link Supervisor} to fetch assignments when start up. * @param supervisor {@link Supervisor} */ public void getAssignmentsFromMasterUntilSuccess(Supervisor supervisor) { boolean success = false; while (!success) { try (NimbusClient master = NimbusClient.getConfiguredClient(supervisor.getConf())) { SupervisorAssignments assignments = master.getClient().getSupervisorAssignments(supervisor.getAssignmentId()); assignedAssignmentsToLocal(supervisor.getStormClusterState(), assignments); success = true; } catch (Exception t) { // just ignore the exception } if (!success) { LOG.info("Waiting for a success sync of assignments from master..."); try { Time.sleep(5000L); } catch (InterruptedException e) { throw new RuntimeException(e); } } } }
Time.sleep(staticState.killSleepMs);
Time.sleep(staticState.monitorFreqMs); return dynamicState;
Time.sleep(1000); return dynamicState;
() -> { try { Time.sleep(100); } catch (InterruptedException e) {
public static void sleepSecs (long secs) throws InterruptedException { if (secs > 0) { sleep(secs * 1000); } }
public static void sleep(long millis) { try { Time.sleep(millis); } catch(InterruptedException e) { Thread.currentThread().interrupt(); throw new RuntimeException(e); } }
static DynamicState handleEmpty(DynamicState dynamicState, StaticState staticState) throws InterruptedException, IOException { if (!equivalent(dynamicState.newAssignment, dynamicState.currentAssignment)) { return prepareForNewAssignmentNoWorkersRunning(dynamicState, staticState); } //Both assignments are null, just wait if (dynamicState.profileActions != null && !dynamicState.profileActions.isEmpty()) { //Nothing is scheduled here so throw away all of the profileActions LOG.warn("Dropping {} no topology is running", dynamicState.profileActions); dynamicState = dynamicState.withProfileActions(Collections.<TopoProfileAction> emptySet(), Collections.<TopoProfileAction> emptySet()); } Time.sleep(1000); return dynamicState; }
public void run() { try { while(true) { Map<K, V> dead = null; Time.sleep(sleepTime); synchronized(_lock) { dead = _rotatingMap.rotate(); } if(_callback!=null) { for(Entry<K, V> entry: dead.entrySet()) { _callback.expire(entry.getKey(), entry.getValue()); } } } } catch (InterruptedException ex) { } } });
/** * Kill the current container and relaunch it. (Something odd happened) * PRECONDITION: container != null * @param dynamicState current state * @param staticState static data * @return the next state * @throws Exception */ static DynamicState killAndRelaunchContainer(DynamicState dynamicState, StaticState staticState) throws Exception { assert(dynamicState.container != null); dynamicState.container.kill(); Time.sleep(staticState.killSleepMs); //any stop profile actions that hadn't timed out yet, we should restart after the worker is running again. HashSet<TopoProfileAction> mod = new HashSet<>(dynamicState.profileActions); mod.addAll(dynamicState.pendingStopProfileActions); return dynamicState.withState(MachineState.KILL_AND_RELAUNCH).withProfileActions(mod, Collections.<TopoProfileAction> emptySet()); }
/** * Kill the current container and start downloading what the new assignment needs, if there is a new assignment * PRECONDITION: container != null * @param dynamicState current state * @param staticState static data * @return the next state * @throws Exception */ static DynamicState killContainerForChangedAssignment(DynamicState dynamicState, StaticState staticState) throws Exception { assert(dynamicState.container != null); staticState.iSupervisor.killedWorker(staticState.port); dynamicState.container.kill(); Future<Void> pendingDownload = null; if (dynamicState.newAssignment != null) { pendingDownload = staticState.localizer.requestDownloadBaseTopologyBlobs(dynamicState.newAssignment, staticState.port); } Time.sleep(staticState.killSleepMs); return dynamicState.withPendingLocalization(dynamicState.newAssignment, pendingDownload).withState(MachineState.KILL); }