public OutstandingRequest(String function, DRPCRequest req) { _start = Time.currentTimeMillis(); _function = function; _req = req; }
private long now() { return Time.currentTimeMillis(); } }
/** * 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); }
private static void rotateTopologyCleanupMap(long deletionDelay) { if (Time.currentTimeMillis() - topologyCleanupRotationTime > deletionDelay) { topologyCleanupDetected.rotate(); topologyCleanupRotationTime = Time.currentTimeMillis(); } }
public String toString() { StringBuffer sb = new StringBuffer(); sb.append(state); sb.append(" msInState: "); sb.append(Time.currentTimeMillis() - startTime); if (container != null) { sb.append(" "); sb.append(container); } return sb.toString(); }
public SolverResult(SearcherState state, boolean success) { this.statesSearched = state.getStatesSearched(); this.success = success; timeTakenMillis = Time.currentTimeMillis() - state.startTimeMillis; backtracked = state.numBacktrack; }
private void rotateIfNeeded() { long nowMs = Time.currentTimeMillis(); if (nowMs >= lastRotationMs + timeoutMs) { //Rotate once per timeout period that has passed since last time this was called. //This is necessary since this method may be called at arbitrary intervals. int rotationsToDo = (int) ((nowMs - lastRotationMs) / timeoutMs); for (int i = 0; i < rotationsToDo; i++) { cachedGroups.rotate(); } lastRotationMs = nowMs; } }
@Override public void prepare(Map conf) { NODE_MAX_TIMEOUT_SECS = ObjectReader.getInt(conf.get(Config.SUPERVISOR_WORKER_HEARTBEATS_MAX_TIMEOUT_SECS), 600); this.startTimeSecs = Time.currentTimeMillis() / 1000L; this.reportedIds = new HashSet<>(); }
private void inactiveExecute() throws InterruptedException { if (lastActive.get()) { lastActive.set(false); deactivateSpouts(); } long start = Time.currentTimeMillis(); Time.sleep(100); spoutThrottlingMetrics.skippedInactiveMs(Time.currentTimeMillis() - start); }
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 sleepUntil(long targetTimeMs) throws InterruptedException { if (SIMULATING.get()) { simulatedSleepUntilNanos(millisToNanos(targetTimeMs)); } else { long sleepTimeMs = targetTimeMs - currentTimeMillis(); if (sleepTimeMs > 0) { Thread.sleep(sleepTimeMs); } } }
/** * Invoked once immediately after construction * * @param topoConf Storm configuration */ @Override public void prepare(Map<String, Object> topoConf) { timeoutMs = TimeUnit.SECONDS.toMillis(ObjectReader.getInt(topoConf.get(Config.STORM_GROUP_MAPPING_SERVICE_CACHE_DURATION_SECS))); lastRotationMs = Time.currentTimeMillis(); cachedGroups = new RotatingMap<>(2); }
private static long getTopologyCleanupDetectedTime(String topologyId) { Long firstDetectedForDeletion = topologyCleanupDetected.get(topologyId); if (firstDetectedForDeletion == null) { firstDetectedForDeletion = Time.currentTimeMillis(); topologyCleanupDetected.put(topologyId, firstDetectedForDeletion); } return firstDetectedForDeletion; }
public String createVersion() throws IOException { Long mostRecent = mostRecentVersion(); long version = Time.currentTimeMillis(); if (mostRecent != null && version <= mostRecent) { version = mostRecent + 1; } return createVersion(version); }
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(); } }
@Test public void testLogResetTriggersForPastTime() { try (SimulatedTime t = new SimulatedTime()) { long past = Time.currentTimeMillis() - 1000; TreeMap<String, LogLevel> config = new TreeMap<>(); config.put("foo", ll("INFO", "WARN", past)); AtomicReference<TreeMap<String, LogLevel>> atomConf = new AtomicReference<>(config); LogConfigManager underTest = new LogConfigManagerUnderTest(atomConf); underTest.resetLogLevels(); assertEquals(new TreeMap<>(), atomConf.get()); } }
@Test public void testLogResetResetsRootLoggerIfSet() { try (SimulatedTime t = new SimulatedTime()) { long past = Time.currentTimeMillis() - 1000; TreeMap<String, LogLevel> config = new TreeMap<>(); config.put(LogManager.ROOT_LOGGER_NAME, ll("DEBUG", "WARN", past)); AtomicReference<TreeMap<String, LogLevel>> atomConf = new AtomicReference<>(config); LogConfigManager underTest = spy(new LogConfigManagerUnderTest(atomConf)); underTest.resetLogLevels(); assertEquals(new TreeMap<>(), atomConf.get()); verify(underTest).setLoggerLevel(anyObject(), eq(LogManager.ROOT_LOGGER_NAME), eq("WARN")); } }
@Test public void testLogResetShouldNotTriggerForFutureTime() { try (SimulatedTime t = new SimulatedTime()) { long theFuture = Time.currentTimeMillis() + 1000; TreeMap<String, LogLevel> config = new TreeMap<>(); config.put("foo", ll(theFuture)); AtomicReference<TreeMap<String, LogLevel>> atomConf = new AtomicReference<>(config); LogConfigManager underTest = new LogConfigManagerUnderTest(atomConf); underTest.resetLogLevels(); assertNotNull(atomConf.get()); } }
@Test public void shouldNotAdvanceTimeTest() { try (SimulatedTime t = new SimulatedTime()) { long current = Time.currentTimeMillis(); Time.advanceTime(0); Assert.assertEquals(Time.deltaMs(current), 0); } }
@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); } }