com.vmware.xenon.common.Utils类的使用及代码示例

x33g5p2x  于2022-02-18 转载在 其他  
字(6.5k)|赞(0)|评价(0)|浏览(169)

本文整理了Java中com.vmware.xenon.common.Utils类的一些代码示例,展示了Utils类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Utils类的具体详情如下:
包路径:com.vmware.xenon.common.Utils
类名称:Utils

Utils介绍

[英]Runtime utility functions
[中]运行时实用程序函数

代码示例

代码示例来源:origin: vmware/admiral

private static Map<String, JsonElement> parseStats(String statsJson) {
  Map<String, JsonElement> stats = null;
  try {
    stats = Utils.fromJson(statsJson, new TypeToken<Map<String, JsonElement>>() {
    }.getType());
  } catch (Exception e) {
    Utils.logWarning("Error parsing container stats: [%s]. Error: %s", statsJson,
        Utils.toString(e));
  }
  return stats;
}

代码示例来源:origin: vmware/xenon

public FindForLink(ServiceDocument document) {
  this.selfLink = document.documentSelfLink;
  String s = Utils.toJson(document);
  this.json = Utils.fromJson(s, JsonObject.class);
  this.documentClass = document.getClass().getName();
}

代码示例来源:origin: vmware/admiral

public TableDescription setStateType(Class<? extends ServiceDocument> stateType) {
  this.stateType = stateType;
  this.documentKind = Utils.buildKind(stateType);
  return this;
}

代码示例来源:origin: vmware/xenon

public static Object getPropertyValue(PropertyDescription pd, Object instance) {
  try {
    return pd.accessor.get(instance);
  } catch (Exception e) {
    Utils.logWarning("Reflection error: %s", Utils.toString(e));
  }
  return null;
}

代码示例来源: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/admiral

public void registerCertificate(SslTrustCertificateState sslTrustCert) {
  String alias = sslTrustCert.getAlias();
  try {
    this.putDelegate(alias, sslTrustCert.certificate);
    Utils.log(getClass(), "Self Signed Trust Store", Level.FINE,
        "Certificate with alias %s updated", alias);
  } catch (Throwable e) {
    Utils.logWarning(
        "Exception during certificate reload with alias: %s. Error: %s",
        alias, Utils.toString(e));
  }
}

代码示例来源:origin: vmware/xenon

@Ignore("https://www.pivotaltracker.com/story/show/151532080 Fail on windows")
@Test
public void testPathJsonSerialization() {
  Path p = Paths.get("test");
  String jsonRepr = Utils.toJson(p);
  assertEquals("\"" + p.toAbsolutePath().toAbsolutePath() + "\"", jsonRepr);
  Arguments arguments = new Arguments();
  Logger.getAnonymousLogger().info(Utils.toJsonHtml(arguments));
}

代码示例来源:origin: vmware/xenon

@Override
protected void handshakeFailure(ChannelHandlerContext ctx, Throwable cause)
    throws Exception {
  log(Level.WARNING, "TLS handshake failed: %s", Utils.toString(cause));
  ctx.close();
}

代码示例来源:origin: vmware/xenon

/**
 * Build new URI based on a canonical URL, i.e., "http://example.com/example")
 */
public static URI buildUri(String uri) {
  try {
    return new URI(uri);
  } catch (Exception e) {
    Utils.log(Utils.class, Utils.class.getSimpleName(), Level.SEVERE,
        "Failure building uri %s: %s", uri, Utils.toString(e));
  }
  return null;
}

代码示例来源:origin: vmware/xenon

private static void handleQueryCompletion(ServiceHost host, Operation o, Throwable e) {
  if (e != null) {
    host.log(Level.SEVERE, "Query task failed: %s", Utils.toString(e));
    return;
  }
  QueryTask queryTask = o.getBody(QueryTask.class);
  if (queryTask.results.documentLinks.isEmpty()) {
    host.log(Level.INFO, "Query returned no results");
    return;
  }
  host.log(Level.INFO, "Returned query results: %s", Utils.toJsonHtml(queryTask.results));
}

代码示例来源:origin: vmware/xenon

public QueryElementResult<T> result(Object json, long count) {
  QueryElementResult<T> r = new QueryElementResult<>();
  r.result = Utils.fromJson(json, this.type);
  r.documentSelfLink = r.result.documentSelfLink;
  r.count = count;
  return r;
}

代码示例来源: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

private void loadSslTrustCertServices() {
  // make sure first get the time, then issue the query not to miss an interval with updates
  long currentDocumentUpdateTimeMicros = Utils.getNowMicrosUtc();
  sslTrustQuery.queryUpdatedSince(documentUpdateTimeMicros, queryHandler);
  this.documentUpdateTimeMicros = currentDocumentUpdateTimeMicros;
}

代码示例来源:origin: vmware/xenon

private Object removeFactoryPathFromSelfLink(Object jsonObject, String factoryPath) {
  String selfLink = extractId(jsonObject, factoryPath);
  return Utils.toJson(
      Utils.setJsonProperty(jsonObject, ServiceDocument.FIELD_NAME_SELF_LINK, selfLink));
}

代码示例来源:origin: vmware/xenon

private void saveState(File sandboxDir) throws IOException, InterruptedException {
  File hostStateFile = new File(sandboxDir, SERVICE_HOST_STATE_FILE);
  this.state.documentUpdateTimeMicros = Utils.getNowMicrosUtc();
  byte[] serializedState = Utils.toJsonHtml(this.state).getBytes(Utils.CHARSET);
  Files.write(hostStateFile.toPath(), serializedState, StandardOpenOption.CREATE,
      StandardOpenOption.TRUNCATE_EXISTING);
}

代码示例来源:origin: vmware/xenon

private void markServiceInConflict(ServiceDocument state, ServiceDocument bestPeerRsp) {
    logWarning("State in conflict. Local: %s, Among peers: %s",
        Utils.toJsonHtml(state), Utils.toJsonHtml(bestPeerRsp));
  }
}

代码示例来源:origin: vmware/xenon

private void log(Level level, String fmt, Object... args) {
    Utils.log(Http2NegotiationHandler.class, Http2NegotiationHandler.class.getSimpleName(),
        level, fmt, args);
  }
}

代码示例来源: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

@Override
public void inspectImage(String imageName, String computeStateLink, Consumer<Throwable> errorHandler) {
  Utils.logWarning("Not implemented");
  errorHandler.accept(new Exception("Not implemented"));
}

代码示例来源:origin: com.vmware.xenon/xenon-common

private void validateBinaryExampleServiceState(Object queryResult, String link, Long counter) {
  ServiceDocument serviceDocument = Utils.fromQueryBinaryDocument(link, queryResult);
  assertNotNull(serviceDocument);
  ExampleServiceState resultState = (ExampleServiceState) serviceDocument;
  assertEquals(counter, resultState.counter);
  assertEquals(Action.POST.toString(), resultState.documentUpdateAction);
  assertEquals(Utils.buildKind(ExampleServiceState.class), resultState.documentKind);
  assertNotNull(resultState.name);
}

相关文章