本文整理了Java中com.vmware.xenon.common.Utils.fromNowMicrosUtc()
方法的一些代码示例,展示了Utils.fromNowMicrosUtc()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Utils.fromNowMicrosUtc()
方法的具体详情如下:
包路径:com.vmware.xenon.common.Utils
类名称:Utils
方法名:fromNowMicrosUtc
[英]Adds the supplied argument to the value from #getSystemNowMicrosUtc() and returns an absolute expiration time in the future
[中]将提供的参数添加到#GetSystemNowMicroUTC()的值中,并返回将来的绝对过期时间
代码示例来源:origin: vmware/admiral
/**
* Adds the supplied argument to the value from
* {@link com.vmware.xenon.common.Utils#getSystemNowMicrosUtc()} and returns an absolute
* expiration time in the future
*/
public static long getExpirationTimeFromNowInMicros(long microsFromNow) {
return Utils.fromNowMicrosUtc(microsFromNow);
}
代码示例来源:origin: vmware/admiral
public static long getDefaultQueryExpiration() {
return Utils.fromNowMicrosUtc(DEFAULT_EXPIRATION_TIME_IN_MICROS);
}
代码示例来源:origin: vmware/xenon
public static long getDefaultQueryExpiration() {
return Utils.fromNowMicrosUtc(DEFAULT_EXPIRATION_TIME_IN_MICROS);
}
代码示例来源: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/admiral
private boolean isInspectionNeeded(ContainerState container) {
Long lastInspect = inspectCache.get(container.documentSelfLink);
if (lastInspect == null || lastInspect < Utils.fromNowMicrosUtc(-INSPECT_INTERVAL)) {
inspectCache.put(container.documentSelfLink, Utils.getNowMicrosUtc());
return true;
}
return false;
}
代码示例来源:origin: vmware/xenon
private static Operation prepareOp(Operation op, State currentState) {
if (currentState.operationTimeoutMicros != null) {
op.setExpiration(Utils.fromNowMicrosUtc(currentState.operationTimeoutMicros));
}
return op;
}
代码示例来源:origin: vmware/admiral
private void initTask(Closure closure, Operation op) {
ClosureDescription closureDesc = op.getBody(ClosureDescription.class);
closure.inputs = new HashMap<>();
closure.name = closureDesc.name;
if (closureDesc.inputs != null) {
closureDesc.inputs.forEach((k, v) -> closure.inputs.put(k, v));
}
closure.outputs = new HashMap<>();
if (closureDesc.outputNames != null) {
closureDesc.outputNames.forEach((k) -> closure.outputs.put(k, null));
}
// custom properties
propagateCustomProperties(closure, closureDesc);
closure.documentExpirationTimeMicros = Utils.fromNowMicrosUtc(TimeUnit.DAYS
.toMicros(ClosureProps.DEFAULT_CLOSURE_EXPIRATION_DAYS));
}
代码示例来源:origin: vmware/admiral
@Override
public void handleCreate(Operation post) {
RequestStatus body = post.getBody(RequestStatus.class);
body.documentExpirationTimeMicros = Utils.fromNowMicrosUtc(EXPIRATION_MICROS);
post.complete();
}
代码示例来源:origin: vmware/xenon
private void setExpiration(Operation op) {
if (op.getExpirationMicrosUtc() != 0) {
return;
}
long expMicros = this.host != null ? this.host.getOperationTimeoutMicros()
: ServiceHostState.DEFAULT_OPERATION_TIMEOUT_MICROS;
op.setExpiration(Utils.fromNowMicrosUtc(expMicros));
}
代码示例来源:origin: vmware/xenon
public void registerForServiceAvailability(CompletionHandler completion,
String nodeSelectorPath, boolean checkReplica, String... servicePaths) {
if (servicePaths == null || servicePaths.length == 0) {
throw new IllegalArgumentException("selfLinks are required");
}
Operation op = Operation.createPost(null)
.setCompletion(completion)
.setExpiration(Utils.fromNowMicrosUtc(getOperationTimeoutMicros()));
registerForServiceAvailability(op, checkReplica, nodeSelectorPath, servicePaths);
}
代码示例来源:origin: vmware/admiral
private Query createUpdatedSinceTimeRange(long timeInMicros) {
long limitToNowInMicros = Utils.fromNowMicrosUtc(TimeUnit.SECONDS.toMicros(10));
NumericRange<Long> range = NumericRange.createLongRange(timeInMicros, limitToNowInMicros,
true, false);
range.precisionStep = 64; // 4 and 8 doesn't work. 16 works but set 64 to be certain.
QueryTask.Query latestSinceCondition = new QueryTask.Query()
.setTermPropertyName(ServiceDocument.FIELD_NAME_UPDATE_TIME_MICROS)
.setNumericRange(range)
.setTermMatchType(MatchType.TERM);
latestSinceCondition.occurance = Occurance.MUST_OCCUR;
return latestSinceCondition;
}
代码示例来源:origin: vmware/admiral
public static void registerForReplicatedServiceAvailability(ServiceHost host,
CompletionHandler completion, AuthorizationContext authorizationContext,
String nodeSelectorPath, String... servicePaths) {
for (String link : servicePaths) {
Operation op = Operation.createPost(host, link)
.setCompletion(completion)
.setExpiration(Utils.fromNowMicrosUtc(host.getOperationTimeoutMicros()));
registerForReplicatedServiceAvailability(host, op, link, nodeSelectorPath,
authorizationContext);
}
}
代码示例来源:origin: vmware/admiral
private void updateClosureContainerDescription(
ContainerDescription containerDesc) {
containerDesc.documentExpirationTimeMicros = Utils
.fromNowMicrosUtc(TimeUnit.SECONDS.toMicros
(ClosureProps.CLOSURE_CONTAINER_DESCRIPTION_EXPIRATION_SECONDS));
sendRequest(Operation
.createPatch(getHost(), containerDesc.documentSelfLink)
.setBody(containerDesc)
.setCompletion((op, ex) -> {
if (ex != null) {
logSevere("Unable to set expiration time on closure container description"
+ " %s. Error: %s",
containerDesc.documentSelfLink, Utils.toString(ex));
}
}));
}
代码示例来源:origin: vmware/admiral
private static QueryTask getQueryTask() {
Query computeQuery = Query.Builder.create()
.addKindFieldClause(SslTrustCertificateState.class)
.build();
QueryTask task = QueryTask.Builder
.create()
.addOption(QueryOption.CONTINUOUS)
.addOption(QueryOption.EXPAND_CONTENT)
.setQuery(computeQuery).build();
task.documentSelfLink = QUERY_TASK_SELF_LINK_PREFIX;
task.documentExpirationTimeMicros = Utils.fromNowMicrosUtc(
TimeUnit.DAYS.toMicros(QUERY_TASK_EXPIRATION_DAYS));
return task;
}
代码示例来源:origin: vmware/xenon
private void sendSynchRequest(URI parentUri, String documentSelfLink, CompletionHandler ch) {
ServiceDocument synchState = new ServiceDocument();
synchState.documentSelfLink = documentSelfLink;
Operation synchOp = Operation
.createPost(this.host, parentUri.getPath())
.setBody(synchState)
.addPragmaDirective(Operation.PRAGMA_DIRECTIVE_SYNCH_OWNER)
.setReferer(this.host.getUri())
.setExpiration(Utils.fromNowMicrosUtc(NodeGroupService.PEER_REQUEST_TIMEOUT_MICROS))
.setCompletion((o, e) -> ch.handle(o, e));
this.host.handleRequest(null, synchOp);
}
代码示例来源:origin: vmware/admiral
private void callWebhook(String webHookUriStr, Closure closure) {
logInfo("Calling execution container for closure: %s", closure.documentSelfLink);
URI webHookUri = UriUtils.buildUri(webHookUriStr);
sendRequest(Operation
.createPost(webHookUri)
.setExpiration(Utils.fromNowMicrosUtc(TimeUnit.SECONDS
.toMicros(ClosureProps.DEFAULT_WEB_HOOK_EXPIRATION_TIMEOUT)))
.setBody(closure)
.setCompletion((op, ex) -> {
if (ex != null) {
logWarning("Unable to send closure state to: %s. Reason: %s",
webHookUriStr, Utils.toString(ex));
} else {
logInfo("Successfully sent closure state to: %s", webHookUri);
}
}));
}
代码示例来源:origin: com.vmware.xenon/xenon-common
@Test
public void registerForServiceAvailabilityTimeout()
throws Throwable {
setUp(false);
int c = 10;
this.host.testStart(c);
// issue requests to service paths we know do not exist, but induce the automatic
// queuing behavior for service availability, by setting targetReplicated = true
for (int i = 0; i < c; i++) {
this.host.send(Operation
.createGet(UriUtils.buildUri(this.host, UUID.randomUUID().toString()))
.setExpiration(Utils.fromNowMicrosUtc(TimeUnit.SECONDS.toMicros(1)))
.setCompletion(this.host.getExpectedFailureCompletion()));
}
this.host.testWait();
}
代码示例来源:origin: vmware/xenon
@Test
public void registerForServiceAvailabilityTimeout()
throws Throwable {
setUp(false);
int c = 10;
this.host.testStart(c);
// issue requests to service paths we know do not exist, but induce the automatic
// queuing behavior for service availability, by setting targetReplicated = true
for (int i = 0; i < c; i++) {
this.host.send(Operation
.createGet(UriUtils.buildUri(this.host, UUID.randomUUID().toString()))
.setExpiration(Utils.fromNowMicrosUtc(TimeUnit.SECONDS.toMicros(1)))
.setCompletion(this.host.getExpectedFailureCompletion()));
}
this.host.testWait();
}
代码示例来源:origin: com.vmware.xenon/xenon-common
AuthorizationContext createAuthorizationContext(String subject, VerificationHost host)
throws GeneralSecurityException {
Map<String, String> properties = new HashMap<>();
properties.put("hello", "world");
Claims.Builder builder = new Claims.Builder();
builder.setIssuer(AuthenticationConstants.DEFAULT_ISSUER);
builder.setSubject(UriUtils.buildUriPath(ServiceUriPaths.CORE_AUTHZ_USERS, subject));
long expirationTimeMicros = Utils.fromNowMicrosUtc(TimeUnit.HOURS.toMicros(1));
builder.setExpirationTime(TimeUnit.MICROSECONDS.toSeconds(expirationTimeMicros));
builder.setProperties(properties);
Claims claims = builder.getResult();
AuthorizationContext.Builder ab = AuthorizationContext.Builder.create();
ab.setClaims(claims);
ab.setToken(host.getTokenSigner().sign(claims));
return ab.getResult();
}
代码示例来源:origin: vmware/admiral
@Test
public void testPatchExpiration() throws Throwable {
ContainerState container = createContainer("/parent/1", "tenant1");
URI containerUri = UriUtils.buildUri(host, container.documentSelfLink);
ContainerState patch = new ContainerState();
long expirationTime = Utils.fromNowMicrosUtc(TimeUnit.SECONDS.toMicros(30));
patch.documentExpirationTimeMicros = expirationTime;
doOperation(patch, containerUri, false, Action.PATCH);
ContainerState updatedContainer = getDocument(ContainerState.class,
container.documentSelfLink);
assertEquals(expirationTime, updatedContainer.documentExpirationTimeMicros);
patch = new ContainerState();
patch.documentExpirationTimeMicros = -1;
doOperation(patch, containerUri, false, Action.PATCH);
updatedContainer = getDocument(ContainerState.class, container.documentSelfLink);
assertEquals(0, updatedContainer.documentExpirationTimeMicros);
}
内容来源于网络,如有侵权,请联系作者删除!