Git merge upstream/master
|
@ -29,7 +29,7 @@ data.
|
||||||
our current version is 1.0-beta-8
|
our current version is 1.0-beta-8
|
||||||
our dev version is 1.0-SNAPSHOT
|
our dev version is 1.0-SNAPSHOT
|
||||||
|
|
||||||
our compute api supports: ec2, gogrid, cloudservers (rackspace), rimuhosting, vcloud,
|
our compute api supports: ec2, gogrid, cloudservers (rackspace), vcloud,
|
||||||
trmk-ecloud, trmk-vcloudexpress, eucalyptus, cloudsigma,
|
trmk-ecloud, trmk-vcloudexpress, eucalyptus, cloudsigma,
|
||||||
elasticstack, bluelock-vclouddirector, slicehost,
|
elasticstack, bluelock-vclouddirector, slicehost,
|
||||||
elastichosts-lon-p (Peer 1), elastichosts-sat-p (Peer 1),
|
elastichosts-lon-p (Peer 1), elastichosts-sat-p (Peer 1),
|
||||||
|
@ -45,8 +45,8 @@ our blobstore api supports: s3, cloudfiles (rackspace), azurestorage, atmosonlin
|
||||||
* note * the pom dependency org.jclouds/jclouds-allblobstore gives you access to
|
* note * the pom dependency org.jclouds/jclouds-allblobstore gives you access to
|
||||||
to all of these providers
|
to all of these providers
|
||||||
|
|
||||||
we also have support for: ibmdev, mezeo, nirvanix, boxdotnet, as well a number of features
|
we also have support for: ibmdev, mezeo, nirvanix, boxdotnet, rimuhosting, as well
|
||||||
the sandbox
|
a number of features the sandbox
|
||||||
|
|
||||||
|
|
||||||
If you want access to all jclouds components, include the maven dependency org.jclouds/jclouds-all
|
If you want access to all jclouds components, include the maven dependency org.jclouds/jclouds-all
|
||||||
|
@ -105,7 +105,7 @@ Compute Example (Clojure):
|
||||||
|
|
||||||
Downloads:
|
Downloads:
|
||||||
* distribution zip: http://jclouds.googlecode.com/files/jclouds-1.0-beta-8.zip
|
* distribution zip: http://jclouds.googlecode.com/files/jclouds-1.0-beta-8.zip
|
||||||
* maven repo: https://oss.sonatype.org/content/repositories/releases
|
* maven repo: http://repo2.maven.org/maven2 (maven central - the default repository)
|
||||||
* snapshot repo: https://oss.sonatype.org/content/repositories/snapshots
|
* snapshot repo: https://oss.sonatype.org/content/repositories/snapshots
|
||||||
|
|
||||||
Links:
|
Links:
|
||||||
|
|
|
@ -39,5 +39,10 @@
|
||||||
<artifactId>jclouds-allblobstore</artifactId>
|
<artifactId>jclouds-allblobstore</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jclouds.provider</groupId>
|
||||||
|
<artifactId>aws-simpledb</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -50,8 +50,8 @@
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>${project.groupId}</groupId>
|
<groupId>org.jclouds.api</groupId>
|
||||||
<artifactId>jclouds-filesystem</artifactId>
|
<artifactId>filesystem</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
|
@ -39,11 +39,6 @@
|
||||||
<artifactId>jclouds-rackspace</artifactId>
|
<artifactId>jclouds-rackspace</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>${project.groupId}</groupId>
|
|
||||||
<artifactId>jclouds-rimuhosting</artifactId>
|
|
||||||
<version>${project.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>${project.groupId}</groupId>
|
<groupId>${project.groupId}</groupId>
|
||||||
<artifactId>jclouds-vcloud</artifactId>
|
<artifactId>jclouds-vcloud</artifactId>
|
||||||
|
@ -60,13 +55,13 @@
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>${project.groupId}</groupId>
|
<groupId>org.jclouds.provider</groupId>
|
||||||
<artifactId>jclouds-gogrid</artifactId>
|
<artifactId>gogrid</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>${project.groupId}</groupId>
|
<groupId>org.jclouds.provider</groupId>
|
||||||
<artifactId>jclouds-slicehost</artifactId>
|
<artifactId>slicehost</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -75,8 +70,8 @@
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>${project.groupId}</groupId>
|
<groupId>org.jclouds.provider</groupId>
|
||||||
<artifactId>jclouds-cloudsigma</artifactId>
|
<artifactId>cloudsigma</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
|
@ -0,0 +1,110 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!--
|
||||||
|
|
||||||
|
|
||||||
|
Copyright (C) 2010 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.
|
||||||
|
====================================================================
|
||||||
|
|
||||||
|
-->
|
||||||
|
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4.0.0.xsd" >
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>org.jclouds.api</groupId>
|
||||||
|
<artifactId>jclouds-apis-project</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
<relativePath>../pom.xml</relativePath>
|
||||||
|
</parent>
|
||||||
|
<artifactId>cloudwatch</artifactId>
|
||||||
|
<name>jcloud cloudwatch api</name>
|
||||||
|
<description>jclouds components to access an implementation of CloudWatch</description>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<test.cloudwatch.endpoint>https://monitoring.us-east-1.amazonaws.com</test.cloudwatch.endpoint>
|
||||||
|
<test.cloudwatch.apiversion>2009-05-15</test.cloudwatch.apiversion>
|
||||||
|
<test.cloudwatch.identity>${test.aws.identity}</test.cloudwatch.identity>
|
||||||
|
<test.cloudwatch.credential>${test.aws.credential}</test.cloudwatch.credential>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jclouds</groupId>
|
||||||
|
<artifactId>jclouds-aws</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
<type>jar</type>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jclouds</groupId>
|
||||||
|
<artifactId>jclouds-core</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
<type>test-jar</type>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jclouds</groupId>
|
||||||
|
<artifactId>jclouds-log4j</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<profiles>
|
||||||
|
<profile>
|
||||||
|
<id>live</id>
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>integration</id>
|
||||||
|
<phase>integration-test</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>test</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<systemProperties>
|
||||||
|
<property>
|
||||||
|
<name>test.cloudwatch.endpoint</name>
|
||||||
|
<value>${test.cloudwatch.endpoint}</value>
|
||||||
|
</property>
|
||||||
|
<property>
|
||||||
|
<name>test.cloudwatch.apiversion</name>
|
||||||
|
<value>${test.cloudwatch.apiversion}</value>
|
||||||
|
</property>
|
||||||
|
<property>
|
||||||
|
<name>test.cloudwatch.identity</name>
|
||||||
|
<value>${test.cloudwatch.identity}</value>
|
||||||
|
</property>
|
||||||
|
<property>
|
||||||
|
<name>test.cloudwatch.credential</name>
|
||||||
|
<value>${test.cloudwatch.credential}</value>
|
||||||
|
</property>
|
||||||
|
</systemProperties>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</profile>
|
||||||
|
</profiles>
|
||||||
|
|
||||||
|
|
||||||
|
</project>
|
||||||
|
|
|
@ -0,0 +1,129 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!--
|
||||||
|
|
||||||
|
|
||||||
|
Copyright (C) 2010 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.
|
||||||
|
====================================================================
|
||||||
|
|
||||||
|
-->
|
||||||
|
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4.0.0.xsd" >
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>org.jclouds.api</groupId>
|
||||||
|
<artifactId>jclouds-apis-project</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
<relativePath>../pom.xml</relativePath>
|
||||||
|
</parent>
|
||||||
|
<artifactId>ec2</artifactId>
|
||||||
|
<name>jcloud ec2 api</name>
|
||||||
|
<description>jclouds components to access an implementation of EC2</description>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<!-- when instances are hung, open a ticket and add here -->
|
||||||
|
<jclouds.compute.blacklist-nodes>trmkrun-ccc,test.trmk-924</jclouds.compute.blacklist-nodes>
|
||||||
|
<test.ec2.endpoint>https://ec2.us-east-1.amazonaws.com</test.ec2.endpoint>
|
||||||
|
<test.ec2.apiversion>2010-06-15</test.ec2.apiversion>
|
||||||
|
<test.ec2.identity>${test.aws.identity}</test.ec2.identity>
|
||||||
|
<test.ec2.credential>${test.aws.credential}</test.ec2.credential>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jclouds</groupId>
|
||||||
|
<artifactId>jclouds-aws</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
<type>jar</type>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jclouds</groupId>
|
||||||
|
<artifactId>jclouds-compute</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
<type>jar</type>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jclouds</groupId>
|
||||||
|
<artifactId>jclouds-core</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
<type>test-jar</type>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jclouds</groupId>
|
||||||
|
<artifactId>jclouds-compute</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
<type>test-jar</type>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jclouds</groupId>
|
||||||
|
<artifactId>jclouds-log4j</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<profiles>
|
||||||
|
<profile>
|
||||||
|
<id>live</id>
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>integration</id>
|
||||||
|
<phase>integration-test</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>test</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<systemProperties>
|
||||||
|
<property>
|
||||||
|
<name>test.ec2.endpoint</name>
|
||||||
|
<value>${test.ec2.endpoint}</value>
|
||||||
|
</property>
|
||||||
|
<property>
|
||||||
|
<name>test.ec2.apiversion</name>
|
||||||
|
<value>${test.ec2.apiversion}</value>
|
||||||
|
</property>
|
||||||
|
<property>
|
||||||
|
<name>test.ec2.identity</name>
|
||||||
|
<value>${test.ec2.identity}</value>
|
||||||
|
</property>
|
||||||
|
<property>
|
||||||
|
<name>test.ec2.credential</name>
|
||||||
|
<value>${test.ec2.credential}</value>
|
||||||
|
</property>
|
||||||
|
<property>
|
||||||
|
<name>jclouds.compute.blacklist-nodes</name>
|
||||||
|
<value>${jclouds.compute.blacklist-nodes}</value>
|
||||||
|
</property>
|
||||||
|
</systemProperties>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</profile>
|
||||||
|
</profiles>
|
||||||
|
|
||||||
|
|
||||||
|
</project>
|
||||||
|
|
|
@ -0,0 +1,129 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!--
|
||||||
|
|
||||||
|
|
||||||
|
Copyright (C) 2010 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.
|
||||||
|
====================================================================
|
||||||
|
|
||||||
|
-->
|
||||||
|
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4.0.0.xsd" >
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>org.jclouds.api</groupId>
|
||||||
|
<artifactId>jclouds-apis-project</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
<relativePath>../pom.xml</relativePath>
|
||||||
|
</parent>
|
||||||
|
<artifactId>elb</artifactId>
|
||||||
|
<name>jcloud elb api</name>
|
||||||
|
<description>jclouds components to access an implementation of Elastic Load Balancer</description>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<test.elb.endpoint>https://elasticloadbalancing.us-east-1.amazonaws.com</test.elb.endpoint>
|
||||||
|
<test.elb.apiversion>2010-07-01</test.elb.apiversion>
|
||||||
|
<test.elb.identity>${test.aws.identity}</test.elb.identity>
|
||||||
|
<test.elb.credential>${test.aws.credential}</test.elb.credential>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jclouds</groupId>
|
||||||
|
<artifactId>jclouds-aws</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
<type>jar</type>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jclouds</groupId>
|
||||||
|
<artifactId>jclouds-loadbalancer</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
<type>jar</type>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jclouds</groupId>
|
||||||
|
<artifactId>jclouds-core</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
<type>test-jar</type>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jclouds</groupId>
|
||||||
|
<artifactId>jclouds-jsch</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jclouds</groupId>
|
||||||
|
<artifactId>jclouds-loadbalancer</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
<type>test-jar</type>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jclouds</groupId>
|
||||||
|
<artifactId>jclouds-log4j</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<profiles>
|
||||||
|
<profile>
|
||||||
|
<id>live</id>
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>integration</id>
|
||||||
|
<phase>integration-test</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>test</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<systemProperties>
|
||||||
|
<property>
|
||||||
|
<name>test.elb.endpoint</name>
|
||||||
|
<value>${test.elb.endpoint}</value>
|
||||||
|
</property>
|
||||||
|
<property>
|
||||||
|
<name>test.elb.apiversion</name>
|
||||||
|
<value>${test.elb.apiversion}</value>
|
||||||
|
</property>
|
||||||
|
<property>
|
||||||
|
<name>test.elb.identity</name>
|
||||||
|
<value>${test.elb.identity}</value>
|
||||||
|
</property>
|
||||||
|
<property>
|
||||||
|
<name>test.elb.credential</name>
|
||||||
|
<value>${test.elb.credential}</value>
|
||||||
|
</property>
|
||||||
|
</systemProperties>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</profile>
|
||||||
|
</profiles>
|
||||||
|
|
||||||
|
|
||||||
|
</project>
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jclouds.aws.elb;
|
package org.jclouds.elb;
|
||||||
|
|
||||||
import static org.jclouds.aws.ec2.reference.EC2Parameters.ACTION;
|
import static org.jclouds.aws.ec2.reference.EC2Parameters.ACTION;
|
||||||
import static org.jclouds.aws.ec2.reference.EC2Parameters.VERSION;
|
import static org.jclouds.aws.ec2.reference.EC2Parameters.VERSION;
|
||||||
|
@ -29,20 +29,23 @@ import javax.ws.rs.FormParam;
|
||||||
import javax.ws.rs.POST;
|
import javax.ws.rs.POST;
|
||||||
import javax.ws.rs.Path;
|
import javax.ws.rs.Path;
|
||||||
|
|
||||||
import org.jclouds.aws.elb.binders.BindAvailabilityZonesToIndexedFormParams;
|
|
||||||
import org.jclouds.aws.elb.binders.BindELBInstanceIdsToIndexedFormParams;
|
|
||||||
import org.jclouds.aws.elb.domain.LoadBalancer;
|
|
||||||
import org.jclouds.aws.elb.xml.CreateLoadBalancerResponseHandler;
|
|
||||||
import org.jclouds.aws.elb.xml.DescribeLoadBalancersResponseHandler;
|
|
||||||
import org.jclouds.aws.elb.xml.RegisterInstancesWithLoadBalancerResponseHandler;
|
|
||||||
import org.jclouds.aws.filters.FormSigner;
|
import org.jclouds.aws.filters.FormSigner;
|
||||||
import org.jclouds.aws.functions.RegionToEndpoint;
|
import org.jclouds.elb.binders.BindAvailabilityZonesToIndexedFormParams;
|
||||||
|
import org.jclouds.elb.binders.BindInstanceIdsToIndexedFormParams;
|
||||||
|
import org.jclouds.elb.binders.BindLoadBalancerNamesToIndexedFormParams;
|
||||||
|
import org.jclouds.elb.domain.LoadBalancer;
|
||||||
|
import org.jclouds.elb.xml.CreateLoadBalancerResponseHandler;
|
||||||
|
import org.jclouds.elb.xml.DescribeLoadBalancersResponseHandler;
|
||||||
|
import org.jclouds.elb.xml.RegisterInstancesWithLoadBalancerResponseHandler;
|
||||||
|
import org.jclouds.location.functions.RegionToEndpointOrProviderIfNull;
|
||||||
import org.jclouds.rest.annotations.BinderParam;
|
import org.jclouds.rest.annotations.BinderParam;
|
||||||
import org.jclouds.rest.annotations.EndpointParam;
|
import org.jclouds.rest.annotations.EndpointParam;
|
||||||
|
import org.jclouds.rest.annotations.ExceptionParser;
|
||||||
import org.jclouds.rest.annotations.FormParams;
|
import org.jclouds.rest.annotations.FormParams;
|
||||||
import org.jclouds.rest.annotations.RequestFilters;
|
import org.jclouds.rest.annotations.RequestFilters;
|
||||||
import org.jclouds.rest.annotations.VirtualHost;
|
import org.jclouds.rest.annotations.VirtualHost;
|
||||||
import org.jclouds.rest.annotations.XMLResponseParser;
|
import org.jclouds.rest.annotations.XMLResponseParser;
|
||||||
|
import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404;
|
||||||
|
|
||||||
import com.google.common.util.concurrent.ListenableFuture;
|
import com.google.common.util.concurrent.ListenableFuture;
|
||||||
|
|
||||||
|
@ -56,7 +59,7 @@ import com.google.common.util.concurrent.ListenableFuture;
|
||||||
@FormParams(keys = VERSION, values = ELBAsyncClient.VERSION)
|
@FormParams(keys = VERSION, values = ELBAsyncClient.VERSION)
|
||||||
@VirtualHost
|
@VirtualHost
|
||||||
public interface ELBAsyncClient {
|
public interface ELBAsyncClient {
|
||||||
public static final String VERSION = "2009-11-25";
|
public static final String VERSION = "2010-07-01";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see ELBClient#createLoadBalancerInRegion
|
* @see ELBClient#createLoadBalancerInRegion
|
||||||
|
@ -66,9 +69,8 @@ public interface ELBAsyncClient {
|
||||||
@XMLResponseParser(CreateLoadBalancerResponseHandler.class)
|
@XMLResponseParser(CreateLoadBalancerResponseHandler.class)
|
||||||
@FormParams(keys = ACTION, values = "CreateLoadBalancer")
|
@FormParams(keys = ACTION, values = "CreateLoadBalancer")
|
||||||
ListenableFuture<String> createLoadBalancerInRegion(
|
ListenableFuture<String> createLoadBalancerInRegion(
|
||||||
@EndpointParam(parser = RegionToEndpoint.class) @Nullable String region,
|
@EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region,
|
||||||
@FormParam("LoadBalancerName") String name,
|
@FormParam("LoadBalancerName") String name, @FormParam("Listeners.member.1.Protocol") String protocol,
|
||||||
@FormParam("Listeners.member.1.Protocol") String protocol,
|
|
||||||
@FormParam("Listeners.member.1.LoadBalancerPort") int loadBalancerPort,
|
@FormParam("Listeners.member.1.LoadBalancerPort") int loadBalancerPort,
|
||||||
@FormParam("Listeners.member.1.InstancePort") int instancePort,
|
@FormParam("Listeners.member.1.InstancePort") int instancePort,
|
||||||
@BinderParam(BindAvailabilityZonesToIndexedFormParams.class) String... availabilityZones);
|
@BinderParam(BindAvailabilityZonesToIndexedFormParams.class) String... availabilityZones);
|
||||||
|
@ -80,7 +82,7 @@ public interface ELBAsyncClient {
|
||||||
@Path("/")
|
@Path("/")
|
||||||
@FormParams(keys = ACTION, values = "DeleteLoadBalancer")
|
@FormParams(keys = ACTION, values = "DeleteLoadBalancer")
|
||||||
ListenableFuture<Void> deleteLoadBalancerInRegion(
|
ListenableFuture<Void> deleteLoadBalancerInRegion(
|
||||||
@EndpointParam(parser = RegionToEndpoint.class) @Nullable String region,
|
@EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region,
|
||||||
@FormParam("LoadBalancerName") String name);
|
@FormParam("LoadBalancerName") String name);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -90,10 +92,10 @@ public interface ELBAsyncClient {
|
||||||
@Path("/")
|
@Path("/")
|
||||||
@XMLResponseParser(RegisterInstancesWithLoadBalancerResponseHandler.class)
|
@XMLResponseParser(RegisterInstancesWithLoadBalancerResponseHandler.class)
|
||||||
@FormParams(keys = ACTION, values = "RegisterInstancesWithLoadBalancer")
|
@FormParams(keys = ACTION, values = "RegisterInstancesWithLoadBalancer")
|
||||||
ListenableFuture<? extends Set<String>> registerInstancesWithLoadBalancerInRegion(
|
ListenableFuture<Set<String>> registerInstancesWithLoadBalancerInRegion(
|
||||||
@EndpointParam(parser = RegionToEndpoint.class) @Nullable String region,
|
@EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region,
|
||||||
@FormParam("LoadBalancerName") String name,
|
@FormParam("LoadBalancerName") String name,
|
||||||
@BinderParam(BindELBInstanceIdsToIndexedFormParams.class) String... instanceIds);
|
@BinderParam(BindInstanceIdsToIndexedFormParams.class) String... instanceIds);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see ELBClient#deregisterInstancesWithLoadBalancerInRegion
|
* @see ELBClient#deregisterInstancesWithLoadBalancerInRegion
|
||||||
|
@ -102,9 +104,9 @@ public interface ELBAsyncClient {
|
||||||
@Path("/")
|
@Path("/")
|
||||||
@FormParams(keys = ACTION, values = "DeregisterInstancesFromLoadBalancer")
|
@FormParams(keys = ACTION, values = "DeregisterInstancesFromLoadBalancer")
|
||||||
ListenableFuture<Void> deregisterInstancesWithLoadBalancerInRegion(
|
ListenableFuture<Void> deregisterInstancesWithLoadBalancerInRegion(
|
||||||
@EndpointParam(parser = RegionToEndpoint.class) @Nullable String region,
|
@EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region,
|
||||||
@FormParam("LoadBalancerName") String name,
|
@FormParam("LoadBalancerName") String name,
|
||||||
@BinderParam(BindELBInstanceIdsToIndexedFormParams.class) String... instanceIds);
|
@BinderParam(BindInstanceIdsToIndexedFormParams.class) String... instanceIds);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see ELBClient#describeLoadBalancersInRegion
|
* @see ELBClient#describeLoadBalancersInRegion
|
||||||
|
@ -113,7 +115,9 @@ public interface ELBAsyncClient {
|
||||||
@Path("/")
|
@Path("/")
|
||||||
@XMLResponseParser(DescribeLoadBalancersResponseHandler.class)
|
@XMLResponseParser(DescribeLoadBalancersResponseHandler.class)
|
||||||
@FormParams(keys = ACTION, values = "DescribeLoadBalancers")
|
@FormParams(keys = ACTION, values = "DescribeLoadBalancers")
|
||||||
ListenableFuture<? extends Set<LoadBalancer>> describeLoadBalancersInRegion(
|
@ExceptionParser(ReturnEmptySetOnNotFoundOr404.class)
|
||||||
@EndpointParam(parser = RegionToEndpoint.class) @Nullable String region);
|
ListenableFuture<Set<? extends LoadBalancer>> describeLoadBalancersInRegion(
|
||||||
|
@EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region,
|
||||||
|
@BinderParam(BindLoadBalancerNamesToIndexedFormParams.class) String... loadbalancerNames);
|
||||||
|
|
||||||
}
|
}
|
|
@ -17,15 +17,15 @@
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jclouds.aws.elb;
|
package org.jclouds.elb;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import org.jclouds.aws.elb.domain.LoadBalancer;
|
|
||||||
import org.jclouds.concurrent.Timeout;
|
import org.jclouds.concurrent.Timeout;
|
||||||
|
import org.jclouds.elb.domain.LoadBalancer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides access to EC2 Elastic Load Balancer via their REST API.
|
* Provides access to EC2 Elastic Load Balancer via their REST API.
|
||||||
|
@ -97,8 +97,9 @@ public interface ELBClient {
|
||||||
/**
|
/**
|
||||||
* Returns a set of elastic load balancers
|
* Returns a set of elastic load balancers
|
||||||
* @param region
|
* @param region
|
||||||
|
* @param loadbalancerNames names associated with the LoadBalancers at creation time.
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
Set<LoadBalancer> describeLoadBalancersInRegion(@Nullable String region);
|
Set<? extends LoadBalancer> describeLoadBalancersInRegion(@Nullable String region, String... loadbalancerNames);
|
||||||
|
|
||||||
}
|
}
|
|
@ -17,15 +17,16 @@
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jclouds.aws.elb;
|
package org.jclouds.elb;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import org.jclouds.aws.elb.config.ELBRestClientModule;
|
import org.jclouds.elb.config.ELBRestClientModule;
|
||||||
|
import org.jclouds.elb.loadbalancer.config.ELBLoadBalancerContextModule;
|
||||||
import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule;
|
import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule;
|
||||||
|
import org.jclouds.loadbalancer.LoadBalancerServiceContextBuilder;
|
||||||
import org.jclouds.logging.jdk.config.JDKLoggingModule;
|
import org.jclouds.logging.jdk.config.JDKLoggingModule;
|
||||||
import org.jclouds.rest.RestContextBuilder;
|
|
||||||
|
|
||||||
import com.google.inject.Injector;
|
import com.google.inject.Injector;
|
||||||
import com.google.inject.Module;
|
import com.google.inject.Module;
|
||||||
|
@ -43,7 +44,12 @@ import com.google.inject.Module;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
* @see ELBContext
|
* @see ELBContext
|
||||||
*/
|
*/
|
||||||
public class ELBContextBuilder extends RestContextBuilder<ELBClient, ELBAsyncClient> {
|
public class ELBContextBuilder extends LoadBalancerServiceContextBuilder<ELBClient, ELBAsyncClient> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void addContextModule(List<Module> modules) {
|
||||||
|
modules.add(new ELBLoadBalancerContextModule());
|
||||||
|
}
|
||||||
|
|
||||||
public ELBContextBuilder(Properties props) {
|
public ELBContextBuilder(Properties props) {
|
||||||
super(ELBClient.class, ELBAsyncClient.class, props);
|
super(ELBClient.class, ELBAsyncClient.class, props);
|
|
@ -17,13 +17,14 @@
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jclouds.aws.elb;
|
package org.jclouds.elb;
|
||||||
|
|
||||||
import static org.jclouds.Constants.PROPERTY_API_VERSION;
|
import static org.jclouds.Constants.PROPERTY_API_VERSION;
|
||||||
import static org.jclouds.Constants.PROPERTY_ENDPOINT;
|
import static org.jclouds.Constants.PROPERTY_ENDPOINT;
|
||||||
import static org.jclouds.aws.reference.AWSConstants.PROPERTY_AUTH_TAG;
|
import static org.jclouds.aws.reference.AWSConstants.PROPERTY_AUTH_TAG;
|
||||||
import static org.jclouds.aws.reference.AWSConstants.PROPERTY_HEADER_TAG;
|
import static org.jclouds.aws.reference.AWSConstants.PROPERTY_HEADER_TAG;
|
||||||
import static org.jclouds.aws.reference.AWSConstants.PROPERTY_REGIONS;
|
import static org.jclouds.aws.reference.AWSConstants.PROPERTY_ZONECLIENT_ENDPOINT;
|
||||||
|
import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS;
|
||||||
|
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
|
@ -44,10 +45,9 @@ public class ELBPropertiesBuilder extends PropertiesBuilder {
|
||||||
properties.setProperty(PROPERTY_AUTH_TAG, "AWS");
|
properties.setProperty(PROPERTY_AUTH_TAG, "AWS");
|
||||||
properties.setProperty(PROPERTY_HEADER_TAG, "amz");
|
properties.setProperty(PROPERTY_HEADER_TAG, "amz");
|
||||||
properties.setProperty(PROPERTY_API_VERSION, ELBAsyncClient.VERSION);
|
properties.setProperty(PROPERTY_API_VERSION, ELBAsyncClient.VERSION);
|
||||||
properties.setProperty(PROPERTY_REGIONS, Joiner.on(',').join(Region.US_EAST_1,
|
properties.setProperty(PROPERTY_REGIONS,
|
||||||
Region.US_WEST_1, Region.EU_WEST_1, Region.AP_SOUTHEAST_1));
|
Joiner.on(',').join(Region.US_EAST_1, Region.US_WEST_1, Region.EU_WEST_1, Region.AP_SOUTHEAST_1));
|
||||||
properties.setProperty(PROPERTY_ENDPOINT,
|
properties.setProperty(PROPERTY_ENDPOINT, "https://elasticloadbalancing.us-east-1.amazonaws.com");
|
||||||
"https://elasticloadbalancing.us-east-1.amazonaws.com");
|
|
||||||
properties.setProperty(PROPERTY_ENDPOINT + "." + Region.US_EAST_1,
|
properties.setProperty(PROPERTY_ENDPOINT + "." + Region.US_EAST_1,
|
||||||
"https://elasticloadbalancing.us-east-1.amazonaws.com");
|
"https://elasticloadbalancing.us-east-1.amazonaws.com");
|
||||||
properties.setProperty(PROPERTY_ENDPOINT + "." + Region.US_WEST_1,
|
properties.setProperty(PROPERTY_ENDPOINT + "." + Region.US_WEST_1,
|
||||||
|
@ -56,6 +56,7 @@ public class ELBPropertiesBuilder extends PropertiesBuilder {
|
||||||
"https://elasticloadbalancing.eu-west-1.amazonaws.com");
|
"https://elasticloadbalancing.eu-west-1.amazonaws.com");
|
||||||
properties.setProperty(PROPERTY_ENDPOINT + "." + Region.AP_SOUTHEAST_1,
|
properties.setProperty(PROPERTY_ENDPOINT + "." + Region.AP_SOUTHEAST_1,
|
||||||
"https://elasticloadbalancing.ap-southeast-1.amazonaws.com");
|
"https://elasticloadbalancing.ap-southeast-1.amazonaws.com");
|
||||||
|
properties.setProperty(PROPERTY_ZONECLIENT_ENDPOINT, "https://ec2.us-east-1.amazonaws.com");
|
||||||
return properties;
|
return properties;
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jclouds.aws.elb.binders;
|
package org.jclouds.elb.binders;
|
||||||
|
|
||||||
import static org.jclouds.aws.ec2.util.EC2Utils.indexStringArrayToFormValuesWithStringFormat;
|
import static org.jclouds.aws.ec2.util.EC2Utils.indexStringArrayToFormValuesWithStringFormat;
|
||||||
|
|
||||||
|
@ -33,9 +33,9 @@ import org.jclouds.rest.Binder;
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class BindAvailabilityZonesToIndexedFormParams implements Binder {
|
public class BindAvailabilityZonesToIndexedFormParams implements Binder {
|
||||||
|
@Override
|
||||||
public void bindToRequest(HttpRequest request, Object input) {
|
public <R extends HttpRequest> R bindToRequest(R request, Object input) {
|
||||||
indexStringArrayToFormValuesWithStringFormat(request, "AvailabilityZones.member.%s", input);
|
return indexStringArrayToFormValuesWithStringFormat(request, "AvailabilityZones.member.%s", input);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -17,7 +17,7 @@
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jclouds.aws.elb.binders;
|
package org.jclouds.elb.binders;
|
||||||
|
|
||||||
import static org.jclouds.aws.ec2.util.EC2Utils.indexStringArrayToFormValuesWithStringFormat;
|
import static org.jclouds.aws.ec2.util.EC2Utils.indexStringArrayToFormValuesWithStringFormat;
|
||||||
|
|
||||||
|
@ -32,10 +32,10 @@ import org.jclouds.rest.Binder;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class BindELBInstanceIdsToIndexedFormParams implements Binder {
|
public class BindInstanceIdsToIndexedFormParams implements Binder {
|
||||||
|
@Override
|
||||||
public void bindToRequest(HttpRequest request, Object input) {
|
public <R extends HttpRequest> R bindToRequest(R request, Object input) {
|
||||||
indexStringArrayToFormValuesWithStringFormat(request, "Instances.member.%s.InstanceId", input);
|
return indexStringArrayToFormValuesWithStringFormat(request, "Instances.member.%s.InstanceId", input);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
package org.jclouds.elb.binders;
|
||||||
|
|
||||||
|
import static org.jclouds.aws.ec2.util.EC2Utils.indexStringArrayToFormValuesWithStringFormat;
|
||||||
|
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
import org.jclouds.http.HttpRequest;
|
||||||
|
import org.jclouds.rest.Binder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Binds the String [] to form parameters named with LoadBalancerNames.member.index
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
@Singleton
|
||||||
|
public class BindLoadBalancerNamesToIndexedFormParams implements Binder {
|
||||||
|
@Override
|
||||||
|
public <R extends HttpRequest> R bindToRequest(R request, Object input) {
|
||||||
|
return indexStringArrayToFormValuesWithStringFormat(request, "LoadBalancerNames.member.%s", input);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -17,11 +17,11 @@
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jclouds.aws.elb.config;
|
package org.jclouds.elb.config;
|
||||||
|
|
||||||
import org.jclouds.aws.config.AWSFormSigningRestClientModule;
|
import org.jclouds.aws.config.WithZonesFormSigningRestClientModule;
|
||||||
import org.jclouds.aws.elb.ELBAsyncClient;
|
import org.jclouds.elb.ELBAsyncClient;
|
||||||
import org.jclouds.aws.elb.ELBClient;
|
import org.jclouds.elb.ELBClient;
|
||||||
import org.jclouds.http.RequiresHttp;
|
import org.jclouds.http.RequiresHttp;
|
||||||
import org.jclouds.rest.ConfiguresRestClient;
|
import org.jclouds.rest.ConfiguresRestClient;
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ import org.jclouds.rest.ConfiguresRestClient;
|
||||||
*/
|
*/
|
||||||
@RequiresHttp
|
@RequiresHttp
|
||||||
@ConfiguresRestClient
|
@ConfiguresRestClient
|
||||||
public class ELBRestClientModule extends AWSFormSigningRestClientModule<ELBClient, ELBAsyncClient> {
|
public class ELBRestClientModule extends WithZonesFormSigningRestClientModule<ELBClient, ELBAsyncClient> {
|
||||||
public ELBRestClientModule() {
|
public ELBRestClientModule() {
|
||||||
super(ELBClient.class, ELBAsyncClient.class);
|
super(ELBClient.class, ELBAsyncClient.class);
|
||||||
}
|
}
|
|
@ -17,7 +17,7 @@
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jclouds.aws.elb.domain;
|
package org.jclouds.elb.domain;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
@ -45,9 +45,8 @@ public class LoadBalancer implements Comparable<LoadBalancer> {
|
||||||
this.loadBalancerListeners = new HashSet<LoadBalancerListener>();
|
this.loadBalancerListeners = new HashSet<LoadBalancerListener>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public LoadBalancer(String region, String name, Set<String> instanceIds,
|
public LoadBalancer(String region, String name, Set<String> instanceIds, Set<String> availabilityZones,
|
||||||
Set<String> availabilityZones, String dnsName) {
|
String dnsName) {
|
||||||
super();
|
|
||||||
this.region = region;
|
this.region = region;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.instanceIds = instanceIds;
|
this.instanceIds = instanceIds;
|
||||||
|
@ -125,19 +124,24 @@ public class LoadBalancer implements Comparable<LoadBalancer> {
|
||||||
return name.compareTo(that.name);
|
return name.compareTo(that.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "[region=" + region + ", name=" + name + ", instanceIds=" + instanceIds + ", availabilityZones="
|
||||||
|
+ availabilityZones + ", dnsName=" + dnsName + ", appCookieStickinessPolicy=" + appCookieStickinessPolicy
|
||||||
|
+ ", lBCookieStickinessPolicy=" + lBCookieStickinessPolicy + ", loadBalancerListeners="
|
||||||
|
+ loadBalancerListeners + "]";
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
final int prime = 31;
|
final int prime = 31;
|
||||||
int result = 1;
|
int result = 1;
|
||||||
result = prime * result
|
result = prime * result + ((appCookieStickinessPolicy == null) ? 0 : appCookieStickinessPolicy.hashCode());
|
||||||
+ ((appCookieStickinessPolicy == null) ? 0 : appCookieStickinessPolicy.hashCode());
|
|
||||||
result = prime * result + ((availabilityZones == null) ? 0 : availabilityZones.hashCode());
|
result = prime * result + ((availabilityZones == null) ? 0 : availabilityZones.hashCode());
|
||||||
result = prime * result + ((dnsName == null) ? 0 : dnsName.hashCode());
|
result = prime * result + ((dnsName == null) ? 0 : dnsName.hashCode());
|
||||||
result = prime * result + ((instanceIds == null) ? 0 : instanceIds.hashCode());
|
result = prime * result + ((instanceIds == null) ? 0 : instanceIds.hashCode());
|
||||||
result = prime * result
|
result = prime * result + ((lBCookieStickinessPolicy == null) ? 0 : lBCookieStickinessPolicy.hashCode());
|
||||||
+ ((lBCookieStickinessPolicy == null) ? 0 : lBCookieStickinessPolicy.hashCode());
|
result = prime * result + ((loadBalancerListeners == null) ? 0 : loadBalancerListeners.hashCode());
|
||||||
result = prime * result
|
|
||||||
+ ((loadBalancerListeners == null) ? 0 : loadBalancerListeners.hashCode());
|
|
||||||
result = prime * result + ((name == null) ? 0 : name.hashCode());
|
result = prime * result + ((name == null) ? 0 : name.hashCode());
|
||||||
result = prime * result + ((region == null) ? 0 : region.hashCode());
|
result = prime * result + ((region == null) ? 0 : region.hashCode());
|
||||||
return result;
|
return result;
|
||||||
|
@ -234,6 +238,11 @@ public class LoadBalancer implements Comparable<LoadBalancer> {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "[policyName=" + policyName + ", cookieName=" + cookieName + "]";
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
if (this == obj)
|
if (this == obj)
|
||||||
|
@ -292,8 +301,7 @@ public class LoadBalancer implements Comparable<LoadBalancer> {
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
final int prime = 31;
|
final int prime = 31;
|
||||||
int result = 1;
|
int result = 1;
|
||||||
result = prime * result
|
result = prime * result + ((cookieExpirationPeriod == null) ? 0 : cookieExpirationPeriod.hashCode());
|
||||||
+ ((cookieExpirationPeriod == null) ? 0 : cookieExpirationPeriod.hashCode());
|
|
||||||
result = prime * result + ((policyName == null) ? 0 : policyName.hashCode());
|
result = prime * result + ((policyName == null) ? 0 : policyName.hashCode());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -320,6 +328,11 @@ public class LoadBalancer implements Comparable<LoadBalancer> {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "[policyName=" + policyName + ", cookieExpirationPeriod=" + cookieExpirationPeriod + "]";
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class LoadBalancerListener {
|
public static class LoadBalancerListener {
|
||||||
|
@ -328,8 +341,8 @@ public class LoadBalancer implements Comparable<LoadBalancer> {
|
||||||
private Integer loadBalancerPort;
|
private Integer loadBalancerPort;
|
||||||
private String protocol;
|
private String protocol;
|
||||||
|
|
||||||
public LoadBalancerListener(Set<String> policyNames, Integer instancePort,
|
public LoadBalancerListener(Set<String> policyNames, Integer instancePort, Integer loadBalancerPort,
|
||||||
Integer loadBalancerPort, String protocol) {
|
String protocol) {
|
||||||
super();
|
super();
|
||||||
this.policyNames = policyNames;
|
this.policyNames = policyNames;
|
||||||
this.instancePort = instancePort;
|
this.instancePort = instancePort;
|
||||||
|
@ -416,5 +429,11 @@ public class LoadBalancer implements Comparable<LoadBalancer> {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "[policyNames=" + policyNames + ", instancePort=" + instancePort + ", loadBalancerPort="
|
||||||
|
+ loadBalancerPort + ", protocol=" + protocol + "]";
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,56 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 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.elb.loadbalancer.config;
|
||||||
|
|
||||||
|
import org.jclouds.elb.loadbalancer.strategy.ELBDestroyLoadBalancerStrategy;
|
||||||
|
import org.jclouds.elb.loadbalancer.strategy.ELBGetLoadBalancerMetadataStrategy;
|
||||||
|
import org.jclouds.elb.loadbalancer.strategy.ELBListLoadBalancersStrategy;
|
||||||
|
import org.jclouds.elb.loadbalancer.strategy.ELBLoadBalanceNodesStrategy;
|
||||||
|
import org.jclouds.loadbalancer.config.BindLoadBalancerStrategiesByClass;
|
||||||
|
import org.jclouds.loadbalancer.strategy.DestroyLoadBalancerStrategy;
|
||||||
|
import org.jclouds.loadbalancer.strategy.GetLoadBalancerMetadataStrategy;
|
||||||
|
import org.jclouds.loadbalancer.strategy.ListLoadBalancersStrategy;
|
||||||
|
import org.jclouds.loadbalancer.strategy.LoadBalanceNodesStrategy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
public class ELBBindLoadBalancerStrategiesByClass extends BindLoadBalancerStrategiesByClass {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Class<? extends LoadBalanceNodesStrategy> defineLoadBalanceNodesStrategy() {
|
||||||
|
return ELBLoadBalanceNodesStrategy.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Class<? extends DestroyLoadBalancerStrategy> defineDestroyLoadBalancerStrategy() {
|
||||||
|
return ELBDestroyLoadBalancerStrategy.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Class<? extends GetLoadBalancerMetadataStrategy> defineGetLoadBalancerMetadataStrategy() {
|
||||||
|
return ELBGetLoadBalancerMetadataStrategy.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Class<? extends ListLoadBalancersStrategy> defineListLoadBalancersStrategy() {
|
||||||
|
return ELBListLoadBalancersStrategy.class;
|
||||||
|
}
|
||||||
|
}
|
|
@ -17,35 +17,29 @@
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jclouds.compute.suppliers;
|
package org.jclouds.elb.loadbalancer.config;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
|
||||||
import javax.inject.Singleton;
|
|
||||||
|
|
||||||
import org.jclouds.domain.Location;
|
import org.jclouds.domain.Location;
|
||||||
|
import org.jclouds.loadbalancer.config.BindLoadBalancerSuppliersByClass;
|
||||||
|
import org.jclouds.location.suppliers.FirstZoneOrRegionMatchingRegionId;
|
||||||
|
import org.jclouds.location.suppliers.ZoneToRegionToProvider;
|
||||||
|
|
||||||
import com.google.common.base.Supplier;
|
import com.google.common.base.Supplier;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*
|
|
||||||
* By default allows you to use a static set of locations bound to Set<? extends Location>
|
|
||||||
*/
|
*/
|
||||||
@Singleton
|
public class ELBBindLoadBalancerSuppliersByClass extends BindLoadBalancerSuppliersByClass {
|
||||||
public class LocationSupplier implements Supplier<Set<? extends Location>> {
|
|
||||||
private final Set<? extends Location> locations;
|
|
||||||
|
|
||||||
@Inject
|
@Override
|
||||||
LocationSupplier(Set<? extends Location> locations) {
|
protected Class<? extends Supplier<Location>> defineDefaultLocationSupplier() {
|
||||||
this.locations = locations;
|
return FirstZoneOrRegionMatchingRegionId.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<? extends Location> get() {
|
protected Class<? extends Supplier<Set<? extends Location>>> defineLocationSupplier() {
|
||||||
return locations;
|
return ZoneToRegionToProvider.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -0,0 +1,39 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 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.elb.loadbalancer.config;
|
||||||
|
|
||||||
|
import org.jclouds.loadbalancer.config.BaseLoadBalancerServiceContextModule;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configures the ELB connection.
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class ELBLoadBalancerContextModule extends BaseLoadBalancerServiceContextModule {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void configure() {
|
||||||
|
install(new ELBBindLoadBalancerSuppliersByClass());
|
||||||
|
install(new ELBBindLoadBalancerStrategiesByClass());
|
||||||
|
install(new ELBLoadBalancerServiceDependenciesModule());
|
||||||
|
super.configure();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
package org.jclouds.elb.loadbalancer.config;
|
||||||
|
|
||||||
|
import org.jclouds.elb.domain.LoadBalancer;
|
||||||
|
import org.jclouds.elb.loadbalancer.functions.LoadBalancerToLoadBalancerMetadata;
|
||||||
|
import org.jclouds.loadbalancer.domain.LoadBalancerMetadata;
|
||||||
|
|
||||||
|
import com.google.common.base.Function;
|
||||||
|
import com.google.inject.AbstractModule;
|
||||||
|
import com.google.inject.TypeLiteral;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
public class ELBLoadBalancerServiceDependenciesModule extends AbstractModule {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void configure() {
|
||||||
|
bind(new TypeLiteral<Function<LoadBalancer, LoadBalancerMetadata>>() {
|
||||||
|
}).to(LoadBalancerToLoadBalancerMetadata.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,59 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 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.elb.loadbalancer.functions;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
import org.jclouds.domain.Location;
|
||||||
|
import org.jclouds.elb.domain.LoadBalancer;
|
||||||
|
import org.jclouds.loadbalancer.domain.LoadBalancerMetadata;
|
||||||
|
import org.jclouds.loadbalancer.domain.LoadBalancerType;
|
||||||
|
import org.jclouds.loadbalancer.domain.internal.LoadBalancerMetadataImpl;
|
||||||
|
|
||||||
|
import com.google.common.base.Function;
|
||||||
|
import com.google.common.base.Supplier;
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
@Singleton
|
||||||
|
public class LoadBalancerToLoadBalancerMetadata implements Function<LoadBalancer, LoadBalancerMetadata> {
|
||||||
|
protected final Supplier<Map<String, ? extends Location>> locationMap;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
public LoadBalancerToLoadBalancerMetadata(Supplier<Map<String, ? extends Location>> locationMap) {
|
||||||
|
this.locationMap = locationMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LoadBalancerMetadata apply(LoadBalancer input) {
|
||||||
|
Location location = locationMap.get().get(input.getRegion());
|
||||||
|
// TODO Builder
|
||||||
|
return new LoadBalancerMetadataImpl(LoadBalancerType.LB, input.getName(), input.getName(), input.getRegion()
|
||||||
|
+ "/" + input.getName(), location, null, ImmutableMap.<String, String> of(), ImmutableSet.of(input
|
||||||
|
.getDnsName()));
|
||||||
|
}
|
||||||
|
}
|
|
@ -17,21 +17,21 @@
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jclouds.aws.ec2.compute.strategy;
|
package org.jclouds.elb.loadbalancer.strategy;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
import static org.jclouds.aws.ec2.util.EC2Utils.parseHandle;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Named;
|
import javax.inject.Named;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import org.jclouds.aws.ec2.util.EC2Utils;
|
import org.jclouds.elb.ELBClient;
|
||||||
import org.jclouds.aws.elb.ELBClient;
|
import org.jclouds.loadbalancer.domain.LoadBalancerMetadata;
|
||||||
import org.jclouds.compute.reference.ComputeServiceConstants;
|
import org.jclouds.loadbalancer.reference.LoadBalancerConstants;
|
||||||
import org.jclouds.compute.strategy.DestroyLoadBalancerStrategy;
|
import org.jclouds.loadbalancer.strategy.DestroyLoadBalancerStrategy;
|
||||||
|
import org.jclouds.loadbalancer.strategy.GetLoadBalancerMetadataStrategy;
|
||||||
import org.jclouds.logging.Logger;
|
import org.jclouds.logging.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -39,25 +39,26 @@ import org.jclouds.logging.Logger;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class EC2DestroyLoadBalancerStrategy implements DestroyLoadBalancerStrategy {
|
public class ELBDestroyLoadBalancerStrategy implements DestroyLoadBalancerStrategy {
|
||||||
@Resource
|
@Resource
|
||||||
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
|
@Named(LoadBalancerConstants.LOADBALANCER_LOGGER)
|
||||||
protected Logger logger = Logger.NULL;
|
protected Logger logger = Logger.NULL;
|
||||||
|
|
||||||
private final ELBClient elbClient;
|
private final ELBClient elbClient;
|
||||||
|
private final GetLoadBalancerMetadataStrategy getLoadBalancer;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
protected EC2DestroyLoadBalancerStrategy(ELBClient elbClient) {
|
protected ELBDestroyLoadBalancerStrategy(ELBClient elbClient, GetLoadBalancerMetadataStrategy getLoadBalancer) {
|
||||||
this.elbClient = checkNotNull(elbClient, "elbClient");
|
this.elbClient = checkNotNull(elbClient, "elbClient");
|
||||||
|
this.getLoadBalancer = checkNotNull(getLoadBalancer, "getLoadBalancer");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(String loadBalancer) {
|
public LoadBalancerMetadata destroyLoadBalancer(String id) {
|
||||||
Map<String, String> tuple = EC2Utils.getLoadBalancerNameAndRegionFromDnsName(loadBalancer);
|
String[] parts = parseHandle(id);
|
||||||
// Only one load balancer per DNS name is expected
|
String region = parts[0];
|
||||||
for (String key : tuple.keySet()) {
|
String instanceId = parts[1];
|
||||||
elbClient.deleteLoadBalancerInRegion(key, tuple.get(key));
|
elbClient.deleteLoadBalancerInRegion(region, instanceId);
|
||||||
}
|
return getLoadBalancer.getLoadBalancer(id);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,47 @@
|
||||||
|
package org.jclouds.elb.loadbalancer.strategy;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
import static com.google.common.collect.Iterables.getOnlyElement;
|
||||||
|
import static org.jclouds.aws.ec2.util.EC2Utils.parseHandle;
|
||||||
|
|
||||||
|
import java.util.NoSuchElementException;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
import org.jclouds.elb.ELBClient;
|
||||||
|
import org.jclouds.elb.domain.LoadBalancer;
|
||||||
|
import org.jclouds.loadbalancer.domain.LoadBalancerMetadata;
|
||||||
|
import org.jclouds.loadbalancer.strategy.GetLoadBalancerMetadataStrategy;
|
||||||
|
|
||||||
|
import com.google.common.base.Function;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
@Singleton
|
||||||
|
public class ELBGetLoadBalancerMetadataStrategy implements GetLoadBalancerMetadataStrategy {
|
||||||
|
|
||||||
|
private final ELBClient client;
|
||||||
|
private final Function<LoadBalancer, LoadBalancerMetadata> converter;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
protected ELBGetLoadBalancerMetadataStrategy(ELBClient client, Function<LoadBalancer, LoadBalancerMetadata> converter) {
|
||||||
|
this.client = checkNotNull(client, "client");
|
||||||
|
this.converter = checkNotNull(converter, "converter");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LoadBalancerMetadata getLoadBalancer(String id) {
|
||||||
|
String[] parts = parseHandle(id);
|
||||||
|
String region = parts[0];
|
||||||
|
String instanceId = parts[1];
|
||||||
|
try {
|
||||||
|
return converter.apply(getOnlyElement(client.describeLoadBalancersInRegion(region, region, instanceId)));
|
||||||
|
} catch (NoSuchElementException e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,93 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 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.elb.loadbalancer.strategy;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
import static com.google.common.collect.Iterables.concat;
|
||||||
|
import static com.google.common.collect.Iterables.transform;
|
||||||
|
import static org.jclouds.concurrent.FutureIterables.transformParallel;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.ExecutorService;
|
||||||
|
import java.util.concurrent.Future;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Named;
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
import org.jclouds.Constants;
|
||||||
|
import org.jclouds.elb.ELBAsyncClient;
|
||||||
|
import org.jclouds.elb.ELBClient;
|
||||||
|
import org.jclouds.elb.domain.LoadBalancer;
|
||||||
|
import org.jclouds.loadbalancer.domain.LoadBalancerMetadata;
|
||||||
|
import org.jclouds.loadbalancer.reference.LoadBalancerConstants;
|
||||||
|
import org.jclouds.loadbalancer.strategy.ListLoadBalancersStrategy;
|
||||||
|
import org.jclouds.location.Region;
|
||||||
|
import org.jclouds.logging.Logger;
|
||||||
|
|
||||||
|
import com.google.common.base.Function;
|
||||||
|
import com.google.common.util.concurrent.ListenableFuture;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
@Singleton
|
||||||
|
public class ELBListLoadBalancersStrategy implements ListLoadBalancersStrategy {
|
||||||
|
@Resource
|
||||||
|
@Named(LoadBalancerConstants.LOADBALANCER_LOGGER)
|
||||||
|
protected Logger logger = Logger.NULL;
|
||||||
|
|
||||||
|
private final ELBClient client;
|
||||||
|
private final ELBAsyncClient aclient;
|
||||||
|
private final Function<LoadBalancer, LoadBalancerMetadata> converter;
|
||||||
|
private final ExecutorService executor;
|
||||||
|
private final Set<String> regions;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
protected ELBListLoadBalancersStrategy(ELBClient client, ELBAsyncClient aclient,
|
||||||
|
Function<LoadBalancer, LoadBalancerMetadata> converter,
|
||||||
|
@Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor, @Nullable @Region Set<String> regions) {
|
||||||
|
this.client = checkNotNull(client, "client");
|
||||||
|
this.aclient = checkNotNull(aclient, "aclient");
|
||||||
|
this.regions = checkNotNull(regions, "regions");
|
||||||
|
this.converter = checkNotNull(converter, "converter");
|
||||||
|
this.executor = checkNotNull(executor, "executor");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Iterable<? extends LoadBalancerMetadata> listLoadBalancers() {
|
||||||
|
Iterable<? extends LoadBalancer> loadBalancers;
|
||||||
|
if (regions != null)
|
||||||
|
loadBalancers = concat(transformParallel(regions, new Function<String, Future<Set<? extends LoadBalancer>>>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ListenableFuture<Set<? extends LoadBalancer>> apply(String from) {
|
||||||
|
return aclient.describeLoadBalancersInRegion(from);
|
||||||
|
}
|
||||||
|
|
||||||
|
}, executor, null, logger, "loadbalancers"));
|
||||||
|
else
|
||||||
|
loadBalancers = client.describeLoadBalancersInRegion(null);
|
||||||
|
return transform(loadBalancers, converter);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,109 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 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.elb.loadbalancer.strategy;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
import static org.jclouds.aws.ec2.compute.util.EC2ComputeUtils.getRegionFromLocationOrNull;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Named;
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
|
import org.jclouds.domain.Location;
|
||||||
|
import org.jclouds.elb.ELBClient;
|
||||||
|
import org.jclouds.elb.domain.LoadBalancer;
|
||||||
|
import org.jclouds.loadbalancer.domain.LoadBalancerMetadata;
|
||||||
|
import org.jclouds.loadbalancer.reference.LoadBalancerConstants;
|
||||||
|
import org.jclouds.loadbalancer.strategy.LoadBalanceNodesStrategy;
|
||||||
|
import org.jclouds.logging.Logger;
|
||||||
|
|
||||||
|
import com.google.common.base.Function;
|
||||||
|
import com.google.common.collect.Iterables;
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
@Singleton
|
||||||
|
public class ELBLoadBalanceNodesStrategy implements LoadBalanceNodesStrategy {
|
||||||
|
@Resource
|
||||||
|
@Named(LoadBalancerConstants.LOADBALANCER_LOGGER)
|
||||||
|
protected Logger logger = Logger.NULL;
|
||||||
|
protected final ELBClient client;
|
||||||
|
protected final Function<LoadBalancer, LoadBalancerMetadata> converter;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
protected ELBLoadBalanceNodesStrategy(ELBClient client, Function<LoadBalancer, LoadBalancerMetadata> converter) {
|
||||||
|
this.client = checkNotNull(client, "client");
|
||||||
|
this.converter = checkNotNull(converter, "converter");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LoadBalancerMetadata createLoadBalancerInLocation(Location location, String name, String protocol,
|
||||||
|
int loadBalancerPort, int instancePort, Iterable<? extends NodeMetadata> nodes) {
|
||||||
|
checkNotNull(location, "location");
|
||||||
|
String region = getRegionFromLocationOrNull(location);
|
||||||
|
|
||||||
|
List<String> availabilityZones = Lists.newArrayList(Iterables.transform(nodes,
|
||||||
|
new Function<NodeMetadata, String>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String apply(NodeMetadata from) {
|
||||||
|
return from.getLocation().getId();
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
|
client.createLoadBalancerInRegion(region, name, protocol, loadBalancerPort, instancePort,
|
||||||
|
availabilityZones.toArray(new String[] {}));
|
||||||
|
|
||||||
|
List<String> instanceIds = Lists.newArrayList(Iterables.transform(nodes, new Function<NodeMetadata, String>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String apply(NodeMetadata from) {
|
||||||
|
return from.getProviderId();
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
|
String[] instanceIdArray = instanceIds.toArray(new String[] {});
|
||||||
|
|
||||||
|
Set<String> registeredInstanceIds = client.registerInstancesWithLoadBalancerInRegion(region, name,
|
||||||
|
instanceIdArray);
|
||||||
|
|
||||||
|
// deregister instances
|
||||||
|
boolean changed = registeredInstanceIds.removeAll(instanceIds);
|
||||||
|
if (changed) {
|
||||||
|
List<String> list = new ArrayList<String>(registeredInstanceIds);
|
||||||
|
instanceIdArray = new String[list.size()];
|
||||||
|
for (int i = 0; i < list.size(); i++) {
|
||||||
|
instanceIdArray[i] = list.get(i);
|
||||||
|
}
|
||||||
|
if (instanceIdArray.length > 0)
|
||||||
|
client.deregisterInstancesWithLoadBalancerInRegion(region, name, instanceIdArray);
|
||||||
|
}
|
||||||
|
return converter.apply(Iterables.getOnlyElement(client.describeLoadBalancersInRegion(region, name)));
|
||||||
|
}
|
||||||
|
}
|
|
@ -17,7 +17,7 @@
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jclouds.aws.elb.xml;
|
package org.jclouds.elb.xml;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
|
|
@ -17,24 +17,22 @@
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jclouds.aws.elb.xml;
|
package org.jclouds.elb.xml;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import org.jclouds.aws.Region;
|
|
||||||
import org.jclouds.aws.ec2.util.EC2Utils;
|
import org.jclouds.aws.ec2.util.EC2Utils;
|
||||||
import org.jclouds.aws.elb.domain.LoadBalancer;
|
|
||||||
import org.jclouds.aws.elb.domain.LoadBalancer.AppCookieStickinessPolicy;
|
|
||||||
import org.jclouds.aws.elb.domain.LoadBalancer.LBCookieStickinessPolicy;
|
|
||||||
import org.jclouds.aws.elb.domain.LoadBalancer.LoadBalancerListener;
|
|
||||||
import org.jclouds.date.DateService;
|
import org.jclouds.date.DateService;
|
||||||
|
import org.jclouds.elb.domain.LoadBalancer;
|
||||||
|
import org.jclouds.elb.domain.LoadBalancer.AppCookieStickinessPolicy;
|
||||||
|
import org.jclouds.elb.domain.LoadBalancer.LBCookieStickinessPolicy;
|
||||||
|
import org.jclouds.elb.domain.LoadBalancer.LoadBalancerListener;
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.functions.ParseSax;
|
import org.jclouds.http.functions.ParseSax;
|
||||||
import org.jclouds.logging.Logger;
|
import org.jclouds.logging.Logger;
|
||||||
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
|
||||||
import org.xml.sax.Attributes;
|
import org.xml.sax.Attributes;
|
||||||
|
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
|
@ -45,22 +43,20 @@ import com.google.common.collect.Sets;
|
||||||
*/
|
*/
|
||||||
public class DescribeLoadBalancersResponseHandler extends
|
public class DescribeLoadBalancersResponseHandler extends
|
||||||
ParseSax.HandlerForGeneratedRequestWithResult<Set<LoadBalancer>> {
|
ParseSax.HandlerForGeneratedRequestWithResult<Set<LoadBalancer>> {
|
||||||
@Inject
|
private final DateService dateService;
|
||||||
public DescribeLoadBalancersResponseHandler(@Region String defaultRegion) {
|
private final LoadBalancerListenerHandler listenerHandler;
|
||||||
this.defaultRegion = defaultRegion;
|
|
||||||
this.listenerHandler = new LoadBalancerListenerHandler();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
protected DateService dateService;
|
public DescribeLoadBalancersResponseHandler(DateService dateService, LoadBalancerListenerHandler listenerHandler) {
|
||||||
|
this.dateService = dateService;
|
||||||
|
this.listenerHandler = listenerHandler;
|
||||||
|
}
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
protected Logger logger = Logger.NULL;
|
protected Logger logger = Logger.NULL;
|
||||||
|
|
||||||
private Set<LoadBalancer> contents = Sets.newLinkedHashSet();
|
private Set<LoadBalancer> contents = Sets.newLinkedHashSet();
|
||||||
private StringBuilder currentText = new StringBuilder();
|
private StringBuilder currentText = new StringBuilder();
|
||||||
private final String defaultRegion;
|
|
||||||
private final LoadBalancerListenerHandler listenerHandler;
|
|
||||||
|
|
||||||
private boolean inListenerDescriptions = false;
|
private boolean inListenerDescriptions = false;
|
||||||
private boolean inInstances = false;
|
private boolean inInstances = false;
|
||||||
|
@ -93,8 +89,7 @@ public class DescribeLoadBalancersResponseHandler extends
|
||||||
}
|
}
|
||||||
|
|
||||||
if (qName.equals("member")) {
|
if (qName.equals("member")) {
|
||||||
if (!(inListenerDescriptions || inAppCookieStickinessPolicies || inInstances
|
if (!(inListenerDescriptions || inAppCookieStickinessPolicies || inInstances || inLBCookieStickinessPolicies || inAvailabilityZones)) {
|
||||||
|| inLBCookieStickinessPolicies || inAvailabilityZones)) {
|
|
||||||
elb = new LoadBalancer();
|
elb = new LoadBalancer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -132,9 +127,6 @@ public class DescribeLoadBalancersResponseHandler extends
|
||||||
|| inLBCookieStickinessPolicies || inAvailabilityZones)) {
|
|| inLBCookieStickinessPolicies || inAvailabilityZones)) {
|
||||||
try {
|
try {
|
||||||
String region = EC2Utils.findRegionInArgsOrNull(getRequest());
|
String region = EC2Utils.findRegionInArgsOrNull(getRequest());
|
||||||
if (region == null)
|
|
||||||
region = defaultRegion;
|
|
||||||
|
|
||||||
elb.setRegion(region);
|
elb.setRegion(region);
|
||||||
contents.add(elb);
|
contents.add(elb);
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
|
@ -166,8 +158,7 @@ public class DescribeLoadBalancersResponseHandler extends
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public class LoadBalancerListenerHandler extends
|
public static class LoadBalancerListenerHandler extends ParseSax.HandlerWithResult<Set<LoadBalancerListener>> {
|
||||||
ParseSax.HandlerWithResult<Set<LoadBalancerListener>> {
|
|
||||||
private Set<LoadBalancerListener> listeners = Sets.newHashSet();
|
private Set<LoadBalancerListener> listeners = Sets.newHashSet();
|
||||||
private StringBuilder currentText = new StringBuilder();
|
private StringBuilder currentText = new StringBuilder();
|
||||||
private LoadBalancerListener listener;
|
private LoadBalancerListener listener;
|
|
@ -17,7 +17,7 @@
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jclouds.aws.elb.xml;
|
package org.jclouds.elb.xml;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
|
@ -0,0 +1,192 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 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.elb;
|
||||||
|
|
||||||
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
import javax.inject.Named;
|
||||||
|
|
||||||
|
import org.jclouds.Constants;
|
||||||
|
import org.jclouds.aws.filters.FormSigner;
|
||||||
|
import org.jclouds.date.DateService;
|
||||||
|
import org.jclouds.elb.config.ELBRestClientModule;
|
||||||
|
import org.jclouds.elb.xml.CreateLoadBalancerResponseHandler;
|
||||||
|
import org.jclouds.elb.xml.DescribeLoadBalancersResponseHandler;
|
||||||
|
import org.jclouds.elb.xml.RegisterInstancesWithLoadBalancerResponseHandler;
|
||||||
|
import org.jclouds.http.HttpRequest;
|
||||||
|
import org.jclouds.http.RequiresHttp;
|
||||||
|
import org.jclouds.http.functions.ParseSax;
|
||||||
|
import org.jclouds.http.functions.ReleasePayloadAndReturn;
|
||||||
|
import org.jclouds.rest.ConfiguresRestClient;
|
||||||
|
import org.jclouds.rest.RestClientTest;
|
||||||
|
import org.jclouds.rest.RestContextFactory;
|
||||||
|
import org.jclouds.rest.RestContextSpec;
|
||||||
|
import org.jclouds.rest.functions.MapHttp4xxCodesToExceptions;
|
||||||
|
import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404;
|
||||||
|
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
import com.google.inject.Module;
|
||||||
|
import com.google.inject.TypeLiteral;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests behavior of {@code ELBAsyncClient}
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
|
||||||
|
@Test(groups = "unit", testName = "ELBAsyncClientTest")
|
||||||
|
public class ELBAsyncClientTest extends RestClientTest<ELBAsyncClient> {
|
||||||
|
|
||||||
|
public void testCreateLoadBalancerInRegion() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
|
Method method = ELBAsyncClient.class.getMethod("createLoadBalancerInRegion", String.class, String.class,
|
||||||
|
String.class, int.class, int.class, String[].class);
|
||||||
|
HttpRequest request = processor.createRequest(method, null, "name", "http", 80, 80);
|
||||||
|
|
||||||
|
assertRequestLineEquals(request, "POST https://elasticloadbalancing.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||||
|
assertNonPayloadHeadersEqual(request, "Host: elasticloadbalancing.us-east-1.amazonaws.com\n");
|
||||||
|
assertPayloadEquals(
|
||||||
|
request,
|
||||||
|
"Version=2010-07-01&Action=CreateLoadBalancer&Listeners.member.1.Protocol=http&LoadBalancerName=name&Listeners.member.1.InstancePort=80&Listeners.member.1.LoadBalancerPort=80",
|
||||||
|
"application/x-www-form-urlencoded", false);
|
||||||
|
|
||||||
|
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||||
|
assertSaxResponseParserClassEquals(method, CreateLoadBalancerResponseHandler.class);
|
||||||
|
assertExceptionParserClassEquals(method, MapHttp4xxCodesToExceptions.class);
|
||||||
|
|
||||||
|
checkFilters(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testDescribeLoadBalancers() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
|
Method method = ELBAsyncClient.class.getMethod("describeLoadBalancersInRegion", String.class, String[].class);
|
||||||
|
HttpRequest request = processor.createRequest(method, (String) null);
|
||||||
|
|
||||||
|
assertRequestLineEquals(request, "POST https://elasticloadbalancing.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||||
|
assertNonPayloadHeadersEqual(request, "Host: elasticloadbalancing.us-east-1.amazonaws.com\n");
|
||||||
|
assertPayloadEquals(request, "Version=2010-07-01&Action=DescribeLoadBalancers",
|
||||||
|
"application/x-www-form-urlencoded", false);
|
||||||
|
|
||||||
|
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||||
|
assertSaxResponseParserClassEquals(method, DescribeLoadBalancersResponseHandler.class);
|
||||||
|
assertExceptionParserClassEquals(method, ReturnEmptySetOnNotFoundOr404.class);
|
||||||
|
|
||||||
|
checkFilters(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testDescribeLoadBalancersArgs() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
|
Method method = ELBAsyncClient.class.getMethod("describeLoadBalancersInRegion", String.class, String[].class);
|
||||||
|
HttpRequest request = processor.createRequest(method, null, "1", "2");
|
||||||
|
|
||||||
|
assertRequestLineEquals(request, "POST https://elasticloadbalancing.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||||
|
assertNonPayloadHeadersEqual(request, "Host: elasticloadbalancing.us-east-1.amazonaws.com\n");
|
||||||
|
assertPayloadEquals(
|
||||||
|
request,
|
||||||
|
"Version=2010-07-01&Action=DescribeLoadBalancers&LoadBalancerNames.member.1=1&LoadBalancerNames.member.2=2",
|
||||||
|
"application/x-www-form-urlencoded", false);
|
||||||
|
|
||||||
|
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||||
|
assertSaxResponseParserClassEquals(method, DescribeLoadBalancersResponseHandler.class);
|
||||||
|
assertExceptionParserClassEquals(method, ReturnEmptySetOnNotFoundOr404.class);
|
||||||
|
|
||||||
|
checkFilters(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testRegisterInstancesWithLoadBalancer() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
|
Method method = ELBAsyncClient.class.getMethod("registerInstancesWithLoadBalancerInRegion", String.class,
|
||||||
|
String.class, String[].class);
|
||||||
|
|
||||||
|
HttpRequest request = processor.createRequest(method, null, "ReferenceAP1", "i-6055fa09");
|
||||||
|
|
||||||
|
assertRequestLineEquals(request, "POST https://elasticloadbalancing.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||||
|
assertNonPayloadHeadersEqual(request, "Host: elasticloadbalancing.us-east-1.amazonaws.com\n");
|
||||||
|
assertPayloadEquals(
|
||||||
|
request,
|
||||||
|
"Version=2010-07-01&Action=RegisterInstancesWithLoadBalancer&LoadBalancerName=ReferenceAP1&Instances.member.1.InstanceId=i-6055fa09",
|
||||||
|
"application/x-www-form-urlencoded", false);
|
||||||
|
|
||||||
|
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||||
|
assertSaxResponseParserClassEquals(method, RegisterInstancesWithLoadBalancerResponseHandler.class);
|
||||||
|
assertExceptionParserClassEquals(method, null);
|
||||||
|
|
||||||
|
checkFilters(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testDeregisterInstancesWithLoadBalancer() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
|
Method method = ELBAsyncClient.class.getMethod("deregisterInstancesWithLoadBalancerInRegion", String.class,
|
||||||
|
String.class, String[].class);
|
||||||
|
|
||||||
|
HttpRequest request = processor.createRequest(method, null, "ReferenceAP1", "i-6055fa09");
|
||||||
|
|
||||||
|
assertRequestLineEquals(request, "POST https://elasticloadbalancing.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||||
|
assertNonPayloadHeadersEqual(request, "Host: elasticloadbalancing.us-east-1.amazonaws.com\n");
|
||||||
|
assertPayloadEquals(
|
||||||
|
request,
|
||||||
|
"Version=2010-07-01&Action=DeregisterInstancesFromLoadBalancer&LoadBalancerName=ReferenceAP1&Instances.member.1.InstanceId=i-6055fa09",
|
||||||
|
"application/x-www-form-urlencoded", false);
|
||||||
|
|
||||||
|
assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
|
||||||
|
assertSaxResponseParserClassEquals(method, null);
|
||||||
|
assertExceptionParserClassEquals(method, null);
|
||||||
|
|
||||||
|
checkFilters(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected TypeLiteral<RestAnnotationProcessor<ELBAsyncClient>> createTypeLiteral() {
|
||||||
|
return new TypeLiteral<RestAnnotationProcessor<ELBAsyncClient>>() {
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequiresHttp
|
||||||
|
@ConfiguresRestClient
|
||||||
|
private static final class TestELBRestClientModule extends ELBRestClientModule {
|
||||||
|
@Override
|
||||||
|
protected void configure() {
|
||||||
|
super.configure();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String provideTimeStamp(final DateService dateService,
|
||||||
|
@Named(Constants.PROPERTY_SESSION_INTERVAL) int expiration) {
|
||||||
|
return "2009-11-08T15:54:08.897Z";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Module createModule() {
|
||||||
|
return new TestELBRestClientModule();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public RestContextSpec<?, ?> createContextSpec() {
|
||||||
|
return new RestContextFactory().createContextSpec("elb", "identity", "credential", new Properties());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void checkFilters(HttpRequest request) {
|
||||||
|
assertEquals(request.getFilters().size(), 1);
|
||||||
|
assertEquals(request.getFilters().get(0).getClass(), FormSigner.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -17,22 +17,22 @@
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jclouds.aws.elb;
|
package org.jclouds.elb;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static org.testng.Assert.assertNotNull;
|
import static org.testng.Assert.assertNotNull;
|
||||||
|
|
||||||
|
import java.util.Map.Entry;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.Map.Entry;
|
|
||||||
|
|
||||||
import org.jclouds.Constants;
|
import org.jclouds.Constants;
|
||||||
import org.jclouds.aws.domain.Region;
|
import org.jclouds.aws.domain.Region;
|
||||||
import org.jclouds.aws.ec2.domain.AvailabilityZone;
|
import org.jclouds.aws.ec2.domain.AvailabilityZone;
|
||||||
import org.jclouds.aws.elb.domain.LoadBalancer;
|
import org.jclouds.elb.domain.LoadBalancer;
|
||||||
|
import org.jclouds.loadbalancer.LoadBalancerServiceContextFactory;
|
||||||
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
|
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
|
||||||
import org.jclouds.rest.RestContext;
|
import org.jclouds.rest.RestContext;
|
||||||
import org.jclouds.rest.RestContextFactory;
|
|
||||||
import org.testng.annotations.AfterTest;
|
import org.testng.annotations.AfterTest;
|
||||||
import org.testng.annotations.BeforeGroups;
|
import org.testng.annotations.BeforeGroups;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
@ -47,7 +47,7 @@ import com.google.inject.Module;
|
||||||
*
|
*
|
||||||
* @author Lili Nader
|
* @author Lili Nader
|
||||||
*/
|
*/
|
||||||
@Test(groups = "live", sequential = true, testName = "ec2.ELBClientLiveTest")
|
@Test(groups = "live", sequential = true)
|
||||||
public class ELBClientLiveTest {
|
public class ELBClientLiveTest {
|
||||||
|
|
||||||
private ELBClient client;
|
private ELBClient client;
|
||||||
|
@ -62,9 +62,8 @@ public class ELBClientLiveTest {
|
||||||
identity = checkNotNull(System.getProperty("test." + provider + ".identity"), "test." + provider + ".identity");
|
identity = checkNotNull(System.getProperty("test." + provider + ".identity"), "test." + provider + ".identity");
|
||||||
credential = checkNotNull(System.getProperty("test." + provider + ".credential"), "test." + provider
|
credential = checkNotNull(System.getProperty("test." + provider + ".credential"), "test." + provider
|
||||||
+ ".credential");
|
+ ".credential");
|
||||||
endpoint = checkNotNull(System.getProperty("test." + provider + ".endpoint"), "test." + provider + ".endpoint");
|
endpoint = System.getProperty("test." + provider + ".endpoint");
|
||||||
apiversion = checkNotNull(System.getProperty("test." + provider + ".apiversion"), "test." + provider
|
apiversion = System.getProperty("test." + provider + ".apiversion");
|
||||||
+ ".apiversion");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Properties setupProperties() {
|
protected Properties setupProperties() {
|
||||||
|
@ -72,8 +71,11 @@ public class ELBClientLiveTest {
|
||||||
overrides.setProperty(Constants.PROPERTY_TRUST_ALL_CERTS, "true");
|
overrides.setProperty(Constants.PROPERTY_TRUST_ALL_CERTS, "true");
|
||||||
overrides.setProperty(Constants.PROPERTY_RELAX_HOSTNAME, "true");
|
overrides.setProperty(Constants.PROPERTY_RELAX_HOSTNAME, "true");
|
||||||
overrides.setProperty(provider + ".identity", identity);
|
overrides.setProperty(provider + ".identity", identity);
|
||||||
|
if (credential != null)
|
||||||
overrides.setProperty(provider + ".credential", credential);
|
overrides.setProperty(provider + ".credential", credential);
|
||||||
|
if (endpoint != null)
|
||||||
overrides.setProperty(provider + ".endpoint", endpoint);
|
overrides.setProperty(provider + ".endpoint", endpoint);
|
||||||
|
if (apiversion != null)
|
||||||
overrides.setProperty(provider + ".apiversion", apiversion);
|
overrides.setProperty(provider + ".apiversion", apiversion);
|
||||||
return overrides;
|
return overrides;
|
||||||
}
|
}
|
||||||
|
@ -82,8 +84,8 @@ public class ELBClientLiveTest {
|
||||||
public void setupClient() {
|
public void setupClient() {
|
||||||
setupCredentials();
|
setupCredentials();
|
||||||
Properties overrides = setupProperties();
|
Properties overrides = setupProperties();
|
||||||
context = new RestContextFactory().createContext(provider, ImmutableSet.<Module> of(new Log4JLoggingModule()),
|
context = new LoadBalancerServiceContextFactory().createContext(provider,
|
||||||
overrides);
|
ImmutableSet.<Module> of(new Log4JLoggingModule()), overrides).getProviderSpecificContext();
|
||||||
client = context.getApi();
|
client = context.getApi();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,8 +95,8 @@ public class ELBClientLiveTest {
|
||||||
for (Entry<String, String> regionZone : ImmutableMap.<String, String> of(Region.US_EAST_1,
|
for (Entry<String, String> regionZone : ImmutableMap.<String, String> of(Region.US_EAST_1,
|
||||||
AvailabilityZone.US_EAST_1A, Region.US_WEST_1, AvailabilityZone.US_WEST_1A, Region.EU_WEST_1,
|
AvailabilityZone.US_EAST_1A, Region.US_WEST_1, AvailabilityZone.US_WEST_1A, Region.EU_WEST_1,
|
||||||
AvailabilityZone.EU_WEST_1A, Region.AP_SOUTHEAST_1, AvailabilityZone.AP_SOUTHEAST_1A).entrySet()) {
|
AvailabilityZone.EU_WEST_1A, Region.AP_SOUTHEAST_1, AvailabilityZone.AP_SOUTHEAST_1A).entrySet()) {
|
||||||
String dnsName = client.createLoadBalancerInRegion(regionZone.getKey(), name, "http", 80, 80, regionZone
|
String dnsName = client.createLoadBalancerInRegion(regionZone.getKey(), name, "http", 80, 80,
|
||||||
.getValue());
|
regionZone.getValue());
|
||||||
assertNotNull(dnsName);
|
assertNotNull(dnsName);
|
||||||
assert (dnsName.startsWith(name));
|
assert (dnsName.startsWith(name));
|
||||||
}
|
}
|
||||||
|
@ -104,7 +106,7 @@ public class ELBClientLiveTest {
|
||||||
void testDescribeLoadBalancers() {
|
void testDescribeLoadBalancers() {
|
||||||
for (String region : Lists.newArrayList(null, Region.EU_WEST_1, Region.US_EAST_1, Region.US_WEST_1,
|
for (String region : Lists.newArrayList(null, Region.EU_WEST_1, Region.US_EAST_1, Region.US_WEST_1,
|
||||||
Region.AP_SOUTHEAST_1)) {
|
Region.AP_SOUTHEAST_1)) {
|
||||||
Set<LoadBalancer> allResults = client.describeLoadBalancersInRegion(region);
|
Set<? extends LoadBalancer> allResults = client.describeLoadBalancersInRegion(region);
|
||||||
assertNotNull(allResults);
|
assertNotNull(allResults);
|
||||||
assert (allResults.size() >= 1);
|
assert (allResults.size() >= 1);
|
||||||
}
|
}
|
|
@ -0,0 +1,41 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 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.elb;
|
||||||
|
|
||||||
|
import org.jclouds.rest.Providers;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
import com.google.common.collect.Iterables;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Test(groups = "unit")
|
||||||
|
public class ProvidersInPropertiesTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSupportedProviders() {
|
||||||
|
Iterable<String> providers = Providers.getSupportedProviders();
|
||||||
|
assert Iterables.contains(providers, "elb") : providers;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -17,7 +17,7 @@
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jclouds.aws.ec2.compute;
|
package org.jclouds.elb.loadbalancer;
|
||||||
|
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
import static org.testng.Assert.assertNotNull;
|
import static org.testng.Assert.assertNotNull;
|
||||||
|
@ -26,35 +26,25 @@ import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.jclouds.aws.domain.Region;
|
import org.jclouds.aws.domain.Region;
|
||||||
import org.jclouds.aws.elb.ELBAsyncClient;
|
|
||||||
import org.jclouds.aws.elb.ELBClient;
|
|
||||||
import org.jclouds.aws.elb.domain.LoadBalancer;
|
|
||||||
import org.jclouds.compute.BaseLoadBalancerServiceLiveTest;
|
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
|
import org.jclouds.elb.ELBAsyncClient;
|
||||||
|
import org.jclouds.elb.ELBClient;
|
||||||
|
import org.jclouds.elb.domain.LoadBalancer;
|
||||||
|
import org.jclouds.loadbalancer.BaseLoadBalancerServiceLiveTest;
|
||||||
import org.jclouds.rest.RestContext;
|
import org.jclouds.rest.RestContext;
|
||||||
import org.jclouds.rest.RestContextFactory;
|
|
||||||
import org.jclouds.ssh.jsch.config.JschSshClientModule;
|
import org.jclouds.ssh.jsch.config.JschSshClientModule;
|
||||||
import org.testng.annotations.AfterGroups;
|
|
||||||
import org.testng.annotations.BeforeClass;
|
|
||||||
import org.testng.annotations.BeforeGroups;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Lili Nadar
|
* @author Lili Nadar
|
||||||
*/
|
*/
|
||||||
@Test(groups = "live", sequential = true, testName = "ec2.EC2LoadBalancerServiceLiveTest")
|
@Test(groups = "live", sequential = true)
|
||||||
public class EC2LoadBalancerServiceLiveTest extends BaseLoadBalancerServiceLiveTest {
|
public class ELBLoadBalancerServiceLiveTest extends BaseLoadBalancerServiceLiveTest {
|
||||||
|
|
||||||
private RestContext<ELBClient, ELBAsyncClient> elbContext;
|
public ELBLoadBalancerServiceLiveTest() {
|
||||||
|
provider = "elb";
|
||||||
@BeforeClass
|
computeProvider = "ec2";
|
||||||
@Override
|
|
||||||
public void setServiceDefaults() {
|
|
||||||
provider = "ec2";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -62,20 +52,9 @@ public class EC2LoadBalancerServiceLiveTest extends BaseLoadBalancerServiceLiveT
|
||||||
return new JschSshClientModule();
|
return new JschSshClientModule();
|
||||||
}
|
}
|
||||||
|
|
||||||
@BeforeGroups(groups = { "live" })
|
|
||||||
public void setupELBClient() {
|
|
||||||
elbContext = new RestContextFactory().createContext("elb", identity, credential,
|
|
||||||
ImmutableSet.of(new Log4JLoggingModule()));
|
|
||||||
}
|
|
||||||
|
|
||||||
@AfterGroups(groups = { "live" })
|
|
||||||
public void tearDownELBClient() {
|
|
||||||
if (elbContext != null)
|
|
||||||
elbContext.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void validateNodesInLoadBalancer() {
|
protected void validateNodesInLoadBalancer() {
|
||||||
|
RestContext<ELBClient, ELBAsyncClient> elbContext = context.getProviderSpecificContext();
|
||||||
// TODO create a LoadBalancer object and an appropriate list method so that this
|
// TODO create a LoadBalancer object and an appropriate list method so that this
|
||||||
// does not have to be EC2 specific code
|
// does not have to be EC2 specific code
|
||||||
ELBClient elbClient = elbContext.getApi();
|
ELBClient elbClient = elbContext.getApi();
|
||||||
|
@ -84,11 +63,10 @@ public class EC2LoadBalancerServiceLiveTest extends BaseLoadBalancerServiceLiveT
|
||||||
for (NodeMetadata node : nodes) {
|
for (NodeMetadata node : nodes) {
|
||||||
instanceIds.add(node.getProviderId());
|
instanceIds.add(node.getProviderId());
|
||||||
}
|
}
|
||||||
Set<LoadBalancer> elbs = elbClient.describeLoadBalancersInRegion(Region.US_EAST_1);
|
Set<? extends LoadBalancer> elbs = elbClient.describeLoadBalancersInRegion(Region.US_EAST_1);
|
||||||
assertNotNull(elbs);
|
assertNotNull(elbs);
|
||||||
for(LoadBalancer elb:elbs)
|
for (LoadBalancer elb : elbs) {
|
||||||
{
|
if (elb.getName().equals(tag))
|
||||||
if(elb.getName().equals(tag))
|
|
||||||
assertEquals(elb.getInstanceIds(), instanceIds);
|
assertEquals(elb.getInstanceIds(), instanceIds);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -17,7 +17,7 @@
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jclouds.aws.elb.xml;
|
package org.jclouds.elb.xml;
|
||||||
|
|
||||||
import static org.easymock.EasyMock.expect;
|
import static org.easymock.EasyMock.expect;
|
||||||
import static org.easymock.classextension.EasyMock.createMock;
|
import static org.easymock.classextension.EasyMock.createMock;
|
||||||
|
@ -27,29 +27,31 @@ import static org.testng.Assert.assertEquals;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.jclouds.aws.ec2.xml.BaseEC2HandlerTest;
|
import org.jclouds.elb.domain.LoadBalancer;
|
||||||
import org.jclouds.aws.elb.domain.LoadBalancer;
|
import org.jclouds.http.functions.BaseHandlerTest;
|
||||||
import org.jclouds.http.functions.ParseSax;
|
import org.jclouds.http.functions.ParseSax;
|
||||||
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests behavior of {@code DescribeLoadBalancersResponseHandler}
|
* Tests behavior of {@code DescribeLoadBalancerResponseHandler}
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = "unit", testName = "elb.DescribeLoadBalancersResponseHandlerTest")
|
// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
|
||||||
public class DescribeLoadBalancerResponseHandlerTest extends BaseEC2HandlerTest {
|
@Test(groups = "unit", testName = "DescribeLoadBalancerResponseHandlerTest")
|
||||||
|
public class DescribeLoadBalancerResponseHandlerTest extends BaseHandlerTest {
|
||||||
|
|
||||||
public void testParse() {
|
public void testParse() {
|
||||||
InputStream is = getClass().getResourceAsStream("/elb/describe_loadbalancers.xml");
|
InputStream is = getClass().getResourceAsStream("/describe_loadbalancers.xml");
|
||||||
|
|
||||||
Set<LoadBalancer> contents = Sets.newHashSet();
|
Set<LoadBalancer> contents = Sets.newHashSet();
|
||||||
LoadBalancer dummy = new LoadBalancer(defaultRegion, "my-load-balancer", ImmutableSet.of(
|
LoadBalancer dummy = new LoadBalancer(null, "my-load-balancer", ImmutableSet.of("i-5b33e630",
|
||||||
"i-5b33e630", "i-8f26d7e4", "i-5933e632"), ImmutableSet.of("us-east-1a"),
|
"i-8f26d7e4", "i-5933e632"), ImmutableSet.of("us-east-1a"),
|
||||||
"my-load-balancer-1400212309.us-east-1.elb.amazonaws.com");
|
"my-load-balancer-1400212309.us-east-1.elb.amazonaws.com");
|
||||||
contents.add(dummy);
|
contents.add(dummy);
|
||||||
|
|
||||||
|
@ -59,8 +61,7 @@ public class DescribeLoadBalancerResponseHandlerTest extends BaseEC2HandlerTest
|
||||||
}
|
}
|
||||||
|
|
||||||
private Set<LoadBalancer> parseLoadBalancers(InputStream is) {
|
private Set<LoadBalancer> parseLoadBalancers(InputStream is) {
|
||||||
DescribeLoadBalancersResponseHandler handler = injector
|
DescribeLoadBalancersResponseHandler handler = injector.getInstance(DescribeLoadBalancersResponseHandler.class);
|
||||||
.getInstance(DescribeLoadBalancersResponseHandler.class);
|
|
||||||
addDefaultRegionToHandler(handler);
|
addDefaultRegionToHandler(handler);
|
||||||
Set<LoadBalancer> result = factory.create(handler).parse(is);
|
Set<LoadBalancer> result = factory.create(handler).parse(is);
|
||||||
return result;
|
return result;
|
||||||
|
@ -68,7 +69,7 @@ public class DescribeLoadBalancerResponseHandlerTest extends BaseEC2HandlerTest
|
||||||
|
|
||||||
private void addDefaultRegionToHandler(ParseSax.HandlerWithResult<?> handler) {
|
private void addDefaultRegionToHandler(ParseSax.HandlerWithResult<?> handler) {
|
||||||
GeneratedHttpRequest<?> request = createMock(GeneratedHttpRequest.class);
|
GeneratedHttpRequest<?> request = createMock(GeneratedHttpRequest.class);
|
||||||
expect(request.getArgs()).andReturn(new Object[] { null });
|
expect(request.getArgs()).andReturn(ImmutableList.<Object> of());
|
||||||
replay(request);
|
replay(request);
|
||||||
handler.setContext(request);
|
handler.setContext(request);
|
||||||
}
|
}
|
|
@ -17,29 +17,29 @@
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jclouds.aws.elb.xml;
|
package org.jclouds.elb.xml;
|
||||||
|
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.jclouds.aws.ec2.xml.BaseEC2HandlerTest;
|
import org.jclouds.http.functions.BaseHandlerTest;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests behavior of {@code DescribeLoadBalancersResponseHandler}
|
* Tests behavior of {@code RegisterInstancesWithLoadBalancerResponseHandler}
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = "unit", testName = "ec2.RegisterInstancesWithLoadBalancerResponseHandlerTest")
|
// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
|
||||||
public class RegisterInstancesWithLoadBalancerResponseHandlerTest extends BaseEC2HandlerTest {
|
@Test(groups = "unit", testName = "RegisterInstancesWithLoadBalancerResponseHandlerTest")
|
||||||
|
public class RegisterInstancesWithLoadBalancerResponseHandlerTest extends BaseHandlerTest {
|
||||||
|
|
||||||
public void testParse() {
|
public void testParse() {
|
||||||
InputStream is = getClass().getResourceAsStream(
|
InputStream is = getClass().getResourceAsStream("/register_instances_with_loadbalancer.xml");
|
||||||
"/ec2/register_instances_with_loadbalancer.xml");
|
|
||||||
|
|
||||||
Set<String> instanceIds = Sets.newHashSet();
|
Set<String> instanceIds = Sets.newHashSet();
|
||||||
instanceIds.add("i-6055fa09");
|
instanceIds.add("i-6055fa09");
|
|
@ -0,0 +1,155 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!--
|
||||||
|
|
||||||
|
|
||||||
|
Copyright (C) 2010 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.
|
||||||
|
====================================================================
|
||||||
|
-->
|
||||||
|
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
|
||||||
|
|
||||||
|
<!--
|
||||||
|
For more configuration infromation and examples see the Apache
|
||||||
|
Log4j website: http://logging.apache.org/log4j/
|
||||||
|
-->
|
||||||
|
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"
|
||||||
|
debug="false">
|
||||||
|
|
||||||
|
<!-- A time/date based rolling appender -->
|
||||||
|
<appender name="WIREFILE" class="org.apache.log4j.DailyRollingFileAppender">
|
||||||
|
<param name="File" value="target/test-data/jclouds-wire.log" />
|
||||||
|
<param name="Append" value="true" />
|
||||||
|
|
||||||
|
<!-- Rollover at midnight each day -->
|
||||||
|
<param name="DatePattern" value="'.'yyyy-MM-dd" />
|
||||||
|
|
||||||
|
<param name="Threshold" value="TRACE" />
|
||||||
|
|
||||||
|
<layout class="org.apache.log4j.PatternLayout">
|
||||||
|
<!-- The default pattern: Date Priority [Category] Message\n -->
|
||||||
|
<param name="ConversionPattern" value="%d %-5p [%c] (%t) %m%n" />
|
||||||
|
|
||||||
|
<!--
|
||||||
|
The full pattern: Date MS Priority [Category]
|
||||||
|
(Thread:NDC) Message\n <param name="ConversionPattern"
|
||||||
|
value="%d %-5r %-5p [%c] (%t:%x) %m%n"/>
|
||||||
|
-->
|
||||||
|
</layout>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<!-- A time/date based rolling appender -->
|
||||||
|
<appender name="FILE" class="org.apache.log4j.DailyRollingFileAppender">
|
||||||
|
<param name="File" value="target/test-data/jclouds.log" />
|
||||||
|
<param name="Append" value="true" />
|
||||||
|
|
||||||
|
<!-- Rollover at midnight each day -->
|
||||||
|
<param name="DatePattern" value="'.'yyyy-MM-dd" />
|
||||||
|
|
||||||
|
<param name="Threshold" value="TRACE" />
|
||||||
|
|
||||||
|
<layout class="org.apache.log4j.PatternLayout">
|
||||||
|
<!-- The default pattern: Date Priority [Category] Message\n -->
|
||||||
|
<param name="ConversionPattern" value="%d %-5p [%c] (%t) %m%n" />
|
||||||
|
|
||||||
|
<!--
|
||||||
|
The full pattern: Date MS Priority [Category]
|
||||||
|
(Thread:NDC) Message\n <param name="ConversionPattern"
|
||||||
|
value="%d %-5r %-5p [%c] (%t:%x) %m%n"/>
|
||||||
|
-->
|
||||||
|
</layout>
|
||||||
|
</appender>
|
||||||
|
<!-- A time/date based rolling appender -->
|
||||||
|
<appender name="LOADBALANCERFILE" class="org.apache.log4j.DailyRollingFileAppender">
|
||||||
|
<param name="File" value="target/test-data/jclouds-loadbalancer.log" />
|
||||||
|
<param name="Append" value="true" />
|
||||||
|
<param name="DatePattern" value="'.'yyyy-MM-dd" />
|
||||||
|
<param name="Threshold" value="TRACE" />
|
||||||
|
<layout class="org.apache.log4j.PatternLayout">
|
||||||
|
<param name="ConversionPattern" value="%d %-5p [%c] (%t) %m%n" />
|
||||||
|
</layout>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<!-- A time/date based rolling appender -->
|
||||||
|
<appender name="COMPUTEFILE" class="org.apache.log4j.DailyRollingFileAppender">
|
||||||
|
<param name="File" value="target/test-data/jclouds-compute.log" />
|
||||||
|
<param name="Append" value="true" />
|
||||||
|
|
||||||
|
<!-- Rollover at midnight each day -->
|
||||||
|
<param name="DatePattern" value="'.'yyyy-MM-dd" />
|
||||||
|
|
||||||
|
<param name="Threshold" value="TRACE" />
|
||||||
|
|
||||||
|
<layout class="org.apache.log4j.PatternLayout">
|
||||||
|
<!-- The default pattern: Date Priority [Category] Message\n -->
|
||||||
|
<param name="ConversionPattern" value="%d %-5p [%c] (%t) %m%n" />
|
||||||
|
|
||||||
|
<!--
|
||||||
|
The full pattern: Date MS Priority [Category]
|
||||||
|
(Thread:NDC) Message\n <param name="ConversionPattern"
|
||||||
|
value="%d %-5r %-5p [%c] (%t:%x) %m%n"/>
|
||||||
|
-->
|
||||||
|
</layout>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<appender name="ASYNCCOMPUTE" class="org.apache.log4j.AsyncAppender">
|
||||||
|
<appender-ref ref="COMPUTEFILE" />
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<appender name="ASYNC" class="org.apache.log4j.AsyncAppender">
|
||||||
|
<appender-ref ref="FILE" />
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<appender name="ASYNCWIRE" class="org.apache.log4j.AsyncAppender">
|
||||||
|
<appender-ref ref="WIREFILE" />
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<appender name="ASYNCLOADBALANCER" class="org.apache.log4j.AsyncAppender">
|
||||||
|
<appender-ref ref="LOADBALANCERFILE" />
|
||||||
|
</appender>
|
||||||
|
<!-- ================ -->
|
||||||
|
<!-- Limit categories -->
|
||||||
|
<!-- ================ -->
|
||||||
|
|
||||||
|
<category name="org.jclouds">
|
||||||
|
<priority value="DEBUG" />
|
||||||
|
<appender-ref ref="ASYNC" />
|
||||||
|
</category>
|
||||||
|
|
||||||
|
<category name="jclouds.headers">
|
||||||
|
<priority value="DEBUG" />
|
||||||
|
<appender-ref ref="ASYNCWIRE" />
|
||||||
|
</category>
|
||||||
|
|
||||||
|
<category name="jclouds.wire">
|
||||||
|
<priority value="DEBUG" />
|
||||||
|
<appender-ref ref="ASYNCWIRE" />
|
||||||
|
</category>
|
||||||
|
<category name="jclouds.loadbalancer">
|
||||||
|
<priority value="DEBUG" />
|
||||||
|
<appender-ref ref="ASYNCLOADBALANCER" />
|
||||||
|
</category>
|
||||||
|
<category name="jclouds.compute">
|
||||||
|
<priority value="TRACE" />
|
||||||
|
<appender-ref ref="ASYNCCOMPUTE" />
|
||||||
|
</category>
|
||||||
|
<!-- ======================= -->
|
||||||
|
<!-- Setup the Root category -->
|
||||||
|
<!-- ======================= -->
|
||||||
|
|
||||||
|
<root>
|
||||||
|
<priority value="WARN" />
|
||||||
|
</root>
|
||||||
|
|
||||||
|
</log4j:configuration>
|
|
@ -24,24 +24,24 @@
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4.0.0.xsd" >
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4.0.0.xsd" >
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.jclouds</groupId>
|
<groupId>org.jclouds.api</groupId>
|
||||||
<artifactId>jclouds-project</artifactId>
|
<artifactId>jclouds-apis-project</artifactId>
|
||||||
<version>1.0-SNAPSHOT</version>
|
<version>1.0-SNAPSHOT</version>
|
||||||
<relativePath>../project/pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>jclouds-filesystem</artifactId>
|
<artifactId>filesystem</artifactId>
|
||||||
<name>jcloud filesystem core</name>
|
<name>jcloud filesystem core</name>
|
||||||
<description>jclouds components to access filesystem</description>
|
<description>jclouds components to access filesystem</description>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>${project.groupId}</groupId>
|
<groupId>org.jclouds</groupId>
|
||||||
<artifactId>jclouds-blobstore</artifactId>
|
<artifactId>jclouds-blobstore</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
<type>jar</type>
|
<type>jar</type>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>${project.groupId}</groupId>
|
<groupId>org.jclouds</groupId>
|
||||||
<artifactId>jclouds-core</artifactId>
|
<artifactId>jclouds-core</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
<type>test-jar</type>
|
<type>test-jar</type>
|
||||||
|
@ -53,14 +53,14 @@
|
||||||
<version>1.4</version>
|
<version>1.4</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>${project.groupId}</groupId>
|
<groupId>org.jclouds</groupId>
|
||||||
<artifactId>jclouds-blobstore</artifactId>
|
<artifactId>jclouds-blobstore</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
<type>test-jar</type>
|
<type>test-jar</type>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>${project.groupId}</groupId>
|
<groupId>org.jclouds</groupId>
|
||||||
<artifactId>jclouds-log4j</artifactId>
|
<artifactId>jclouds-log4j</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
|
@ -463,10 +463,6 @@ public class FilesystemAsyncBlobStore extends BaseAsyncBlobStore {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public HttpRequest getRequest() {
|
|
||||||
return new HttpRequest("GET", URI.create("http://stub"));
|
|
||||||
}
|
|
||||||
|
|
||||||
public int incrementFailureCount() {
|
public int incrementFailureCount() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -475,6 +471,16 @@ public class FilesystemAsyncBlobStore extends BaseAsyncBlobStore {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HttpRequest getCurrentRequest() {
|
||||||
|
return new HttpRequest("GET", URI.create("http://stub"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setCurrentRequest(HttpRequest request) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}, response);
|
}, response);
|
||||||
}
|
}
|
||||||
|
|
Before Width: | Height: | Size: 339 KiB After Width: | Height: | Size: 339 KiB |
Before Width: | Height: | Size: 844 KiB After Width: | Height: | Size: 844 KiB |
Before Width: | Height: | Size: 641 KiB After Width: | Height: | Size: 641 KiB |
Before Width: | Height: | Size: 2.8 MiB After Width: | Height: | Size: 2.8 MiB |
|
@ -0,0 +1,44 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!--
|
||||||
|
|
||||||
|
|
||||||
|
Copyright (C) 2010 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.
|
||||||
|
====================================================================
|
||||||
|
|
||||||
|
-->
|
||||||
|
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<artifactId>jclouds-project</artifactId>
|
||||||
|
<groupId>org.jclouds</groupId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
<relativePath>../project/pom.xml</relativePath>
|
||||||
|
</parent>
|
||||||
|
<groupId>org.jclouds.api</groupId>
|
||||||
|
<artifactId>jclouds-apis-project</artifactId>
|
||||||
|
<packaging>pom</packaging>
|
||||||
|
<name>jclouds apis project</name>
|
||||||
|
<modules>
|
||||||
|
<module>filesystem</module>
|
||||||
|
<module>s3</module>
|
||||||
|
<module>ec2</module>
|
||||||
|
<module>elb</module>
|
||||||
|
<module>sqs</module>
|
||||||
|
<module>simpledb</module>
|
||||||
|
<module>cloudwatch</module>
|
||||||
|
</modules>
|
||||||
|
</project>
|
|
@ -0,0 +1,128 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!--
|
||||||
|
|
||||||
|
|
||||||
|
Copyright (C) 2010 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.
|
||||||
|
====================================================================
|
||||||
|
|
||||||
|
-->
|
||||||
|
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4.0.0.xsd" >
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>org.jclouds.api</groupId>
|
||||||
|
<artifactId>jclouds-apis-project</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
<relativePath>../pom.xml</relativePath>
|
||||||
|
</parent>
|
||||||
|
<artifactId>s3</artifactId>
|
||||||
|
<name>jcloud s3 api</name>
|
||||||
|
<description>jclouds components to access an implementation of S3</description>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<test.initializer>org.jclouds.s3.blobstore.S3TestInitializer</test.initializer>
|
||||||
|
<test.s3.endpoint>https://s3.amazonaws.com</test.s3.endpoint>
|
||||||
|
<test.s3.apiversion>2006-03-01</test.s3.apiversion>
|
||||||
|
<test.s3.identity>${test.aws.identity}</test.s3.identity>
|
||||||
|
<test.s3.credential>${test.aws.credential}</test.s3.credential>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jclouds</groupId>
|
||||||
|
<artifactId>jclouds-aws</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
<type>jar</type>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jclouds</groupId>
|
||||||
|
<artifactId>jclouds-blobstore</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
<type>jar</type>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jclouds</groupId>
|
||||||
|
<artifactId>jclouds-core</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
<type>test-jar</type>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jclouds</groupId>
|
||||||
|
<artifactId>jclouds-blobstore</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
<type>test-jar</type>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jclouds</groupId>
|
||||||
|
<artifactId>jclouds-log4j</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<profiles>
|
||||||
|
<profile>
|
||||||
|
<id>live</id>
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>integration</id>
|
||||||
|
<phase>integration-test</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>test</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<systemProperties>
|
||||||
|
<property>
|
||||||
|
<name>test.s3.endpoint</name>
|
||||||
|
<value>${test.s3.endpoint}</value>
|
||||||
|
</property>
|
||||||
|
<property>
|
||||||
|
<name>test.s3.apiversion</name>
|
||||||
|
<value>${test.s3.apiversion}</value>
|
||||||
|
</property>
|
||||||
|
<property>
|
||||||
|
<name>test.s3.identity</name>
|
||||||
|
<value>${test.s3.identity}</value>
|
||||||
|
</property>
|
||||||
|
<property>
|
||||||
|
<name>test.s3.credential</name>
|
||||||
|
<value>${test.s3.credential}</value>
|
||||||
|
</property>
|
||||||
|
<property>
|
||||||
|
<name>test.initializer</name>
|
||||||
|
<value>${test.initializer}</value>
|
||||||
|
</property>
|
||||||
|
</systemProperties>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</profile>
|
||||||
|
</profiles>
|
||||||
|
|
||||||
|
|
||||||
|
</project>
|
||||||
|
|
|
@ -0,0 +1,110 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!--
|
||||||
|
|
||||||
|
|
||||||
|
Copyright (C) 2010 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.
|
||||||
|
====================================================================
|
||||||
|
|
||||||
|
-->
|
||||||
|
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4.0.0.xsd" >
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>org.jclouds.api</groupId>
|
||||||
|
<artifactId>jclouds-apis-project</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
<relativePath>../pom.xml</relativePath>
|
||||||
|
</parent>
|
||||||
|
<artifactId>simpledb</artifactId>
|
||||||
|
<name>jcloud simpledb api</name>
|
||||||
|
<description>jclouds components to access an implementation of Simple DB</description>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<test.simpledb.endpoint>https://sdb.amazonaws.com</test.simpledb.endpoint>
|
||||||
|
<test.simpledb.apiversion>2009-04-15</test.simpledb.apiversion>
|
||||||
|
<test.simpledb.identity>${test.aws.identity}</test.simpledb.identity>
|
||||||
|
<test.simpledb.credential>${test.aws.credential}</test.simpledb.credential>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jclouds</groupId>
|
||||||
|
<artifactId>jclouds-aws</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
<type>jar</type>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jclouds</groupId>
|
||||||
|
<artifactId>jclouds-core</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
<type>test-jar</type>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jclouds</groupId>
|
||||||
|
<artifactId>jclouds-log4j</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<profiles>
|
||||||
|
<profile>
|
||||||
|
<id>live</id>
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>integration</id>
|
||||||
|
<phase>integration-test</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>test</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<systemProperties>
|
||||||
|
<property>
|
||||||
|
<name>test.simpledb.endpoint</name>
|
||||||
|
<value>${test.simpledb.endpoint}</value>
|
||||||
|
</property>
|
||||||
|
<property>
|
||||||
|
<name>test.simpledb.apiversion</name>
|
||||||
|
<value>${test.simpledb.apiversion}</value>
|
||||||
|
</property>
|
||||||
|
<property>
|
||||||
|
<name>test.simpledb.identity</name>
|
||||||
|
<value>${test.simpledb.identity}</value>
|
||||||
|
</property>
|
||||||
|
<property>
|
||||||
|
<name>test.simpledb.credential</name>
|
||||||
|
<value>${test.simpledb.credential}</value>
|
||||||
|
</property>
|
||||||
|
</systemProperties>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</profile>
|
||||||
|
</profiles>
|
||||||
|
|
||||||
|
|
||||||
|
</project>
|
||||||
|
|
|
@ -17,10 +17,12 @@
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jclouds.aws.simpledb;
|
package org.jclouds.simpledb;
|
||||||
|
|
||||||
import static org.jclouds.aws.simpledb.reference.SimpleDBParameters.ACTION;
|
import static org.jclouds.simpledb.reference.SimpleDBParameters.ACTION;
|
||||||
import static org.jclouds.aws.simpledb.reference.SimpleDBParameters.VERSION;
|
import static org.jclouds.simpledb.reference.SimpleDBParameters.VERSION;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import javax.ws.rs.FormParam;
|
import javax.ws.rs.FormParam;
|
||||||
|
@ -28,15 +30,19 @@ import javax.ws.rs.POST;
|
||||||
import javax.ws.rs.Path;
|
import javax.ws.rs.Path;
|
||||||
|
|
||||||
import org.jclouds.aws.filters.FormSigner;
|
import org.jclouds.aws.filters.FormSigner;
|
||||||
import org.jclouds.aws.functions.RegionToEndpoint;
|
import org.jclouds.location.functions.RegionToEndpointOrProviderIfNull;
|
||||||
import org.jclouds.aws.simpledb.domain.ListDomainsResponse;
|
import org.jclouds.rest.annotations.BinderParam;
|
||||||
import org.jclouds.aws.simpledb.options.ListDomainsOptions;
|
|
||||||
import org.jclouds.aws.simpledb.xml.ListDomainsResponseHandler;
|
|
||||||
import org.jclouds.rest.annotations.EndpointParam;
|
import org.jclouds.rest.annotations.EndpointParam;
|
||||||
import org.jclouds.rest.annotations.FormParams;
|
import org.jclouds.rest.annotations.FormParams;
|
||||||
import org.jclouds.rest.annotations.RequestFilters;
|
import org.jclouds.rest.annotations.RequestFilters;
|
||||||
import org.jclouds.rest.annotations.VirtualHost;
|
import org.jclouds.rest.annotations.VirtualHost;
|
||||||
import org.jclouds.rest.annotations.XMLResponseParser;
|
import org.jclouds.rest.annotations.XMLResponseParser;
|
||||||
|
import org.jclouds.simpledb.binders.BindAttributesToIndexedFormParams;
|
||||||
|
import org.jclouds.simpledb.domain.Item;
|
||||||
|
import org.jclouds.simpledb.domain.ListDomainsResponse;
|
||||||
|
import org.jclouds.simpledb.options.ListDomainsOptions;
|
||||||
|
import org.jclouds.simpledb.xml.ItemsHandler;
|
||||||
|
import org.jclouds.simpledb.xml.ListDomainsResponseHandler;
|
||||||
|
|
||||||
import com.google.common.util.concurrent.ListenableFuture;
|
import com.google.common.util.concurrent.ListenableFuture;
|
||||||
|
|
||||||
|
@ -45,6 +51,7 @@ import com.google.common.util.concurrent.ListenableFuture;
|
||||||
* <p/>
|
* <p/>
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
|
* @author Luís A. Bastião Silva <bastiao@ua.pt>
|
||||||
*/
|
*/
|
||||||
@RequestFilters(FormSigner.class)
|
@RequestFilters(FormSigner.class)
|
||||||
@FormParams(keys = VERSION, values = SimpleDBAsyncClient.VERSION)
|
@FormParams(keys = VERSION, values = SimpleDBAsyncClient.VERSION)
|
||||||
|
@ -60,7 +67,7 @@ public interface SimpleDBAsyncClient {
|
||||||
@FormParams(keys = ACTION, values = "ListDomains")
|
@FormParams(keys = ACTION, values = "ListDomains")
|
||||||
@XMLResponseParser(ListDomainsResponseHandler.class)
|
@XMLResponseParser(ListDomainsResponseHandler.class)
|
||||||
ListenableFuture<? extends ListDomainsResponse> listDomainsInRegion(
|
ListenableFuture<? extends ListDomainsResponse> listDomainsInRegion(
|
||||||
@EndpointParam(parser = RegionToEndpoint.class) @Nullable String region, ListDomainsOptions... options);
|
@EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, ListDomainsOptions... options);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see SimpleDBClient#createDomainInRegion
|
* @see SimpleDBClient#createDomainInRegion
|
||||||
|
@ -68,7 +75,7 @@ public interface SimpleDBAsyncClient {
|
||||||
@POST
|
@POST
|
||||||
@Path("/")
|
@Path("/")
|
||||||
@FormParams(keys = ACTION, values = "CreateDomain")
|
@FormParams(keys = ACTION, values = "CreateDomain")
|
||||||
ListenableFuture<Void> createDomainInRegion(@EndpointParam(parser = RegionToEndpoint.class) @Nullable String region,
|
ListenableFuture<Void> createDomainInRegion(@EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region,
|
||||||
@FormParam("DomainName") String domainName);
|
@FormParam("DomainName") String domainName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -77,7 +84,31 @@ public interface SimpleDBAsyncClient {
|
||||||
@POST
|
@POST
|
||||||
@Path("/")
|
@Path("/")
|
||||||
@FormParams(keys = ACTION, values = "DeleteDomain")
|
@FormParams(keys = ACTION, values = "DeleteDomain")
|
||||||
ListenableFuture<Void> deleteDomainInRegion(@EndpointParam(parser = RegionToEndpoint.class) @Nullable String region,
|
ListenableFuture<Void> deleteDomainInRegion(@EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region,
|
||||||
@FormParam("DomainName") String domainName);
|
@FormParam("DomainName") String domainName);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see SimpleDBClient#putAttributes
|
||||||
|
*/
|
||||||
|
@POST
|
||||||
|
@Path("/")
|
||||||
|
@FormParams(keys = ACTION, values = "PutAttributes")
|
||||||
|
ListenableFuture<Void> putAttributes(@EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region,
|
||||||
|
@FormParam("DomainName") String domainName,
|
||||||
|
@FormParam("ItemName") String itemName,
|
||||||
|
@BinderParam(BindAttributesToIndexedFormParams.class) Item attributes);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see SimpleDBClient#putAttributes
|
||||||
|
*/
|
||||||
|
@POST
|
||||||
|
@Path("/")
|
||||||
|
@FormParams(keys = ACTION, values = "Select")
|
||||||
|
@XMLResponseParser(ItemsHandler.class)
|
||||||
|
ListenableFuture<? extends Map<String, Item>> select(@EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region,
|
||||||
|
@FormParam("SelectExpression") String selectExpression);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -17,21 +17,24 @@
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jclouds.aws.simpledb;
|
package org.jclouds.simpledb;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import org.jclouds.aws.simpledb.domain.ListDomainsResponse;
|
|
||||||
import org.jclouds.aws.simpledb.options.ListDomainsOptions;
|
|
||||||
import org.jclouds.concurrent.Timeout;
|
import org.jclouds.concurrent.Timeout;
|
||||||
|
import org.jclouds.simpledb.domain.Item;
|
||||||
|
import org.jclouds.simpledb.domain.ListDomainsResponse;
|
||||||
|
import org.jclouds.simpledb.options.ListDomainsOptions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides access to SimpleDB via their REST API.
|
* Provides access to SimpleDB via their REST API.
|
||||||
* <p/>
|
* <p/>
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
|
* @author Luís A. Bastião Silva <bastiao@ua.pt>
|
||||||
*/
|
*/
|
||||||
@Timeout(duration = 30, timeUnit = TimeUnit.SECONDS)
|
@Timeout(duration = 30, timeUnit = TimeUnit.SECONDS)
|
||||||
public interface SimpleDBClient {
|
public interface SimpleDBClient {
|
||||||
|
@ -69,7 +72,7 @@ public interface SimpleDBClient {
|
||||||
* You can create up to 100 domains per account.
|
* You can create up to 100 domains per account.
|
||||||
* <p/>
|
* <p/>
|
||||||
* If you require additional domains, go to
|
* If you require additional domains, go to
|
||||||
* http://aws.amazon.com/contact-us/simpledb-limit-request/.
|
* http://amazon.com/contact-us/simpledb-limit-request/.
|
||||||
*
|
*
|
||||||
* @param region
|
* @param region
|
||||||
* Domains are Region-specific.
|
* Domains are Region-specific.
|
||||||
|
@ -103,5 +106,6 @@ public interface SimpleDBClient {
|
||||||
* />
|
* />
|
||||||
*/
|
*/
|
||||||
void deleteDomainInRegion(String region, String domainName);
|
void deleteDomainInRegion(String region, String domainName);
|
||||||
|
void putAttributes(String region, String domain, String itemName, Item attributes);
|
||||||
|
Map<String, Item> select(String region, String selectionExpression);
|
||||||
}
|
}
|
|
@ -17,15 +17,15 @@
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jclouds.aws.simpledb;
|
package org.jclouds.simpledb;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import org.jclouds.aws.simpledb.config.SimpleDBRestClientModule;
|
|
||||||
import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule;
|
import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule;
|
||||||
import org.jclouds.logging.jdk.config.JDKLoggingModule;
|
import org.jclouds.logging.jdk.config.JDKLoggingModule;
|
||||||
import org.jclouds.rest.RestContextBuilder;
|
import org.jclouds.rest.RestContextBuilder;
|
||||||
|
import org.jclouds.simpledb.config.SimpleDBRestClientModule;
|
||||||
|
|
||||||
import com.google.inject.Injector;
|
import com.google.inject.Injector;
|
||||||
import com.google.inject.Module;
|
import com.google.inject.Module;
|
||||||
|
@ -41,6 +41,7 @@ import com.google.inject.Module;
|
||||||
* {@link JavaUrlHttpCommandExecutorServiceModule http transports} will be installed.
|
* {@link JavaUrlHttpCommandExecutorServiceModule http transports} will be installed.
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
|
* @author Luís A. Bastião Silva <bastiao@ua.pt>
|
||||||
* @see SimpleDBContext
|
* @see SimpleDBContext
|
||||||
*/
|
*/
|
||||||
public class SimpleDBContextBuilder extends RestContextBuilder<SimpleDBClient, SimpleDBAsyncClient> {
|
public class SimpleDBContextBuilder extends RestContextBuilder<SimpleDBClient, SimpleDBAsyncClient> {
|
|
@ -17,20 +17,16 @@
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jclouds.aws.simpledb;
|
package org.jclouds.simpledb;
|
||||||
|
|
||||||
import static org.jclouds.Constants.PROPERTY_API_VERSION;
|
import static org.jclouds.Constants.PROPERTY_API_VERSION;
|
||||||
import static org.jclouds.Constants.PROPERTY_ENDPOINT;
|
import static org.jclouds.Constants.PROPERTY_ENDPOINT;
|
||||||
import static org.jclouds.aws.reference.AWSConstants.PROPERTY_AUTH_TAG;
|
import static org.jclouds.aws.reference.AWSConstants.PROPERTY_AUTH_TAG;
|
||||||
import static org.jclouds.aws.reference.AWSConstants.PROPERTY_HEADER_TAG;
|
import static org.jclouds.aws.reference.AWSConstants.PROPERTY_HEADER_TAG;
|
||||||
import static org.jclouds.aws.reference.AWSConstants.PROPERTY_REGIONS;
|
|
||||||
|
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import org.jclouds.PropertiesBuilder;
|
import org.jclouds.PropertiesBuilder;
|
||||||
import org.jclouds.aws.domain.Region;
|
|
||||||
|
|
||||||
import com.google.common.base.Joiner;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builds properties used in SimpleDB Clients
|
* Builds properties used in SimpleDB Clients
|
||||||
|
@ -38,23 +34,14 @@ import com.google.common.base.Joiner;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
public class SimpleDBPropertiesBuilder extends PropertiesBuilder {
|
public class SimpleDBPropertiesBuilder extends PropertiesBuilder {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Properties defaultProperties() {
|
protected Properties defaultProperties() {
|
||||||
Properties properties = super.defaultProperties();
|
Properties properties = super.defaultProperties();
|
||||||
properties.setProperty(PROPERTY_AUTH_TAG, "AWS");
|
properties.setProperty(PROPERTY_AUTH_TAG, "AWS");
|
||||||
properties.setProperty(PROPERTY_HEADER_TAG, "amz");
|
properties.setProperty(PROPERTY_HEADER_TAG, "amz");
|
||||||
properties.setProperty(PROPERTY_API_VERSION, SimpleDBAsyncClient.VERSION);
|
properties.setProperty(PROPERTY_API_VERSION, SimpleDBAsyncClient.VERSION);
|
||||||
properties.setProperty(PROPERTY_REGIONS, Joiner.on(',').join(Region.US_EAST_1,
|
|
||||||
Region.US_WEST_1, Region.EU_WEST_1, Region.AP_SOUTHEAST_1));
|
|
||||||
properties.setProperty(PROPERTY_ENDPOINT, "https://sdb.amazonaws.com");
|
properties.setProperty(PROPERTY_ENDPOINT, "https://sdb.amazonaws.com");
|
||||||
properties.setProperty(PROPERTY_ENDPOINT + "." + Region.US_EAST_1,
|
|
||||||
"https://sdb.amazonaws.com");
|
|
||||||
properties.setProperty(PROPERTY_ENDPOINT + "." + Region.US_WEST_1,
|
|
||||||
"https://sdb.us-west-1.amazonaws.com");
|
|
||||||
properties.setProperty(PROPERTY_ENDPOINT + "." + Region.EU_WEST_1,
|
|
||||||
"https://sdb.eu-west-1.amazonaws.com");
|
|
||||||
properties.setProperty(PROPERTY_ENDPOINT + "." + Region.AP_SOUTHEAST_1,
|
|
||||||
"https://sdb.ap-southeast-1.amazonaws.com");
|
|
||||||
return properties;
|
return properties;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,60 @@
|
||||||
|
package org.jclouds.simpledb.binders;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
import static java.lang.String.format;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Iterator;
|
||||||
|
|
||||||
|
import org.jclouds.simpledb.domain.AttributePair;
|
||||||
|
import org.jclouds.simpledb.domain.Item;
|
||||||
|
import org.jclouds.http.HttpRequest;
|
||||||
|
import org.jclouds.http.utils.ModifyRequest;
|
||||||
|
import org.jclouds.rest.Binder;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableMultimap;
|
||||||
|
import com.google.common.collect.ImmutableMultimap.Builder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Luís A. Bastião Silva <bastiao@ua.pt>
|
||||||
|
*/
|
||||||
|
public class BindAttributesToIndexedFormParams implements Binder {
|
||||||
|
|
||||||
|
private final String attributeName = "Attribute.%d.Name";
|
||||||
|
private final String attributeValue = "Attribute.%d.Value";
|
||||||
|
private final String attributeReplace = "Attribute.%d.Replace";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <R extends HttpRequest> R bindToRequest(R request, Object input) {
|
||||||
|
checkArgument(checkNotNull(input, "input") instanceof Item, "this binder is only valid for AttributeMap");
|
||||||
|
Item attributeMap = (Item) input;
|
||||||
|
|
||||||
|
Builder<String, String> builder = ImmutableMultimap.<String, String> builder();
|
||||||
|
int amazonOneBasedIndex = 1; // according to docs, counters must start with 1
|
||||||
|
for (String itemName : attributeMap.getAttributes().keySet()) {
|
||||||
|
|
||||||
|
Collection<AttributePair> c = attributeMap.getAttributes().get(itemName);
|
||||||
|
Iterator<AttributePair> it = c.iterator();
|
||||||
|
while (it.hasNext()) {
|
||||||
|
AttributePair attr = it.next();
|
||||||
|
// not null by contract
|
||||||
|
|
||||||
|
String value = attr.getValue();
|
||||||
|
|
||||||
|
if (value != null) {
|
||||||
|
builder.put(format(attributeName, amazonOneBasedIndex), attr.getKey());
|
||||||
|
builder.put(format(attributeValue, amazonOneBasedIndex), value);
|
||||||
|
builder.put(format(attributeReplace, amazonOneBasedIndex), String.valueOf(attr.isReplace()));
|
||||||
|
|
||||||
|
}
|
||||||
|
amazonOneBasedIndex++;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
ImmutableMultimap<String, String> forms = builder.build();
|
||||||
|
return forms.size() == 0 ? request : ModifyRequest.putFormParams(request, forms);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -17,22 +17,23 @@
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jclouds.aws.simpledb.config;
|
package org.jclouds.simpledb.config;
|
||||||
|
|
||||||
import org.jclouds.aws.config.AWSFormSigningRestClientModule;
|
import org.jclouds.aws.config.FormSigningRestClientModule;
|
||||||
import org.jclouds.aws.simpledb.SimpleDBAsyncClient;
|
|
||||||
import org.jclouds.aws.simpledb.SimpleDBClient;
|
|
||||||
import org.jclouds.http.RequiresHttp;
|
import org.jclouds.http.RequiresHttp;
|
||||||
import org.jclouds.rest.ConfiguresRestClient;
|
import org.jclouds.rest.ConfiguresRestClient;
|
||||||
|
import org.jclouds.simpledb.SimpleDBAsyncClient;
|
||||||
|
import org.jclouds.simpledb.SimpleDBClient;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configures the SimpleDB connection.
|
* Configures the SimpleDB connection.
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
|
* @author Luís A. Bastião Silva <bastiao@ua.pt>
|
||||||
*/
|
*/
|
||||||
@RequiresHttp
|
@RequiresHttp
|
||||||
@ConfiguresRestClient
|
@ConfiguresRestClient
|
||||||
public class SimpleDBRestClientModule extends AWSFormSigningRestClientModule<SimpleDBClient, SimpleDBAsyncClient> {
|
public class SimpleDBRestClientModule extends FormSigningRestClientModule<SimpleDBClient, SimpleDBAsyncClient> {
|
||||||
|
|
||||||
public SimpleDBRestClientModule() {
|
public SimpleDBRestClientModule() {
|
||||||
super(SimpleDBClient.class, SimpleDBAsyncClient.class);
|
super(SimpleDBClient.class, SimpleDBAsyncClient.class);
|
|
@ -0,0 +1,60 @@
|
||||||
|
package org.jclouds.simpledb.domain;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AttributePair is a class to support the attributes to put in the SimpleDB
|
||||||
|
* <p/>
|
||||||
|
*
|
||||||
|
* @author Luís A. Bastião Silva <bastiao@ua.pt>
|
||||||
|
*/
|
||||||
|
public class AttributePair
|
||||||
|
{
|
||||||
|
|
||||||
|
private String key;
|
||||||
|
private String value;
|
||||||
|
private boolean replace;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Default constructor to represent an attribute in a domain in SimpleDB
|
||||||
|
*
|
||||||
|
* <p/>
|
||||||
|
*
|
||||||
|
* @param key Name of Attribute
|
||||||
|
* @param value Value of Attribute
|
||||||
|
* @param replace Replace value if it already exists in domain
|
||||||
|
*/
|
||||||
|
public AttributePair(String key, String value, boolean replace)
|
||||||
|
{
|
||||||
|
this.key = key;
|
||||||
|
|
||||||
|
this.value = value ;
|
||||||
|
this.replace = replace;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public String getKey() {
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public String getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValue(String value)
|
||||||
|
{
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public boolean isReplace() {
|
||||||
|
return replace;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -17,7 +17,7 @@
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jclouds.aws.simpledb.domain;
|
package org.jclouds.simpledb.domain;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
|
@ -27,6 +27,7 @@ import java.util.Date;
|
||||||
* "http://docs.amazonwebservices.com/AmazonSimpleDB/2009-04-15/DeveloperGuide/index.html?SDB_API_CreateDomain.html"
|
* "http://docs.amazonwebservices.com/AmazonSimpleDB/2009-04-15/DeveloperGuide/index.html?SDB_API_CreateDomain.html"
|
||||||
* />
|
* />
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
|
* @author Luís A. Bastião Silva <bastiao@ua.pt>
|
||||||
*/
|
*/
|
||||||
public class DomainMetadata {
|
public class DomainMetadata {
|
||||||
private final String region;
|
private final String region;
|
|
@ -0,0 +1,45 @@
|
||||||
|
package org.jclouds.simpledb.domain;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableMultimap;
|
||||||
|
import com.google.common.collect.LinkedHashMultimap;
|
||||||
|
import com.google.common.collect.Multimap;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defines the mapping of Items
|
||||||
|
*
|
||||||
|
* @author Luís A. Bastião Silva <bastiao@ua.pt>
|
||||||
|
*/
|
||||||
|
public class Item {
|
||||||
|
|
||||||
|
private final Multimap<String, AttributePair> attributes = LinkedHashMultimap
|
||||||
|
.create();
|
||||||
|
|
||||||
|
public Item() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a map of Attribute Pair
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public Item(Multimap<String, AttributePair> attributes)
|
||||||
|
{
|
||||||
|
|
||||||
|
this.attributes.putAll(attributes);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public Item addAttributePair(@Nullable String itemName,
|
||||||
|
AttributePair attrPair)
|
||||||
|
{
|
||||||
|
this.attributes.put(itemName, attrPair);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Multimap<String, AttributePair> getAttributes()
|
||||||
|
{
|
||||||
|
return ImmutableMultimap.<String, AttributePair> builder().putAll(
|
||||||
|
attributes).build();
|
||||||
|
}
|
||||||
|
}
|
|
@ -17,13 +17,14 @@
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jclouds.aws.simpledb.domain;
|
package org.jclouds.simpledb.domain;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
|
* @author Luís A. Bastião Silva <bastiao@ua.pt>
|
||||||
* @see <a href="http://docs.amazonwebservices.com/AmazonS3/2006-03-01/index.html" />
|
* @see <a href="http://docs.amazonwebservices.com/AmazonS3/2006-03-01/index.html" />
|
||||||
*/
|
*/
|
||||||
public interface ListDomainsResponse extends Set<String> {
|
public interface ListDomainsResponse extends Set<String> {
|
|
@ -17,7 +17,7 @@
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jclouds.aws.simpledb.options;
|
package org.jclouds.simpledb.options;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkArgument;
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
@ -31,13 +31,14 @@ import org.jclouds.http.options.BaseHttpRequestOptions;
|
||||||
* (if needed):
|
* (if needed):
|
||||||
* <p/>
|
* <p/>
|
||||||
* <code>
|
* <code>
|
||||||
* import static org.jclouds.aws.simpledb.options.ListDomainsOptions.Builder.*
|
* import static org.jclouds.simpledb.options.ListDomainsOptions.Builder.*
|
||||||
* <p/>
|
* <p/>
|
||||||
* SimpleDBClient connection = // get connection
|
* SimpleDBClient connection = // get connection
|
||||||
* Set<String> domains = connection.listDomainsInRegion(maxNumberOfDomains(1));
|
* Set<String> domains = connection.listDomainsInRegion(maxNumberOfDomains(1));
|
||||||
* <code>
|
* <code>
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
|
* @author Luís A. Bastião Silva <bastiao@ua.pt>
|
||||||
* @see <a href=
|
* @see <a href=
|
||||||
* "http://docs.amazonwebservices.com/AmazonSimpleDB/2009-04-15/DeveloperGuide/SDB_API_ListDomains.html"
|
* "http://docs.amazonwebservices.com/AmazonSimpleDB/2009-04-15/DeveloperGuide/SDB_API_ListDomains.html"
|
||||||
* />
|
* />
|
|
@ -21,5 +21,6 @@
|
||||||
*
|
*
|
||||||
* @see <a href="http://docs.amazonwebservices.com/AmazonSimpleDB/2009-04-15/DeveloperGuide/index.html"/>
|
* @see <a href="http://docs.amazonwebservices.com/AmazonSimpleDB/2009-04-15/DeveloperGuide/index.html"/>
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
|
* @author Luís A. Bastião Silva <bastiao@ua.pt>
|
||||||
*/
|
*/
|
||||||
package org.jclouds.aws.simpledb;
|
package org.jclouds.simpledb;
|
|
@ -17,7 +17,7 @@
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jclouds.aws.simpledb.reference;
|
package org.jclouds.simpledb.reference;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configuration properties and constants used in SimpleDB connections.
|
* Configuration properties and constants used in SimpleDB connections.
|
||||||
|
@ -25,6 +25,7 @@ package org.jclouds.aws.simpledb.reference;
|
||||||
* @see <a href="http://docs.amazonwebservices.com/AWSSimpleDomainService/2009-02-01/APIReference/Query_QueryParams.html"
|
* @see <a href="http://docs.amazonwebservices.com/AWSSimpleDomainService/2009-02-01/APIReference/Query_QueryParams.html"
|
||||||
* />
|
* />
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
|
* @author Luís A. Bastião Silva <bastiao@ua.pt>
|
||||||
*/
|
*/
|
||||||
public interface SimpleDBParameters {
|
public interface SimpleDBParameters {
|
||||||
|
|
|
@ -21,4 +21,4 @@
|
||||||
* This package contains properties and reference data used in SimpleDB.
|
* This package contains properties and reference data used in SimpleDB.
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
package org.jclouds.aws.simpledb.reference;
|
package org.jclouds.simpledb.reference;
|
|
@ -0,0 +1,110 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 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.simpledb.xml;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.jclouds.date.DateService;
|
||||||
|
import org.jclouds.http.functions.ParseSax;
|
||||||
|
import org.jclouds.simpledb.domain.AttributePair;
|
||||||
|
import org.jclouds.simpledb.domain.Item;
|
||||||
|
import org.xml.sax.Attributes;
|
||||||
|
|
||||||
|
import com.google.common.collect.LinkedHashMultimap;
|
||||||
|
import com.google.common.collect.Maps;
|
||||||
|
import com.google.common.collect.Multimap;
|
||||||
|
import com.google.inject.Inject;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Luís A. Bastião Silva <bastiao@ua.pt>
|
||||||
|
*/
|
||||||
|
public class ItemsHandler extends
|
||||||
|
ParseSax.HandlerWithResult<Map<String, Item>> {
|
||||||
|
private StringBuilder currentText = new StringBuilder();
|
||||||
|
|
||||||
|
private Map<String, Item> items = Maps.newConcurrentMap();
|
||||||
|
private Multimap<String, AttributePair> attributes = LinkedHashMultimap.create();
|
||||||
|
private String attributeName;
|
||||||
|
private String attributeValue = "";
|
||||||
|
private String itemName;
|
||||||
|
|
||||||
|
private boolean inside = false;
|
||||||
|
|
||||||
|
protected final DateService dateService;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
public ItemsHandler(DateService dateService) {
|
||||||
|
this.dateService = dateService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, Item> getResult() {
|
||||||
|
return items;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void startElement(String uri, String localName, String qName, Attributes attributes)
|
||||||
|
{
|
||||||
|
if (qName.equals("Attribute")) {
|
||||||
|
inside = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void endElement(String uri, String name, String qName)
|
||||||
|
{
|
||||||
|
if (qName.equals("Attribute"))
|
||||||
|
{
|
||||||
|
inside = false;
|
||||||
|
|
||||||
|
|
||||||
|
System.out.println("AttributeName: " + attributeName);
|
||||||
|
System.out.println("AttributeValue: " + attributeValue);
|
||||||
|
}
|
||||||
|
else if(qName.equals("Name")) {
|
||||||
|
if (inside)
|
||||||
|
attributeName = currentText.toString().trim();
|
||||||
|
else
|
||||||
|
itemName = currentText.toString().trim();
|
||||||
|
|
||||||
|
} else if (qName.equals("Value"))
|
||||||
|
{
|
||||||
|
attributeValue = currentText.toString().trim();
|
||||||
|
|
||||||
|
attributes.put(attributeName,new AttributePair(attributeName,
|
||||||
|
attributeValue, false));
|
||||||
|
}
|
||||||
|
else if (qName.equals("Item"))
|
||||||
|
{
|
||||||
|
System.out.println("ItemName: " + itemName);
|
||||||
|
|
||||||
|
Item item = new Item(attributes);
|
||||||
|
items.put(itemName, item);
|
||||||
|
attributes = LinkedHashMultimap.create();
|
||||||
|
this.attributeName = null;
|
||||||
|
this.attributeValue = null;
|
||||||
|
this.itemName = null;
|
||||||
|
inside = false;
|
||||||
|
}
|
||||||
|
currentText = new StringBuilder();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void characters(char ch[], int start, int length) {
|
||||||
|
currentText.append(ch, start, length);
|
||||||
|
}
|
||||||
|
}
|
|
@ -17,12 +17,12 @@
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jclouds.aws.simpledb.xml;
|
package org.jclouds.simpledb.xml;
|
||||||
|
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.jclouds.aws.simpledb.domain.ListDomainsResponse;
|
import org.jclouds.simpledb.domain.ListDomainsResponse;
|
||||||
import org.jclouds.http.functions.ParseSax;
|
import org.jclouds.http.functions.ParseSax;
|
||||||
|
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
|
@ -34,6 +34,7 @@ import com.google.common.collect.Sets;
|
||||||
* ListDomainsResponse
|
* ListDomainsResponse
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
|
* @author Luís A. Bastião Silva <bastiao@ua.pt>
|
||||||
* @see <a href=
|
* @see <a href=
|
||||||
* "http://docs.amazonwebservices.com/AmazonSimpleDB/2009-04-15/DeveloperGuide/SDB_API_ListDomains.htm l"
|
* "http://docs.amazonwebservices.com/AmazonSimpleDB/2009-04-15/DeveloperGuide/SDB_API_ListDomains.htm l"
|
||||||
* />
|
* />
|
|
@ -0,0 +1,41 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 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.simpledb;
|
||||||
|
|
||||||
|
import org.jclouds.rest.Providers;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
import com.google.common.collect.Iterables;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Test(groups = "unit")
|
||||||
|
public class ProvidersInPropertiesTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSupportedProviders() {
|
||||||
|
Iterable<String> providers = Providers.getSupportedProviders();
|
||||||
|
assert Iterables.contains(providers, "simpledb") : providers;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -17,19 +17,16 @@
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jclouds.aws.simpledb;
|
package org.jclouds.simpledb;
|
||||||
|
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import org.jclouds.aws.domain.Region;
|
|
||||||
import org.jclouds.aws.filters.FormSigner;
|
import org.jclouds.aws.filters.FormSigner;
|
||||||
import org.jclouds.aws.simpledb.config.SimpleDBRestClientModule;
|
|
||||||
import org.jclouds.aws.simpledb.options.ListDomainsOptions;
|
|
||||||
import org.jclouds.aws.simpledb.xml.ListDomainsResponseHandler;
|
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.RequiresHttp;
|
import org.jclouds.http.RequiresHttp;
|
||||||
import org.jclouds.http.functions.ParseSax;
|
import org.jclouds.http.functions.ParseSax;
|
||||||
|
@ -39,6 +36,9 @@ import org.jclouds.rest.RestClientTest;
|
||||||
import org.jclouds.rest.RestContextFactory;
|
import org.jclouds.rest.RestContextFactory;
|
||||||
import org.jclouds.rest.RestContextSpec;
|
import org.jclouds.rest.RestContextSpec;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
||||||
|
import org.jclouds.simpledb.config.SimpleDBRestClientModule;
|
||||||
|
import org.jclouds.simpledb.options.ListDomainsOptions;
|
||||||
|
import org.jclouds.simpledb.xml.ListDomainsResponseHandler;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.inject.Module;
|
import com.google.inject.Module;
|
||||||
|
@ -49,9 +49,12 @@ import com.google.inject.TypeLiteral;
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = "unit", testName = "simpledb.SimpleDBAsyncClientTest")
|
// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
|
||||||
|
@Test(groups = "unit", testName = "SimpleDBAsyncClientTest")
|
||||||
public class SimpleDBAsyncClientTest extends RestClientTest<SimpleDBAsyncClient> {
|
public class SimpleDBAsyncClientTest extends RestClientTest<SimpleDBAsyncClient> {
|
||||||
|
|
||||||
|
protected String provider = "simpledb";
|
||||||
|
|
||||||
@RequiresHttp
|
@RequiresHttp
|
||||||
@ConfiguresRestClient
|
@ConfiguresRestClient
|
||||||
private static final class TestSimpleDBRestClientModule extends SimpleDBRestClientModule {
|
private static final class TestSimpleDBRestClientModule extends SimpleDBRestClientModule {
|
||||||
|
@ -94,11 +97,23 @@ public class SimpleDBAsyncClientTest extends RestClientTest<SimpleDBAsyncClient>
|
||||||
checkFilters(request);
|
checkFilters(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testAllRegions() throws SecurityException, NoSuchMethodException, IOException {
|
// TODO fix this test as it has the wrong arg type
|
||||||
Method method = SimpleDBAsyncClient.class.getMethod("createDomainInRegion", String.class, String.class);
|
@Test(enabled = false)
|
||||||
for (String region : Region.ALL_SIMPLEDB) {
|
public void testPutAttributes() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
processor.createRequest(method, region, "domainName");
|
Method method = SimpleDBAsyncClient.class.getMethod("putAttributes", String.class, String.class, Map.class);
|
||||||
}
|
HttpRequest request = processor.createRequest(method, null, "domainName");
|
||||||
|
|
||||||
|
assertRequestLineEquals(request, "POST https://sdb.amazonaws.com/ HTTP/1.1");
|
||||||
|
assertNonPayloadHeadersEqual(request, "Host: sdb.amazonaws.com\n");
|
||||||
|
assertPayloadEquals(request, "Version=2009-04-15&Action=PutAttributes&DomainName=domainName&ItemName=itemName"
|
||||||
|
+ "&Attribute.1.Name=name" + "&Attribute.1.Value=fuzzy" + "&Attribute.1.Replace=true",
|
||||||
|
"application/x-www-form-urlencoded", false);
|
||||||
|
|
||||||
|
assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
|
||||||
|
assertSaxResponseParserClassEquals(method, null);
|
||||||
|
assertExceptionParserClassEquals(method, null);
|
||||||
|
|
||||||
|
checkFilters(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -120,7 +135,7 @@ public class SimpleDBAsyncClientTest extends RestClientTest<SimpleDBAsyncClient>
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RestContextSpec<?, ?> createContextSpec() {
|
public RestContextSpec<?, ?> createContextSpec() {
|
||||||
return new RestContextFactory().createContextSpec("simpledb", "identity", "credential", new Properties());
|
return new RestContextFactory().createContextSpec(provider, "identity", "credential", new Properties());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -17,7 +17,7 @@
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jclouds.aws.simpledb;
|
package org.jclouds.simpledb;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static org.testng.Assert.assertNotNull;
|
import static org.testng.Assert.assertNotNull;
|
||||||
|
@ -27,17 +27,15 @@ import java.util.Set;
|
||||||
import java.util.SortedSet;
|
import java.util.SortedSet;
|
||||||
|
|
||||||
import org.jclouds.Constants;
|
import org.jclouds.Constants;
|
||||||
import org.jclouds.aws.domain.Region;
|
|
||||||
import org.jclouds.aws.simpledb.domain.ListDomainsResponse;
|
|
||||||
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
|
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
|
||||||
import org.jclouds.rest.RestContext;
|
import org.jclouds.rest.RestContext;
|
||||||
import org.jclouds.rest.RestContextFactory;
|
import org.jclouds.rest.RestContextFactory;
|
||||||
|
import org.jclouds.simpledb.domain.ListDomainsResponse;
|
||||||
import org.testng.annotations.AfterTest;
|
import org.testng.annotations.AfterTest;
|
||||||
import org.testng.annotations.BeforeGroups;
|
import org.testng.annotations.BeforeGroups;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
import com.google.inject.Module;
|
import com.google.inject.Module;
|
||||||
|
|
||||||
|
@ -46,14 +44,14 @@ import com.google.inject.Module;
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = "live", sequential = true, testName = "simpledb.SimpleDBClientLiveTest")
|
@Test(groups = "live", sequential = true)
|
||||||
public class SimpleDBClientLiveTest {
|
public class SimpleDBClientLiveTest {
|
||||||
|
|
||||||
private SimpleDBClient client;
|
protected SimpleDBClient client;
|
||||||
|
|
||||||
private RestContext<SimpleDBClient, SimpleDBAsyncClient> context;
|
private RestContext<SimpleDBClient, SimpleDBAsyncClient> context;
|
||||||
|
|
||||||
private Set<String> domains = Sets.newHashSet();
|
protected Set<String> domains = Sets.newHashSet();
|
||||||
protected String provider = "simpledb";
|
protected String provider = "simpledb";
|
||||||
protected String identity;
|
protected String identity;
|
||||||
protected String credential;
|
protected String credential;
|
||||||
|
@ -92,9 +90,11 @@ public class SimpleDBClientLiveTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testListDomainsInRegion() throws InterruptedException {
|
protected void testListDomains() throws InterruptedException {
|
||||||
for (String region : Lists.newArrayList(null, Region.EU_WEST_1, Region.US_EAST_1, Region.US_WEST_1,
|
listDomainInRegion(null);
|
||||||
Region.AP_SOUTHEAST_1)) {
|
}
|
||||||
|
|
||||||
|
protected void listDomainInRegion(String region) throws InterruptedException {
|
||||||
SortedSet<String> allResults = Sets.newTreeSet(client.listDomainsInRegion(region));
|
SortedSet<String> allResults = Sets.newTreeSet(client.listDomainsInRegion(region));
|
||||||
assertNotNull(allResults);
|
assertNotNull(allResults);
|
||||||
if (allResults.size() >= 1) {
|
if (allResults.size() >= 1) {
|
||||||
|
@ -102,16 +102,10 @@ public class SimpleDBClientLiveTest {
|
||||||
assertDomainInList(region, domain);
|
assertDomainInList(region, domain);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static final String PREFIX = System.getProperty("user.name") + "-simpledb";
|
public static final String PREFIX = System.getProperty("user.name") + "-simpledb";
|
||||||
|
|
||||||
@Test
|
protected String createDomainInRegion(String region, String domainName) throws InterruptedException {
|
||||||
void testCreateDomain() throws InterruptedException {
|
|
||||||
String domainName = PREFIX + "1";
|
|
||||||
|
|
||||||
for (final String region : Lists.newArrayList(null, Region.EU_WEST_1, Region.US_EAST_1, Region.US_WEST_1,
|
|
||||||
Region.AP_SOUTHEAST_1)) {
|
|
||||||
try {
|
try {
|
||||||
SortedSet<String> result = Sets.newTreeSet(client.listDomainsInRegion(region));
|
SortedSet<String> result = Sets.newTreeSet(client.listDomainsInRegion(region));
|
||||||
if (result.size() >= 1) {
|
if (result.size() >= 1) {
|
||||||
|
@ -130,10 +124,15 @@ public class SimpleDBClientLiveTest {
|
||||||
// assertEquals(domain.getName(), domainName);
|
// assertEquals(domain.getName(), domainName);
|
||||||
assertDomainInList(region, domainName);
|
assertDomainInList(region, domainName);
|
||||||
domains.add(domainName);
|
domains.add(domainName);
|
||||||
}
|
return domainName;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertDomainInList(final String region, final String domain) throws InterruptedException {
|
@Test
|
||||||
|
protected void testCreateDomain() throws InterruptedException {
|
||||||
|
createDomainInRegion(null, PREFIX + "1");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void assertDomainInList(final String region, final String domain) throws InterruptedException {
|
||||||
assertEventually(new Runnable() {
|
assertEventually(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
ListDomainsResponse domains = client.listDomainsInRegion(region);
|
ListDomainsResponse domains = client.listDomainsInRegion(region);
|
|
@ -17,10 +17,10 @@
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jclouds.aws.simpledb.options;
|
package org.jclouds.simpledb.options;
|
||||||
|
|
||||||
import static org.jclouds.aws.simpledb.options.ListDomainsOptions.Builder.maxNumberOfDomains;
|
import static org.jclouds.simpledb.options.ListDomainsOptions.Builder.maxNumberOfDomains;
|
||||||
import static org.jclouds.aws.simpledb.options.ListDomainsOptions.Builder.nextToken;
|
import static org.jclouds.simpledb.options.ListDomainsOptions.Builder.nextToken;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
|
@ -17,14 +17,14 @@
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jclouds.aws.simpledb.xml;
|
package org.jclouds.simpledb.xml;
|
||||||
|
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
|
||||||
import org.jclouds.aws.simpledb.domain.ListDomainsResponse;
|
|
||||||
import org.jclouds.http.functions.BaseHandlerTest;
|
import org.jclouds.http.functions.BaseHandlerTest;
|
||||||
|
import org.jclouds.simpledb.domain.ListDomainsResponse;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
@ -34,11 +34,12 @@ import com.google.common.collect.ImmutableSet;
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = "unit", sequential = true, testName = "simpledb.ListDomainsResponseHandlerTest")
|
// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
|
||||||
|
@Test(groups = "unit", testName = "ListDomainsResponseHandlerTest")
|
||||||
public class ListDomainsResponseHandlerTest extends BaseHandlerTest {
|
public class ListDomainsResponseHandlerTest extends BaseHandlerTest {
|
||||||
|
|
||||||
public void test() {
|
public void test() {
|
||||||
InputStream is = getClass().getResourceAsStream("/simpledb/list_domains.xml");
|
InputStream is = getClass().getResourceAsStream("/list_domains.xml");
|
||||||
|
|
||||||
ListDomainsResponse result = factory.create(injector.getInstance(ListDomainsResponseHandler.class)).parse(is);
|
ListDomainsResponse result = factory.create(injector.getInstance(ListDomainsResponseHandler.class)).parse(is);
|
||||||
|
|
|
@ -0,0 +1,108 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!--
|
||||||
|
|
||||||
|
|
||||||
|
Copyright (C) 2010 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.
|
||||||
|
====================================================================
|
||||||
|
-->
|
||||||
|
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
|
||||||
|
|
||||||
|
<!--
|
||||||
|
For more configuration infromation and examples see the Apache
|
||||||
|
Log4j website: http://logging.apache.org/log4j/
|
||||||
|
-->
|
||||||
|
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"
|
||||||
|
debug="false">
|
||||||
|
|
||||||
|
<!-- A time/date based rolling appender -->
|
||||||
|
<appender name="WIREFILE" class="org.apache.log4j.DailyRollingFileAppender">
|
||||||
|
<param name="File" value="target/test-data/jclouds-wire.log" />
|
||||||
|
<param name="Append" value="true" />
|
||||||
|
|
||||||
|
<!-- Rollover at midnight each day -->
|
||||||
|
<param name="DatePattern" value="'.'yyyy-MM-dd" />
|
||||||
|
|
||||||
|
<param name="Threshold" value="TRACE" />
|
||||||
|
|
||||||
|
<layout class="org.apache.log4j.PatternLayout">
|
||||||
|
<!-- The default pattern: Date Priority [Category] Message\n -->
|
||||||
|
<param name="ConversionPattern" value="%d %-5p [%c] (%t) %m%n" />
|
||||||
|
|
||||||
|
<!--
|
||||||
|
The full pattern: Date MS Priority [Category]
|
||||||
|
(Thread:NDC) Message\n <param name="ConversionPattern"
|
||||||
|
value="%d %-5r %-5p [%c] (%t:%x) %m%n"/>
|
||||||
|
-->
|
||||||
|
</layout>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<!-- A time/date based rolling appender -->
|
||||||
|
<appender name="FILE" class="org.apache.log4j.DailyRollingFileAppender">
|
||||||
|
<param name="File" value="target/test-data/jclouds.log" />
|
||||||
|
<param name="Append" value="true" />
|
||||||
|
|
||||||
|
<!-- Rollover at midnight each day -->
|
||||||
|
<param name="DatePattern" value="'.'yyyy-MM-dd" />
|
||||||
|
|
||||||
|
<param name="Threshold" value="TRACE" />
|
||||||
|
|
||||||
|
<layout class="org.apache.log4j.PatternLayout">
|
||||||
|
<!-- The default pattern: Date Priority [Category] Message\n -->
|
||||||
|
<param name="ConversionPattern" value="%d %-5p [%c] (%t) %m%n" />
|
||||||
|
|
||||||
|
<!--
|
||||||
|
The full pattern: Date MS Priority [Category]
|
||||||
|
(Thread:NDC) Message\n <param name="ConversionPattern"
|
||||||
|
value="%d %-5r %-5p [%c] (%t:%x) %m%n"/>
|
||||||
|
-->
|
||||||
|
</layout>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<appender name="ASYNC" class="org.apache.log4j.AsyncAppender">
|
||||||
|
<appender-ref ref="FILE" />
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<appender name="ASYNCWIRE" class="org.apache.log4j.AsyncAppender">
|
||||||
|
<appender-ref ref="WIREFILE" />
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<!-- ================ -->
|
||||||
|
<!-- Limit categories -->
|
||||||
|
<!-- ================ -->
|
||||||
|
|
||||||
|
<category name="org.jclouds">
|
||||||
|
<priority value="DEBUG" />
|
||||||
|
<appender-ref ref="ASYNC" />
|
||||||
|
</category>
|
||||||
|
|
||||||
|
<category name="jclouds.headers">
|
||||||
|
<priority value="DEBUG" />
|
||||||
|
<appender-ref ref="ASYNCWIRE" />
|
||||||
|
</category>
|
||||||
|
|
||||||
|
<category name="jclouds.wire">
|
||||||
|
<priority value="DEBUG" />
|
||||||
|
<appender-ref ref="ASYNCWIRE" />
|
||||||
|
</category>
|
||||||
|
<!-- ======================= -->
|
||||||
|
<!-- Setup the Root category -->
|
||||||
|
<!-- ======================= -->
|
||||||
|
|
||||||
|
<root>
|
||||||
|
<priority value="WARN" />
|
||||||
|
</root>
|
||||||
|
|
||||||
|
</log4j:configuration>
|
|
@ -0,0 +1,110 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!--
|
||||||
|
|
||||||
|
|
||||||
|
Copyright (C) 2010 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.
|
||||||
|
====================================================================
|
||||||
|
|
||||||
|
-->
|
||||||
|
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4.0.0.xsd" >
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>org.jclouds.api</groupId>
|
||||||
|
<artifactId>jclouds-apis-project</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
<relativePath>../pom.xml</relativePath>
|
||||||
|
</parent>
|
||||||
|
<artifactId>sqs</artifactId>
|
||||||
|
<name>jcloud sqs api</name>
|
||||||
|
<description>jclouds components to access an implementation of Simple Queue Service</description>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<test.sqs.endpoint>https://sqs.us-east-1.amazonaws.com</test.sqs.endpoint>
|
||||||
|
<test.sqs.apiversion>2009-02-01</test.sqs.apiversion>
|
||||||
|
<test.sqs.identity>${test.aws.identity}</test.sqs.identity>
|
||||||
|
<test.sqs.credential>${test.aws.credential}</test.sqs.credential>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jclouds</groupId>
|
||||||
|
<artifactId>jclouds-aws</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
<type>jar</type>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jclouds</groupId>
|
||||||
|
<artifactId>jclouds-core</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
<type>test-jar</type>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jclouds</groupId>
|
||||||
|
<artifactId>jclouds-log4j</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<profiles>
|
||||||
|
<profile>
|
||||||
|
<id>live</id>
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>integration</id>
|
||||||
|
<phase>integration-test</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>test</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<systemProperties>
|
||||||
|
<property>
|
||||||
|
<name>test.sqs.endpoint</name>
|
||||||
|
<value>${test.sqs.endpoint}</value>
|
||||||
|
</property>
|
||||||
|
<property>
|
||||||
|
<name>test.sqs.apiversion</name>
|
||||||
|
<value>${test.sqs.apiversion}</value>
|
||||||
|
</property>
|
||||||
|
<property>
|
||||||
|
<name>test.sqs.identity</name>
|
||||||
|
<value>${test.sqs.identity}</value>
|
||||||
|
</property>
|
||||||
|
<property>
|
||||||
|
<name>test.sqs.credential</name>
|
||||||
|
<value>${test.sqs.credential}</value>
|
||||||
|
</property>
|
||||||
|
</systemProperties>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</profile>
|
||||||
|
</profiles>
|
||||||
|
|
||||||
|
|
||||||
|
</project>
|
||||||
|
|
|
@ -82,7 +82,6 @@ public interface AtmosStorageAsyncClient {
|
||||||
* @see AtmosStorageClient#listDirectories
|
* @see AtmosStorageClient#listDirectories
|
||||||
*/
|
*/
|
||||||
@GET
|
@GET
|
||||||
@Path("")
|
|
||||||
@ResponseParser(ParseDirectoryListFromContentAndHeaders.class)
|
@ResponseParser(ParseDirectoryListFromContentAndHeaders.class)
|
||||||
@Consumes(MediaType.TEXT_XML)
|
@Consumes(MediaType.TEXT_XML)
|
||||||
ListenableFuture<BoundedSet<? extends DirectoryEntry>> listDirectories(ListOptions... options);
|
ListenableFuture<BoundedSet<? extends DirectoryEntry>> listDirectories(ListOptions... options);
|
||||||
|
|
|
@ -41,7 +41,7 @@ public class AtmosStorageResponseException extends HttpResponseException {
|
||||||
|
|
||||||
public AtmosStorageResponseException(HttpCommand command, HttpResponse response,
|
public AtmosStorageResponseException(HttpCommand command, HttpResponse response,
|
||||||
AtmosStorageError error) {
|
AtmosStorageError error) {
|
||||||
super(String.format("command %s failed with code %s, error: %s", command.getRequest()
|
super(String.format("command %s failed with code %s, error: %s", command.getCurrentRequest()
|
||||||
.getRequestLine(), response.getStatusCode(), error.toString()), command, response);
|
.getRequestLine(), response.getStatusCode(), error.toString()), command, response);
|
||||||
this.setError(error);
|
this.setError(error);
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ public class AtmosStorageResponseException extends HttpResponseException {
|
||||||
|
|
||||||
public AtmosStorageResponseException(HttpCommand command, HttpResponse response,
|
public AtmosStorageResponseException(HttpCommand command, HttpResponse response,
|
||||||
AtmosStorageError error, Throwable cause) {
|
AtmosStorageError error, Throwable cause) {
|
||||||
super(String.format("command %1$s failed with error: %2$s", command.getRequest()
|
super(String.format("command %1$s failed with error: %2$s", command.getCurrentRequest()
|
||||||
.getRequestLine(), error.toString()), command, response, cause);
|
.getRequestLine(), error.toString()), command, response, cause);
|
||||||
this.setError(error);
|
this.setError(error);
|
||||||
|
|
||||||
|
|
|
@ -20,28 +20,36 @@
|
||||||
package org.jclouds.atmosonline.saas.binders;
|
package org.jclouds.atmosonline.saas.binders;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkArgument;
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import org.jclouds.atmosonline.saas.domain.AtmosObject;
|
import org.jclouds.atmosonline.saas.domain.AtmosObject;
|
||||||
import org.jclouds.crypto.Crypto;
|
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.rest.Binder;
|
import org.jclouds.rest.Binder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class BindMetadataToHeaders implements Binder {
|
public class BindMetadataToHeaders implements Binder {
|
||||||
private final BindUserMetadataToHeaders metaBinder;
|
private final BindUserMetadataToHeaders metaBinder;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
protected BindMetadataToHeaders(BindUserMetadataToHeaders metaBinder, Crypto crypto) {
|
protected BindMetadataToHeaders(BindUserMetadataToHeaders metaBinder) {
|
||||||
this.metaBinder = metaBinder;
|
this.metaBinder = metaBinder;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void bindToRequest(HttpRequest request, Object payload) {
|
@Override
|
||||||
AtmosObject object = (AtmosObject) payload;
|
public <R extends HttpRequest> R bindToRequest(R request, Object input) {
|
||||||
|
checkArgument(checkNotNull(input, "input") instanceof AtmosObject, "this binder is only valid for AtmosObject!");
|
||||||
|
checkNotNull(request, "request");
|
||||||
|
|
||||||
|
AtmosObject object = AtmosObject.class.cast(input);
|
||||||
|
checkNotNull(object.getPayload(), "object payload");
|
||||||
checkArgument(object.getPayload().getContentMetadata().getContentLength() != null,
|
checkArgument(object.getPayload().getContentMetadata().getContentLength() != null,
|
||||||
"contentLength must be set, streaming not supported");
|
"contentLength must be set, streaming not supported");
|
||||||
metaBinder.bindToRequest(request, object.getUserMetadata());
|
return metaBinder.bindToRequest(request, object.getUserMetadata());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,36 +19,57 @@
|
||||||
|
|
||||||
package org.jclouds.atmosonline.saas.binders;
|
package org.jclouds.atmosonline.saas.binders;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import org.jclouds.atmosonline.saas.domain.UserMetadata;
|
import org.jclouds.atmosonline.saas.domain.UserMetadata;
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
|
import org.jclouds.http.utils.ModifyRequest;
|
||||||
import org.jclouds.rest.Binder;
|
import org.jclouds.rest.Binder;
|
||||||
|
|
||||||
|
import com.google.common.base.Function;
|
||||||
import com.google.common.base.Joiner;
|
import com.google.common.base.Joiner;
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
import com.google.common.collect.ImmutableMap.Builder;
|
||||||
|
import com.google.common.collect.Multimaps;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class BindUserMetadataToHeaders implements Binder {
|
public class BindUserMetadataToHeaders implements Binder, Function<UserMetadata, Map<String, String>> {
|
||||||
|
@Override
|
||||||
|
public <R extends HttpRequest> R bindToRequest(R request, Object input) {
|
||||||
|
checkArgument(checkNotNull(input, "input") instanceof UserMetadata,
|
||||||
|
"this binder is only valid for UserMetadatas!");
|
||||||
|
checkNotNull(request, "request");
|
||||||
|
|
||||||
public void bindToRequest(HttpRequest request, Object payload) {
|
return ModifyRequest.putHeaders(request, Multimaps.forMap(apply(UserMetadata.class.cast(input))));
|
||||||
UserMetadata md = (UserMetadata) checkNotNull(payload, "payload");
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, String> apply(UserMetadata md) {
|
||||||
|
Builder<String, String> headers = ImmutableMap.<String, String> builder();
|
||||||
if (md.getMetadata().size() > 0) {
|
if (md.getMetadata().size() > 0) {
|
||||||
String header = Joiner.on(',').withKeyValueSeparator("=").join(md.getMetadata());
|
String header = Joiner.on(',').withKeyValueSeparator("=").join(md.getMetadata());
|
||||||
request.getHeaders().put("x-emc-meta", header);
|
headers.put("x-emc-meta", header);
|
||||||
}
|
}
|
||||||
if (md.getListableMetadata().size() > 0) {
|
if (md.getListableMetadata().size() > 0) {
|
||||||
String header = Joiner.on(',').withKeyValueSeparator("=").join(md.getListableMetadata());
|
String header = Joiner.on(',').withKeyValueSeparator("=").join(md.getListableMetadata());
|
||||||
request.getHeaders().put("x-emc-listable-meta", header);
|
headers.put("x-emc-listable-meta", header);
|
||||||
}
|
}
|
||||||
if (md.getTags().size() > 0) {
|
if (md.getTags().size() > 0) {
|
||||||
String header = Joiner.on(',').join(md.getTags());
|
String header = Joiner.on(',').join(md.getTags());
|
||||||
request.getHeaders().put("x-emc-tags", header);
|
headers.put("x-emc-tags", header);
|
||||||
}
|
}
|
||||||
if (md.getListableTags().size() > 0) {
|
if (md.getListableTags().size() > 0) {
|
||||||
String header = Joiner.on(',').join(md.getListableTags());
|
String header = Joiner.on(',').join(md.getListableTags());
|
||||||
request.getHeaders().put("x-emc-listable-tags", header);
|
headers.put("x-emc-listable-tags", header);
|
||||||
}
|
}
|
||||||
|
return headers.build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@ import org.jclouds.collect.Memoized;
|
||||||
import org.jclouds.domain.Location;
|
import org.jclouds.domain.Location;
|
||||||
import org.jclouds.domain.LocationScope;
|
import org.jclouds.domain.LocationScope;
|
||||||
import org.jclouds.domain.internal.LocationImpl;
|
import org.jclouds.domain.internal.LocationImpl;
|
||||||
import org.jclouds.rest.annotations.Provider;
|
import org.jclouds.location.Provider;
|
||||||
|
|
||||||
import com.google.common.base.Supplier;
|
import com.google.common.base.Supplier;
|
||||||
import com.google.common.base.Suppliers;
|
import com.google.common.base.Suppliers;
|
||||||
|
|