private void checkStateAvailable(String id, NodeMetadata node) { checkState(node != null, "node with id %s terminated or unavailable!", id); checkState(node.getStatus() != Status.TERMINATED, "node %s terminated or unavailable! current status: %s", node, formatStatus(node)); }
protected ToStringHelper string() { ToStringHelper helper = computeToStringPrefix(); helper.add("os", getOperatingSystem()).add("description", getDescription()).add("version", getVersion()) .add("status", formatStatus(this)) .add("loginUser", defaultCredentials != null ? defaultCredentials.identity : null); return addComputeToStringSuffix(helper); }
protected ToStringHelper string() { ToStringHelper helper = computeToStringPrefix(); helper.add("os", getOperatingSystem()).add("description", getDescription()).add("version", getVersion()) .add("status", formatStatus(this)) .add("loginUser", defaultCredentials != null ? defaultCredentials.identity : null); return addComputeToStringSuffix(helper); }
public boolean checkStatus(C resource) { if (resource == null) return false; logger.trace("%s: looking for resource state %s: currently: %s", resource.getId(), intended, formatStatus(resource)); if (invalids.contains(resource.getStatus())) throw new IllegalStateException("resource " + resource.getId() + " in location " + resource.getLocation() + " is in invalid status " + formatStatus(resource)); return resource.getStatus() == intended; }
public boolean checkStatus(C resource) { if (resource == null) return false; logger.trace("%s: looking for resource state %s: currently: %s", resource.getId(), intended, formatStatus(resource)); if (invalids.contains(resource.getStatus())) throw new IllegalStateException("resource " + resource.getId() + " in location " + resource.getLocation() + " is in invalid status " + formatStatus(resource)); return resource.getStatus() == intended; }
protected ToStringHelper string() { ToStringHelper helper = computeToStringPrefix(); helper.add("group", getGroup()).add("imageId", getImageId()).add("os", getOperatingSystem()) .add("status", formatStatus(this)).add("loginPort", getLoginPort()).add("hostname", getHostname()); if (getPrivateAddresses().size() > 0) helper.add("privateAddresses", getPrivateAddresses()); if (getPublicAddresses().size() > 0) helper.add("publicAddresses", getPublicAddresses()); helper.add("hardware", getHardware()).add("loginUser", credentials != null ? credentials.identity : null); return addComputeToStringSuffix(helper); } }
protected ToStringHelper string() { ToStringHelper helper = computeToStringPrefix(); helper.add("group", getGroup()).add("imageId", getImageId()).add("os", getOperatingSystem()) .add("status", formatStatus(this)).add("loginPort", getLoginPort()).add("hostname", getHostname()); if (getPrivateAddresses().size() > 0) helper.add("privateAddresses", getPrivateAddresses()); if (getPublicAddresses().size() > 0) helper.add("publicAddresses", getPublicAddresses()); helper.add("hardware", getHardware()).add("loginUser", credentials != null ? credentials.identity : null); return addComputeToStringSuffix(helper); } }
protected ToStringHelper string() { ToStringHelper helper = computeToStringPrefix(); helper.add("group", getGroup()).add("imageId", getImageId()).add("os", getOperatingSystem()) .add("status", formatStatus(this)).add("loginPort", getLoginPort()).add("hostname", getHostname()); if (!getPrivateAddresses().isEmpty()) helper.add("privateAddresses", getPrivateAddresses()); if (!getPublicAddresses().isEmpty()) helper.add("publicAddresses", getPublicAddresses()); helper.add("hardware", getHardware()).add("loginUser", credentials != null ? credentials.identity : null); return addComputeToStringSuffix(helper); } }
@Override public void resumeNode(String id) { NodeMetadata node = nodes.get(id); if (node == null) throw new ResourceNotFoundException("node not found: " + id); if (node.getStatus() == Status.RUNNING) return; if (node.getStatus() != Status.SUSPENDED) throw new IllegalStateException("to resume a node, it must be in suspended status, not: " + formatStatus(node)); setStateOnNode(Status.PENDING, node); setStateOnNodeAfterDelay(Status.RUNNING, node, 50); }
@Override public void suspendNode(String id) { NodeMetadata node = nodes.get(id); if (node == null) throw new ResourceNotFoundException("node not found: " + id); if (node.getStatus() == Status.SUSPENDED) return; if (node.getStatus() != Status.RUNNING) throw new IllegalStateException("to suspend a node, it must be in running status, not: " + formatStatus(node)); setStateOnNode(Status.PENDING, node); setStateOnNodeAfterDelay(Status.SUSPENDED, node, 50); }
public boolean checkStatus(C resource) { if (resource == null) return true; logger.trace("%s: looking for resource status %s: currently: %s", resource.getId(), deletedStatus, formatStatus(resource)); return resource.getStatus() == deletedStatus; }
public boolean checkStatus(C resource) { if (resource == null) return true; logger.trace("%s: looking for resource status %s: currently: %s", resource.getId(), deletedStatus, formatStatus(resource)); return resource.getStatus() == deletedStatus; }
@Override public void resumeNode(String id) { NodeMetadata node = nodes.get(id); if (node == null) throw new ResourceNotFoundException("node not found: " + id); if (node.getStatus() == Status.RUNNING) return; if (node.getStatus() != Status.SUSPENDED) throw new IllegalStateException("to resume a node, it must be in suspended status, not: " + formatStatus(node)); setStateOnNode(Status.PENDING, node); setStateOnNodeAfterDelay(Status.RUNNING, node, 50); }
@Override public void suspendNode(String id) { NodeMetadata node = nodes.get(id); if (node == null) throw new ResourceNotFoundException("node not found: " + id); if (node.getStatus() == Status.SUSPENDED) return; if (node.getStatus() != Status.RUNNING) throw new IllegalStateException("to suspend a node, it must be in running status, not: " + formatStatus(node)); setStateOnNode(Status.PENDING, node); setStateOnNodeAfterDelay(Status.SUSPENDED, node, 50); }
@Override public void resumeNode(String id) { NodeMetadata node = nodes.get(id); if (node == null) throw new ResourceNotFoundException("node not found: " + id); if (node.getStatus() == Status.RUNNING) return; if (node.getStatus() != Status.SUSPENDED) throw new IllegalStateException("to resume a node, it must be in suspended status, not: " + formatStatus(node)); setStateOnNode(Status.PENDING, node); setStateOnNodeAfterDelay(Status.RUNNING, node, 50); }
@Override public void suspendNode(String id) { NodeMetadata node = nodes.get(id); if (node == null) throw new ResourceNotFoundException("node not found: " + id); if (node.getStatus() == Status.SUSPENDED) return; if (node.getStatus() != Status.RUNNING) throw new IllegalStateException("to suspend a node, it must be in running status, not: " + formatStatus(node)); setStateOnNode(Status.PENDING, node); setStateOnNodeAfterDelay(Status.SUSPENDED, node, 50); }
@SuppressWarnings("unchecked") @Test public void testFormatStatusWithBackendStatus() { ComputeMetadataIncludingStatus<Image.Status> resource = createMock(ComputeMetadataIncludingStatus.class); expect(resource.getStatus()).andReturn(Image.Status.PENDING); expect(resource.getBackendStatus()).andReturn("queued").anyTimes(); replay(resource); assertEquals(formatStatus(resource), "PENDING[queued]"); verify(resource); }
@SuppressWarnings("unchecked") @Test public void testFormatStatusWithoutBackendStatus() { ComputeMetadataIncludingStatus<Image.Status> resource = createMock(ComputeMetadataIncludingStatus.class); expect(resource.getStatus()).andReturn(Image.Status.PENDING); expect(resource.getBackendStatus()).andReturn(null).anyTimes(); replay(resource); assertEquals(formatStatus(resource), "PENDING"); verify(resource); }
@Override public AtomicReference<NodeMetadata> call() throws Exception { NodeMetadata node = null; logger.debug(">> adding node location(%s) name(%s) image(%s) hardware(%s)", template.getLocation().getId(), name, template.getImage().getProviderId(), template.getHardware().getProviderId()); node = addNodeWithGroupStrategy.createNodeWithGroupEncodedIntoName(group, name, template); logger.debug("<< %s node(%s)", formatStatus(node), node.getId()); return new AtomicReference<NodeMetadata>(node); }
@Override public AtomicReference<NodeMetadata> call() throws Exception { NodeMetadata node = null; logger.debug(">> adding node location(%s) name(%s) image(%s) hardware(%s)", template.getLocation().getId(), name, template.getImage().getProviderId(), template.getHardware().getProviderId()); node = addNodeWithGroupStrategy.createNodeWithGroupEncodedIntoName(group, name, template); logger.debug("<< %s node(%s)", formatStatus(node), node.getId()); return new AtomicReference<NodeMetadata>(node); }