Issue 9, Issue 127: updated javadoc, modified dist to not jarjar, changed dist to support profiles, tools, blobstore, and compute api

git-svn-id: http://jclouds.googlecode.com/svn/trunk@2754 3d8758e0-26b5-11de-8745-db77d3ebf521
This commit is contained in:
adrian.f.cole 2010-02-02 08:31:30 +00:00
parent 7120f6e536
commit b217410ac0
34 changed files with 454 additions and 374 deletions

View File

@ -31,6 +31,8 @@
<scope>runtime</scope> <scope>runtime</scope>
<excludes> <excludes>
<exclude>org.jclouds:jclouds-core</exclude> <exclude>org.jclouds:jclouds-core</exclude>
<exclude>org.jclouds:jclouds-blobstore</exclude>
<exclude>org.jclouds:jclouds-compute</exclude>
</excludes> </excludes>
<!-- exclude all transitive dependencies of core too --> <!-- exclude all transitive dependencies of core too -->
<useTransitiveFiltering>true</useTransitiveFiltering> <useTransitiveFiltering>true</useTransitiveFiltering>
@ -50,4 +52,4 @@
<outputDirectory>META-INF/maven/${project.groupId}/${project.artifactId}</outputDirectory> <outputDirectory>META-INF/maven/${project.groupId}/${project.artifactId}</outputDirectory>
</fileSet> </fileSet>
</fileSets> </fileSets>
</assembly> </assembly>

View File

@ -28,9 +28,15 @@
LICENSE.txt LICENSE.txt
README.txt README.txt
core core
+ docs <- javadoc for core + docs <- javadoc for core, blobstore, and compute
+ lib <- core jar and dependencies for core + lib <- core, blobstore, and compute jars and dependencies for core
+ src <- expanded or source jar for core + src <- expanded or source jar for core, blobstore, and compute
profiles
+ enterprise
+ README.txt <- how to use the profile
+ lib <- not core
+ docs <- not core
+ src <- not core
extensions extensions
+ log4j + log4j
+ README.txt <- how to use the extension + README.txt <- how to use the extension
@ -43,6 +49,12 @@
+ lib <- not core + lib <- not core
+ docs <- not core + docs <- not core
+ src <- not core + src <- not core
tools <- integrations with other tools
+ antcontrib
+ README.txt <- how to use the tool
+ lib <- not core
+ docs <- not core
+ src <- not core
samples <- includes samples and demos samples <- includes samples and demos
+ tweetstore + tweetstore
+ README.txt <- how to build and run the sample + README.txt <- how to build and run the sample
@ -75,6 +87,20 @@
</includes> </includes>
<outputDirectory>core/lib</outputDirectory> <outputDirectory>core/lib</outputDirectory>
</fileSet> </fileSet>
<fileSet>
<directory>blobstore/target</directory>
<includes>
<include>jclouds-blobstore-${project.version}.jar</include>
</includes>
<outputDirectory>core/lib</outputDirectory>
</fileSet>
<fileSet>
<directory>compute/target</directory>
<includes>
<include>jclouds-compute-${project.version}.jar</include>
</includes>
<outputDirectory>core/lib</outputDirectory>
</fileSet>
<fileSet> <fileSet>
<directory>core/target</directory> <directory>core/target</directory>
<includes> <includes>
@ -82,16 +108,38 @@
</includes> </includes>
<outputDirectory>core/src</outputDirectory> <outputDirectory>core/src</outputDirectory>
</fileSet> </fileSet>
<fileSet>
<directory>blobstore/target</directory>
<includes>
<include>jclouds-blobstore-${project.version}-sources.jar</include>
</includes>
<outputDirectory>core/src</outputDirectory>
</fileSet>
<fileSet>
<directory>compute/target</directory>
<includes>
<include>jclouds-compute-${project.version}-sources.jar</include>
</includes>
<outputDirectory>core/src</outputDirectory>
</fileSet>
<fileSet> <fileSet>
<directory>core/target/apidocs</directory> <directory>core/target/apidocs</directory>
<outputDirectory>core/docs</outputDirectory> <outputDirectory>core/docs</outputDirectory>
</fileSet> </fileSet>
<fileSet>
<directory>blobstore/target/apidocs</directory>
<outputDirectory>core/docs</outputDirectory>
</fileSet>
<fileSet>
<directory>compute/target/apidocs</directory>
<outputDirectory>core/docs</outputDirectory>
</fileSet>
<!-- providers: atmos --> <!-- providers: atmos -->
<fileSet> <fileSet>
<directory>atmos/target</directory> <directory>atmos/target</directory>
<includes> <includes>
<include>jclouds-atmos-${project.version}-jar-with-dependencies.jar</include> <include>jclouds-atmos-${project.version}.jar</include>
</includes> </includes>
<outputDirectory>providers/atmos/lib</outputDirectory> <outputDirectory>providers/atmos/lib</outputDirectory>
</fileSet> </fileSet>
@ -118,7 +166,7 @@
<fileSet> <fileSet>
<directory>aws/core/target</directory> <directory>aws/core/target</directory>
<includes> <includes>
<include>jclouds-aws-${project.version}-jar-with-dependencies.jar</include> <include>jclouds-aws-${project.version}.jar</include>
</includes> </includes>
<outputDirectory>providers/aws/lib</outputDirectory> <outputDirectory>providers/aws/lib</outputDirectory>
</fileSet> </fileSet>
@ -172,7 +220,7 @@
<fileSet> <fileSet>
<directory>azure/target</directory> <directory>azure/target</directory>
<includes> <includes>
<include>jclouds-azure-${project.version}-jar-with-dependencies.jar</include> <include>jclouds-azure-${project.version}.jar</include>
</includes> </includes>
<outputDirectory>providers/azure/lib</outputDirectory> <outputDirectory>providers/azure/lib</outputDirectory>
</fileSet> </fileSet>
@ -199,7 +247,7 @@
<fileSet> <fileSet>
<directory>vcloud/hostingdotcom/target</directory> <directory>vcloud/hostingdotcom/target</directory>
<includes> <includes>
<include>jclouds-hostingdotcom-${project.version}-jar-with-dependencies.jar</include> <include>jclouds-hostingdotcom-${project.version}.jar</include>
</includes> </includes>
<outputDirectory>providers/hostingdotcom/lib</outputDirectory> <outputDirectory>providers/hostingdotcom/lib</outputDirectory>
</fileSet> </fileSet>
@ -226,7 +274,7 @@
<fileSet> <fileSet>
<directory>mezeo/pcs2/target</directory> <directory>mezeo/pcs2/target</directory>
<includes> <includes>
<include>jclouds-pcs2-${project.version}-jar-with-dependencies.jar</include> <include>jclouds-pcs2-${project.version}.jar</include>
</includes> </includes>
<outputDirectory>providers/mezeo/lib</outputDirectory> <outputDirectory>providers/mezeo/lib</outputDirectory>
</fileSet> </fileSet>
@ -253,7 +301,7 @@
<fileSet> <fileSet>
<directory>nirvanix/sdn/target</directory> <directory>nirvanix/sdn/target</directory>
<includes> <includes>
<include>jclouds-sdn-${project.version}-jar-with-dependencies.jar</include> <include>jclouds-sdn-${project.version}.jar</include>
</includes> </includes>
<outputDirectory>providers/nirvanix/lib</outputDirectory> <outputDirectory>providers/nirvanix/lib</outputDirectory>
</fileSet> </fileSet>
@ -280,7 +328,7 @@
<fileSet> <fileSet>
<directory>rackspace/target</directory> <directory>rackspace/target</directory>
<includes> <includes>
<include>jclouds-rackspace-${project.version}-jar-with-dependencies.jar</include> <include>jclouds-rackspace-${project.version}.jar</include>
</includes> </includes>
<outputDirectory>providers/rackspace/lib</outputDirectory> <outputDirectory>providers/rackspace/lib</outputDirectory>
</fileSet> </fileSet>
@ -334,7 +382,7 @@
<fileSet> <fileSet>
<directory>vcloud/terremark/target</directory> <directory>vcloud/terremark/target</directory>
<includes> <includes>
<include>jclouds-terremark-${project.version}-jar-with-dependencies.jar</include> <include>jclouds-terremark-${project.version}.jar</include>
</includes> </includes>
<outputDirectory>providers/terremark/lib</outputDirectory> <outputDirectory>providers/terremark/lib</outputDirectory>
</fileSet> </fileSet>
@ -411,6 +459,33 @@
<outputDirectory>extensions/bouncycastle</outputDirectory> <outputDirectory>extensions/bouncycastle</outputDirectory>
</fileSet> </fileSet>
<!-- profiles: enterprise -->
<fileSet>
<directory>extensions/enterprise/target</directory>
<includes>
<include>jclouds-enterprise-${project.version}-jar-with-dependencies.jar</include>
</includes>
<outputDirectory>profiles/enterprise/lib</outputDirectory>
</fileSet>
<fileSet>
<directory>extensions/enterprise/target</directory>
<includes>
<include>jclouds-enterprise-${project.version}-sources.jar</include>
</includes>
<outputDirectory>profiles/enterprise/src</outputDirectory>
</fileSet>
<fileSet>
<directory>extensions/enterprise/target/apidocs</directory>
<outputDirectory>profiles/enterprise/docs</outputDirectory>
</fileSet>
<fileSet>
<directory>extensions/enterprise</directory>
<includes>
<include>README.txt</include>
</includes>
<outputDirectory>profiles/enterprise</outputDirectory>
</fileSet>
<!-- extensions: gae --> <!-- extensions: gae -->
<fileSet> <fileSet>
<directory>extensions/gae/target</directory> <directory>extensions/gae/target</directory>
@ -469,7 +544,7 @@
<fileSet> <fileSet>
<directory>extensions/httpnio/target</directory> <directory>extensions/httpnio/target</directory>
<includes> <includes>
<include>jclouds-httpnio-${project.version}-jar-with-dependencies.jar</include> <include>jclouds-httpnio-${project.version}.jar</include>
</includes> </includes>
<outputDirectory>extensions/httpnio/lib</outputDirectory> <outputDirectory>extensions/httpnio/lib</outputDirectory>
</fileSet> </fileSet>
@ -496,7 +571,7 @@
<fileSet> <fileSet>
<directory>extensions/jsch/target</directory> <directory>extensions/jsch/target</directory>
<includes> <includes>
<include>jclouds-jsch-${project.version}-jar-with-dependencies.jar</include> <include>jclouds-jsch-${project.version}.jar</include>
</includes> </includes>
<outputDirectory>extensions/ssh/jsch/lib</outputDirectory> <outputDirectory>extensions/ssh/jsch/lib</outputDirectory>
</fileSet> </fileSet>
@ -545,7 +620,61 @@
</includes> </includes>
<outputDirectory>extensions/log4j</outputDirectory> <outputDirectory>extensions/log4j</outputDirectory>
</fileSet> </fileSet>
<!-- tools: antcontrib -->
<fileSet>
<directory>tools/antcontrib/target</directory>
<includes>
<include>jclouds-antcontrib-${project.version}-jar-with-dependencies.jar</include>
</includes>
<outputDirectory>tools/antcontrib/lib</outputDirectory>
</fileSet>
<fileSet>
<directory>tools/antcontrib/target</directory>
<includes>
<include>jclouds-antcontrib-${project.version}-sources.jar</include>
</includes>
<outputDirectory>tools/antcontrib/src</outputDirectory>
</fileSet>
<fileSet>
<directory>tools/antcontrib/target/apidocs</directory>
<outputDirectory>tools/antcontrib/docs</outputDirectory>
</fileSet>
<fileSet>
<directory>tools/antcontrib</directory>
<includes>
<include>README.txt</include>
</includes>
<outputDirectory>tools/antcontrib</outputDirectory>
</fileSet>
<!-- tools: vfs -->
<fileSet>
<directory>tools/vfs/target</directory>
<includes>
<include>jclouds-vfs-${project.version}-jar-with-dependencies.jar</include>
</includes>
<outputDirectory>tools/vfs/lib</outputDirectory>
</fileSet>
<fileSet>
<directory>tools/vfs/target</directory>
<includes>
<include>jclouds-vfs-${project.version}-sources.jar</include>
</includes>
<outputDirectory>tools/vfs/src</outputDirectory>
</fileSet>
<fileSet>
<directory>tools/vfs/target/apidocs</directory>
<outputDirectory>tools/vfs/docs</outputDirectory>
</fileSet>
<fileSet>
<directory>tools/vfs</directory>
<includes>
<include>README.txt</include>
</includes>
<outputDirectory>tools/vfs</outputDirectory>
</fileSet>
<!-- samples --> <!-- samples -->
<fileSet> <fileSet>
<directory>demos/gae-tweetstore/target/jclouds-demo-gae-tweetstore</directory> <directory>demos/gae-tweetstore/target/jclouds-demo-gae-tweetstore</directory>

View File

@ -71,7 +71,7 @@ public interface AsyncBlobStore {
ListenableFuture<Void> clearContainer(String container); ListenableFuture<Void> clearContainer(String container);
/** /**
* @see BlobStore#clearDirectory(String, ListContainerOptions) * @see BlobStore#clearContainer(String, ListContainerOptions)
*/ */
ListenableFuture<Void> clearContainer(String container, ListContainerOptions options); ListenableFuture<Void> clearContainer(String container, ListContainerOptions options);
@ -111,7 +111,7 @@ public interface AsyncBlobStore {
ListenableFuture<BlobMetadata> blobMetadata(String container, String key); ListenableFuture<BlobMetadata> blobMetadata(String container, String key);
/** /**
* @see BlobStore#newBlob(String, String) * @see BlobStore#getBlob(String, String)
*/ */
ListenableFuture<? extends Blob> getBlob(String container, String key); ListenableFuture<? extends Blob> getBlob(String container, String key);

View File

@ -26,12 +26,18 @@ import org.jclouds.blobstore.options.GetOptions;
import org.jclouds.blobstore.options.ListContainerOptions; import org.jclouds.blobstore.options.ListContainerOptions;
/** /**
* Provides hooks needed to run a blob store * Synchronous access to a BlobStore such as Amazon S3
* *
* @author Adrian Cole
* @see AsyncBlobStore * @see AsyncBlobStore
*
* @see BlobStoreContextFactory
*/ */
public interface BlobStore { public interface BlobStore {
/**
* creates a new blob with the specified name.
*/
Blob newBlob(String name); Blob newBlob(String name);
/** /**
@ -39,42 +45,117 @@ public interface BlobStore {
*/ */
PageSet<? extends StorageMetadata> list(); PageSet<? extends StorageMetadata> list();
/**
* determines if a service-level container exists
*/
boolean containerExists(String container); boolean containerExists(String container);
/**
* Creates a namespace for your blobs
* <p/>
*
* A container is a namespace for your objects. Depending on the service, the scope can be
* global, account, or sub-account scoped. For example, in Amazon S3, containers are called
* buckets, and they must be uniquely named such that no-one else in the world conflicts. In
* other blobstores, the naming convention of the container is less strict. All blobstores allow
* you to list your containers and also the contents within them. These contents can either be
* blobs, folders, or virtual paths.
*
* @param location
* some blobstores allow you to specify a location, such as US-EAST, for where this
* container will exist.
* @param container
* namespace. Typically constrained to lowercase alpha-numeric and hyphens.
* @return true if the container was created, false if it already existed.
*/
boolean createContainerInLocation(String location, String container); boolean createContainerInLocation(String location, String container);
/** /**
* Lists all resources available at the specified path. Note that path may be a container, or a * Lists all resources in a container non-recursive.
* path within it delimited by {@code /} characters.
* *
* @param parent * @param container
* - base path to list; non-recursive * what to list
* @return a list that may be incomplete, depending on whether PageSet#getNextMarker is set
*/ */
PageSet<? extends StorageMetadata> list(String container); PageSet<? extends StorageMetadata> list(String container);
/**
* Like {@link #list(String)} except you can control the size, recursion, and context of the list
* using {@link ListContainerOptions options}
*
* @param container
* what to list
* @param options
* size, recursion, and context of the list
* @return a list that may be incomplete, depending on whether PageSet#getNextMarker is set
*/
PageSet<? extends StorageMetadata> list(String container, ListContainerOptions options); PageSet<? extends StorageMetadata> list(String container, ListContainerOptions options);
/** /**
* This will delete the contents of a container without removing it * This will delete the contents of a container at its root path without deleting the container
* *
* @param container * @param container
* what to clear
*/ */
void clearContainer(String container); void clearContainer(String container);
/**
* Like {@link #clearContainer(String)} except you can use options to do things like recursive
* deletes, or clear at a different path than root.
*
* @param container
* what to clear
* @param options
* recursion and path to clear
*/
void clearContainer(String container, ListContainerOptions options); void clearContainer(String container, ListContainerOptions options);
/** /**
* This will delete a container recursively. * This will delete everything inside a container recursively.
* *
* @param container * @param container
* what to delete
*/ */
void deleteContainer(String container); void deleteContainer(String container);
/**
* Determines if a directory exists
*
* @param container
* container where the directory resides
* @param directory
* full path to the directory
*/
boolean directoryExists(String container, String directory); boolean directoryExists(String container, String directory);
/**
* Creates a folder or a directory marker depending on the service
*
* @param container
* container to create the directory in
* @param directory
* full path to the directory
*/
void createDirectory(String container, String directory); void createDirectory(String container, String directory);
/**
* Deletes a folder or a directory marker depending on the service
*
* @param container
* container to delete the directory from
* @param directory
* full path to the directory to delete
*/
void deleteDirectory(String containerName, String name); void deleteDirectory(String containerName, String name);
/**
* Determines if a blob exists
*
* @param container
* container where the blob resides
* @param directory
* full path to the blob
*/
boolean blobExists(String container, String name); boolean blobExists(String container, String name);
/** /**
@ -112,14 +193,25 @@ public interface BlobStore {
* container where this exists. * container where this exists.
* @param name * @param name
* fully qualified name relative to the container. * fully qualified name relative to the container.
* @param options
* byte range or condition options
* @return the blob you intended to receive or null, if it doesn't exist. * @return the blob you intended to receive or null, if it doesn't exist.
* @throws ContainerNotFoundException * @throws ContainerNotFoundException
* if the container doesn't exist * if the container doesn't exist
*/ */
Blob getBlob(String container, String name); Blob getBlob(String container, String name);
/**
* Retrieves a {@code Blob} representing the data at location {@code container/name}
*
* @param container
* container where this exists.
* @param name
* fully qualified name relative to the container.
* @param options
* byte range or condition options
* @return the blob you intended to receive or null, if it doesn't exist.
* @throws ContainerNotFoundException
* if the container doesn't exist
*/
Blob getBlob(String container, String name, GetOptions options); Blob getBlob(String container, String name, GetOptions options);
/** /**
@ -134,8 +226,15 @@ public interface BlobStore {
*/ */
void removeBlob(String container, String name); void removeBlob(String container, String name);
/**
* @return a count of all blobs in the container, excluding directory markers
*/
long countBlobs(String container); long countBlobs(String container);
/**
* @return a count of all blobs that are in a listing constrained by the options specified,
* excluding directory markers
*/
long countBlobs(String container, ListContainerOptions options); long countBlobs(String container, ListContainerOptions options);
} }

View File

@ -26,8 +26,8 @@ import org.jclouds.rest.RestContext;
import com.google.inject.ImplementedBy; import com.google.inject.ImplementedBy;
/** /**
* Represents a cloud that has key-value storage functionality. * Represents a cloud that has key-value storage functionality. This object is scoped to a service
* * and an account.
* *
* @author Adrian Cole * @author Adrian Cole
* *
@ -36,30 +36,78 @@ import com.google.inject.ImplementedBy;
public interface BlobStoreContext { public interface BlobStoreContext {
/** /**
* Creates a <code>Map<String,InputStream></code> view of the specified container. * Creates a <code>Map<String,InputStream></code> view of the specified container. Use this for
* simplest access to blobstore, knowing that MD5s will be calculated for every object.
* *
* @param container * @param container
* existing container you wish to read or modify
* @param options
* allow you to specify a directory within the container, or whether to list
* recursively.
*/ */
InputStreamMap createInputStreamMap(String container, ListContainerOptions options); InputStreamMap createInputStreamMap(String container, ListContainerOptions options);
/**
* Creates a <code>Map<String,InputStream></code> view of the specified container. Use this for
* simplest access to blobstore, knowing that MD5s will be calculated for every object.
*
* Only root-level blobs will be visible.
*
* @param container
* existing container you wish to read or modify
*/
InputStreamMap createInputStreamMap(String container); InputStreamMap createInputStreamMap(String container);
/** /**
* Creates a <code>Map<String,B></code> view of the specified container. * Creates a <code>Map<String,Blob></code> view of the specified container. Use this when you wan
* to control the content type, or manually specify length or size of blobs.
* *
* @param container * @param container
* existing container you wish to read or modify
* @param options
* allow you to specify a directory within the container, or whether to list
* recursively.
*/ */
BlobMap createBlobMap(String container, ListContainerOptions options); BlobMap createBlobMap(String container, ListContainerOptions options);
/**
* Creates a <code>Map<String,Blob></code> view of the specified container. Use this when you wan
* to control the content type, or manually specify length or size of blobs.
*
* Only root-level blobs will be visible.
*
* @param container
* existing container you wish to read or modify
*/
BlobMap createBlobMap(String container); BlobMap createBlobMap(String container);
/**
* @return a portable asynchronous interface for the BlobStore, which returns {@code Future}s for
* each call.
*/
AsyncBlobStore getAsyncBlobStore(); AsyncBlobStore getAsyncBlobStore();
/**
* @return a portable interface for the BlobStore.
*/
BlobStore getBlobStore(); BlobStore getBlobStore();
/**
*
* @return best guess at the consistency model used in this BlobStore.
*/
ConsistencyModels getConsistencyModel(); ConsistencyModels getConsistencyModel();
/**
*
* @return a context you can use to the access provider or vendor specific api underlying this
* context.
*/
<A, S> RestContext<A, S> getProviderSpecificContext(); <A, S> RestContext<A, S> getProviderSpecificContext();
/**
* closes threads and resources related to this connection.
*
*/
void close(); void close();
} }

View File

@ -28,6 +28,13 @@ import org.jclouds.rest.RestContextFactory;
/** /**
* Helper class to instantiate {@code BlobStoreContext} instances. * Helper class to instantiate {@code BlobStoreContext} instances.
* *
* <h3>Example usage</h3>
*
* <pre>
* BlobStoreContext context = new BlobStoreContextFactory()
* .createContext(&quot;s3&quot;, accesskeyid, secretkey);
* </pre>
*
* @author Adrian Cole * @author Adrian Cole
*/ */
public class BlobStoreContextFactory extends public class BlobStoreContextFactory extends
@ -54,6 +61,9 @@ public class BlobStoreContextFactory extends
super(properties); super(properties);
} }
/**
* {@inheritDoc}
*/
@Override @Override
protected BlobStoreContext build(BlobStoreContextBuilder<?, ?> contextBuilder) { protected BlobStoreContext build(BlobStoreContextBuilder<?, ?> contextBuilder) {
return contextBuilder.buildBlobStoreContext(); return contextBuilder.buildBlobStoreContext();

View File

@ -24,15 +24,21 @@ import com.google.common.collect.Multimap;
import com.google.inject.internal.Nullable; import com.google.inject.internal.Nullable;
/** /**
* Value type for an HTTP Blob service. Blobs are stored in containers and consist * Value type for an HTTP Blob service. Blobs are stored in containers and consist of a
* of a {@link org.jclouds.blobstore.domain.Value#getContent() value}, a {@link Blob#getKey key and * {@link MutableBlobMetadata#getName name}, {@link Payload payload}, and
* * {@link MutableBlobMetadata metadata}.
* @link Blob.Metadata#getUserMetadata() metadata}
* *
* @author Adrian Cole * @author Adrian Cole
*/ */
public interface Blob extends PayloadEnclosing, Comparable<Blob> { public interface Blob extends PayloadEnclosing, Comparable<Blob> {
/**
* Allows you to construct blobs without knowing the implementation type
*/
public interface Factory { public interface Factory {
/**
* Creates a blob, optionally setting its metadata to a known value. This is useful in making
* copies of blobs.
*/
Blob create(@Nullable MutableBlobMetadata metadata); Blob create(@Nullable MutableBlobMetadata metadata);
} }
@ -41,8 +47,15 @@ public interface Blob extends PayloadEnclosing, Comparable<Blob> {
*/ */
MutableBlobMetadata getMetadata(); MutableBlobMetadata getMetadata();
/**
* @return headers returned from the services
*/
Multimap<String, String> getAllHeaders(); Multimap<String, String> getAllHeaders();
/**
*
* @see #getAllHeaders
*/
void setAllHeaders(Multimap<String, String> allHeaders); void setAllHeaders(Multimap<String, String> allHeaders);
} }

View File

@ -47,7 +47,7 @@ public interface ComputeService {
* it is a good indicator of relative speed within a cloud. memory is measured in megabytes and * it is a good indicator of relative speed within a cloud. memory is measured in megabytes and
* disks in gigabytes. * disks in gigabytes.
* *
* @retun a map of sizes by ID, conceding that in some clouds the "id" is not used. * @return a map of sizes by ID, conceding that in some clouds the "id" is not used.
*/ */
Map<String, ? extends Size> getSizes(); Map<String, ? extends Size> getSizes();

View File

@ -39,7 +39,7 @@ public class ComputeServiceContextFactory extends
* *
* @throws IOException * @throws IOException
* if the default properties file cannot be loaded * if the default properties file cannot be loaded
* @see RestContextFactory#getProperties * @see RestContextFactory#getPropertiesFromResource
*/ */
public ComputeServiceContextFactory() throws IOException { public ComputeServiceContextFactory() throws IOException {
super("compute.properties"); super("compute.properties");

View File

@ -42,7 +42,7 @@ import com.google.common.annotations.VisibleForTesting;
public abstract class PropertiesBuilder { public abstract class PropertiesBuilder {
/** /**
* @see org.jclouds.http.Constants.PROPERTY_RELAX_HOSTNAME * @see org.jclouds.Constants.PROPERTY_RELAX_HOSTNAME
*/ */
public PropertiesBuilder relaxSSLHostname(boolean relax) { public PropertiesBuilder relaxSSLHostname(boolean relax) {
properties.setProperty(PROPERTY_RELAX_HOSTNAME, relax + ""); properties.setProperty(PROPERTY_RELAX_HOSTNAME, relax + "");
@ -50,7 +50,7 @@ public abstract class PropertiesBuilder {
} }
/** /**
* @see org.jclouds.http.Constants.PROPERTY_PROXY_SYSTEM * @see org.jclouds.Constants.PROPERTY_PROXY_SYSTEM
*/ */
public PropertiesBuilder useSystemProxies(boolean useSystemProxies) { public PropertiesBuilder useSystemProxies(boolean useSystemProxies) {
properties.setProperty(PROPERTY_PROXY_SYSTEM, useSystemProxies + ""); properties.setProperty(PROPERTY_PROXY_SYSTEM, useSystemProxies + "");
@ -58,7 +58,7 @@ public abstract class PropertiesBuilder {
} }
/** /**
* @see org.jclouds.http.Constants.PROPERTY_MAX_RETRIES * @see org.jclouds.Constants.PROPERTY_MAX_RETRIES
*/ */
public PropertiesBuilder withHttpMaxRetries(int httpMaxRetries) { public PropertiesBuilder withHttpMaxRetries(int httpMaxRetries) {
properties.setProperty(PROPERTY_MAX_RETRIES, Integer.toString(httpMaxRetries)); properties.setProperty(PROPERTY_MAX_RETRIES, Integer.toString(httpMaxRetries));
@ -66,7 +66,7 @@ public abstract class PropertiesBuilder {
} }
/** /**
* @see org.jclouds.http.Constants.PROPERTY_MAX_REDIRECTS * @see org.jclouds.Constants.PROPERTY_MAX_REDIRECTS
*/ */
public PropertiesBuilder withHttpMaxRedirects(int httpMaxRedirects) { public PropertiesBuilder withHttpMaxRedirects(int httpMaxRedirects) {
properties.setProperty(PROPERTY_MAX_REDIRECTS, Integer.toString(httpMaxRedirects)); properties.setProperty(PROPERTY_MAX_REDIRECTS, Integer.toString(httpMaxRedirects));
@ -74,7 +74,7 @@ public abstract class PropertiesBuilder {
} }
/** /**
* @see org.jclouds.http.Constants.PROPERTY_MAX_CONNECTION_REUSE * @see org.jclouds.Constants.PROPERTY_MAX_CONNECTION_REUSE
*/ */
public PropertiesBuilder withMaxClientReuse(int poolMaxClientReuse) { public PropertiesBuilder withMaxClientReuse(int poolMaxClientReuse) {
properties.setProperty(PROPERTY_MAX_CONNECTION_REUSE, Integer.toString(poolMaxClientReuse)); properties.setProperty(PROPERTY_MAX_CONNECTION_REUSE, Integer.toString(poolMaxClientReuse));
@ -82,7 +82,7 @@ public abstract class PropertiesBuilder {
} }
/** /**
* @see org.jclouds.http.Constants.PROPERTY_MAX_SESSION_FAILURES * @see org.jclouds.Constants.PROPERTY_MAX_SESSION_FAILURES
*/ */
public PropertiesBuilder withMaxSessionFailures(int poolMaxSessionFailures) { public PropertiesBuilder withMaxSessionFailures(int poolMaxSessionFailures) {
properties.setProperty(PROPERTY_MAX_SESSION_FAILURES, Integer properties.setProperty(PROPERTY_MAX_SESSION_FAILURES, Integer
@ -92,7 +92,7 @@ public abstract class PropertiesBuilder {
} }
/** /**
* @see org.jclouds.http.Constants.PROPERTY_IO_WORKER_THREADS * @see org.jclouds.Constants.PROPERTY_IO_WORKER_THREADS
*/ */
public PropertiesBuilder limitIoWorkerThreadsTo(int poolIoWorkerThreads) { public PropertiesBuilder limitIoWorkerThreadsTo(int poolIoWorkerThreads) {
properties.setProperty(PROPERTY_IO_WORKER_THREADS, Integer.toString(poolIoWorkerThreads)); properties.setProperty(PROPERTY_IO_WORKER_THREADS, Integer.toString(poolIoWorkerThreads));
@ -100,7 +100,7 @@ public abstract class PropertiesBuilder {
} }
/** /**
* @see org.jclouds.http.Constants.PROPERTY_IO_WORKER_THREADS * @see org.jclouds.Constants.PROPERTY_IO_WORKER_THREADS
*/ */
public PropertiesBuilder limitUserThreadsTo(int poolIoWorkerThreads) { public PropertiesBuilder limitUserThreadsTo(int poolIoWorkerThreads) {
properties.setProperty(PROPERTY_USER_THREADS, Integer.toString(poolIoWorkerThreads)); properties.setProperty(PROPERTY_USER_THREADS, Integer.toString(poolIoWorkerThreads));
@ -108,7 +108,7 @@ public abstract class PropertiesBuilder {
} }
/** /**
* @see org.jclouds.http.Constants.PROPERTY_MAX_CONNECTIONS_PER_CONTEXT * @see org.jclouds.Constants.PROPERTY_MAX_CONNECTIONS_PER_CONTEXT
*/ */
public PropertiesBuilder limitConnectionsTo(int connectionLimit) { public PropertiesBuilder limitConnectionsTo(int connectionLimit) {
properties.setProperty(PROPERTY_MAX_CONNECTIONS_PER_CONTEXT, Integer properties.setProperty(PROPERTY_MAX_CONNECTIONS_PER_CONTEXT, Integer
@ -117,7 +117,7 @@ public abstract class PropertiesBuilder {
} }
/** /**
* @see org.jclouds.http.Constants.PROPERTY_MAX_CONNECTIONS_PER_HOST * @see org.jclouds.Constants.PROPERTY_MAX_CONNECTIONS_PER_HOST
*/ */
public PropertiesBuilder limitConnectionsPerHostTo(int connectionLimit) { public PropertiesBuilder limitConnectionsPerHostTo(int connectionLimit) {
properties.setProperty(PROPERTY_MAX_CONNECTIONS_PER_HOST, Integer.toString(connectionLimit)); properties.setProperty(PROPERTY_MAX_CONNECTIONS_PER_HOST, Integer.toString(connectionLimit));

View File

@ -49,7 +49,7 @@ public interface MutableResourceMetadata<T extends Enum<T>> extends ResourceMeta
void setName(String name); void setName(String name);
/** /**
* @see #getLocation * @see #getLocationId
*/ */
void setLocationId(String location); void setLocationId(String location);

View File

@ -29,14 +29,14 @@ public interface HttpCommand {
/** /**
* increments the current number of redirect attempts for this command. * increments the current number of redirect attempts for this command.
* *
* @see getRedirectCount * @see #getRedirectCount
*/ */
int incrementRedirectCount(); int incrementRedirectCount();
/** /**
* This displays the current number of redirect attempts for this command. * This displays the current number of redirect attempts for this command.
* *
* @see org.jclouds.http.Constants.PROPERTY_HTTP_MAX_REDIRECTS * @see org.jclouds.Constants.PROPERTY_MAX_REDIRECTS
*/ */
int getRedirectCount(); int getRedirectCount();
@ -64,14 +64,14 @@ public interface HttpCommand {
/** /**
* increment the current failure count. * increment the current failure count.
* *
* @see getFailureCount * @see #getFailureCount
*/ */
int incrementFailureCount(); int incrementFailureCount();
/** /**
* This displays the current number of error retries for this command. * This displays the current number of error retries for this command.
* *
* @see org.jclouds.http.Constants.PROPERTY_HTTP_MAX_RETRIES * @see org.jclouds.Constants.PROPERTY_MAX_RETRIES
*/ */
int getFailureCount(); int getFailureCount();
@ -86,7 +86,7 @@ public interface HttpCommand {
void setException(Exception exception); void setException(Exception exception);
/** /**
* @see setException * @see #setException
*/ */
Exception getException(); Exception getException();

View File

@ -31,8 +31,6 @@ public interface HttpCommandExecutorService {
* Asks the command to build a request relevant for an endpoint that produces responses of * Asks the command to build a request relevant for an endpoint that produces responses of
* generic type {@code HttpResponse}. and invokes it on the endpoint, returning a future * generic type {@code HttpResponse}. and invokes it on the endpoint, returning a future
* *
* @param <T>
* type of result the command extracts from the return value
* @param command * @param command
* that generates requests * that generates requests
* @return {@link ListenableFuture} containing the response from the {@code endpoint} * @return {@link ListenableFuture} containing the response from the {@code endpoint}

View File

@ -93,7 +93,7 @@ public class HttpRequest extends HttpMessage {
* We cannot return an enum, as per specification custom methods are allowed. Enums are not * We cannot return an enum, as per specification custom methods are allowed. Enums are not
* extensible. * extensible.
* *
* @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec5.html#sec5.1.1 * @see <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec5.html#sec5.1.1" >rfc2616</a>
*/ */
public String getMethod() { public String getMethod() {
return method; return method;

View File

@ -131,7 +131,6 @@ public class HttpUtils {
* breaks, if there are special characters like '/' present. Otherwise, we wouldn't need this * breaks, if there are special characters like '/' present. Otherwise, we wouldn't need this
* class, and we could simply use URI.create("uri").getUserData(); * class, and we could simply use URI.create("uri").getUserData();
* *
* @author Adrian Cole
*/ */
public static URI createUri(String uriPath) { public static URI createUri(String uriPath) {
if (uriPath.indexOf('@') != 1) { if (uriPath.indexOf('@') != 1) {

View File

@ -48,7 +48,7 @@ public interface PayloadEnclosing {
Payload getPayload(); Payload getPayload();
/** /**
* @return InputStream, if downloading, or whatever was set during {@link #setPayload(Object)} * @return InputStream, if downloading, or whatever was set during {@link #setPayload(Payload)}
*/ */
InputStream getContent(); InputStream getContent();
@ -61,8 +61,8 @@ public interface PayloadEnclosing {
* range, or startAt. * range, or startAt.
* *
* @return the length in bytes that can be be obtained from {@link #getContent()} * @return the length in bytes that can be be obtained from {@link #getContent()}
* @see org.jclouds.http.HttpHeaders#CONTENT_LENGTH * @see javax.ws.rs.core.HttpHeaders#CONTENT_LENGTH
* @see GetObjectOptions * @see org.jclouds.http.options.GetOptions
*/ */
Long getContentLength(); Long getContentLength();

View File

@ -37,7 +37,7 @@ import com.google.common.util.concurrent.ListenableFuture;
* Executor which will invoke and transform the response of an {@code EndpointCommand} into generic * Executor which will invoke and transform the response of an {@code EndpointCommand} into generic
* type <T>. * type <T>.
* *
* @see TransformingEndpointCommand * @see TransformingHttpCommand
* *
* @author Adrian Cole * @author Adrian Cole
*/ */
@ -83,6 +83,7 @@ public class TransformingHttpCommandImpl<T> implements TransformingHttpCommand<T
* <p /> * <p />
* This also removes the Host header in order to avoid ssl problems. * This also removes the Host header in order to avoid ssl problems.
*/ */
@Override
public void changeHostAndPortTo(String host, int port) { public void changeHostAndPortTo(String host, int port) {
UriBuilder builder = UriBuilder.fromUri(request.getEndpoint()); UriBuilder builder = UriBuilder.fromUri(request.getEndpoint());
builder.host(host); builder.host(host);
@ -92,9 +93,9 @@ public class TransformingHttpCommandImpl<T> implements TransformingHttpCommand<T
} }
/** /**
* mutable for redirects * in some scenarios, HEAD commands cannot be redirected. This method changes the request to GET
* in such a case.
* *
* @param method
*/ */
public void changeToGETRequest() { public void changeToGETRequest() {
request.setMethod(HttpMethod.GET); request.setMethod(HttpMethod.GET);
@ -120,11 +121,6 @@ public class TransformingHttpCommandImpl<T> implements TransformingHttpCommand<T
return (request.getPayload() == null) ? true : request.getPayload().isRepeatable(); return (request.getPayload() == null) ? true : request.getPayload().isRepeatable();
} }
/**
* public void checkCode() { int code = getResponse().getStatusCode(); if (code >= 300) {
* Closeables.closeQuietly(getResponse().getContent()); throw new
* IllegalStateException("incorrect code for this operation: " + getResponse()); } }
**/
public HttpRequest getRequest() { public HttpRequest getRequest() {
return request; return request;
} }
@ -136,7 +132,7 @@ public class TransformingHttpCommandImpl<T> implements TransformingHttpCommand<T
@Override @Override
public String toString() { public String toString() {
return "TransformingHttpCommandImpl [request=" + request.getRequestLine() + "]"; return "[request=" + request.getRequestLine() + "]";
} }
} }

View File

@ -42,6 +42,10 @@ import org.jclouds.logging.Logger;
import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.ListenableFuture;
/**
*
* @author Adrian Cole
*/
public abstract class BaseHttpCommandExecutorService<Q> implements HttpCommandExecutorService { public abstract class BaseHttpCommandExecutorService<Q> implements HttpCommandExecutorService {
private final DelegatingRetryHandler retryHandler; private final DelegatingRetryHandler retryHandler;
@ -123,16 +127,6 @@ public abstract class BaseHttpCommandExecutorService<Q> implements HttpCommandEx
protected abstract Q convert(HttpRequest request) throws IOException, InterruptedException; protected abstract Q convert(HttpRequest request) throws IOException, InterruptedException;
/**
*
* FIXME Comment this
*
* @param nativeRequest
* @return
* @throws IOException
* @throws InterruptedException
* if interrupted waiting for a connection.
*/
protected abstract HttpResponse invoke(Q nativeRequest) throws IOException, InterruptedException; protected abstract HttpResponse invoke(Q nativeRequest) throws IOException, InterruptedException;
protected abstract void cleanup(Q nativeResponse); protected abstract void cleanup(Q nativeResponse);

View File

@ -26,10 +26,8 @@ import org.jclouds.logging.Logger;
import org.jclouds.logging.internal.Wire; import org.jclouds.logging.internal.Wire;
/** /**
* Logs data to the wire LOG.
* *
* @author Adrian Cole * @author Adrian Cole
* @see org.apache.HttpWire.impl.conn.Wire
*/ */
public class HttpWire extends Wire { public class HttpWire extends Wire {

View File

@ -26,10 +26,7 @@ import org.jclouds.logging.Logger;
import org.jclouds.logging.internal.Wire; import org.jclouds.logging.internal.Wire;
/** /**
* Logs data to the wire LOG.
*
* @author Adrian Cole * @author Adrian Cole
* @see org.apache.HttpWire.impl.conn.Wire
*/ */
public class SignatureWire extends Wire { public class SignatureWire extends Wire {

View File

@ -44,8 +44,8 @@ import com.google.common.collect.Multimap;
* import static org.jclouds.http.options.GetOptions.Builder.* * import static org.jclouds.http.options.GetOptions.Builder.*
* *
* *
* // this will get the first megabyte of an object, provided it wasn't modified since yesterday * // this will get the first megabyte of an object.
* ListenableFuture<S3Object> object = client.get("objectName",range(0,1024).ifUnmodifiedSince(new Date().minusDays(1))); * blob = client.get("objectName",range(0,1024));
* <code> * <code>
* *
* @author Adrian Cole * @author Adrian Cole
@ -106,7 +106,7 @@ public class GetOptions extends BaseHttpRequestOptions {
/** /**
* Only return the object if it has changed since this time. * Only return the object if it has changed since this time.
* <p /> * <p />
* Not compatible with {@link #ifETagMatches(byte[])} or {@link #ifUnmodifiedSince(Date)} * Not compatible with {@link #ifETagMatches(String)} or {@link #ifUnmodifiedSince(Date)}
*/ */
public GetOptions ifModifiedSince(Date ifModifiedSince) { public GetOptions ifModifiedSince(Date ifModifiedSince) {
checkArgument(getIfMatch() == null, checkArgument(getIfMatch() == null,
@ -124,7 +124,7 @@ public class GetOptions extends BaseHttpRequestOptions {
* Return the object only if it has been modified since the specified time, otherwise return a * Return the object only if it has been modified since the specified time, otherwise return a
* 304 (not modified). * 304 (not modified).
* *
* @see GetOptions#ifModifiedSince(Date) * @see #ifModifiedSince(Date)
*/ */
public String getIfModifiedSince() { public String getIfModifiedSince() {
return this.getFirstHeaderOrNull(HttpHeaders.IF_MODIFIED_SINCE); return this.getFirstHeaderOrNull(HttpHeaders.IF_MODIFIED_SINCE);
@ -133,7 +133,7 @@ public class GetOptions extends BaseHttpRequestOptions {
/** /**
* Only return the object if it hasn't changed since this time. * Only return the object if it hasn't changed since this time.
* <p /> * <p />
* Not compatible with {@link #ifETagDoesntMatch(byte[])} or {@link #ifModifiedSince(Date)} * Not compatible with {@link #ifETagDoesntMatch(String)} or {@link #ifModifiedSince(Date)}
*/ */
public GetOptions ifUnmodifiedSince(Date ifUnmodifiedSince) { public GetOptions ifUnmodifiedSince(Date ifUnmodifiedSince) {
checkArgument(getIfNoneMatch() == null, checkArgument(getIfNoneMatch() == null,
@ -151,7 +151,7 @@ public class GetOptions extends BaseHttpRequestOptions {
* Return the object only if it has not been modified since the specified time, otherwise return * Return the object only if it has not been modified since the specified time, otherwise return
* a 412 (precondition failed). * a 412 (precondition failed).
* *
* @see GetOptions#ifUnmodifiedSince(Date) * @see #ifUnmodifiedSince(Date)
*/ */
public String getIfUnmodifiedSince() { public String getIfUnmodifiedSince() {
return this.getFirstHeaderOrNull(HttpHeaders.IF_UNMODIFIED_SINCE); return this.getFirstHeaderOrNull(HttpHeaders.IF_UNMODIFIED_SINCE);
@ -183,7 +183,7 @@ public class GetOptions extends BaseHttpRequestOptions {
* Return the object only if its payload tag (ETag) is the same as the eTag specified, otherwise * Return the object only if its payload tag (ETag) is the same as the eTag specified, otherwise
* return a 412 (precondition failed). * return a 412 (precondition failed).
* *
* @see GetOptions#ifETagMatches(byte[]) * @see #ifETagMatches(String)
*/ */
public String getIfMatch() { public String getIfMatch() {
return this.getFirstHeaderOrNull(HttpHeaders.IF_MATCH); return this.getFirstHeaderOrNull(HttpHeaders.IF_MATCH);
@ -215,7 +215,7 @@ public class GetOptions extends BaseHttpRequestOptions {
* Return the object only if its payload tag (ETag) is different from the one specified, otherwise * Return the object only if its payload tag (ETag) is different from the one specified, otherwise
* return a 304 (not modified). * return a 304 (not modified).
* *
* @see GetOptions#ifETagDoesntMatch(byte[]) * @see #ifETagDoesntMatch(String)
*/ */
public String getIfNoneMatch() { public String getIfNoneMatch() {
return this.getFirstHeaderOrNull(HttpHeaders.IF_NONE_MATCH); return this.getFirstHeaderOrNull(HttpHeaders.IF_NONE_MATCH);

View File

@ -1,204 +0,0 @@
/**
*
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ====================================================================
*/
package org.jclouds.io;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
/**
* Ported from org.apache.commons.io.input.TeeInputStream
*
* InputStream proxy that transparently writes a copy of all bytes read from the delegate stream to
* a given OutputStream. Using {@link #skip(long)} or {@link #mark(int)}/{@link #reset()} on the
* stream will result on some bytes from the input stream being skipped or duplicated in the output
* stream.
* <p>
* The delegate input stream is closed when the {@link #close()} method is called on this proxy. It
* is configurable whether the associated output stream will also closed.
*
* @see Commons IO 1.4
* @see org.apache.commons.io.input.TeeInputStream
*/
public class TeeInputStream extends InputStream {
/**
* The input stream to delegate to.
*/
private final InputStream delegate;
/**
* The output stream that will receive a copy of all bytes read from the delegate input stream.
*/
private final OutputStream branch;
/**
* Flag for closing also the associated output stream when this stream is closed.
*/
private final boolean closeBranch;
/**
* Creates a TeeInputStream that delegates to the given {@link InputStream} and copies all read
* bytes to the given {@link OutputStream}. The given output stream will not be closed when this
* stream gets closed.
*
* @param input
* input stream to be delegate
* @param branch
* output stream that will receive a copy of all bytes read
*/
public TeeInputStream(InputStream delegate, OutputStream branch) {
this(delegate, branch, false);
}
/**
* Creates a TeeInputStream that proxies the given {@link InputStream} and copies all read bytes
* to the given {@link OutputStream}. The given output stream will be closed when this stream
* gets closed if the closeBranch parameter is <code>true</code>.
*
* @param input
* input stream to be delegate
* @param branch
* output stream that will receive a copy of all bytes read
* @param closeBranch
* flag for closing also the output stream when this stream is closed
*/
public TeeInputStream(InputStream delegate, OutputStream branch, boolean closeBranch) {
this.delegate = delegate;
this.branch = branch;
this.closeBranch = closeBranch;
}
/**
* Closes the delegate input stream and, if so configured, the associated output stream. An
* exception thrown from one stream will not prevent closing of the other stream.
*
* @throws IOException
* if either of the streams could not be closed
*/
@Override
public void close() throws IOException {
try {
delegate.close();
} finally {
if (closeBranch) {
branch.close();
}
}
}
/**
* Reads a single byte from the delegate input stream and writes it to the associated output
* stream.
*
* @return next byte from the stream, or -1 if the stream has ended
* @throws IOException
* if the stream could not be read (or written)
*/
public int read() throws IOException {
int ch = delegate.read();
if (ch != -1) {
branch.write(ch);
}
return ch;
}
/**
* Reads bytes from the delegate input stream and writes the read bytes to the associated output
* stream.
*
* @param bts
* byte buffer
* @param st
* start offset within the buffer
* @param end
* maximum number of bytes to read
* @return number of bytes read, or -1 if the stream has ended
* @throws IOException
* if the stream could not be read (or written)
*/
@Override
public int read(byte[] bts, int st, int end) throws IOException {
int n = delegate.read(bts, st, end);
if (n != -1) {
branch.write(bts, st, n);
}
return n;
}
/**
* Reads bytes from the delegate input stream and writes the read bytes to the associated output
* stream.
*
* @param bts
* byte buffer
* @return number of bytes read, or -1 if the stream has ended
* @throws IOException
* if the stream could not be read (or written)
*/
@Override
public int read(byte[] bts) throws IOException {
int n = delegate.read(bts);
if (n != -1) {
branch.write(bts, 0, n);
}
return n;
}
/**
* {@inheritDoc}
*/
@Override
public int available() throws IOException {
return delegate.available();
}
/**
* {@inheritDoc}
*/
@Override
public synchronized void mark(int readlimit) {
delegate.mark(readlimit);
}
/**
* {@inheritDoc}
*/
@Override
public boolean markSupported() {
return delegate.markSupported();
}
/**
* {@inheritDoc}
*/
@Override
public synchronized void reset() throws IOException {
delegate.reset();
}
/**
* {@inheritDoc}
*/
@Override
public long skip(long n) throws IOException {
return delegate.skip(n);
}
}

View File

@ -46,7 +46,7 @@ import com.google.inject.spi.TypeListener;
/** /**
* This associates java lifecycle annotations with guice hooks. For example, we invoke * This associates java lifecycle annotations with guice hooks. For example, we invoke
* {@link PostConstruct} after injection, and Associate {@link PostDestroy} with a global * {@link PostConstruct} after injection, and Associate {@link PreDestroy} with a global
* {@link Closer} object. * {@link Closer} object.
* *
* @author Adrian Cole * @author Adrian Cole

View File

@ -36,10 +36,9 @@ import com.google.common.io.Closeables;
import com.google.common.io.FileBackedOutputStream; import com.google.common.io.FileBackedOutputStream;
/** /**
* Logs data to the wire LOG. * Logs data to the wire LOG, similar to {@code org.apache.HttpWire.impl.conn.Wire}
* *
* @author Adrian Cole * @author Adrian Cole
* @see org.apache.HttpWire.impl.conn.Wire
*/ */
public abstract class Wire { public abstract class Wire {

View File

@ -180,5 +180,9 @@ public abstract class RestContextFactory<T, B extends RestContextBuilder<?, ?>>
} }
} }
/**
* Hook so that you can specify how to create an object using the contextBuilder produced with
* this factory.
*/
protected abstract T build(B contextBuilder); protected abstract T build(B contextBuilder);
} }

View File

@ -42,7 +42,7 @@ public @interface Headers {
/** /**
* @see HttpHeaders * @see HttpHeaders
*/ */
String [] keys(); String[] keys();
/** /**
* can be defined literally, or with enclosed variables (ex. <code>{variable}</code>) * can be defined literally, or with enclosed variables (ex. <code>{variable}</code>)
@ -50,9 +50,8 @@ public @interface Headers {
* The inputs to these variables are taken from method parameters annotated with {@code * The inputs to these variables are taken from method parameters annotated with {@code
* @PathParam}. * @PathParam}.
* *
* @see PathParam * @see javax.ws.rs.PathParam
* *
* @return
*/ */
String [] values(); String[] values();
} }

View File

@ -51,4 +51,26 @@
--> -->
</dependencies> </dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project> </project>

View File

@ -45,7 +45,6 @@ import com.google.common.collect.MapMaker;
import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.ListenableFuture;
/** /**
* // TODO: Adrian: Document this!
* *
* @author Adrian Cole * @author Adrian Cole
*/ */
@ -123,7 +122,7 @@ public class ConnectionPoolTransformingHttpCommandExecutorService<C> extends Bas
/** /**
* This is an asynchronous operation that puts the <code>command</code> onto a queue. Later, it * This is an asynchronous operation that puts the <code>command</code> onto a queue. Later, it
* will be processed via the {@link #invoke(TransformingHttpCommandExecutorService) invoke} * will be processed via the {@link #invoke(HttpCommandRendezvous) invoke}
* method. * method.
*/ */
public <T> ListenableFuture<T> submit(HttpCommand command, public <T> ListenableFuture<T> submit(HttpCommand command,

View File

@ -536,41 +536,6 @@ pageTracker._trackPageview();
</dependency> </dependency>
</dependencies> </dependencies>
</plugin> </plugin>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>repackage-jar-with-dependencies</id>
<phase>package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<taskdef name="jarjar" classname="com.tonicsystems.jarjar.JarJarTask"/>
<jarjar destfile="${build.directory}/${build.finalName}-jar-with-dependencies.jar" update="true">
<!-- Replace "x.y.." with "org.jclouds.repackaged.x.y..". Note: can't deal with package-info.class files.
See http://code.google.com/p/jarjar/wiki/CommandLineDocs for more information on jarjar rules. -->
<rule pattern="javax.annotation.**" result="${project.groupId}.repackaged.@0"/>
<rule pattern="javax.inject.**" result="${project.groupId}.repackaged.@0"/>
<rule pattern="javax.ws.**" result="${project.groupId}.repackaged.@0"/>
<!-- google-guava and google-collections -->
<rule pattern="com.google.common.**" result="${project.groupId}.repackaged.@0"/>
<!-- guice -->
<rule pattern="com.google.inject.**" result="${project.groupId}.repackaged.@0"/>
</jarjar>
</tasks>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>com.tonicsystems.jarjar</groupId>
<artifactId>jarjar</artifactId>
<version>1.0-rc8</version>
</dependency>
</dependencies>
</plugin>
</plugins> </plugins>
</build> </build>
</profile> </profile>

View File

@ -61,7 +61,7 @@ public class Statements {
/** /**
* *
* Runs the script in a way that it can be matched later with {@link findPid} * Runs the script in a way that it can be matched later with {@link #findPid}
* *
* @param instanceName * @param instanceName
* - what to match the process on * - what to match the process on

View File

@ -114,20 +114,18 @@
<property name="location" value="" /> <property name="location" value="" />
<target name="create" description="create the node ${nodetag}"> <target name="create" description="create the node ${nodetag}">
<property name="privatekeyfile" value="${user.home}/.ssh/id_rsa" />
<property name="publickeyfile" value="${user.home}/.ssh/id_rsa.pub" />
<property name="os" value="UBUNTU" /> <property name="os" value="UBUNTU" />
<property name="count" value="1" />
<input <input
message="What do you want to tag your nodes with?" message="What do you want to tag your nodes with?"
addproperty="nodetag" addproperty="nodetag"
/> />
<input
message="How many nodes would you like to create?"
addproperty="count"
/>
<compute actions="create" provider="${jclouds.compute.url}"> <compute actions="create" provider="${jclouds.compute.url}">
<nodes tag="${nodetag}" count="${count}" os="${os}" size="SMALLEST" hostproperty="host" usernameproperty="username" passwordproperty="password" /> <nodes privatekeyfile="${privatekeyfile}" publickeyfile="${publickeyfile}" tag="${nodetag}" count="${count}" os="${os}" size="SMALLEST" hostproperty="host" usernameproperty="username" passwordproperty="password" />
</compute> </compute>
</target> </target>

View File

@ -23,10 +23,8 @@ import static org.jclouds.tools.ant.taskdefs.compute.ComputeTaskUtils.buildCompu
import static org.jclouds.tools.ant.taskdefs.compute.ComputeTaskUtils.createTemplateFromElement; import static org.jclouds.tools.ant.taskdefs.compute.ComputeTaskUtils.createTemplateFromElement;
import static org.jclouds.tools.ant.taskdefs.compute.ComputeTaskUtils.ipOrEmptyString; import static org.jclouds.tools.ant.taskdefs.compute.ComputeTaskUtils.ipOrEmptyString;
import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.net.URI; import java.net.URI;
import java.nio.charset.Charset;
import java.util.Map; import java.util.Map;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@ -46,7 +44,6 @@ import org.jclouds.http.HttpUtils;
import com.google.common.base.CaseFormat; import com.google.common.base.CaseFormat;
import com.google.common.base.Splitter; import com.google.common.base.Splitter;
import com.google.common.io.Files;
import com.google.inject.Provider; import com.google.inject.Provider;
/** /**
@ -193,31 +190,17 @@ public class ComputeTask extends Task {
for (NodeMetadata createdNode : computeService.runNodesWithTag(tag, nodeElement.getCount(), for (NodeMetadata createdNode : computeService.runNodesWithTag(tag, nodeElement.getCount(),
template)) { template)) {
logNodeDetails(createdNode); logDetails(computeService, createdNode);
addNodeDetailsAsProjectProperties(createdNode); addNodeDetailsAsProjectProperties(createdNode);
} }
} }
private void logNodeDetails(NodeMetadata createdNode) {
log(String.format(" id=%s, tag=%s, location=%s, tag=%s, connection=%s:%s@%s", createdNode
.getId(), createdNode.getTag(), createdNode.getLocationId(), createdNode.getName(),
createdNode.getCredentials().account, createdNode.getCredentials().key,
ipOrEmptyString(createdNode.getPublicAddresses())));
}
private void addNodeDetailsAsProjectProperties(NodeMetadata createdNode) { private void addNodeDetailsAsProjectProperties(NodeMetadata createdNode) {
if (nodeElement.getIdproperty() != null) if (nodeElement.getIdproperty() != null)
getProject().setProperty(nodeElement.getIdproperty(), createdNode.getId()); getProject().setProperty(nodeElement.getIdproperty(), createdNode.getId());
if (nodeElement.getHostproperty() != null) if (nodeElement.getHostproperty() != null)
getProject().setProperty(nodeElement.getHostproperty(), getProject().setProperty(nodeElement.getHostproperty(),
ipOrEmptyString(createdNode.getPublicAddresses())); ipOrEmptyString(createdNode.getPublicAddresses()));
if (nodeElement.getKeyfile() != null && isKeyAuth(createdNode))
try {
Files.write(createdNode.getCredentials().key, new File(nodeElement.getKeyfile()),
Charset.defaultCharset());
} catch (IOException e) {
throw new BuildException(e);
}
if (nodeElement.getPasswordproperty() != null && !isKeyAuth(createdNode)) if (nodeElement.getPasswordproperty() != null && !isKeyAuth(createdNode))
getProject().setProperty(nodeElement.getPasswordproperty(), getProject().setProperty(nodeElement.getPasswordproperty(),
createdNode.getCredentials().key); createdNode.getCredentials().key);

View File

@ -46,6 +46,7 @@ import org.jclouds.compute.reference.ComputeServiceConstants;
import org.jclouds.ssh.jsch.config.JschSshClientModule; import org.jclouds.ssh.jsch.config.JschSshClientModule;
import org.jclouds.tools.ant.logging.config.AntLoggingModule; import org.jclouds.tools.ant.logging.config.AntLoggingModule;
import com.google.common.base.Charsets;
import com.google.common.base.Function; import com.google.common.base.Function;
import com.google.common.base.Splitter; import com.google.common.base.Splitter;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
@ -131,6 +132,8 @@ public class ComputeTaskUtils {
TemplateOptions options = new TemplateOptions() TemplateOptions options = new TemplateOptions()
.inboundPorts(getPortsToOpenFromElement(nodeElement)); .inboundPorts(getPortsToOpenFromElement(nodeElement));
addRunScriptToOptionsIfPresentInNodeElement(nodeElement, options); addRunScriptToOptionsIfPresentInNodeElement(nodeElement, options);
addPrivateKeyToOptionsIfPresentInNodeElement(nodeElement, options);
addPublicKeyToOptionsIfPresentInNodeElement(nodeElement, options);
return options; return options;
} }
@ -144,6 +147,28 @@ public class ComputeTaskUtils {
} }
} }
static void addPrivateKeyToOptionsIfPresentInNodeElement(NodeElement nodeElement,
TemplateOptions options) {
if (nodeElement.getPrivatekeyfile() != null)
try {
options.installPrivateKey(Files.toString(nodeElement.getPrivatekeyfile(),
Charsets.UTF_8));
} catch (IOException e) {
throw new BuildException(e);
}
}
static void addPublicKeyToOptionsIfPresentInNodeElement(NodeElement nodeElement,
TemplateOptions options) {
if (nodeElement.getPrivatekeyfile() != null)
try {
options.authorizePublicKey(Files.toString(nodeElement.getPublickeyfile(),
Charsets.UTF_8));
} catch (IOException e) {
throw new BuildException(e);
}
}
static String ipOrEmptyString(Set<InetAddress> set) { static String ipOrEmptyString(Set<InetAddress> set) {
if (set.size() > 0) { if (set.size() > 0) {
return Iterables.get(set, 0).getHostAddress(); return Iterables.get(set, 0).getHostAddress();

View File

@ -32,7 +32,8 @@ public class NodeElement {
private int count = 1; private int count = 1;
private String openports = "22"; private String openports = "22";
private String passwordproperty; private String passwordproperty;
private String keyfile; private File privatekeyfile;
private File publickeyfile;
private String hostproperty; private String hostproperty;
private String idproperty; private String idproperty;
private String usernameproperty; private String usernameproperty;
@ -95,16 +96,6 @@ public class NodeElement {
return idproperty; return idproperty;
} }
/**
* The name of a file under which to store the DSA key of the user (if supported)
*/
public void setKeyfile(String keyfile) {
this.keyfile = keyfile;
}
String getKeyfile() {
return keyfile;
}
public void setSize(String size) { public void setSize(String size) {
this.size = size; this.size = size;
@ -162,4 +153,20 @@ public class NodeElement {
return tag; return tag;
} }
public void setPrivatekeyfile(File privatekeyfile) {
this.privatekeyfile = privatekeyfile;
}
public File getPrivatekeyfile() {
return privatekeyfile;
}
public void setPublickeyfile(File publickeyfile) {
this.publickeyfile = publickeyfile;
}
public File getPublickeyfile() {
return publickeyfile;
}
} }