mirror of https://github.com/apache/jclouds.git
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:
parent
7120f6e536
commit
b217410ac0
|
@ -31,6 +31,8 @@
|
|||
<scope>runtime</scope>
|
||||
<excludes>
|
||||
<exclude>org.jclouds:jclouds-core</exclude>
|
||||
<exclude>org.jclouds:jclouds-blobstore</exclude>
|
||||
<exclude>org.jclouds:jclouds-compute</exclude>
|
||||
</excludes>
|
||||
<!-- exclude all transitive dependencies of core too -->
|
||||
<useTransitiveFiltering>true</useTransitiveFiltering>
|
||||
|
|
|
@ -28,9 +28,15 @@
|
|||
LICENSE.txt
|
||||
README.txt
|
||||
core
|
||||
+ docs <- javadoc for core
|
||||
+ lib <- core jar and dependencies for core
|
||||
+ src <- expanded or source jar for core
|
||||
+ docs <- javadoc for core, blobstore, and compute
|
||||
+ lib <- core, blobstore, and compute jars and dependencies 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
|
||||
+ log4j
|
||||
+ README.txt <- how to use the extension
|
||||
|
@ -43,6 +49,12 @@
|
|||
+ lib <- not core
|
||||
+ docs <- 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
|
||||
+ tweetstore
|
||||
+ README.txt <- how to build and run the sample
|
||||
|
@ -75,6 +87,20 @@
|
|||
</includes>
|
||||
<outputDirectory>core/lib</outputDirectory>
|
||||
</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>
|
||||
<directory>core/target</directory>
|
||||
<includes>
|
||||
|
@ -82,16 +108,38 @@
|
|||
</includes>
|
||||
<outputDirectory>core/src</outputDirectory>
|
||||
</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>
|
||||
<directory>core/target/apidocs</directory>
|
||||
<outputDirectory>core/docs</outputDirectory>
|
||||
</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 -->
|
||||
<fileSet>
|
||||
<directory>atmos/target</directory>
|
||||
<includes>
|
||||
<include>jclouds-atmos-${project.version}-jar-with-dependencies.jar</include>
|
||||
<include>jclouds-atmos-${project.version}.jar</include>
|
||||
</includes>
|
||||
<outputDirectory>providers/atmos/lib</outputDirectory>
|
||||
</fileSet>
|
||||
|
@ -118,7 +166,7 @@
|
|||
<fileSet>
|
||||
<directory>aws/core/target</directory>
|
||||
<includes>
|
||||
<include>jclouds-aws-${project.version}-jar-with-dependencies.jar</include>
|
||||
<include>jclouds-aws-${project.version}.jar</include>
|
||||
</includes>
|
||||
<outputDirectory>providers/aws/lib</outputDirectory>
|
||||
</fileSet>
|
||||
|
@ -172,7 +220,7 @@
|
|||
<fileSet>
|
||||
<directory>azure/target</directory>
|
||||
<includes>
|
||||
<include>jclouds-azure-${project.version}-jar-with-dependencies.jar</include>
|
||||
<include>jclouds-azure-${project.version}.jar</include>
|
||||
</includes>
|
||||
<outputDirectory>providers/azure/lib</outputDirectory>
|
||||
</fileSet>
|
||||
|
@ -199,7 +247,7 @@
|
|||
<fileSet>
|
||||
<directory>vcloud/hostingdotcom/target</directory>
|
||||
<includes>
|
||||
<include>jclouds-hostingdotcom-${project.version}-jar-with-dependencies.jar</include>
|
||||
<include>jclouds-hostingdotcom-${project.version}.jar</include>
|
||||
</includes>
|
||||
<outputDirectory>providers/hostingdotcom/lib</outputDirectory>
|
||||
</fileSet>
|
||||
|
@ -226,7 +274,7 @@
|
|||
<fileSet>
|
||||
<directory>mezeo/pcs2/target</directory>
|
||||
<includes>
|
||||
<include>jclouds-pcs2-${project.version}-jar-with-dependencies.jar</include>
|
||||
<include>jclouds-pcs2-${project.version}.jar</include>
|
||||
</includes>
|
||||
<outputDirectory>providers/mezeo/lib</outputDirectory>
|
||||
</fileSet>
|
||||
|
@ -253,7 +301,7 @@
|
|||
<fileSet>
|
||||
<directory>nirvanix/sdn/target</directory>
|
||||
<includes>
|
||||
<include>jclouds-sdn-${project.version}-jar-with-dependencies.jar</include>
|
||||
<include>jclouds-sdn-${project.version}.jar</include>
|
||||
</includes>
|
||||
<outputDirectory>providers/nirvanix/lib</outputDirectory>
|
||||
</fileSet>
|
||||
|
@ -280,7 +328,7 @@
|
|||
<fileSet>
|
||||
<directory>rackspace/target</directory>
|
||||
<includes>
|
||||
<include>jclouds-rackspace-${project.version}-jar-with-dependencies.jar</include>
|
||||
<include>jclouds-rackspace-${project.version}.jar</include>
|
||||
</includes>
|
||||
<outputDirectory>providers/rackspace/lib</outputDirectory>
|
||||
</fileSet>
|
||||
|
@ -334,7 +382,7 @@
|
|||
<fileSet>
|
||||
<directory>vcloud/terremark/target</directory>
|
||||
<includes>
|
||||
<include>jclouds-terremark-${project.version}-jar-with-dependencies.jar</include>
|
||||
<include>jclouds-terremark-${project.version}.jar</include>
|
||||
</includes>
|
||||
<outputDirectory>providers/terremark/lib</outputDirectory>
|
||||
</fileSet>
|
||||
|
@ -411,6 +459,33 @@
|
|||
<outputDirectory>extensions/bouncycastle</outputDirectory>
|
||||
</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 -->
|
||||
<fileSet>
|
||||
<directory>extensions/gae/target</directory>
|
||||
|
@ -469,7 +544,7 @@
|
|||
<fileSet>
|
||||
<directory>extensions/httpnio/target</directory>
|
||||
<includes>
|
||||
<include>jclouds-httpnio-${project.version}-jar-with-dependencies.jar</include>
|
||||
<include>jclouds-httpnio-${project.version}.jar</include>
|
||||
</includes>
|
||||
<outputDirectory>extensions/httpnio/lib</outputDirectory>
|
||||
</fileSet>
|
||||
|
@ -496,7 +571,7 @@
|
|||
<fileSet>
|
||||
<directory>extensions/jsch/target</directory>
|
||||
<includes>
|
||||
<include>jclouds-jsch-${project.version}-jar-with-dependencies.jar</include>
|
||||
<include>jclouds-jsch-${project.version}.jar</include>
|
||||
</includes>
|
||||
<outputDirectory>extensions/ssh/jsch/lib</outputDirectory>
|
||||
</fileSet>
|
||||
|
@ -546,6 +621,60 @@
|
|||
<outputDirectory>extensions/log4j</outputDirectory>
|
||||
</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 -->
|
||||
<fileSet>
|
||||
<directory>demos/gae-tweetstore/target/jclouds-demo-gae-tweetstore</directory>
|
||||
|
|
|
@ -71,7 +71,7 @@ public interface AsyncBlobStore {
|
|||
ListenableFuture<Void> clearContainer(String container);
|
||||
|
||||
/**
|
||||
* @see BlobStore#clearDirectory(String, ListContainerOptions)
|
||||
* @see BlobStore#clearContainer(String, ListContainerOptions)
|
||||
*/
|
||||
ListenableFuture<Void> clearContainer(String container, ListContainerOptions options);
|
||||
|
||||
|
@ -111,7 +111,7 @@ public interface AsyncBlobStore {
|
|||
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);
|
||||
|
||||
|
|
|
@ -26,12 +26,18 @@ import org.jclouds.blobstore.options.GetOptions;
|
|||
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 BlobStoreContextFactory
|
||||
*/
|
||||
public interface BlobStore {
|
||||
|
||||
/**
|
||||
* creates a new blob with the specified name.
|
||||
*/
|
||||
Blob newBlob(String name);
|
||||
|
||||
/**
|
||||
|
@ -39,42 +45,117 @@ public interface BlobStore {
|
|||
*/
|
||||
PageSet<? extends StorageMetadata> list();
|
||||
|
||||
/**
|
||||
* determines if a service-level container exists
|
||||
*/
|
||||
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);
|
||||
|
||||
/**
|
||||
* Lists all resources available at the specified path. Note that path may be a container, or a
|
||||
* path within it delimited by {@code /} characters.
|
||||
* Lists all resources in a container non-recursive.
|
||||
*
|
||||
* @param parent
|
||||
* - base path to list; non-recursive
|
||||
* @param container
|
||||
* what to list
|
||||
* @return a list that may be incomplete, depending on whether PageSet#getNextMarker is set
|
||||
*/
|
||||
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);
|
||||
|
||||
/**
|
||||
* 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
|
||||
* what to clear
|
||||
*/
|
||||
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);
|
||||
|
||||
/**
|
||||
* This will delete a container recursively.
|
||||
* This will delete everything inside a container recursively.
|
||||
*
|
||||
* @param container
|
||||
* what to delete
|
||||
*/
|
||||
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);
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
/**
|
||||
|
@ -112,14 +193,25 @@ public interface BlobStore {
|
|||
* 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);
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
/**
|
||||
|
@ -134,8 +226,15 @@ public interface BlobStore {
|
|||
*/
|
||||
void removeBlob(String container, String name);
|
||||
|
||||
/**
|
||||
* @return a count of all blobs in the container, excluding directory markers
|
||||
*/
|
||||
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);
|
||||
|
||||
}
|
||||
|
|
|
@ -26,8 +26,8 @@ import org.jclouds.rest.RestContext;
|
|||
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
|
||||
*
|
||||
|
@ -36,30 +36,78 @@ import com.google.inject.ImplementedBy;
|
|||
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
|
||||
* 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);
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
/**
|
||||
* 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
|
||||
* 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);
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
/**
|
||||
* @return a portable asynchronous interface for the BlobStore, which returns {@code Future}s for
|
||||
* each call.
|
||||
*/
|
||||
AsyncBlobStore getAsyncBlobStore();
|
||||
|
||||
/**
|
||||
* @return a portable interface for the BlobStore.
|
||||
*/
|
||||
BlobStore getBlobStore();
|
||||
|
||||
/**
|
||||
*
|
||||
* @return best guess at the consistency model used in this BlobStore.
|
||||
*/
|
||||
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();
|
||||
|
||||
/**
|
||||
* closes threads and resources related to this connection.
|
||||
*
|
||||
*/
|
||||
void close();
|
||||
}
|
|
@ -28,6 +28,13 @@ import org.jclouds.rest.RestContextFactory;
|
|||
/**
|
||||
* Helper class to instantiate {@code BlobStoreContext} instances.
|
||||
*
|
||||
* <h3>Example usage</h3>
|
||||
*
|
||||
* <pre>
|
||||
* BlobStoreContext context = new BlobStoreContextFactory()
|
||||
* .createContext("s3", accesskeyid, secretkey);
|
||||
* </pre>
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class BlobStoreContextFactory extends
|
||||
|
@ -54,6 +61,9 @@ public class BlobStoreContextFactory extends
|
|||
super(properties);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected BlobStoreContext build(BlobStoreContextBuilder<?, ?> contextBuilder) {
|
||||
return contextBuilder.buildBlobStoreContext();
|
||||
|
|
|
@ -24,15 +24,21 @@ import com.google.common.collect.Multimap;
|
|||
import com.google.inject.internal.Nullable;
|
||||
|
||||
/**
|
||||
* Value type for an HTTP Blob service. Blobs are stored in containers and consist
|
||||
* of a {@link org.jclouds.blobstore.domain.Value#getContent() value}, a {@link Blob#getKey key and
|
||||
*
|
||||
* @link Blob.Metadata#getUserMetadata() metadata}
|
||||
* Value type for an HTTP Blob service. Blobs are stored in containers and consist of a
|
||||
* {@link MutableBlobMetadata#getName name}, {@link Payload payload}, and
|
||||
* {@link MutableBlobMetadata metadata}.
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public interface Blob extends PayloadEnclosing, Comparable<Blob> {
|
||||
/**
|
||||
* Allows you to construct blobs without knowing the implementation type
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -41,8 +47,15 @@ public interface Blob extends PayloadEnclosing, Comparable<Blob> {
|
|||
*/
|
||||
MutableBlobMetadata getMetadata();
|
||||
|
||||
/**
|
||||
* @return headers returned from the services
|
||||
*/
|
||||
Multimap<String, String> getAllHeaders();
|
||||
|
||||
/**
|
||||
*
|
||||
* @see #getAllHeaders
|
||||
*/
|
||||
void setAllHeaders(Multimap<String, String> allHeaders);
|
||||
|
||||
}
|
|
@ -47,7 +47,7 @@ public interface ComputeService {
|
|||
* it is a good indicator of relative speed within a cloud. memory is measured in megabytes and
|
||||
* 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();
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ public class ComputeServiceContextFactory extends
|
|||
*
|
||||
* @throws IOException
|
||||
* if the default properties file cannot be loaded
|
||||
* @see RestContextFactory#getProperties
|
||||
* @see RestContextFactory#getPropertiesFromResource
|
||||
*/
|
||||
public ComputeServiceContextFactory() throws IOException {
|
||||
super("compute.properties");
|
||||
|
|
|
@ -42,7 +42,7 @@ import com.google.common.annotations.VisibleForTesting;
|
|||
public abstract class PropertiesBuilder {
|
||||
|
||||
/**
|
||||
* @see org.jclouds.http.Constants.PROPERTY_RELAX_HOSTNAME
|
||||
* @see org.jclouds.Constants.PROPERTY_RELAX_HOSTNAME
|
||||
*/
|
||||
public PropertiesBuilder relaxSSLHostname(boolean 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) {
|
||||
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) {
|
||||
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) {
|
||||
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) {
|
||||
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) {
|
||||
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) {
|
||||
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) {
|
||||
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) {
|
||||
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) {
|
||||
properties.setProperty(PROPERTY_MAX_CONNECTIONS_PER_HOST, Integer.toString(connectionLimit));
|
||||
|
|
|
@ -49,7 +49,7 @@ public interface MutableResourceMetadata<T extends Enum<T>> extends ResourceMeta
|
|||
void setName(String name);
|
||||
|
||||
/**
|
||||
* @see #getLocation
|
||||
* @see #getLocationId
|
||||
*/
|
||||
void setLocationId(String location);
|
||||
|
||||
|
|
|
@ -29,14 +29,14 @@ public interface HttpCommand {
|
|||
/**
|
||||
* increments the current number of redirect attempts for this command.
|
||||
*
|
||||
* @see getRedirectCount
|
||||
* @see #getRedirectCount
|
||||
*/
|
||||
int incrementRedirectCount();
|
||||
|
||||
/**
|
||||
* 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();
|
||||
|
||||
|
@ -64,14 +64,14 @@ public interface HttpCommand {
|
|||
/**
|
||||
* increment the current failure count.
|
||||
*
|
||||
* @see getFailureCount
|
||||
* @see #getFailureCount
|
||||
*/
|
||||
int incrementFailureCount();
|
||||
|
||||
/**
|
||||
* 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();
|
||||
|
||||
|
@ -86,7 +86,7 @@ public interface HttpCommand {
|
|||
void setException(Exception exception);
|
||||
|
||||
/**
|
||||
* @see setException
|
||||
* @see #setException
|
||||
*/
|
||||
Exception getException();
|
||||
|
||||
|
|
|
@ -31,8 +31,6 @@ public interface HttpCommandExecutorService {
|
|||
* 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
|
||||
*
|
||||
* @param <T>
|
||||
* type of result the command extracts from the return value
|
||||
* @param command
|
||||
* that generates requests
|
||||
* @return {@link ListenableFuture} containing the response from the {@code endpoint}
|
||||
|
|
|
@ -93,7 +93,7 @@ public class HttpRequest extends HttpMessage {
|
|||
* We cannot return an enum, as per specification custom methods are allowed. Enums are not
|
||||
* 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() {
|
||||
return method;
|
||||
|
|
|
@ -131,7 +131,6 @@ public class HttpUtils {
|
|||
* breaks, if there are special characters like '/' present. Otherwise, we wouldn't need this
|
||||
* class, and we could simply use URI.create("uri").getUserData();
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public static URI createUri(String uriPath) {
|
||||
if (uriPath.indexOf('@') != 1) {
|
||||
|
|
|
@ -48,7 +48,7 @@ public interface PayloadEnclosing {
|
|||
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();
|
||||
|
||||
|
@ -61,8 +61,8 @@ public interface PayloadEnclosing {
|
|||
* range, or startAt.
|
||||
*
|
||||
* @return the length in bytes that can be be obtained from {@link #getContent()}
|
||||
* @see org.jclouds.http.HttpHeaders#CONTENT_LENGTH
|
||||
* @see GetObjectOptions
|
||||
* @see javax.ws.rs.core.HttpHeaders#CONTENT_LENGTH
|
||||
* @see org.jclouds.http.options.GetOptions
|
||||
*/
|
||||
Long getContentLength();
|
||||
|
||||
|
|
|
@ -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
|
||||
* type <T>.
|
||||
*
|
||||
* @see TransformingEndpointCommand
|
||||
* @see TransformingHttpCommand
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
|
@ -83,6 +83,7 @@ public class TransformingHttpCommandImpl<T> implements TransformingHttpCommand<T
|
|||
* <p />
|
||||
* This also removes the Host header in order to avoid ssl problems.
|
||||
*/
|
||||
@Override
|
||||
public void changeHostAndPortTo(String host, int port) {
|
||||
UriBuilder builder = UriBuilder.fromUri(request.getEndpoint());
|
||||
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() {
|
||||
request.setMethod(HttpMethod.GET);
|
||||
|
@ -120,11 +121,6 @@ public class TransformingHttpCommandImpl<T> implements TransformingHttpCommand<T
|
|||
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() {
|
||||
return request;
|
||||
}
|
||||
|
@ -136,7 +132,7 @@ public class TransformingHttpCommandImpl<T> implements TransformingHttpCommand<T
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "TransformingHttpCommandImpl [request=" + request.getRequestLine() + "]";
|
||||
return "[request=" + request.getRequestLine() + "]";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -42,6 +42,10 @@ import org.jclouds.logging.Logger;
|
|||
|
||||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public abstract class BaseHttpCommandExecutorService<Q> implements HttpCommandExecutorService {
|
||||
|
||||
private final DelegatingRetryHandler retryHandler;
|
||||
|
@ -123,16 +127,6 @@ public abstract class BaseHttpCommandExecutorService<Q> implements HttpCommandEx
|
|||
|
||||
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 void cleanup(Q nativeResponse);
|
||||
|
|
|
@ -26,10 +26,8 @@ import org.jclouds.logging.Logger;
|
|||
import org.jclouds.logging.internal.Wire;
|
||||
|
||||
/**
|
||||
* Logs data to the wire LOG.
|
||||
*
|
||||
* @author Adrian Cole
|
||||
* @see org.apache.HttpWire.impl.conn.Wire
|
||||
*/
|
||||
public class HttpWire extends Wire {
|
||||
|
||||
|
|
|
@ -26,10 +26,7 @@ import org.jclouds.logging.Logger;
|
|||
import org.jclouds.logging.internal.Wire;
|
||||
|
||||
/**
|
||||
* Logs data to the wire LOG.
|
||||
*
|
||||
* @author Adrian Cole
|
||||
* @see org.apache.HttpWire.impl.conn.Wire
|
||||
*/
|
||||
public class SignatureWire extends Wire {
|
||||
|
||||
|
|
|
@ -44,8 +44,8 @@ import com.google.common.collect.Multimap;
|
|||
* import static org.jclouds.http.options.GetOptions.Builder.*
|
||||
*
|
||||
*
|
||||
* // this will get the first megabyte of an object, provided it wasn't modified since yesterday
|
||||
* ListenableFuture<S3Object> object = client.get("objectName",range(0,1024).ifUnmodifiedSince(new Date().minusDays(1)));
|
||||
* // this will get the first megabyte of an object.
|
||||
* blob = client.get("objectName",range(0,1024));
|
||||
* <code>
|
||||
*
|
||||
* @author Adrian Cole
|
||||
|
@ -106,7 +106,7 @@ public class GetOptions extends BaseHttpRequestOptions {
|
|||
/**
|
||||
* Only return the object if it has changed since this time.
|
||||
* <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) {
|
||||
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
|
||||
* 304 (not modified).
|
||||
*
|
||||
* @see GetOptions#ifModifiedSince(Date)
|
||||
* @see #ifModifiedSince(Date)
|
||||
*/
|
||||
public String getIfModifiedSince() {
|
||||
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.
|
||||
* <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) {
|
||||
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
|
||||
* a 412 (precondition failed).
|
||||
*
|
||||
* @see GetOptions#ifUnmodifiedSince(Date)
|
||||
* @see #ifUnmodifiedSince(Date)
|
||||
*/
|
||||
public String getIfUnmodifiedSince() {
|
||||
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 a 412 (precondition failed).
|
||||
*
|
||||
* @see GetOptions#ifETagMatches(byte[])
|
||||
* @see #ifETagMatches(String)
|
||||
*/
|
||||
public String getIfMatch() {
|
||||
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 a 304 (not modified).
|
||||
*
|
||||
* @see GetOptions#ifETagDoesntMatch(byte[])
|
||||
* @see #ifETagDoesntMatch(String)
|
||||
*/
|
||||
public String getIfNoneMatch() {
|
||||
return this.getFirstHeaderOrNull(HttpHeaders.IF_NONE_MATCH);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
|
@ -46,7 +46,7 @@ import com.google.inject.spi.TypeListener;
|
|||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @author Adrian Cole
|
||||
|
|
|
@ -36,10 +36,9 @@ import com.google.common.io.Closeables;
|
|||
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
|
||||
* @see org.apache.HttpWire.impl.conn.Wire
|
||||
*/
|
||||
public abstract class Wire {
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ public @interface Headers {
|
|||
/**
|
||||
* @see HttpHeaders
|
||||
*/
|
||||
String [] keys();
|
||||
String[] keys();
|
||||
|
||||
/**
|
||||
* 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
|
||||
* @PathParam}.
|
||||
*
|
||||
* @see PathParam
|
||||
* @see javax.ws.rs.PathParam
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
String [] values();
|
||||
String[] values();
|
||||
}
|
||||
|
|
|
@ -51,4 +51,26 @@
|
|||
-->
|
||||
</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>
|
||||
|
|
|
@ -45,7 +45,6 @@ import com.google.common.collect.MapMaker;
|
|||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
|
||||
/**
|
||||
* // TODO: Adrian: Document this!
|
||||
*
|
||||
* @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
|
||||
* will be processed via the {@link #invoke(TransformingHttpCommandExecutorService) invoke}
|
||||
* will be processed via the {@link #invoke(HttpCommandRendezvous) invoke}
|
||||
* method.
|
||||
*/
|
||||
public <T> ListenableFuture<T> submit(HttpCommand command,
|
||||
|
|
|
@ -536,41 +536,6 @@ pageTracker._trackPageview();
|
|||
</dependency>
|
||||
</dependencies>
|
||||
</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>
|
||||
</build>
|
||||
</profile>
|
||||
|
|
|
@ -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
|
||||
* - what to match the process on
|
||||
|
|
|
@ -114,20 +114,18 @@
|
|||
|
||||
<property name="location" value="" />
|
||||
<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="count" value="1" />
|
||||
|
||||
<input
|
||||
message="What do you want to tag your nodes with?"
|
||||
addproperty="nodetag"
|
||||
/>
|
||||
|
||||
<input
|
||||
message="How many nodes would you like to create?"
|
||||
addproperty="count"
|
||||
/>
|
||||
|
||||
<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>
|
||||
</target>
|
||||
|
||||
|
|
|
@ -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.ipOrEmptyString;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
@ -46,7 +44,6 @@ import org.jclouds.http.HttpUtils;
|
|||
|
||||
import com.google.common.base.CaseFormat;
|
||||
import com.google.common.base.Splitter;
|
||||
import com.google.common.io.Files;
|
||||
import com.google.inject.Provider;
|
||||
|
||||
/**
|
||||
|
@ -193,31 +190,17 @@ public class ComputeTask extends Task {
|
|||
|
||||
for (NodeMetadata createdNode : computeService.runNodesWithTag(tag, nodeElement.getCount(),
|
||||
template)) {
|
||||
logNodeDetails(createdNode);
|
||||
logDetails(computeService, 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) {
|
||||
if (nodeElement.getIdproperty() != null)
|
||||
getProject().setProperty(nodeElement.getIdproperty(), createdNode.getId());
|
||||
if (nodeElement.getHostproperty() != null)
|
||||
getProject().setProperty(nodeElement.getHostproperty(),
|
||||
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))
|
||||
getProject().setProperty(nodeElement.getPasswordproperty(),
|
||||
createdNode.getCredentials().key);
|
||||
|
|
|
@ -46,6 +46,7 @@ import org.jclouds.compute.reference.ComputeServiceConstants;
|
|||
import org.jclouds.ssh.jsch.config.JschSshClientModule;
|
||||
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.Splitter;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
@ -131,6 +132,8 @@ public class ComputeTaskUtils {
|
|||
TemplateOptions options = new TemplateOptions()
|
||||
.inboundPorts(getPortsToOpenFromElement(nodeElement));
|
||||
addRunScriptToOptionsIfPresentInNodeElement(nodeElement, options);
|
||||
addPrivateKeyToOptionsIfPresentInNodeElement(nodeElement, options);
|
||||
addPublicKeyToOptionsIfPresentInNodeElement(nodeElement, 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) {
|
||||
if (set.size() > 0) {
|
||||
return Iterables.get(set, 0).getHostAddress();
|
||||
|
|
|
@ -32,7 +32,8 @@ public class NodeElement {
|
|||
private int count = 1;
|
||||
private String openports = "22";
|
||||
private String passwordproperty;
|
||||
private String keyfile;
|
||||
private File privatekeyfile;
|
||||
private File publickeyfile;
|
||||
private String hostproperty;
|
||||
private String idproperty;
|
||||
private String usernameproperty;
|
||||
|
@ -95,16 +96,6 @@ public class NodeElement {
|
|||
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) {
|
||||
this.size = size;
|
||||
|
@ -162,4 +153,20 @@ public class NodeElement {
|
|||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue