本文整理汇总了Java中org.jclouds.compute.domain.NodeMetadata.Status方法的典型用法代码示例。如果您正苦于以下问题:Java NodeMetadata.Status方法的具体用法?Java NodeMetadata.Status怎么用?Java NodeMetadata.Status使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jclouds.compute.domain.NodeMetadata
的用法示例。
在下文中一共展示了NodeMetadata.Status方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: waitForState
import org.jclouds.compute.domain.NodeMetadata; //导入方法依赖的package包/类
protected final boolean waitForState(NodeMetadata.Status targetStatus, long timeoutInSeconds) {
Objects.requireNonNull(targetStatus, "targetStatus");
LOGGER.debug("Waiting for status '{}' on node '{}' (timeout {}s)", targetStatus.name(), getName(), timeoutInSeconds);
long endTime = System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(timeoutInSeconds);
while (System.currentTimeMillis() < endTime) {
NodeMetadata.Status status = getFreshNodeMetadata().getStatus();
if (status != null && status.equals(targetStatus)) {
LOGGER.debug("Node '{}' is in status '{}'", getName(), targetStatus.name());
return true;
} else if (!NodeMetadata.Status.ERROR.equals(targetStatus) && NodeMetadata.Status.ERROR.equals(status)) {
// fail fast
throw new IllegalStateException("Node '" + getName() + "' is in unexpected ERROR state.");
}
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
LOGGER.warn("Interrupted while waiting for node '{}' to reach state '{}'", getName(), targetStatus.name(), e);
Thread.currentThread().interrupt();
break;
}
}
LOGGER.warn("Node '{}' didn't reach status '{}' in given time ({}s)", getName(), targetStatus.name(), timeoutInSeconds);
return false;
}
示例2: setup
import org.jclouds.compute.domain.NodeMetadata; //导入方法依赖的package包/类
@Before
public void setup()
throws UnknownHostException {
for (int i = 0; i < NUMBER_OF_NODES; i++) {
HashSet<String> privateAddresses = new HashSet<String>();
privateAddresses.add("127.0.0." + (i + 1));
NodeMetadata.Status status = NodeMetadata.Status.PENDING;
if (i < NUMBER_OF_RUNNING_NODES) {
status = NodeMetadata.Status.RUNNING;
addressesOfRunningInstances.add(new Address(privateAddresses.iterator().next(), 0));
}
nodes.add(new NodeMetadataImpl("", "", "dummyId" + i,
null,
null,
new HashMap<String, String>(),
new HashSet<String>(),
null, null, null, null,
status, "",
STARTING_PORT + i, privateAddresses, privateAddresses, null, "dummyHostName" + i));
}
}
示例3: getNodePredicate
import org.jclouds.compute.domain.NodeMetadata; //导入方法依赖的package包/类
/**
* Returns the required {@ComputeMetadata} {@link Predicate} for the Exhcnage.
* The predicate can be used for filtering.
*/
public Predicate<NodeMetadata> getNodePredicate(Exchange exchange) {
final String nodeId = getNodeId(exchange);
final String imageId = getImageId(exchange);
final String group = getGroup(exchange);
final NodeMetadata.Status queryState = getNodeState(exchange);
Predicate<NodeMetadata> predicate = new Predicate<NodeMetadata>() {
public boolean apply(NodeMetadata metadata) {
if (nodeId != null && !nodeId.equals(metadata.getId())) {
return false;
}
if (imageId != null && !imageId.equals(metadata.getImageId())) {
return false;
}
if (queryState != null && !queryState.equals(metadata.getStatus())) {
return false;
}
if (group != null && !group.equals(metadata.getGroup())) {
return false;
}
return true;
}
};
return predicate;
}
示例4: getNodeState
import org.jclouds.compute.domain.NodeMetadata; //导入方法依赖的package包/类
/**
* Retrieves the node state from the URI or from the exchange headers. The header will take precedence over the URI.
*/
public NodeMetadata.Status getNodeState(Exchange exchange) {
NodeMetadata.Status nodeState = null;
String state = getEndpoint().getNodeState();
if (ObjectHelper.isNotEmpty(state)) {
nodeState = NodeMetadata.Status.valueOf(state);
}
if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(JcloudsConstants.NODE_STATE))) {
Object stateHeader = exchange.getIn().getHeader(JcloudsConstants.NODE_STATE);
if (stateHeader == null) {
nodeState = null;
} else if (stateHeader instanceof NodeMetadata.Status) {
nodeState = (NodeMetadata.Status) stateHeader;
} else {
nodeState = NodeMetadata.Status.valueOf(String.valueOf(stateHeader));
}
}
return nodeState;
}
示例5: toState
import org.jclouds.compute.domain.NodeMetadata; //导入方法依赖的package包/类
private ComponentInstance.State toState(NodeMetadata.Status status){
switch (status){
case ERROR:
return ComponentInstance.State.ERROR;
case RUNNING:
return ComponentInstance.State.RUNNING;
case SUSPENDED:
return ComponentInstance.State.STOPPED;
case TERMINATED:
return ComponentInstance.State.TERMINATED;
case PENDING:
return ComponentInstance.State.PENDING;
default:
return ComponentInstance.State.UNRECOGNIZED;
}
}
示例6: toState
import org.jclouds.compute.domain.NodeMetadata; //导入方法依赖的package包/类
private ComponentInstance.State toState(NodeMetadata.Status status){
switch (status){
case ERROR:
return ComponentInstance.State.ERROR;
case RUNNING:
return ComponentInstance.State.RUNNING;
case SUSPENDED:
return ComponentInstance.State.STOPPED;
case TERMINATED:
return ComponentInstance.State.TERMINATED;
case PENDING:
return ComponentInstance.State.PENDING;
default:
return ComponentInstance.State.UNRECOGNIZED;
}
}
示例7: ECSComputeServiceAdapter
import org.jclouds.compute.domain.NodeMetadata; //导入方法依赖的package包/类
@Inject
public ECSComputeServiceAdapter(
ECSApi api,
Map<Instance.Status, NodeMetadata.Status> nodeStatus) {
this.api = api;
this.nodeStatus = nodeStatus;
}
示例8: getInstanceStatus
import org.jclouds.compute.domain.NodeMetadata; //导入方法依赖的package包/类
@Provides
@Singleton
protected final Map<Instance.Status, NodeMetadata.Status> getInstanceStatus() {
return ImmutableMap.<Instance.Status, NodeMetadata.Status> builder()
.put(Instance.Status.RUNNING, NodeMetadata.Status.RUNNING)
.put(Instance.Status.STOPPED, NodeMetadata.Status.SUSPENDED)
.put(Instance.Status.DELETED, NodeMetadata.Status.TERMINATED)
.put(Instance.Status.STARTING, NodeMetadata.Status.PENDING)
.put(Instance.Status.RESETTING, NodeMetadata.Status.PENDING)
.put(Instance.Status.TRANSFERRING, NodeMetadata.Status.PENDING)
.put(Instance.Status.STOPPING, NodeMetadata.Status.PENDING)
.build();
}
示例9: VirtualMachineToNodeMetadata
import org.jclouds.compute.domain.NodeMetadata; //导入方法依赖的package包/类
@Inject
public VirtualMachineToNodeMetadata(Map<VirtualMachinePowerState, NodeMetadata.Status> toPortableNodeStatus,
Supplier<Map<String, CustomFieldDef>> customFields,
Supplier<VSphereServiceInstance> serviceInstanceSupplier,
Function<String, DistributedVirtualPortgroup> distributedVirtualPortgroupFunction,
@Named(VSphereConstants.JCLOUDS_VSPHERE_VM_PASSWORD) String vmInitPassword) {
this.toPortableNodeStatus = checkNotNull(toPortableNodeStatus, "PortableNodeStatus");
this.customFields = checkNotNull(customFields, "customFields");
this.serviceInstanceSupplier = checkNotNull(serviceInstanceSupplier, "serviceInstanceSupplier");
this.distributedVirtualPortgroupFunction = checkNotNull(distributedVirtualPortgroupFunction, "distributedVirtualPortgroupFunction");
this.vmInitPassword = vmInitPassword;
}
示例10: InstanceToNodeMetadata
import org.jclouds.compute.domain.NodeMetadata; //导入方法依赖的package包/类
public InstanceToNodeMetadata(
ECSApi api,
Map<Instance.Status, NodeMetadata.Status> status) {
this.api = api;
this.status = status;
}
示例11: toPortableNodeStatus
import org.jclouds.compute.domain.NodeMetadata; //导入方法依赖的package包/类
@Singleton
@Provides
protected Map<VirtualMachinePowerState, NodeMetadata.Status> toPortableNodeStatus() {
return toPortableNodeStatus;
}