@Override public void end() { endTime = TimeService.currentTimeMillis(); }
public Value(Number value) { this.timestamp = TimeService.currentTimeMillis(); this.value = value; }
protected MarkerEvent() { this(TimeService.currentTimeMillis()); }
@Override public void begin() { beginTime = TimeService.currentTimeMillis(); }
protected long getWaitTime(long startTime) { return startTime + timeout - TimeService.currentTimeMillis(); }
public void establish() throws IOException { discoverySelector = Selector.open(); serverSocketChannel.register(discoverySelector, SelectionKey.OP_ACCEPT); mcastBuffer = ByteBuffer.allocate(DEFAULT_WRITE_BUFF_CAPACITY); int slaveCount = 0; long deadline = TimeService.currentTimeMillis() + CONNECT_TIMEOUT; while (slaveCount < slaves.length) { long timeout = deadline - TimeService.currentTimeMillis(); if (timeout <= 0) { throw new IOException((slaves.length - slaveCount) + " slaves haven't connected within timeout!"); } log.info("Awaiting registration from " + (slaves.length - slaveCount) + " slaves."); slaveCount += connectSlaves(timeout); } log.info("Connection established from " + slaveCount + " slaves."); }
public static void backupFile(File outputFile) { if (outputFile.exists()) { int lastIndexOfDot = outputFile.getName().lastIndexOf('.'); String extension = lastIndexOfDot > 0 ? outputFile.getName().substring(lastIndexOfDot) : ""; File old = new File(outputFile.getParentFile(), "old"); if (!old.exists()) { if (old.mkdirs()) { log.warn("Issues whilst creating dir: " + old); } } String fileName = outputFile.getName() + ".old." + TimeService.currentTimeMillis() + extension; File newFile = new File(old, fileName); log.info("A file named: '" + outputFile.getAbsolutePath() + "' already exists. Moving it to '" + newFile + "'"); if (!outputFile.renameTo(newFile)) { log.warn("Could not rename!!!"); } } }
private boolean checkMemoryReleased() { long percentage = -1; long currentFreeMemory = -1; long deadline = TimeService.currentTimeMillis() + memoryReleaseTimeout; for (; ; ) { System.gc(); Runtime runtime = Runtime.getRuntime(); currentFreeMemory = runtime.freeMemory() + runtime.maxMemory() - runtime.totalMemory(); percentage = (currentFreeMemory * 100) / initialFreeMemory; if (percentage > memoryThreshold || TimeService.currentTimeMillis() > deadline) break; log.infof("Available memory: %d kB (%d%% of initial available memory - %d kB)", currentFreeMemory / 1024, percentage, initialFreeMemory / 1024); Utils.sleep(1000); } if (percentage > memoryThreshold) { return true; } log.error("Using more memory than expected!"); return false; }
@Override public void runMonitor() { long now = TimeService.currentTimeMillis(); for (Map.Entry<String, Number> entry : internalsExposition.getValues().entrySet()) { timeline.addValue(Timeline.Category.customCategory(entry.getKey()), new Timeline.Value(now, entry.getValue())); } }
long deadline = TimeService.currentTimeMillis() + CONNECT_TIMEOUT; while (reconnections > 0) { log.infof("Waiting for %d reconnecting slaves", reconnections); long timeout = deadline - TimeService.currentTimeMillis(); if (timeout <= 0) { throw new IOException(reconnections + " slaves haven't connected within timeout!");
tryPoll[i].start(); long waitEnd = TimeService.currentTimeMillis() + queryTimeout; boolean broken = false; for (int i = 0; i < tryPoll.length; i++) { try { long maxJoinWait = waitEnd - TimeService.currentTimeMillis(); if (maxJoinWait <= 0) { broken = true;
socket.send(packet); long start = TimeService.currentTimeMillis(); int received = 0; while (received < expectedResponseCount) { if (start + timeout < TimeService.currentTimeMillis()) { String errorMessage = "Timed out waiting for query responses"; throw new IOException(errorMessage);
protected void setTime(long value) { PowerMockito.when(TimeService.currentTimeMillis()).thenReturn(value); }
public void smokeTest() throws Exception { CoreStageRunner stageRunner = new CoreStageRunner(1); SleepStage sleepStage = new SleepStage(); sleepStage.time = 1000; long start = TimeService.currentTimeMillis(); StageResult stageResult = stageRunner.executeMasterStage(sleepStage); long end = TimeService.currentTimeMillis(); Assert.assertTrue(end - start >= 1000); Assert.assertEquals(stageResult, StageResult.SUCCESS); } }
thread.interrupt(); long deadline = TimeService.currentTimeMillis() + stopTimeout / 2; for (Thread thread : threads) { long timeout = deadline - TimeService.currentTimeMillis(); if (timeout > 0) { try { long timeout = deadline - TimeService.currentTimeMillis(); if (timeout > 0) { try {
protected StressorsManager setUpAndStartStressors() { long startTime = TimeService.currentTimeMillis(); completion = createCompletion(); CountDownLatch finishCountDown = new CountDownLatch(1); completion.setCompletionHandler(new Runnable() { @Override public void run() { //Stop collecting statistics for duration-based tests if (duration > 0) { finished = true; } finishCountDown.countDown(); } }); operationSelector = wrapOperationSelector(createOperationSelector()); List<Stressor> stressors = startStressors(); started = true; if (rampUp > 0) { try { Thread.sleep(rampUp); } catch (InterruptedException e) { throw new IllegalStateException("Interrupted during ramp-up.", e); } } return new StressorsManager(stressors, startTime, finishCountDown); }
WAIT_LOOP: for (; ; ) { long now = TimeService.currentTimeMillis(); int myOffset = offset; INVOCATIONS_LOOP:
log.info("Service is not Killable, stopping instead"); stoppingTime = TimeService.currentTimeMillis(); if (gracefulStopTimeout <= 0) { lifecycle.stop(); stoppingTime = TimeService.currentTimeMillis(); if (async) { killable.killAsync(); long stoppedTime = TimeService.currentTimeMillis(); slaveState.getTimeline().addEvent(LIFECYCLE, new Timeline.IntervalEvent(stoppingTime, "Stop", stoppedTime - stoppingTime));
private StageResult executeMasterStage(MasterStage stage) { stage.init(state); if (log.isDebugEnabled()) log.debug("Starting master stage " + stage.getName() + ". Details:" + stage); else log.info("Starting master stage " + stage.getName() + "."); long start = TimeService.currentTimeMillis(), end = start; try { StageResult result = stage.execute(); end = TimeService.currentTimeMillis(); if (result.isError()) { log.error("Execution of master stage " + stage.getName() + " failed."); } else { log.info("Finished master stage " + stage.getName()); } return result; } catch (Exception e) { end = TimeService.currentTimeMillis(); log.error("Caught exception", e); return StageResult.FAIL; } finally { state.getTimeline().addEvent(Stage.STAGE, new Timeline.IntervalEvent(start, stage.getName(), end - start)); } }
String stageName = stage.getName(); log.info("Starting stage " + (log.isDebugEnabled() ? stage.toString() : stageName)); long start = TimeService.currentTimeMillis(); long end; try { response = stage.executeOnSlave(); end = TimeService.currentTimeMillis(); if (response == null) { response = new DistStageAck(state).error("Stage returned null response", null); response.setDuration(end - start); } catch (Exception e) { end = TimeService.currentTimeMillis(); log.error("Stage execution has failed", e); response = new DistStageAck(state).error("Stage execution has failed", e);