本文整理了Java中com.vmware.xenon.common.Utils.getSystemNowMicrosUtc()
方法的一些代码示例,展示了Utils.getSystemNowMicrosUtc()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Utils.getSystemNowMicrosUtc()
方法的具体详情如下:
包路径:com.vmware.xenon.common.Utils
类名称:Utils
方法名:getSystemNowMicrosUtc
[英]Returns the current time in microseconds, since Unix Epoch. This method can return the same value on consecutive calls. See #getNowMicrosUtc() for an alternative but with potential for drift from wall clock time
[中]返回当前时间(以微秒为单位),从Unix时代开始。此方法可以在连续调用时返回相同的值。请参阅#getNowMicrosUtc(),以了解另一种可能会偏离挂钟时间的方法
代码示例来源:origin: vmware/xenon
/**
* Adds the supplied argument to the value from {@link #getSystemNowMicrosUtc()} and returns
* an absolute expiration time in the future
*/
public static long fromNowMicrosUtc(long deltaMicros) {
return getSystemNowMicrosUtc() + deltaMicros;
}
代码示例来源:origin: vmware/xenon
/**
* Expects an absolute time, in microseconds since Epoch and returns true if the value represents
* a time before the current system time
*/
public static boolean beforeNow(long microsUtc) {
return getSystemNowMicrosUtc() >= microsUtc;
}
代码示例来源:origin: vmware/admiral
public static boolean isExpired(ServiceDocument serviceDocument) {
return serviceDocument != null
&& serviceDocument.documentExpirationTimeMicros != 0
&& serviceDocument.documentExpirationTimeMicros < Utils.getSystemNowMicrosUtc();
}
}
代码示例来源:origin: vmware/xenon
public void updateLastUseTime() {
this.lastUseTimeMicros = Utils.getSystemNowMicrosUtc();
}
代码示例来源:origin: vmware/xenon
/**
* Compares a time value with current time. Both time values are in micros since epoch.
* Since we can not assume the time came from the same node, we use the concept of a
* time epsilon: any two time values within epsilon are considered too close to
* globally order in respect to each other and this method will return true.
*/
public static boolean isWithinTimeComparisonEpsilon(long timeMicros) {
return Math.abs(timeMicros - Utils.getSystemNowMicrosUtc()) < timeComparisonEpsilon;
}
代码示例来源:origin: vmware/admiral
private long calculatePKSTaskExpirationTime(RequestBrokerState state) {
long t = (state.documentExpirationTimeMicros - Utils.getSystemNowMicrosUtc()) / 2;
t = Utils.fromNowMicrosUtc(t) - TimeUnit.MINUTES.toMicros(5);
return Math.max(t, Utils.fromNowMicrosUtc(TimeUnit.MINUTES.toMicros(5)));
}
代码示例来源:origin: vmware/xenon
private String buildThreadTag() {
if (this.host != null) {
return UriUtils.extendUri(this.host.getUri(), "netty-client").toString();
}
return getClass().getSimpleName() + ":" + Utils.getSystemNowMicrosUtc();
}
代码示例来源:origin: vmware/admiral
private void notifyCallbacks(String containerImageFilePath, byte[] imageData) {
List<Consumer<byte[]>> pendingCallbacks;
synchronized (RETRIEVE_LOCK) {
cachedImages.put(containerImageFilePath, imageData);
lastUsed = Utils.getSystemNowMicrosUtc();
pendingCallbacks = pendingCallbacksByImagePath.remove(containerImageFilePath);
}
host.log(Level.INFO, "Caching system agent image data for %s", containerImageFilePath);
host.schedule(this::cleanCache, CACHED_DATA_MICROS, TimeUnit.MICROSECONDS);
if (pendingCallbacks != null) {
for (Consumer<byte[]> consumer : pendingCallbacks) {
consumer.accept(imageData);
}
}
}
代码示例来源:origin: vmware/admiral
private void cleanCache() {
if (lastUsed + CACHED_DATA_MICROS < Utils.getSystemNowMicrosUtc()) {
// expired, clean the reference
cachedImages.clear();
lastUsed = 0;
host.log(Level.INFO, "System image(s) removed from cache");
} else {
// schedule next check
host.schedule(this::cleanCache, CACHED_DATA_MICROS, TimeUnit.MICROSECONDS);
}
}
代码示例来源:origin: vmware/xenon
private void updateGossipPatchStat(long sendTimeMicros, NodeState remotePeer) {
long patchCompletionTime = Utils.getSystemNowMicrosUtc();
String statName = remotePeer.id + STAT_NAME_PREFIX_GOSSIP_PATCH_DURATION;
ServiceStat st = ServiceStatUtils.getOrCreateHourlyTimeSeriesHistogramStat(this, statName, EnumSet.of(AggregationType.AVG));
setStat(st, patchCompletionTime - sendTimeMicros);
}
代码示例来源:origin: vmware/xenon
/**
* Initiates periodic maintenance for a service. Called on service start or when maintenance is
* dynamically toggled on
*/
protected void scheduleServiceMaintenance(Service s) {
if (!s.hasOption(ServiceOption.PERIODIC_MAINTENANCE)) {
return;
}
this.serviceMaintTracker.schedule(s, Utils.getSystemNowMicrosUtc());
}
代码示例来源:origin: vmware/xenon
public void handleMaintenance(Operation op) {
long now = Utils.getSystemNowMicrosUtc();
if (this.isHttp2Only) {
handleHttp2Maintenance(now);
} else {
handleHttp1Maintenance(now);
}
op.complete();
}
代码示例来源:origin: com.vmware.xenon/xenon-common
@Test
public void getSystemNowMicrosUtc() {
CommandLineArgumentParser.parseFromProperties(this);
long s = System.nanoTime() / 1000;
for (int i = 0; i < this.iterationCount; i++) {
Utils.getSystemNowMicrosUtc();
}
long e = System.nanoTime() / 1000;
double thpt = this.iterationCount / ((e - s) / 1000000.0);
Logger.getAnonymousLogger().info("Throughput: " + thpt);
}
代码示例来源:origin: vmware/xenon
@Test
public void getSystemNowMicrosUtc() {
CommandLineArgumentParser.parseFromProperties(this);
long s = System.nanoTime() / 1000;
for (int i = 0; i < this.iterationCount; i++) {
Utils.getSystemNowMicrosUtc();
}
long e = System.nanoTime() / 1000;
double thpt = this.iterationCount / ((e - s) / 1000000.0);
Logger.getAnonymousLogger().info("Throughput: " + thpt);
}
代码示例来源:origin: vmware/admiral
private void applyDocumentExpirationPolicy(long deadline) throws Exception {
// TODO: need better solution to expire documents, this can be very slow to have
// deletion in batches across tables
int limit = expiredDocumentSearchThreshold;
long now = Utils.getNowMicrosUtc();
for (TableDescription tableDescription : this.dao.getPostgresSchemaManager().getTableDescriptions()) {
if (Utils.getSystemNowMicrosUtc() >= deadline || limit <= 0) {
break;
}
int expired = applyDocumentExpirationPolicyForTable(tableDescription, now, deadline, limit);
limit -= expired;
}
}
代码示例来源:origin: com.vmware.xenon/xenon-common
@Test
public void isWithinTimeComparisonEpsilon() {
Utils.setTimeComparisonEpsilonMicros(TimeUnit.SECONDS.toMicros(10));
// check a value within about a millisecond from now
long l = Utils.getSystemNowMicrosUtc() + 1000;
assertTrue(Utils.isWithinTimeComparisonEpsilon(l));
// check a value days from now
l = Utils.getSystemNowMicrosUtc() + TimeUnit.DAYS.toMicros(2);
assertFalse(Utils.isWithinTimeComparisonEpsilon(l));
}
代码示例来源:origin: vmware/xenon
@Test
public void isWithinTimeComparisonEpsilon() {
Utils.setTimeComparisonEpsilonMicros(TimeUnit.SECONDS.toMicros(10));
// check a value within about a millisecond from now
long l = Utils.getSystemNowMicrosUtc() + 1000;
assertTrue(Utils.isWithinTimeComparisonEpsilon(l));
// check a value days from now
l = Utils.getSystemNowMicrosUtc() + TimeUnit.DAYS.toMicros(2);
assertFalse(Utils.isWithinTimeComparisonEpsilon(l));
}
代码示例来源:origin: vmware/xenon
@Override
public void handleStart(Operation post) {
ServiceDocument initState = post.getBody(ServiceDocument.class);
long interval = initState.documentExpirationTimeMicros - Utils.getSystemNowMicrosUtc();
if (interval < 0) {
logWarning("Task expiration is in the past, extending it");
interval = getHost().getMaintenanceIntervalMicros() * 2;
}
super.toggleOption(ServiceOption.PERIODIC_MAINTENANCE, true);
super.setMaintenanceIntervalMicros(interval);
post.complete();
}
代码示例来源:origin: vmware/admiral
@Test
public void testIsExpired() {
assertFalse(ServiceUtils.isExpired(null));
ServiceDocument sd = new ServiceDocument();
sd.documentExpirationTimeMicros = 0;
assertFalse(ServiceUtils.isExpired(new ServiceDocument()));
sd.documentExpirationTimeMicros = Utils.getSystemNowMicrosUtc()
- TimeUnit.MINUTES.toMicros(1);
assertTrue(ServiceUtils.isExpired(sd));
sd.documentExpirationTimeMicros = Utils.getSystemNowMicrosUtc()
+ TimeUnit.MINUTES.toMicros(1);
assertFalse(ServiceUtils.isExpired(sd));
}
}
代码示例来源:origin: vmware/xenon
private State triggerMigrationTask(URI sourceHostUri, URI destHostUri) {
State state = new State();
state.destinationFactoryLink = ExampleODLService.FACTORY_LINK;
state.destinationNodeGroupReference = UriUtils.buildUri(destHostUri, ServiceUriPaths.DEFAULT_NODE_GROUP);
state.sourceFactoryLink = ExampleODLService.FACTORY_LINK;
state.sourceNodeGroupReference = UriUtils.buildUri(sourceHostUri, ServiceUriPaths.DEFAULT_NODE_GROUP);
state.maintenanceIntervalMicros = TimeUnit.SECONDS.toMicros(1);
state.querySpec = new QuerySpecification();
state.querySpec.resultLimit = this.resultLimit;
// specify expiration time which transcends to query pages
state.documentExpirationTimeMicros = Utils.getSystemNowMicrosUtc() + TimeUnit.SECONDS.toMicros(this.taskWaitSeconds);
Operation op = Operation.createPost(UriUtils.buildUri(destHostUri, MigrationTaskService.FACTORY_LINK)).setBody(state);
state = this.host.getTestRequestSender().sendAndWait(op, State.class);
return state;
}
内容来源于网络,如有侵权,请联系作者删除!