本文整理了Java中com.vmware.xenon.common.Utils.setFactoryAvailabilityIfOwner()
方法的一些代码示例,展示了Utils.setFactoryAvailabilityIfOwner()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Utils.setFactoryAvailabilityIfOwner()
方法的具体详情如下:
包路径:com.vmware.xenon.common.Utils
类名称: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"));
}
内容来源于网络,如有侵权,请联系作者删除!