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

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

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

Utils.setFactoryAvailabilityIfOwner介绍

暂无

代码示例

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

public void setFactoriesAvailabilityIfOwner(boolean isAvailable) {
  for (String serviceLink : this.synchronizationRequiredServices.keySet()) {
    Service factoryService = this.host.findService(serviceLink, true);
    if (factoryService == null || !factoryService.hasOption(ServiceOption.FACTORY)) {
      this.host.log(Level.WARNING,
          "%s does not exist on host or is not a factory - cannot set availability",
          serviceLink);
      continue;
    }
    Utils.setFactoryAvailabilityIfOwner(this.host, serviceLink,
        factoryService.getPeerNodeSelectorPath(), isAvailable);
  }
}

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

@Test
public void failMigrationWhenSourceFactoryNotAvailable() throws Throwable {
  // this test dirties destination host, requires clean up
  clearSourceAndDestInProcessPeers = true;
  URI factoryUri = UriUtils.buildUri(getSourceHost(), ExampleService.FACTORY_LINK);
  this.host.waitForReplicatedFactoryServiceAvailable(factoryUri);
  // set factory availability on factory owner to false
  for (VerificationHost h : this.host.getInProcessHostMap().values()) {
    Utils.setFactoryAvailabilityIfOwner(h, ExampleService.FACTORY_LINK,
        ServiceUriPaths.DEFAULT_NODE_SELECTOR, false);
  }
  // Wait for factory to be not available
  waitForReplicatedFactoryServiceNotAvailable(getSourceHost(), factoryUri,
      ServiceUriPaths.DEFAULT_NODE_SELECTOR);
  // Kick-off migration
  MigrationTaskService.State migrationState = validMigrationState(ExampleService.FACTORY_LINK);
  Operation op = Operation.createPost(this.destinationFactoryUri)
      .setBody(migrationState)
      .setReferer(this.host.getUri());
  String selfLink = getDestinationHost().getTestRequestSender().sendAndWait(op)
      .getBody(State.class).documentSelfLink;
  // Wait for the migration task to fail
  State waitForServiceCompletion = waitForServiceCompletion(selfLink, getDestinationHost());
  assertEquals(waitForServiceCompletion.taskInfo.stage, TaskStage.FAILED);
  // Verify that it failed because of factory service availability check
  assertTrue("Invalid message received: " + waitForServiceCompletion.taskInfo.failure.message,
      waitForServiceCompletion.taskInfo.failure.message.contains(
      "Failed to verify availability of factory service"));
}

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

@Test
public void failMigrationWhenSourceFactoryNotAvailable() throws Throwable {
  // this test dirties destination host, requires clean up
  clearSourceAndDestInProcessPeers = true;
  URI factoryUri = UriUtils.buildUri(getSourceHost(), ExampleService.FACTORY_LINK);
  this.host.waitForReplicatedFactoryServiceAvailable(factoryUri);
  // set factory availability on factory owner to false
  for (VerificationHost h : this.host.getInProcessHostMap().values()) {
    Utils.setFactoryAvailabilityIfOwner(h, ExampleService.FACTORY_LINK,
        ServiceUriPaths.DEFAULT_NODE_SELECTOR, false);
  }
  // Wait for factory to be not available
  waitForReplicatedFactoryServiceNotAvailable(getSourceHost(), factoryUri,
      ServiceUriPaths.DEFAULT_NODE_SELECTOR);
  // Kick-off migration
  MigrationTaskService.State migrationState = validMigrationState(ExampleService.FACTORY_LINK);
  Operation op = Operation.createPost(this.destinationFactoryUri)
      .setBody(migrationState)
      .setReferer(this.host.getUri());
  String selfLink = getDestinationHost().getTestRequestSender().sendAndWait(op)
      .getBody(State.class).documentSelfLink;
  // Wait for the migration task to fail
  State waitForServiceCompletion = waitForServiceCompletion(selfLink, getDestinationHost());
  assertEquals(waitForServiceCompletion.taskInfo.stage, TaskStage.FAILED);
  // Verify that it failed because of factory service availability check
  assertTrue("Invalid message received: " + waitForServiceCompletion.taskInfo.failure.message,
      waitForServiceCompletion.taskInfo.failure.message.contains(
      "Failed to verify availability of source factory service"));
}

相关文章