mirror of https://github.com/apache/jclouds.git
Issue 254: correct docs
This commit is contained in:
parent
efc47969d9
commit
5af9bdd34f
|
@ -229,12 +229,12 @@ public class EC2ComputeServiceContextModule extends EC2ContextModule {
|
|||
}
|
||||
|
||||
@Override
|
||||
public NodeMetadata execute(String handle) {
|
||||
String[] parts = parseHandle(handle);
|
||||
public NodeMetadata execute(String id) {
|
||||
String[] parts = parseHandle(id);
|
||||
String region = parts[0];
|
||||
String id = parts[1];
|
||||
String instanceId = parts[1];
|
||||
RunningInstance runningInstance = Iterables.getOnlyElement(getAllRunningInstancesInRegion(
|
||||
client, region, id));
|
||||
client, region, instanceId));
|
||||
return runningInstanceToNodeMetadata.apply(runningInstance);
|
||||
}
|
||||
|
||||
|
@ -250,11 +250,11 @@ public class EC2ComputeServiceContextModule extends EC2ContextModule {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(String handle) {
|
||||
String[] parts = parseHandle(handle);
|
||||
public boolean execute(String id) {
|
||||
String[] parts = parseHandle(id);
|
||||
String region = parts[0];
|
||||
String id = parts[1];
|
||||
client.rebootInstancesInRegion(region, id);
|
||||
String instanceId = parts[1];
|
||||
client.rebootInstancesInRegion(region, instanceId);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -389,7 +389,9 @@ public class EC2ComputeServiceContextModule extends EC2ContextModule {
|
|||
.describeImagesInRegion(region, ownedBy(amiOwners))) {
|
||||
Image image = parser.apply(from);
|
||||
if (image != null)
|
||||
images.put(new RegionAndName(region, image.getProviderId()), image);
|
||||
images
|
||||
.put(new RegionAndName(region, image.getProviderId()),
|
||||
image);
|
||||
else if (from.getImageType() == ImageType.MACHINE)
|
||||
holder.logger.trace("<< image(%s) didn't parse", from.getId());
|
||||
}
|
||||
|
|
|
@ -59,12 +59,12 @@ public class EC2DestroyNodeStrategy implements DestroyNodeStrategy {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(String handle) {
|
||||
String[] parts = parseHandle(handle);
|
||||
public boolean execute(String id) {
|
||||
String[] parts = parseHandle(id);
|
||||
String region = parts[0];
|
||||
String id = parts[1];
|
||||
ec2Client.getInstanceServices().terminateInstancesInRegion(region, id);
|
||||
String instanceId = parts[1];
|
||||
ec2Client.getInstanceServices().terminateInstancesInRegion(region, instanceId);
|
||||
return instanceStateTerminated.apply(Iterables.getOnlyElement(Iterables.concat(ec2Client
|
||||
.getInstanceServices().describeInstancesInRegion(region, id))));
|
||||
.getInstanceServices().describeInstancesInRegion(region, instanceId))));
|
||||
}
|
||||
}
|
|
@ -64,9 +64,9 @@ public class EC2Utils {
|
|||
return Iterables.concat(client.describeInstancesInRegion(region, id));
|
||||
}
|
||||
|
||||
public static String[] parseHandle(String handle) {
|
||||
String[] parts = checkNotNull(handle, "handle").split("/");
|
||||
checkArgument(parts.length == 2, "handle syntax is region/id");
|
||||
public static String[] parseHandle(String id) {
|
||||
String[] parts = checkNotNull(id, "id").split("/");
|
||||
checkArgument(parts.length == 2, "id syntax is region/instanceid");
|
||||
return parts;
|
||||
}
|
||||
|
||||
|
|
|
@ -146,10 +146,10 @@ public interface ComputeService {
|
|||
Set<? extends NodeMetadata> runNodesWithTag(String tag, int count) throws RunNodesException;
|
||||
|
||||
/**
|
||||
* destroy the node, given its handle. If it is the only node in a tag set, the dependent
|
||||
* destroy the node, given its id. If it is the only node in a tag set, the dependent
|
||||
* resources will also be destroyed.
|
||||
*/
|
||||
void destroyNode(String handle);
|
||||
void destroyNode(String id);
|
||||
|
||||
/**
|
||||
* nodes matching the filter are treated as a logical set. Using the delete command, you can save
|
||||
|
@ -161,9 +161,9 @@ public interface ComputeService {
|
|||
Set<? extends NodeMetadata> destroyNodesMatching(Predicate<NodeMetadata> filter);
|
||||
|
||||
/**
|
||||
* reboot the node, given its handle.
|
||||
* reboot the node, given its id.
|
||||
*/
|
||||
void rebootNode(String handle);
|
||||
void rebootNode(String id);
|
||||
|
||||
/**
|
||||
* nodes matching the filter are treated as a logical set. Using this command, you can save time
|
||||
|
@ -172,9 +172,9 @@ public interface ComputeService {
|
|||
void rebootNodesMatching(Predicate<NodeMetadata> filter);
|
||||
|
||||
/**
|
||||
* Find a node by its handle.
|
||||
* Find a node by its id.
|
||||
*/
|
||||
NodeMetadata getNodeMetadata(String handle);
|
||||
NodeMetadata getNodeMetadata(String id);
|
||||
|
||||
/**
|
||||
* get all nodes including details such as image and ip addresses even if it incurs extra
|
||||
|
|
|
@ -37,12 +37,12 @@ public class ComputeMetadataImpl extends ResourceMetadataImpl<ComputeType> imple
|
|||
|
||||
/** The serialVersionUID */
|
||||
private static final long serialVersionUID = 7374704415964898694L;
|
||||
private final String handle;
|
||||
private final String id;
|
||||
|
||||
public ComputeMetadataImpl(ComputeType type, String id, String name, String handle,
|
||||
public ComputeMetadataImpl(ComputeType type, String providerId, String name, String id,
|
||||
Location location, URI uri, Map<String, String> userMetadata) {
|
||||
super(type, id, name, location, uri, userMetadata);
|
||||
this.handle = checkNotNull(handle, "handle");
|
||||
super(type, providerId, name, location, uri, userMetadata);
|
||||
this.id = checkNotNull(id, "id");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -50,7 +50,7 @@ public class ComputeMetadataImpl extends ResourceMetadataImpl<ComputeType> imple
|
|||
*/
|
||||
@Override
|
||||
public String getId() {
|
||||
return handle;
|
||||
return id;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -52,11 +52,11 @@ public class ImageImpl extends ComputeMetadataImpl implements Image {
|
|||
private final Architecture architecture;
|
||||
private final Credentials defaultCredentials;
|
||||
|
||||
public ImageImpl(String id, String name, String handle, Location location, URI uri,
|
||||
public ImageImpl(String providerId, String name, String id, Location location, URI uri,
|
||||
Map<String, String> userMetadata, String description, String version,
|
||||
@Nullable OsFamily osFamily, String osDescription, Architecture architecture,
|
||||
Credentials defaultCredentials) {
|
||||
super(ComputeType.IMAGE, id, name, handle, location, uri, userMetadata);
|
||||
super(ComputeType.IMAGE, providerId, name, id, location, uri, userMetadata);
|
||||
this.version = checkNotNull(version, "version");
|
||||
this.osFamily = osFamily;
|
||||
this.description = checkNotNull(description, "description");
|
||||
|
@ -115,9 +115,10 @@ public class ImageImpl extends ComputeMetadataImpl implements Image {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[id=" + getProviderId() + ", name=" + getName() + ", locationId=" + getLocation()
|
||||
+ ", architecture=" + architecture + ", osDescription=" + osDescription
|
||||
+ ", osFamily=" + osFamily + ", version=" + version + "]";
|
||||
return "[id=" + getId() + ", providerId=" + getProviderId() + ", name=" + getName()
|
||||
+ ", locationId=" + getLocation() + ", architecture=" + architecture
|
||||
+ ", osDescription=" + osDescription + ", osFamily=" + osFamily + ", version="
|
||||
+ version + "]";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -54,12 +54,12 @@ public class NodeMetadataImpl extends ComputeMetadataImpl implements NodeMetadat
|
|||
private final String tag;
|
||||
private final Image image;
|
||||
|
||||
public NodeMetadataImpl(String id, String name, String handle, Location location, URI uri,
|
||||
public NodeMetadataImpl(String providerId, String name, String id, Location location, URI uri,
|
||||
Map<String, String> userMetadata, @Nullable String tag, @Nullable Image image,
|
||||
NodeState state, Iterable<InetAddress> publicAddresses,
|
||||
Iterable<InetAddress> privateAddresses, Map<String, String> extra,
|
||||
@Nullable Credentials credentials) {
|
||||
super(ComputeType.NODE, id, name, handle, location, uri, userMetadata);
|
||||
super(ComputeType.NODE, providerId, name, id, location, uri, userMetadata);
|
||||
this.tag = tag;
|
||||
this.image = image;
|
||||
this.state = checkNotNull(state, "state");
|
||||
|
@ -128,10 +128,11 @@ public class NodeMetadataImpl extends ComputeMetadataImpl implements NodeMetadat
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[id=" + getProviderId() + ", tag=" + getTag() + ", name=" + getName() + ", location="
|
||||
+ getLocation() + ", uri=" + getUri() + ", image=" + getImage() + ", userMetadata="
|
||||
+ getUserMetadata() + ", state=" + getState() + ", privateAddresses="
|
||||
+ privateAddresses + ", publicAddresses=" + publicAddresses + "]";
|
||||
return "[id=" + getId() + ", providerId=" + getProviderId() + ", tag=" + getTag() + ", name="
|
||||
+ getName() + ", location=" + getLocation() + ", uri=" + getUri() + ", image="
|
||||
+ getImage() + ", userMetadata=" + getUserMetadata() + ", state=" + getState()
|
||||
+ ", privateAddresses=" + privateAddresses + ", publicAddresses=" + publicAddresses
|
||||
+ "]";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -48,10 +48,10 @@ public class SizeImpl extends ComputeMetadataImpl implements Size {
|
|||
|
||||
private final Set<Architecture> supportedArchitectures = Sets.newHashSet();
|
||||
|
||||
public SizeImpl(String id, String name, String handle, @Nullable Location location, URI uri,
|
||||
public SizeImpl(String providerId, String name, String id, @Nullable Location location, URI uri,
|
||||
Map<String, String> userMetadata, double cores, int ram, int disk,
|
||||
Iterable<Architecture> supportedArchitectures) {
|
||||
super(ComputeType.SIZE, id, name, handle, location, uri, userMetadata);
|
||||
super(ComputeType.SIZE, providerId, name, id, location, uri, userMetadata);
|
||||
this.cores = cores;
|
||||
this.ram = ram;
|
||||
this.disk = disk;
|
||||
|
@ -103,8 +103,9 @@ public class SizeImpl extends ComputeMetadataImpl implements Size {
|
|||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[id=" + getProviderId() + ", cores=" + cores + ", ram=" + ram + ", disk=" + disk
|
||||
+ ", supportedArchitectures=" + supportedArchitectures + "]";
|
||||
return "[id=" + getId() + ", providerId=" + getProviderId() + ", cores=" + cores + ", ram="
|
||||
+ ram + ", disk=" + disk + ", supportedArchitectures=" + supportedArchitectures
|
||||
+ "]";
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -147,7 +147,8 @@ public class BaseComputeService implements ComputeService {
|
|||
checkNotNull(template.getLocation(), "location");
|
||||
logger.debug(">> running %d node%s tag(%s) location(%s) image(%s) size(%s) options(%s)",
|
||||
count, count > 1 ? "s" : "", tag, template.getLocation().getId(), template
|
||||
.getImage().getProviderId(), template.getSize().getProviderId(), template.getOptions());
|
||||
.getImage().getProviderId(), template.getSize().getProviderId(), template
|
||||
.getOptions());
|
||||
Set<NodeMetadata> nodes = Sets.newHashSet();
|
||||
Map<NodeMetadata, Exception> badNodes = Maps.newLinkedHashMap();
|
||||
Map<?, ListenableFuture<Void>> responses = runNodesAndAddToSetStrategy.execute(tag, count,
|
||||
|
@ -182,11 +183,11 @@ public class BaseComputeService implements ComputeService {
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void destroyNode(String handle) {
|
||||
checkNotNull(handle, "handle");
|
||||
logger.debug(">> destroying node(%s)", handle);
|
||||
boolean successful = destroyNodeStrategy.execute(handle);
|
||||
logger.debug("<< destroyed node(%s) success(%s)", handle, successful);
|
||||
public void destroyNode(String id) {
|
||||
checkNotNull(id, "id");
|
||||
logger.debug(">> destroying node(%s)", id);
|
||||
boolean successful = destroyNodeStrategy.execute(id);
|
||||
logger.debug("<< destroyed node(%s) success(%s)", id, successful);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -278,20 +279,20 @@ public class BaseComputeService implements ComputeService {
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public NodeMetadata getNodeMetadata(String handle) {
|
||||
checkNotNull(handle, "handle");
|
||||
return getNodeMetadataStrategy.execute(handle);
|
||||
public NodeMetadata getNodeMetadata(String id) {
|
||||
checkNotNull(id, "id");
|
||||
return getNodeMetadataStrategy.execute(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void rebootNode(String handle) {
|
||||
checkNotNull(handle, "handle");
|
||||
logger.debug(">> rebooting node(%s)", handle);
|
||||
boolean successful = rebootNodeStrategy.execute(handle);
|
||||
logger.debug("<< rebooted node(%s) success(%s)", handle, successful);
|
||||
public void rebootNode(String id) {
|
||||
checkNotNull(id, "id");
|
||||
logger.debug(">> rebooting node(%s)", id);
|
||||
boolean successful = rebootNodeStrategy.execute(id);
|
||||
logger.debug("<< rebooted node(%s) success(%s)", id, successful);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -28,6 +28,6 @@ package org.jclouds.compute.strategy;
|
|||
*/
|
||||
public interface DestroyNodeStrategy {
|
||||
|
||||
boolean execute(String handle);
|
||||
boolean execute(String id);
|
||||
|
||||
}
|
|
@ -28,6 +28,6 @@ import org.jclouds.compute.domain.NodeMetadata;
|
|||
*/
|
||||
public interface GetNodeMetadataStrategy {
|
||||
|
||||
NodeMetadata execute(String handle);
|
||||
NodeMetadata execute(String id);
|
||||
|
||||
}
|
|
@ -27,6 +27,6 @@ package org.jclouds.compute.strategy;
|
|||
*/
|
||||
public interface RebootNodeStrategy {
|
||||
|
||||
boolean execute(String handle);
|
||||
boolean execute(String id);
|
||||
|
||||
}
|
|
@ -42,7 +42,7 @@ public class ResourceMetadataImpl<T extends Enum<T>> implements ResourceMetadata
|
|||
|
||||
private final T type;
|
||||
@Nullable
|
||||
private final String id;
|
||||
private final String providerId;
|
||||
@Nullable
|
||||
private final String name;
|
||||
@Nullable
|
||||
|
@ -51,10 +51,10 @@ public class ResourceMetadataImpl<T extends Enum<T>> implements ResourceMetadata
|
|||
private final URI uri;
|
||||
private final Map<String, String> userMetadata = Maps.newLinkedHashMap();
|
||||
|
||||
public ResourceMetadataImpl(T type, @Nullable String id, @Nullable String name,
|
||||
public ResourceMetadataImpl(T type, @Nullable String providerId, @Nullable String name,
|
||||
@Nullable Location location, @Nullable URI uri, Map<String, String> userMetadata) {
|
||||
this.type = checkNotNull(type, "type");
|
||||
this.id = id;
|
||||
this.providerId = providerId;
|
||||
this.name = name;
|
||||
this.location = location;
|
||||
this.uri = uri;
|
||||
|
@ -84,7 +84,7 @@ public class ResourceMetadataImpl<T extends Enum<T>> implements ResourceMetadata
|
|||
*/
|
||||
@Override
|
||||
public String getProviderId() {
|
||||
return id;
|
||||
return providerId;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -121,7 +121,7 @@ public class ResourceMetadataImpl<T extends Enum<T>> implements ResourceMetadata
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[type=" + type + ", id=" + id + ", name=" + name + ", location=" + location
|
||||
return "[type=" + type + ", providerId=" + providerId + ", name=" + name + ", location=" + location
|
||||
+ ", uri=" + uri + ", userMetadata=" + userMetadata + "]";
|
||||
}
|
||||
|
||||
|
@ -129,7 +129,7 @@ public class ResourceMetadataImpl<T extends Enum<T>> implements ResourceMetadata
|
|||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((id == null) ? 0 : id.hashCode());
|
||||
result = prime * result + ((providerId == null) ? 0 : providerId.hashCode());
|
||||
result = prime * result + ((location == null) ? 0 : location.hashCode());
|
||||
result = prime * result + ((name == null) ? 0 : name.hashCode());
|
||||
result = prime * result + ((type == null) ? 0 : type.hashCode());
|
||||
|
@ -146,10 +146,10 @@ public class ResourceMetadataImpl<T extends Enum<T>> implements ResourceMetadata
|
|||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
ResourceMetadataImpl<?> other = (ResourceMetadataImpl<?>) obj;
|
||||
if (id == null) {
|
||||
if (other.id != null)
|
||||
if (providerId == null) {
|
||||
if (other.providerId != null)
|
||||
return false;
|
||||
} else if (!id.equals(other.id))
|
||||
} else if (!providerId.equals(other.providerId))
|
||||
return false;
|
||||
if (location == null) {
|
||||
if (other.location != null)
|
||||
|
|
|
@ -138,9 +138,9 @@ public class GoGridComputeServiceContextModule extends GoGridContextModule {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(String handle) {
|
||||
public boolean execute(String id) {
|
||||
Server server = Iterables.getOnlyElement(client.getServerServices().getServersById(
|
||||
new Long(handle)));
|
||||
new Long(id)));
|
||||
client.getServerServices().power(server.getName(), PowerCommand.RESTART);
|
||||
serverLatestJobCompleted.apply(server);
|
||||
client.getServerServices().power(server.getName(), PowerCommand.START);
|
||||
|
@ -186,9 +186,9 @@ public class GoGridComputeServiceContextModule extends GoGridContextModule {
|
|||
}
|
||||
|
||||
@Override
|
||||
public NodeMetadata execute(String handle) {
|
||||
public NodeMetadata execute(String id) {
|
||||
Server server = Iterables.getOnlyElement(client.getServerServices().getServersById(
|
||||
new Long(checkNotNull(handle, "handle"))));
|
||||
new Long(checkNotNull(id, "id"))));
|
||||
return server == null ? null : serverToNodeMetadata.apply(server);
|
||||
}
|
||||
}
|
||||
|
@ -206,9 +206,9 @@ public class GoGridComputeServiceContextModule extends GoGridContextModule {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(String handle) {
|
||||
public boolean execute(String id) {
|
||||
Server server = Iterables.getOnlyElement(client.getServerServices().getServersById(
|
||||
new Long(handle)));
|
||||
new Long(id)));
|
||||
client.getServerServices().deleteByName(server.getName());
|
||||
return serverLatestJobCompleted.apply(server);
|
||||
}
|
||||
|
|
|
@ -142,8 +142,8 @@ public class CloudServersComputeServiceContextModule extends CloudServersContext
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(String handle) {
|
||||
int serverId = Integer.parseInt(handle);
|
||||
public boolean execute(String id) {
|
||||
int serverId = Integer.parseInt(id);
|
||||
// if false server wasn't around in the first place
|
||||
client.rebootServer(serverId, RebootType.HARD);
|
||||
Server server = client.getServer(serverId);
|
||||
|
@ -165,8 +165,8 @@ public class CloudServersComputeServiceContextModule extends CloudServersContext
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(String handle) {
|
||||
int serverId = Integer.parseInt(handle);
|
||||
public boolean execute(String id) {
|
||||
int serverId = Integer.parseInt(id);
|
||||
// if false server wasn't around in the first place
|
||||
if (!client.deleteServer(serverId))
|
||||
return false;
|
||||
|
@ -243,8 +243,8 @@ public class CloudServersComputeServiceContextModule extends CloudServersContext
|
|||
}
|
||||
|
||||
@Override
|
||||
public NodeMetadata execute(String handle) {
|
||||
int serverId = Integer.parseInt(handle);
|
||||
public NodeMetadata execute(String id) {
|
||||
int serverId = Integer.parseInt(id);
|
||||
Server server = client.getServer(serverId);
|
||||
return server == null ? null : serverToNodeMetadata.apply(server);
|
||||
}
|
||||
|
|
|
@ -140,8 +140,8 @@ public class RimuHostingComputeServiceContextModule extends RimuHostingContextMo
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(String handle) {
|
||||
Long serverId = Long.parseLong(handle);
|
||||
public boolean execute(String id) {
|
||||
Long serverId = Long.parseLong(id);
|
||||
// if false server wasn't around in the first place
|
||||
return client.restartServer(serverId).getState() == RunningState.RUNNING;
|
||||
}
|
||||
|
@ -161,8 +161,8 @@ public class RimuHostingComputeServiceContextModule extends RimuHostingContextMo
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(String handle) {
|
||||
Long serverId = Long.parseLong(handle);
|
||||
public boolean execute(String id) {
|
||||
Long serverId = Long.parseLong(id);
|
||||
client.destroyServer(serverId);
|
||||
return serverDestroyed.apply(client.getServer(serverId));
|
||||
}
|
||||
|
@ -247,8 +247,8 @@ public class RimuHostingComputeServiceContextModule extends RimuHostingContextMo
|
|||
}
|
||||
|
||||
@Override
|
||||
public NodeMetadata execute(String handle) {
|
||||
long serverId = Long.parseLong(handle);
|
||||
public NodeMetadata execute(String id) {
|
||||
long serverId = Long.parseLong(id);
|
||||
Server server = client.getServer(serverId);
|
||||
return server == null ? null : serverToNodeMetadata.apply(server);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue