public static void waitForReader(int port) { AtomicBoolean ab = getHasReader(port); long start = Time.currentTimeMillis(); while (!ab.get()) { if (Time.isSimulating()) { Time.advanceTime(10); } try { Thread.sleep(10); } catch (InterruptedException e) { //Ignored } if (Time.currentTimeMillis() - start > 20000) { LOG.error("DONE WAITING FOR READER AFTER {} ms", Time.currentTimeMillis() - start); break; } } }
/** * Get how long this topology has been executing. */ public int getUpTime() { return Time.currentTimeSecs() - launchTime; }
public int upTime() { return Time.deltaSecs(startTime); } }
public static void sleep(long ms) throws InterruptedException { if (ms > 0) { if (SIMULATING.get()) { simulatedSleepUntilNanos(millisToNanos(currentTimeMillis() + ms)); } else { Thread.sleep(ms); } } }
public static void parkNanos(long nanos) throws InterruptedException { if (nanos > 0) { if (SIMULATING.get()) { simulatedSleepUntilNanos(nanoTime() + nanos); } else { LockSupport.parkNanos(nanos); } } }
public OutstandingRequest(String function, DRPCRequest req) { _start = Time.currentTimeMillis(); _function = function; _req = req; }
long hbAgeMs = (Time.currentTimeSecs() - hb.get_time_secs()) * 1000; if (hbAgeMs <= staticState.hbTimeoutMs) { return dynamicState.withState(MachineState.RUNNING); long timeDiffms = (Time.currentTimeMillis() - dynamicState.startTime); if (timeDiffms > staticState.firstHbTimeoutMs) { LOG.warn("SLOT {}: Container {} failed to launch in {} ms.", staticState.port, dynamicState.container, Time.sleep(1000); return dynamicState;
@Test public void shouldAdvanceForwardTest() { try (SimulatedTime t = new SimulatedTime()) { long current = Time.currentTimeMillis(); Time.advanceTime(1000); Assert.assertEquals(Time.deltaMs(current), 1000); Time.advanceTime(500); Assert.assertEquals(Time.deltaMs(current), 1500); } }
@Test public void deltaSecsConvertsToSecondsTest() { try (SimulatedTime t = new SimulatedTime()) { int current = Time.currentTimeSecs(); Time.advanceTime(1000); Assert.assertEquals(Time.deltaSecs(current), 1); } }
private void inactiveExecute() throws InterruptedException { if (lastActive.get()) { lastActive.set(false); deactivateSpouts(); } long start = Time.currentTimeMillis(); Time.sleep(100); spoutThrottlingMetrics.skippedInactiveMs(Time.currentTimeMillis() - start); }
@Test(expected = IllegalStateException.class) public void ifNotSimulatingAdvanceTimeThrowsTest() { Time.advanceTime(1000); }
/** * Checks if a call to this method occurs later than {@code period} since the timer was initiated or reset. If that is the * case the method returns true, otherwise it returns false. Each time this method returns true, the counter is reset * (re-initiated) and a new cycle will start. * * @return true if the time elapsed since the last call returning true is greater than {@code period}. Returns false * otherwise. */ public boolean isExpiredResetOnTrue() { final boolean expired = Time.nanoTime() - start >= periodNanos; if (expired) { start = Time.nanoTime(); } return expired; } }
private static void setLoggerTimeouts(LogLevel level) { int timeoutSecs = level.get_reset_log_level_timeout_secs(); if (timeoutSecs > 0) { level.set_reset_log_level_timeout_epoch(Time.currentTimeMillis() + Time.secsToMillis(timeoutSecs)); } else { level.unset_reset_log_level_timeout_epoch(); } }
@Override public void report(Throwable error) { LOG.error("Error", error); if (Time.deltaSecs(intervalStartTime.get()) > errorIntervalSecs) { intervalErrors.set(0); intervalStartTime.set(Time.currentTimeSecs()); } if (intervalErrors.incrementAndGet() <= maxPerInterval) { try { stormClusterState.reportError(stormId, componentId, Utils.hostname(), workerTopologyContext.getThisWorkerPort().longValue(), error); } catch (UnknownHostException e) { throw Utils.wrapInRuntime(e); } } } }
public static void sleepSecs(long secs) throws InterruptedException { if (secs > 0) { sleep(secs * 1000); } }
/** * If using simulated time simulate waiting for 10 seconds. This is intended for internal testing only. */ public static void simulateWait(ILocalCluster cluster) throws InterruptedException { if (Time.isSimulating()) { cluster.advanceClusterTime(10); Thread.sleep(100); } }
@Override public void advanceClusterTime(int secs, int incSecs) throws InterruptedException { waitForIdle(); for (int amountLeft = secs; amountLeft > 0; amountLeft -= incSecs) { int diff = Math.min(incSecs, amountLeft); Time.advanceTimeSecs(diff); waitForIdle(); } }
new NimbusSummary(hpi.getHost(), hpi.getPort(), Time.currentTimeSecs(), false, STORM_VERSION)); leaderElector.addToLeaderLockQueue(); this.blobStore.startSyncBlobs(); Long currTime = Time.nanoTime(); Long startTime = schedulingStartTimeNs.get(); return TimeUnit.NANOSECONDS.toMillis(startTime == null ?
/** * Updates the last updated time. This should be called when references are added or removed. */ protected synchronized void touch() { lastUsed = Time.currentTimeMillis(); LOG.debug("Setting {} ts to {}", blobKey, lastUsed); }
long timeDiffMs = (Time.currentTimeSecs() - hb.get_time_secs()) * 1000; if (timeDiffMs > staticState.hbTimeoutMs) { LOG.warn("SLOT {}: HB is too old {} > {}", staticState.port, timeDiffMs, staticState.hbTimeoutMs); boolean isTimeForStop = Time.currentTimeMillis() > action.request.get_time_stamp(); if (isTimeForStop) { if (dynamicState.container.runProfiling(action.request, true)) { LOG.debug("Still pending {} now: {}", action, Time.currentTimeMillis()); if (dynamicState.container.runProfiling(action.request, false)) { modPending.add(action); LOG.debug("Started {} now: {}", action, Time.currentTimeMillis()); } else { LOG.warn("Starting {} failed, will be retried", action); Time.sleep(staticState.monitorFreqMs); return dynamicState;