本文整理了Java中org.apache.brooklyn.util.time.Time.makeTimeStringRounded()
方法的一些代码示例,展示了Time.makeTimeStringRounded()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Time.makeTimeStringRounded()
方法的具体详情如下:
包路径:org.apache.brooklyn.util.time.Time
类名称:Time
方法名:makeTimeStringRounded
暂无
代码示例来源:origin: org.apache.brooklyn/brooklyn-policy
private String getTimeStringSince(Long time) {
return time == null ? null : Time.makeTimeStringRounded(System.currentTimeMillis() - time);
}
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-utils-common
/** @deprecated use {@link Time#makeTimeStringRounded(long)} */
@Deprecated
public static String makeTimeString(long utcMillis) {
return Time.makeTimeStringRounded(utcMillis);
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-utils-common
/**
* A nice string representation of the stopwatch's elapsed time; or null if null is passed in.
*/
public static String makeTimeStringRounded(@Nullable Stopwatch timer) {
return (timer == null) ? null : makeTimeStringRounded(timer.elapsed(TimeUnit.MILLISECONDS), TimeUnit.MILLISECONDS);
}
/** @see #makeTimeString(long, boolean) */
代码示例来源:origin: org.apache.brooklyn/brooklyn-utils-common
@Override @Nullable
public String apply(@Nullable Long input) {
if (input == null) return null;
return Time.makeTimeStringRounded(input);
}
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-utils-common
@Override
@Nullable
public String apply(@Nullable Long input) {
if (input == null) return null;
return Time.makeTimeStringRounded(input);
}
};
代码示例来源:origin: org.apache.brooklyn/brooklyn-core
@Override
public void disconnect() {
if (LOG.isTraceEnabled()) LOG.trace("Disconnecting SshjTool {} ({})", this, System.identityHashCode(this));
try {
Stopwatch perfStopwatch = Stopwatch.createStarted();
sshClientConnection.clear();
if (LOG.isTraceEnabled()) LOG.trace("SSH Performance: {} disconnect took {}", sshClientConnection.getHostAndPort(), Time.makeTimeStringRounded(perfStopwatch));
} catch (Exception e) {
throw Exceptions.propagate(e);
}
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-utils-common
@Test
public void testMakeTimeStringFromStopwatch() {
final AtomicLong time = new AtomicLong();
Ticker ticker = new Ticker() {
@Override public long read() {
return time.get();
}
};
Assert.assertNull(Time.makeTimeStringRounded((Stopwatch)null));
Stopwatch stopwatch = Stopwatch.createStarted(ticker);
time.set(TimeUnit.MILLISECONDS.toNanos(1100));
Assert.assertEquals(Time.makeTimeStringRounded(stopwatch), "1.10s");
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-core
protected void doDelta(Delta delta, PersistenceExceptionHandler exceptionHandler, boolean previouslyQueued) {
Stopwatch stopwatch = deltaImpl(delta, exceptionHandler);
if (LOG.isDebugEnabled()) LOG.debug("Checkpointed "+(previouslyQueued ? "previously queued " : "")+"delta of memento in {}: "
+ "updated {} entities, {} locations, {} policies, {} enrichers, {} catalog items, {} bundles; "
+ "removed {} entities, {} locations, {} policies, {} enrichers, {} catalog items, {} bundles",
new Object[] {Time.makeTimeStringRounded(stopwatch),
delta.entities().size(), delta.locations().size(), delta.policies().size(), delta.enrichers().size(), delta.catalogItems().size(), delta.bundles().size(),
delta.removedEntityIds().size(), delta.removedLocationIds().size(), delta.removedPolicyIds().size(), delta.removedEnricherIds().size(), delta.removedCatalogItemIds().size(), delta.removedBundleIds().size()});
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-core
private void runMany(Runnable task, String context, int iterations) throws Exception {
MBeanServer mbeanServer = ManagementFactory.getPlatformMBeanServer();
ObjectName osMBeanName = ObjectName.getInstance(ManagementFactory.OPERATING_SYSTEM_MXBEAN_NAME);
long preCpuTime = (Long) mbeanServer.getAttribute(osMBeanName, "ProcessCpuTime");
Stopwatch stopwatch = Stopwatch.createStarted();
for (int i = 0; i < iterations; i++) {
task.run();
long postCpuTime = (Long) mbeanServer.getAttribute(osMBeanName, "ProcessCpuTime");
long elapsedTime = stopwatch.elapsed(TimeUnit.MILLISECONDS);
double fractionCpu = (elapsedTime > 0) ? ((double)postCpuTime-preCpuTime) / TimeUnit.MILLISECONDS.toNanos(elapsedTime) : -1;
LOG.info("Executing {}; completed {}; took {}; fraction cpu {}", new Object[] {context, (i+1), Time.makeTimeStringRounded(elapsedTime), fractionCpu});
}
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-software-base
private void checkChildComesUpSoon() {
Stopwatch stopwatch = Stopwatch.createStarted();
EntityAsserts.assertAttributeEqualsEventually(p2, Attributes.SERVICE_UP, true);
log.info("Took "+Time.makeTimeStringRounded(stopwatch)+" for child-process to be service-up");
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-software-base
private long startApp() {
Stopwatch stopwatch = Stopwatch.createStarted();
app.start(Collections.singleton(localhost));
long result = stopwatch.elapsed(TimeUnit.MILLISECONDS);
log.info("Took "+Time.makeTimeStringRounded(result)+" for app.start to complete");
return result;
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-core
@Test(groups = {"Integration"})
public void testExecScriptWithSleepThenExit() throws Exception {
Stopwatch watch = Stopwatch.createStarted();
execScript("sleep 1", "exit 0");
assertTrue(watch.elapsed(TimeUnit.MILLISECONDS) > 900, "only slept "+Time.makeTimeStringRounded(watch));
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-policy
protected String getExplanation(Maybe<Lifecycle> state) {
Duration serviceFailedStabilizationDelay = getConfig(ENTITY_FAILED_STABILIZATION_DELAY);
Duration serviceRecoveredStabilizationDelay = getConfig(ENTITY_RECOVERED_STABILIZATION_DELAY);
return String.format("location=%s; status=%s; lastPublished=%s; timeNow=%s; "+
"currentFailurePeriod=%s; currentRecoveryPeriod=%s",
entity.getLocations(),
(state.orNull() != null ? state : "<unreported>"),
config().get(LAST_PUBLISHED),
Time.makeDateString(System.currentTimeMillis()),
(currentFailureStartTime != null ? getTimeStringSince(currentFailureStartTime) : "<none>") + " (stabilization "+Time.makeTimeStringRounded(serviceFailedStabilizationDelay) + ")",
(currentRecoveryStartTime != null ? getTimeStringSince(currentRecoveryStartTime) : "<none>") + " (stabilization "+Time.makeTimeStringRounded(serviceRecoveredStabilizationDelay) + ")");
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-utils-common
@Test
public void testMakeTimeStringFromDuration() {
Assert.assertNull(Time.makeTimeStringExact((Duration)null));
Assert.assertEquals(Time.makeTimeStringExact(Duration.millis(1100)), "1s 100ms");
Assert.assertNull(Time.makeTimeStringRounded((Duration)null));
Assert.assertEquals(Time.makeTimeStringRounded(Duration.millis(1100)), "1.10s");
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-software-base
@Test(groups = {"Integration", "Broken"})
public void testModeForeground() {
prep(ChildStartableMode.FOREGROUND);
long startTime = startApp();
long timediff = timediff();
Assert.assertTrue( Math.abs(timediff) <= CONCURRENT_MAX_ACCEPTABLE_DIFF_SECS, "should have started concurrently, not with time difference "+timediff+" ("+p1+", "+p2+")" );
Assert.assertTrue(startTime >= PARENT_TASK_SLEEP_LENGTH_SECS*1000 - EARLY_RETURN_GRACE_MS, "startTime="+Time.makeTimeStringRounded(startTime));
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-software-base
@Test(groups = "Integration")
public void testModeForegroundLate() {
prep(ChildStartableMode.FOREGROUND_LATE);
long startTime = startApp();
long timediff = timediff();
Assert.assertTrue( timediff >= SEQUENTIAL_MIN_ACCEPTABLE_DIFF_SECS, "should have started later, not with time difference "+timediff+" ("+p1+", "+p2+")" );
Assert.assertTrue(startTime >= 2*PARENT_TASK_SLEEP_LENGTH_SECS*1000 - EARLY_RETURN_GRACE_MS, "startTime="+Time.makeTimeStringRounded(startTime));
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-software-base
@Test(groups = "Integration")
public void testModeNone() {
prep(ChildStartableMode.NONE);
long startTime = startApp();
Assert.assertNotNull(p1.getAttribute(SoftwareProcess.RUN_DIR));
Assert.assertNull(p2.getAttribute(SoftwareProcess.RUN_DIR));
Assert.assertTrue(startTime >= PARENT_TASK_SLEEP_LENGTH_SECS*1000 - EARLY_RETURN_GRACE_MS, "startTime="+Time.makeTimeStringRounded(startTime));
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-software-base
@Test(groups = {"Integration", "Broken"})
public void testModeBackground() {
prep(ChildStartableMode.BACKGROUND);
long startTime = startApp();
checkChildComesUpSoon();
long timediff = timediff();
Assert.assertTrue( Math.abs(timediff) <= CONCURRENT_MAX_ACCEPTABLE_DIFF_SECS, "should have started concurrently, not with time difference "+timediff+" ("+p1+", "+p2+")" );
Assert.assertTrue(startTime >= PARENT_TASK_SLEEP_LENGTH_SECS*1000 - EARLY_RETURN_GRACE_MS, "startTime="+Time.makeTimeStringRounded(startTime));
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-software-base
private WinRmToolResponse assertSucceeded(Object cmd, WinRmToolResponse response, String stdout, String stderr, Stopwatch stopwatch) {
String msg = "statusCode="+response.getStatusCode()+"; out="+response.getStdOut()+"; err="+response.getStdErr();
LOG.info("Executed in "+Time.makeTimeStringRounded(stopwatch)+" (asserting success): "+msg+"; cmd="+cmd);
assertEquals(response.getStatusCode(), 0, msg);
if (stdout != null) assertEquals(response.getStdOut().trim(), stdout, msg);
if (stderr != null) assertEquals(response.getStdErr().trim(), stderr, msg);
return response;
}
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-software-base
private void assertFailed(Object cmd, WinRmToolResponse response, Stopwatch stopwatch) {
String msg = "statusCode="+response.getStatusCode()+"; out="+response.getStdOut()+"; err="+response.getStdErr();
LOG.info("Executed in "+Time.makeTimeStringRounded(stopwatch)+" (asserting failed): "+msg+"; cmd="+cmd);
assertNotEquals(response.getStatusCode(), 0, msg);
}
内容来源于网络,如有侵权,请联系作者删除!