Issue 385: started on javadoc and renamed methods to correspond to jclouds compute service

This commit is contained in:
Adrian Cole 2010-10-25 15:19:46 -05:00
parent 2291c42b45
commit e5315d3348
7 changed files with 82 additions and 12 deletions

View File

@ -36,13 +36,13 @@
(org.jclouds.compute.config.JCloudsNativeStandaloneComputeServiceContextModule (org.jclouds.compute.config.JCloudsNativeStandaloneComputeServiceContextModule
(defrecord ClojureComputeServiceAdapter [] (defrecord ClojureComputeServiceAdapter []
org.jclouds.compute.JCloudsNativeComputeServiceAdapter org.jclouds.compute.JCloudsNativeComputeServiceAdapter
(^NodeMetadata createNodeAndStoreCredentials [this ^String tag ^String name ^Template template ^Map credentialStore] (^NodeMetadata runNodeWithTagAndNameAndStoreCredentials [this ^String tag ^String name ^Template template ^Map credentialStore]
()) ())
(^Iterable listNodes [this ] (^Iterable listNodes [this ]
()) ())
(^Iterable listImages [this ] (^Iterable listImages [this ]
()) ())
(^Iterable listHardware [this ] (^Iterable listHardwareProfiles [this ]
()) ())
(^Iterable listLocations [this ] (^Iterable listLocations [this ]
()) ())

View File

@ -32,10 +32,56 @@ import org.jclouds.domain.Credentials;
* *
*/ */
public interface ComputeServiceAdapter<N, H, I, L> { public interface ComputeServiceAdapter<N, H, I, L> {
N createNodeAndStoreCredentials(String tag, String name, Template template, Map<String, Credentials> credentialStore);
Iterable<H> listHardware(); /**
* {@link ComputeService#runNodesWithTag(String, int, Template)} generates the parameters passed
* into this method such that each node in the set has a unique name.
* <p/>
* Your responsibility is to create a node with the underlying library and return after storing
* its credentials in the supplied map.
* <p/>
* Note that it is intentional to return the library native node object, as generic type
* {@code N}. If you are not using library-native objects (such as libvirt {@code Domain}) use
* {@link JCloudsNativeComputeServiceAdapter} instead.
*
* @param tag
* used to aggregate nodes with identical configuration
* @param name
* unique supplied name for the node, which has the tag encoded into it.
* @param template
* includes {@code imageId}, {@code locationId}, and {@code hardwareId} used to start
* the instance.
* @param credentialStore
* once the node is started, its login user and password will be encoded based on the
* node {@code id}
* @return library-native representation of a node.
*
* @see ComputeService#runNodesWithTag(String, int, Template)
*/
N runNodeWithTagAndNameAndStoreCredentials(String tag, String name, Template template,
Map<String, Credentials> credentialStore);
/**
* Hardware profiles describe available cpu, memory, and disk configurations that can be used to
* run a node.
* <p/>
* To implement this method, return the library native hardware profiles available to the user.
* These will be used to launch nodes as a part of the template.
*
* @return a non-null iterable of available hardware profiles.
* @see ComputeService#listHardwareProfiles()
*/
Iterable<H> listHardwareProfiles();
/**
* Images are the available configured operating systems that someone can run a node with. *
* <p/>
* To implement this method, return the library native images available to the user. These will
* be used to launch nodes as a part of the template.
*
* @return a non-null iterable of available images.
* @see ComputeService#listImages()
*/
Iterable<I> listImages(); Iterable<I> listImages();
Iterable<L> listLocations(); Iterable<L> listLocations();

View File

@ -36,28 +36,52 @@ import org.jclouds.domain.Location;
*/ */
public interface JCloudsNativeComputeServiceAdapter extends public interface JCloudsNativeComputeServiceAdapter extends
ComputeServiceAdapter<NodeMetadata, Hardware, Image, Location> { ComputeServiceAdapter<NodeMetadata, Hardware, Image, Location> {
/**
* {@inheritDoc}
*/
@Override @Override
NodeMetadata createNodeAndStoreCredentials(String tag, String name, Template template, NodeMetadata runNodeWithTagAndNameAndStoreCredentials(String tag, String name, Template template,
Map<String, Credentials> credentialStore); Map<String, Credentials> credentialStore);
/**
* {@inheritDoc}
*/
@Override @Override
Iterable<NodeMetadata> listNodes(); Iterable<NodeMetadata> listNodes();
/**
* {@inheritDoc}
*/
@Override @Override
Iterable<Image> listImages(); Iterable<Image> listImages();
/**
* {@inheritDoc}
*/
@Override @Override
Iterable<Hardware> listHardware(); Iterable<Hardware> listHardwareProfiles();
/**
* {@inheritDoc}
*/
@Override @Override
Iterable<Location> listLocations(); Iterable<Location> listLocations();
/**
* {@inheritDoc}
*/
@Override @Override
NodeMetadata getNode(String id); NodeMetadata getNode(String id);
/**
* {@inheritDoc}
*/
@Override @Override
void destroyNode(String id); void destroyNode(String id);
/**
* {@inheritDoc}
*/
@Override @Override
void rebootNode(String id); void rebootNode(String id);

View File

@ -87,7 +87,7 @@ public class StandaloneComputeServiceContextModule<N, H, I, L> extends BaseCompu
@Override @Override
public Iterable<H> get() { public Iterable<H> get() {
return adapter.listHardware(); return adapter.listHardwareProfiles();
} }
}, transformer); }, transformer);

View File

@ -127,7 +127,7 @@ public class AdaptingComputeServiceStrategies<N, H, I, L> implements AddNodeWith
template.getLocation().getId(), name, template.getImage().getProviderId(), template.getHardware() template.getLocation().getId(), name, template.getImage().getProviderId(), template.getHardware()
.getProviderId()); .getProviderId());
N from = client.createNodeAndStoreCredentials(tag, name, template, credentialStore); N from = client.runNodeWithTagAndNameAndStoreCredentials(tag, name, template, credentialStore);
NodeMetadata node = nodeMetadataAdapter.apply(from); NodeMetadata node = nodeMetadataAdapter.apply(from);
logger.debug("<< instantiated node(%s)", node.getId()); logger.debug("<< instantiated node(%s)", node.getId());
return node; return node;

View File

@ -76,7 +76,7 @@ public class StubComputeServiceAdapter implements JCloudsNativeComputeServiceAda
} }
@Override @Override
public NodeMetadata createNodeAndStoreCredentials(String tag, String name, Template template, public NodeMetadata runNodeWithTagAndNameAndStoreCredentials(String tag, String name, Template template,
Map<String, Credentials> credentialStore) { Map<String, Credentials> credentialStore) {
NodeMetadataBuilder builder = new NodeMetadataBuilder(); NodeMetadataBuilder builder = new NodeMetadataBuilder();
String id = idProvider.get() + ""; String id = idProvider.get() + "";
@ -98,7 +98,7 @@ public class StubComputeServiceAdapter implements JCloudsNativeComputeServiceAda
} }
@Override @Override
public Iterable<Hardware> listHardware() { public Iterable<Hardware> listHardwareProfiles() {
return ImmutableSet.<Hardware> of(StubComputeServiceDependenciesModule.stub("small", 1, 1740, 160), return ImmutableSet.<Hardware> of(StubComputeServiceDependenciesModule.stub("small", 1, 1740, 160),
StubComputeServiceDependenciesModule.stub("medium", 4, 7680, 850), StubComputeServiceDependenciesModule.stub("medium", 4, 7680, 850),
StubComputeServiceDependenciesModule.stub("large", 8, 15360, 1690)); StubComputeServiceDependenciesModule.stub("large", 8, 15360, 1690));

View File

@ -34,7 +34,7 @@ public class ServerManagerComputeServiceAdapter implements ComputeServiceAdapter
} }
@Override @Override
public Server createNodeAndStoreCredentials(String tag, String name, Template template, public Server runNodeWithTagAndNameAndStoreCredentials(String tag, String name, Template template,
Map<String, Credentials> credentialStore) { Map<String, Credentials> credentialStore) {
// create the backend object using parameters from the template. // create the backend object using parameters from the template.
Server from = client.createServerInDC(template.getLocation().getId(), name, Server from = client.createServerInDC(template.getLocation().getId(), name,
@ -46,7 +46,7 @@ public class ServerManagerComputeServiceAdapter implements ComputeServiceAdapter
} }
@Override @Override
public Iterable<Hardware> listHardware() { public Iterable<Hardware> listHardwareProfiles() {
return client.listHardware(); return client.listHardware();
} }