com.vmware.xenon.common.Utils.setTimeDriftThreshold()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(11.9k)|赞(0)|评价(0)|浏览(113)

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

Utils.setTimeDriftThreshold介绍

[英]Infrastructure use only, do not use outside tests. Set the upper bound between wall clock time as reported by System#currentTimeMillis()and the time reported by #getNowMicrosUtc() (when both converted to micros). The current time value will be reset to latest wall clock time so this call must be avoided at all costs in a production system (it might make #getNowMicrosUtc() return a smaller value than previous calls
[中]只使用基础设施,不要使用外部测试。设置系统#currentTimeMillis()报告的挂钟时间与#GetNowMicroUTC()报告的时间之间的上限(当两者都转换为微秒时)。当前时间值将重置为最新的挂钟时间,因此在生产系统中必须不惜一切代价避免此调用(它可能会使#GetNowMicroUTC()返回的值小于以前的调用)

代码示例

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

public static void main(String[] args) throws Throwable {
  Utils.setTimeDriftThreshold(TIME_DRIFT_THRESHOLD_MICROS);
  ManagementHost h = new ManagementHost();
  h.initializeHostAndServices(args);
  Runtime.getRuntime().addShutdownHook(new Thread(() -> {
    h.log(Level.WARNING, "Host stopping ...");
    h.stop();
    h.log(Level.WARNING, "Host is stopped");
  }));
}

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

@Test
public void serviceVersionRetentionAndGrooming() throws Throwable {
  try {
    Utils.setTimeDriftThreshold(TimeUnit.HOURS.toMicros(1));
    MinimalTestService.setVersionRetentionLimit(1);
    for (int i = 0; i < this.iterationCount; i++) {
      EnumSet<ServiceOption> caps = EnumSet.of(ServiceOption.PERSISTENCE);
      doServiceVersionGroomingValidation(caps);
      tearDown();
    }
  } finally {
    Utils.setTimeDriftThreshold(Utils.DEFAULT_TIME_DRIFT_THRESHOLD_MICROS);
    MinimalTestService.setVersionRetentionLimit(
        MinimalTestService.DEFAULT_VERSION_RETENTION_LIMIT);
  }
}

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

@Test
public void serviceVersionRetentionAndGrooming() throws Throwable {
  try {
    Utils.setTimeDriftThreshold(TimeUnit.HOURS.toMicros(1));
    MinimalTestService.setVersionRetentionLimit(1);
    for (int i = 0; i < this.iterationCount; i++) {
      EnumSet<ServiceOption> caps = EnumSet.of(ServiceOption.PERSISTENCE);
      doServiceVersionGroomingValidation(caps);
      tearDown();
    }
  } finally {
    Utils.setTimeDriftThreshold(Utils.DEFAULT_TIME_DRIFT_THRESHOLD_MICROS);
    MinimalTestService.setVersionRetentionLimit(
        MinimalTestService.DEFAULT_VERSION_RETENTION_LIMIT);
  }
}

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

@AfterClass
public static void tearDownOnce() {
  HOST.tearDownInProcessPeers();
  HOST.tearDown();
  Utils.setTimeDriftThreshold(Utils.DEFAULT_TIME_DRIFT_THRESHOLD_MICROS);
}

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

@AfterClass
public static void tearDownOnce() {
  HOST.tearDownInProcessPeers();
  HOST.tearDown();
  Utils.setTimeDriftThreshold(Utils.DEFAULT_TIME_DRIFT_THRESHOLD_MICROS);
}

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

@AfterClass
public static void tearDownOnce() {
  HOST.tearDownInProcessPeers();
  HOST.tearDown();
  Utils.setTimeDriftThreshold(Utils.DEFAULT_TIME_DRIFT_THRESHOLD_MICROS);
}

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

@Test
public void buildUUID() {
  CommandLineArgumentParser.parseFromProperties(this);
  Utils.setTimeDriftThreshold(TimeUnit.HOURS.toMicros(1));
  try {
    Logger log = Logger.getAnonymousLogger();
    this.testResults.getReport().lastValue(TestResults.KEY_THROUGHPUT, thpt);
  } finally {
    Utils.setTimeDriftThreshold(Utils.DEFAULT_TIME_DRIFT_THRESHOLD_MICROS);

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

@Test
public void buildUUID() {
  CommandLineArgumentParser.parseFromProperties(this);
  Utils.setTimeDriftThreshold(TimeUnit.HOURS.toMicros(1));
  try {
    Logger log = Logger.getAnonymousLogger();
    this.testResults.getReport().lastValue(TestResults.KEY_THROUGHPUT, thpt);
  } finally {
    Utils.setTimeDriftThreshold(Utils.DEFAULT_TIME_DRIFT_THRESHOLD_MICROS);

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

private void setUpHost(int responsePayloadSizeLimit) throws Throwable {
  if (this.host != null) {
    return;
  }
  this.host = VerificationHost.create(0);
  if (responsePayloadSizeLimit > 0) {
    this.host.setResponsePayloadSizeLimit(responsePayloadSizeLimit);
  }
  CommandLineArgumentParser.parseFromProperties(this.host);
  CommandLineArgumentParser.parseFromProperties(this);
  this.host.setStressTest(this.host.isStressTest);
  // disable synchronization so it does not interfere with the various test assumptions
  // on index stats.
  this.host.setPeerSynchronizationEnabled(false);
  this.host.start();
  if (this.host.isStressTest()) {
    Utils.setTimeDriftThreshold(TimeUnit.HOURS.toMicros(1));
  } else {
    this.host.setMaintenanceIntervalMicros(TimeUnit.MILLISECONDS
        .toMicros(VerificationHost.FAST_MAINT_INTERVAL_MILLIS));
    this.host.toggleServiceOptions(this.host.getDocumentIndexServiceUri(),
        EnumSet.of(ServiceOption.INSTRUMENTATION), null);
  }
}

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

private void setUpHost(int responsePayloadSizeLimit) throws Throwable {
  if (this.host != null) {
    return;
  }
  this.host = VerificationHost.create(0);
  if (responsePayloadSizeLimit > 0) {
    this.host.setResponsePayloadSizeLimit(responsePayloadSizeLimit);
  }
  CommandLineArgumentParser.parseFromProperties(this.host);
  CommandLineArgumentParser.parseFromProperties(this);
  this.host.setStressTest(this.host.isStressTest);
  // disable synchronization so it does not interfere with the various test assumptions
  // on index stats.
  this.host.setPeerSynchronizationEnabled(false);
  this.host.start();
  if (this.host.isStressTest()) {
    Utils.setTimeDriftThreshold(TimeUnit.HOURS.toMicros(1));
  } else {
    this.host.setMaintenanceIntervalMicros(TimeUnit.MILLISECONDS
        .toMicros(VerificationHost.FAST_MAINT_INTERVAL_MILLIS));
    this.host.toggleServiceOptions(this.host.getDocumentIndexServiceUri(),
        EnumSet.of(ServiceOption.INSTRUMENTATION), null);
  }
}

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

@Test
public void throughputPut() throws Throwable {
  int serviceThreshold = LuceneDocumentIndexService.getVersionRetentionServiceThreshold();
  long limit = MinimalTestService.getVersionRetentionLimit();
  long floor = MinimalTestService.getVersionRetentionFloor();
  try {
    setUpHost(false);
    LuceneDocumentIndexService.setVersionRetentionServiceThreshold((int) this.serviceCount);
    MinimalTestService.setVersionRetentionLimit(this.retentionLimit);
    MinimalTestService.setVersionRetentionFloor(this.retentionFloor);
    if (this.host.isStressTest()) {
      Utils.setTimeDriftThreshold(TimeUnit.HOURS.toMicros(1));
    }
    // Do throughput testing for basic, mutable services
    doDurableServiceUpdate(Action.PUT, MinimalTestService.class,
        this.serviceCount, this.updateCount, null);
    // Now do the same test for a similar service with indexed metadata
    doDurableServiceUpdate(Action.PUT, MinimalTestServiceWithIndexedMetadata.class,
        this.serviceCount, this.updateCount, null);
  } finally {
    Utils.setTimeDriftThreshold(Utils.DEFAULT_TIME_DRIFT_THRESHOLD_MICROS);
    MinimalTestService.setVersionRetentionLimit(limit);
    MinimalTestService.setVersionRetentionFloor(floor);
    LuceneDocumentIndexService.setVersionRetentionServiceThreshold(serviceThreshold);
  }
}

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

@Test
public void throughputPut() throws Throwable {
  int serviceThreshold = LuceneDocumentIndexService.getVersionRetentionServiceThreshold();
  long limit = MinimalTestService.getVersionRetentionLimit();
  long floor = MinimalTestService.getVersionRetentionFloor();
  try {
    setUpHost(false);
    LuceneDocumentIndexService.setVersionRetentionServiceThreshold((int) this.serviceCount);
    MinimalTestService.setVersionRetentionLimit(this.retentionLimit);
    MinimalTestService.setVersionRetentionFloor(this.retentionFloor);
    if (this.host.isStressTest()) {
      Utils.setTimeDriftThreshold(TimeUnit.HOURS.toMicros(1));
    }
    // Do throughput testing for basic, mutable services
    doDurableServiceUpdate(Action.PUT, MinimalTestService.class,
        this.serviceCount, this.updateCount, null);
    // Now do the same test for a similar service with indexed metadata
    doDurableServiceUpdate(Action.PUT, MinimalTestServiceWithIndexedMetadata.class,
        this.serviceCount, this.updateCount, null);
  } finally {
    Utils.setTimeDriftThreshold(Utils.DEFAULT_TIME_DRIFT_THRESHOLD_MICROS);
    MinimalTestService.setVersionRetentionLimit(limit);
    MinimalTestService.setVersionRetentionFloor(floor);
    LuceneDocumentIndexService.setVersionRetentionServiceThreshold(serviceThreshold);
  }
}

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

@After
public void tearDown() throws Exception {
  Utils.setTimeDriftThreshold(Utils.DEFAULT_TIME_DRIFT_THRESHOLD_MICROS);
  if (this.host == null) {
    return;
  }
  try {
    this.host.setSystemAuthorizationContext();
    this.host.logServiceStats(this.host.getDocumentIndexServiceUri(), this.testResults);
    this.host.logServiceStats(this.inMemoryIndexServiceUri, this.testResults);
  } catch (Throwable e) {
    this.host.log("Error logging stats: %s", e.toString());
  }
  this.host.tearDown();
  this.host = null;
  LuceneDocumentIndexService.setIndexFileCountThresholdForWriterRefresh(
      LuceneDocumentIndexService.DEFAULT_INDEX_FILE_COUNT_THRESHOLD_FOR_WRITER_REFRESH);
  LuceneDocumentIndexService.setExpiredDocumentSearchThreshold(
      LuceneDocumentIndexService.DEFAULT_EXPIRED_DOCUMENT_SEARCH_THRESHOLD);
  TestRequestSender.clearAuthToken();
}

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

@After
public void tearDown() throws Exception {
  Utils.setTimeDriftThreshold(Utils.DEFAULT_TIME_DRIFT_THRESHOLD_MICROS);
  if (this.host == null) {
    return;
  }
  try {
    this.host.setSystemAuthorizationContext();
    this.host.logServiceStats(this.host.getDocumentIndexServiceUri(), this.testResults);
    this.host.logServiceStats(this.inMemoryIndexServiceUri, this.testResults);
  } catch (Throwable e) {
    this.host.log("Error logging stats: %s", e.toString());
  }
  this.host.tearDown();
  this.host = null;
  LuceneDocumentIndexService.setIndexFileCountThresholdForWriterRefresh(
      LuceneDocumentIndexService.DEFAULT_INDEX_FILE_COUNT_THRESHOLD_FOR_WRITER_REFRESH);
  LuceneDocumentIndexService.setExpiredDocumentSearchThreshold(
      LuceneDocumentIndexService.DEFAULT_EXPIRED_DOCUMENT_SEARCH_THRESHOLD);
  TestRequestSender.clearAuthToken();
}

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

@Before
public void setUpPerMethod() throws Throwable {
  CommandLineArgumentParser.parseFromProperties(this);
  this.host = HOST;
  this.host.toggleDebuggingMode(this.detailedLogging);
  this.sender = this.host.getTestRequestSender();
  if (HOST.isStressTest()) {
    Utils.setTimeDriftThreshold(TimeUnit.SECONDS.toMicros(120));
  }
  if (this.enableAuth) {
    if (!this.host.isAuthorizationEnabled()) {
      this.host.log("Restarting host to enable authorization");
      tearDownOnce();
      startHost(true);
      this.host = HOST;
    }
    this.host.log("Auth is enabled. Creating users");
    setUpAuthUsers();
    switchToAuthUser();
  }
}

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

@Before
public void setUpPerMethod() throws Throwable {
  CommandLineArgumentParser.parseFromProperties(this);
  this.host = HOST;
  this.host.toggleDebuggingMode(this.detailedLogging);
  this.sender = this.host.getTestRequestSender();
  if (HOST.isStressTest()) {
    Utils.setTimeDriftThreshold(TimeUnit.SECONDS.toMicros(120));
  }
  if (this.enableAuth) {
    if (!this.host.isAuthorizationEnabled()) {
      this.host.log("Restarting host to enable authorization");
      tearDownOnce();
      startHost(true);
      this.host = HOST;
    }
    this.host.log("Auth is enabled. Creating users");
    setUpAuthUsers();
    switchToAuthUser();
  }
}

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

@Before
public void setUpPerMethod() throws Throwable {
  CommandLineArgumentParser.parseFromProperties(this);
  this.host = HOST;
  this.host.toggleDebuggingMode(this.detailedLogging);
  this.sender = this.host.getTestRequestSender();
  if (HOST.isStressTest()) {
    Utils.setTimeDriftThreshold(TimeUnit.SECONDS.toMicros(120));
  }
  if (this.enableAuth) {
    if (!this.host.isAuthorizationEnabled()) {
      this.host.log("Restarting host to enable authorization");
      tearDownOnce();
      startHost(true);
      this.host = HOST;
    }
    this.host.log("Auth is enabled. Creating users");
    setUpAuthUsers();
    switchToAuthUser();
  }
}

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

private static VerificationHost prepareHost(int nodeCount, int port, String sandboxDir, String[] commandLineArgs) throws Throwable {
  Utils.setTimeDriftThreshold(TimeUnit.SECONDS.toMicros(120));

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

private static VerificationHost prepareHost(int nodeCount, int port, String sandboxDir, String[] commandLineArgs) throws Throwable {
  Utils.setTimeDriftThreshold(TimeUnit.SECONDS.toMicros(120));

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

this.host.setMaintenanceIntervalMicros(
      ServiceHostState.DEFAULT_MAINTENANCE_INTERVAL_MICROS);
  Utils.setTimeDriftThreshold(TimeUnit.SECONDS.toMicros(120));
  LuceneDocumentIndexService.setImplicitQueryResultLimit(10000000);
} else {

相关文章