mirror of https://github.com/apache/jclouds.git
JCLOUDS-54. remove historical demos, archetypes and assemblies modules
This commit is contained in:
parent
7cf8d611af
commit
f22731d908
|
@ -1,55 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
|
||||
Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. jclouds licenses this file
|
||||
to you 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.apache.jclouds</groupId>
|
||||
<artifactId>jclouds-project</artifactId>
|
||||
<version>1.7.0-SNAPSHOT</version>
|
||||
<relativePath>../../project/pom.xml</relativePath>
|
||||
</parent>
|
||||
<artifactId>jclouds-compute-service-archetype</artifactId>
|
||||
<name>jclouds Compute service archetype</name>
|
||||
<description>Maven archetype for a provider of a Compute service</description>
|
||||
<packaging>maven-archetype</packaging>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-archetype-plugin</artifactId>
|
||||
<extensions>true</extensions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<configuration>
|
||||
<encoding>UTF-8</encoding>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
<extensions>
|
||||
<extension>
|
||||
<groupId>org.apache.maven.archetype</groupId>
|
||||
<artifactId>archetype-packaging</artifactId>
|
||||
</extension>
|
||||
</extensions>
|
||||
</build>
|
||||
</project>
|
|
@ -1,64 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
|
||||
Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. jclouds licenses this file
|
||||
to you 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.
|
||||
|
||||
-->
|
||||
<archetype-descriptor name="jclouds-compute-service-archetype" partial="true">
|
||||
<requiredProperties>
|
||||
<requiredProperty key="groupId">
|
||||
<defaultValue>org.jclouds</defaultValue>
|
||||
</requiredProperty>
|
||||
<requiredProperty key="package" >
|
||||
<defaultValue>${groupId}.${artifactId}</defaultValue>
|
||||
</requiredProperty>
|
||||
<requiredProperty key="author">
|
||||
<defaultValue>Adrian Cole</defaultValue>
|
||||
</requiredProperty>
|
||||
<requiredProperty key="providerName" />
|
||||
<requiredProperty key="providerEndpoint" />
|
||||
<requiredProperty key="providerIdentity" />
|
||||
<requiredProperty key="providerCredential" />
|
||||
</requiredProperties>
|
||||
<fileSets>
|
||||
<fileSet filtered="true" packaged="true" encoding="UTF-8">
|
||||
<directory>src/main/java</directory>
|
||||
<includes>
|
||||
<include>**/*.java</include>
|
||||
</includes>
|
||||
</fileSet>
|
||||
<fileSet filtered="true" packaged="true" encoding="UTF-8">
|
||||
<directory>src/test/java</directory>
|
||||
<includes>
|
||||
<include>**/*.java</include>
|
||||
</includes>
|
||||
</fileSet>
|
||||
<fileSet encoding="UTF-8">
|
||||
<directory>src/test/resources</directory>
|
||||
<includes>
|
||||
<include>**/*.xml</include>
|
||||
</includes>
|
||||
</fileSet>
|
||||
<fileSet filtered="true" encoding="UTF-8">
|
||||
<directory />
|
||||
<includes>
|
||||
<include>.gitignore</include>
|
||||
</includes>
|
||||
</fileSet>
|
||||
</fileSets>
|
||||
</archetype-descriptor>
|
|
@ -1,100 +0,0 @@
|
|||
#set( $lcaseProviderName = ${providerName.toLowerCase()} )
|
||||
#set( $symbol_dollar = '$' )
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
|
||||
Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. jclouds licenses this file
|
||||
to you 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.apache.jclouds</groupId>
|
||||
<artifactId>jclouds-project</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<relativePath>../project/pom.xml</relativePath>
|
||||
</parent>
|
||||
<groupId>${groupId}</groupId>
|
||||
<artifactId>jclouds-${artifactId}</artifactId>
|
||||
<name>jclouds ${providerName} compute service</name>
|
||||
<description>jclouds components to access ${providerName}</description>
|
||||
|
||||
<scm>
|
||||
<connection>scm:svn:http://jclouds.googlecode.com/svn/trunk/${lcaseProviderName}</connection>
|
||||
<developerConnection>scm:svn:https://jclouds.googlecode.com/svn/trunk/${lcaseProviderName}</developerConnection>
|
||||
<url>http://jclouds.googlecode.com/svn/trunk/${lcaseProviderName}</url>
|
||||
</scm>
|
||||
|
||||
<!-- bootstrapping: need to fetch the project POM -->
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>sonatype-nexus-snapshots</id>
|
||||
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
|
||||
<releases>
|
||||
<enabled>false</enabled>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<properties>
|
||||
<test.identity>${providerUser}</test.identity>
|
||||
<test.credential>${providerPassword}</test.credential>
|
||||
<test.endpoint>${providerEndpoint}</test.endpoint>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.jclouds</groupId>
|
||||
<artifactId>jclouds-compute</artifactId>
|
||||
<version>${symbol_dollar}{project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.jclouds</groupId>
|
||||
<artifactId>jclouds-compute</artifactId>
|
||||
<version>${symbol_dollar}{project.version}</version>
|
||||
<type>test-jar</type>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.jclouds</groupId>
|
||||
<artifactId>jclouds-core</artifactId>
|
||||
<version>${symbol_dollar}{project.version}</version>
|
||||
<type>test-jar</type>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.jclouds.driver</groupId>
|
||||
<artifactId>jclouds-jsch</artifactId>
|
||||
<version>${symbol_dollar}{project.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.jclouds.driver</groupId>
|
||||
<artifactId>jclouds-log4j</artifactId>
|
||||
<version>${symbol_dollar}{project.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
|
@ -1,58 +0,0 @@
|
|||
#set( $symbol_pound = '#' )
|
||||
#set( $symbol_dollar = '$' )
|
||||
#set( $symbol_escape = '\' )
|
||||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you 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 ${package};
|
||||
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
import com.google.inject.Key;
|
||||
import org.jclouds.compute.ComputeServiceContext;
|
||||
import org.jclouds.compute.ComputeServiceContextBuilder;
|
||||
import org.jclouds.compute.internal.ComputeServiceContextImpl;
|
||||
import ${package}.compute.config.${providerName}ComputeServiceContextModule;
|
||||
import ${package}.config.${providerName}RestClientModule;
|
||||
|
||||
import com.google.inject.Module;
|
||||
import com.google.inject.TypeLiteral;
|
||||
|
||||
/**
|
||||
* @author ${author}
|
||||
*/
|
||||
public class ${providerName}ContextBuilder extends ComputeServiceContextBuilder<${providerName}Client, ${providerName}AsyncClient> {
|
||||
|
||||
public ${providerName}ContextBuilder(String providerName, Properties props) {
|
||||
super(providerName, new TypeLiteral<${providerName}AsyncClient>() {},
|
||||
new TypeLiteral<${providerName}Client>() {},
|
||||
props);
|
||||
}
|
||||
|
||||
protected void addClientModule(List<Module> modules) {
|
||||
modules.add(new ${providerName}RestClientModule());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addContextModule(String providerName, List<Module> modules) {
|
||||
modules.add(new ${providerName}ComputeServiceContextModule(providerName));
|
||||
}
|
||||
|
||||
}
|
|
@ -1,71 +0,0 @@
|
|||
#set( $symbol_pound = '#' )
|
||||
#set( $symbol_dollar = '$' )
|
||||
#set( $symbol_escape = '\' )
|
||||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you 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.
|
||||
*/
|
||||
import java.net.URI;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.jclouds.compute.ComputeServiceContext;
|
||||
import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule;
|
||||
import org.jclouds.logging.jdk.config.JDKLoggingModule;
|
||||
|
||||
import com.google.inject.Module;
|
||||
|
||||
/**
|
||||
* Creates {@link ComputeServiceContext} instances based on the most commonly
|
||||
* requested arguments.
|
||||
* <p/>
|
||||
* Note that Threadsafe objects will be bound as singletons to the Injector or Context provided.
|
||||
* <p/>
|
||||
* <p/>
|
||||
* If no <code>Module</code>s are specified, the default {@link JDKLoggingModule logging} and
|
||||
* {@link JavaUrlHttpCommandExecutorServiceModule http transports} will be installed.
|
||||
*
|
||||
* @author ${author}
|
||||
* @see ComputeServiceContext
|
||||
*/
|
||||
public class ${providerName}ContextFactory {
|
||||
public static ComputeServiceContext createContext(Properties properties, Module... modules) {
|
||||
return new ${providerName}ContextBuilder("${artifactId}",
|
||||
new ${providerName}PropertiesBuilder(properties).build()).withModules(modules)
|
||||
.buildComputeServiceContext();
|
||||
}
|
||||
|
||||
public static ComputeServiceContext createContext(String user, String key,
|
||||
Module... modules) {
|
||||
return new ${providerName}ContextBuilder("${artifactId}",
|
||||
new ${providerName}PropertiesBuilder(user, key).build())
|
||||
.withModules(modules).buildComputeServiceContext();
|
||||
}
|
||||
|
||||
public static ComputeServiceContext createContext(Properties properties, String user,
|
||||
String key, Module... modules) {
|
||||
return new ${providerName}ContextBuilder("${artifactId}",
|
||||
new ${providerName}PropertiesBuilder(properties).withCredentials(user, key)
|
||||
.build()).withModules(modules).buildComputeServiceContext();
|
||||
}
|
||||
|
||||
public static ComputeServiceContext createContext(URI endpoint, String user, String key,
|
||||
Module... modules) {
|
||||
return new ${providerName}ContextBuilder("${artifactId}",
|
||||
new ${providerName}PropertiesBuilder(user, key).withEndpoint(endpoint).build())
|
||||
.withModules(modules).buildComputeServiceContext();
|
||||
}
|
||||
}
|
|
@ -1,255 +0,0 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you 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.
|
||||
*/
|
||||
import static org.jclouds.compute.domain.OsFamily.UBUNTU;
|
||||
|
||||
import java.util.Set;
|
||||
import javax.annotation.Resource;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import ${package}.${providerName}Client;
|
||||
import ${package}.${providerName}AsyncClient;
|
||||
import ${package}.config.${providerName}ContextModule;
|
||||
|
||||
import org.jclouds.compute.ComputeServiceContext;
|
||||
import org.jclouds.compute.LoadBalancerService;
|
||||
import org.jclouds.compute.config.ComputeServiceTimeoutsModule;
|
||||
import org.jclouds.compute.domain.ComputeMetadata;
|
||||
import org.jclouds.compute.domain.Image;
|
||||
import org.jclouds.compute.domain.NodeMetadata;
|
||||
import org.jclouds.compute.domain.Size;
|
||||
import org.jclouds.compute.domain.Template;
|
||||
import org.jclouds.compute.domain.TemplateBuilder;
|
||||
import org.jclouds.compute.internal.ComputeServiceContextImpl;
|
||||
import org.jclouds.compute.predicates.ScriptStatusReturnsZero;
|
||||
import org.jclouds.compute.predicates.ScriptStatusReturnsZero.CommandUsingClient;
|
||||
import org.jclouds.compute.reference.ComputeServiceConstants;
|
||||
import org.jclouds.compute.strategy.AddNodeWithTagStrategy;
|
||||
import org.jclouds.compute.strategy.DestroyNodeStrategy;
|
||||
import org.jclouds.compute.strategy.GetNodeMetadataStrategy;
|
||||
import org.jclouds.compute.strategy.ListNodesStrategy;
|
||||
import org.jclouds.compute.strategy.RebootNodeStrategy;
|
||||
import org.jclouds.domain.Location;
|
||||
import org.jclouds.domain.LocationScope;
|
||||
import org.jclouds.domain.internal.LocationImpl;
|
||||
import org.jclouds.logging.Logger;
|
||||
import org.jclouds.net.IPSocket;
|
||||
import org.jclouds.predicates.RetryablePredicate;
|
||||
import org.jclouds.predicates.SocketOpen;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.base.Predicates;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.inject.Provides;
|
||||
import com.google.inject.Scopes;
|
||||
import com.google.inject.TypeLiteral;
|
||||
import com.google.inject.util.Providers;
|
||||
|
||||
/**
|
||||
* @author ${author}
|
||||
*/
|
||||
public class ${providerName}ComputeServiceContextModule extends ${providerName}ContextModule {
|
||||
|
||||
private final String providerName;
|
||||
|
||||
public ${providerName}ComputeServiceContextModule(String providerName){
|
||||
super(providerName);
|
||||
this.providerName=providerName;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
super.configure();
|
||||
install(new ComputeServiceTimeoutsModule());
|
||||
bind(new TypeLiteral<ComputeServiceContext>() {
|
||||
})
|
||||
.to(
|
||||
new TypeLiteral<ComputeServiceContextImpl<${providerName}Client, ${providerName}AsyncClient>>() {
|
||||
}).in(Scopes.SINGLETON);
|
||||
bind(AddNodeWithTagStrategy.class).to(${providerName}AddNodeWithTagStrategy.class);
|
||||
bind(ListNodesStrategy.class).to(${providerName}ListNodesStrategy.class);
|
||||
bind(GetNodeMetadataStrategy.class).to(${providerName}GetNodeMetadataStrategy.class);
|
||||
bind(RebootNodeStrategy.class).to(${providerName}RebootNodeStrategy.class);
|
||||
bind(DestroyNodeStrategy.class).to(${providerName}DestroyNodeStrategy.class);
|
||||
bind(LoadBalancerService.class).toProvider(Providers.<LoadBalancerService> of(null));
|
||||
}
|
||||
|
||||
/**
|
||||
* tested known configuration
|
||||
*/
|
||||
@Provides
|
||||
@Named("DEFAULT")
|
||||
protected TemplateBuilder provideTemplate(TemplateBuilder template) {
|
||||
return template.osFamily(UBUNTU);
|
||||
}
|
||||
|
||||
@Singleton
|
||||
public static class ${providerName}AddNodeWithTagStrategy implements AddNodeWithTagStrategy {
|
||||
|
||||
@Inject
|
||||
protected ${providerName}AddNodeWithTagStrategy() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public NodeMetadata execute(String tag, String name, Template template) {
|
||||
/*
|
||||
* TODO: implement
|
||||
*/
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Singleton
|
||||
public static class ${providerName}RebootNodeStrategy implements RebootNodeStrategy {
|
||||
|
||||
@Inject
|
||||
protected ${providerName}RebootNodeStrategy() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(String id) {
|
||||
/*
|
||||
* TODO: implement
|
||||
*/
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Singleton
|
||||
public static class ${providerName}ListNodesStrategy implements ListNodesStrategy {
|
||||
|
||||
@Inject
|
||||
protected ${providerName}ListNodesStrategy() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<? extends ComputeMetadata> list() {
|
||||
/*
|
||||
* TODO: implement
|
||||
*/return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<? extends NodeMetadata> listDetailsOnNodesMatching(
|
||||
Predicate<ComputeMetadata> filter) {
|
||||
/*
|
||||
* TODO: implement
|
||||
*/
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Singleton
|
||||
public static class ${providerName}GetNodeMetadataStrategy implements GetNodeMetadataStrategy {
|
||||
|
||||
@Inject
|
||||
protected ${providerName}GetNodeMetadataStrategy() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public NodeMetadata execute(String id) {
|
||||
/*
|
||||
* TODO: implement
|
||||
*/
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Singleton
|
||||
public static class ${providerName}DestroyNodeStrategy implements DestroyNodeStrategy {
|
||||
|
||||
@Inject
|
||||
protected ${providerName}DestroyNodeStrategy() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(String id) {
|
||||
/*
|
||||
* TODO: implement
|
||||
*/
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
Location getDefaultLocation(Set<? extends Location> locations) {
|
||||
|
||||
/*
|
||||
* TODO: implement
|
||||
*/
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
Set<? extends Location> getAssignableLocations(${providerName}Client sync, LogHolder holder ) {
|
||||
final Set<Location> assignableLocations = Sets.newHashSet();
|
||||
holder.logger.debug(">> providing locations");
|
||||
Location parent = new LocationImpl(LocationScope.PROVIDER, providerName, providerName, null);
|
||||
/*
|
||||
* TODO: add children with parent to locations. Note do not add parent to assignablelocations
|
||||
* directly
|
||||
*/
|
||||
|
||||
holder.logger.debug("<< locations(%d)", assignableLocations.size());
|
||||
return assignableLocations;
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
protected Set<? extends Size> provideSizes(${providerName}Client sync,
|
||||
Set<? extends Image> images, LogHolder holder) {
|
||||
final Set<Size> sizes = Sets.newHashSet();
|
||||
holder.logger.debug(">> providing sizes");
|
||||
|
||||
/*
|
||||
* TODO: implement
|
||||
*/
|
||||
|
||||
holder.logger.debug("<< sizes(%d)", sizes.size());
|
||||
return sizes;
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
protected Set<? extends Image> provideImages(final ${providerName}Client sync, LogHolder holder,
|
||||
Location location) {
|
||||
final Set<Image> images = Sets.newHashSet();
|
||||
holder.logger.debug(">> providing images");
|
||||
|
||||
/*
|
||||
* TODO: implement
|
||||
*/
|
||||
|
||||
holder.logger.debug("<< images(%d)", images.size());
|
||||
return images;
|
||||
}
|
||||
|
||||
@Singleton
|
||||
private static class LogHolder {
|
||||
@Resource
|
||||
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
|
||||
protected Logger logger = Logger.NULL;
|
||||
}
|
||||
}
|
|
@ -1,70 +0,0 @@
|
|||
#set( $lcaseProviderName = ${providerName.toLowerCase()} )
|
||||
#set( $camelCaseProviderName = "${providerName.substring(0, 1).toLowerCase()}${providerName.substring(1)}" )
|
||||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you 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 ${package}.compute;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import ${package}.${providerName}AsyncClient;
|
||||
import ${package}.${providerName}Client;
|
||||
import org.jclouds.compute.BaseComputeServiceLiveTest;
|
||||
import org.jclouds.compute.ComputeServiceContextFactory;
|
||||
import org.jclouds.compute.domain.Architecture;
|
||||
import org.jclouds.compute.domain.OsFamily;
|
||||
import org.jclouds.compute.domain.Template;
|
||||
import org.jclouds.rest.RestContext;
|
||||
import org.jclouds.ssh.jsch.config.JschSshClientModule;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
|
||||
/**
|
||||
* @author ${author}
|
||||
*/
|
||||
@Test(groups = "live", enabled = true, sequential = true, testName = "${lcaseProviderName}.${providerName}ComputeServiceLiveTest")
|
||||
public class ${providerName}ComputeServiceLiveTest extends BaseComputeServiceLiveTest {
|
||||
|
||||
@BeforeClass
|
||||
@Override
|
||||
public void setServiceDefaults() {
|
||||
provider = "${lcaseProviderName}";
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTemplateBuilder() {
|
||||
Template defaultTemplate = client.templateBuilder().build();
|
||||
assertEquals(defaultTemplate.getImage().getArchitecture(), Architecture.X86_64);
|
||||
assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU);
|
||||
assertEquals(defaultTemplate.getLocation().getId(), "DFW1");
|
||||
assertEquals(defaultTemplate.getSize().getCores(), 1.0d);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JschSshClientModule getSshModule() {
|
||||
return new JschSshClientModule();
|
||||
}
|
||||
|
||||
public void testAssignability() throws Exception {
|
||||
@SuppressWarnings("unused")
|
||||
RestContext<${providerName}Client, ${providerName}AsyncClient> tmContext = new ComputeServiceContextFactory()
|
||||
.createContext(provider, user, password).getProviderSpecificContext();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,125 +0,0 @@
|
|||
#set( $symbol_pound = '#' )
|
||||
#set( $symbol_dollar = '$' )
|
||||
#set( $symbol_escape = '\' )
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!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="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${symbol_escape}n -->
|
||||
<param name="ConversionPattern" value="%d %-5p [%c] (%t) %m%n" />
|
||||
|
||||
<!--
|
||||
The full pattern: Date MS Priority [Category]
|
||||
(Thread:NDC) Message${symbol_escape}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>
|
||||
|
||||
<!-- 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${symbol_dollar}{symbol_escape}n -->
|
||||
<param name="ConversionPattern" value="%d %-5p [%c] (%t) %m%n" />
|
||||
|
||||
<!--
|
||||
The full pattern: Date MS Priority [Category] (Thread:NDC) Message${symbol_dollar}{symbol_escape}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${symbol_dollar}{symbol_escape}n -->
|
||||
<param name="ConversionPattern" value="%d %-5p [%c] (%t) %m%n" />
|
||||
|
||||
<!--
|
||||
The full pattern: Date MS Priority [Category] (Thread:NDC) Message${symbol_dollar}{symbol_escape}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>
|
||||
|
||||
<category name="jclouds.compute">
|
||||
<priority value="TRACE" />
|
||||
<appender-ref ref="ASYNCCOMPUTE" />
|
||||
</category>
|
||||
|
||||
|
||||
<!-- ======================= -->
|
||||
<!-- Setup the Root category -->
|
||||
<!-- ======================= -->
|
||||
|
||||
<root>
|
||||
<priority value="WARN" />
|
||||
</root>
|
||||
|
||||
</log4j:configuration>
|
|
@ -1,38 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
|
||||
Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. jclouds licenses this file
|
||||
to you 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.apache.jclouds</groupId>
|
||||
<version>1.7.0-SNAPSHOT</version>
|
||||
<relativePath>../project/pom.xml</relativePath>
|
||||
</parent>
|
||||
<artifactId>jclouds-archetypes</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<name>jclouds Maven archetypes</name>
|
||||
|
||||
<modules>
|
||||
<module>rest-client-archetype</module>
|
||||
<module>compute-service-archetype</module>
|
||||
</modules>
|
||||
</project>
|
|
@ -1,57 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
|
||||
Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. jclouds licenses this file
|
||||
to you 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.apache.jclouds</groupId>
|
||||
<artifactId>jclouds-project</artifactId>
|
||||
<version>1.7.0-SNAPSHOT</version>
|
||||
<relativePath>../../project/pom.xml</relativePath>
|
||||
</parent>
|
||||
<artifactId>jclouds-rest-client-archetype</artifactId>
|
||||
<name>jclouds rest client archetype</name>
|
||||
<description>Maven archetype for a provider of a rest-speaking service</description>
|
||||
<packaging>maven-archetype</packaging>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-archetype-plugin</artifactId>
|
||||
<version>2.2</version>
|
||||
<extensions>true</extensions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<configuration>
|
||||
<encoding>UTF-8</encoding>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
<extensions>
|
||||
<extension>
|
||||
<groupId>org.apache.maven.archetype</groupId>
|
||||
<artifactId>archetype-packaging</artifactId>
|
||||
<version>2.2</version>
|
||||
</extension>
|
||||
</extensions>
|
||||
</build>
|
||||
</project>
|
|
@ -1,69 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
|
||||
Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. jclouds licenses this file
|
||||
to you 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.
|
||||
|
||||
-->
|
||||
<archetype-descriptor name="jclouds-rest-client-archetype">
|
||||
<requiredProperties>
|
||||
<requiredProperty key="groupId">
|
||||
<defaultValue>org.jclouds.labs</defaultValue>
|
||||
</requiredProperty>
|
||||
<requiredProperty key="package" >
|
||||
<defaultValue>org.jclouds.${artifactId}</defaultValue>
|
||||
</requiredProperty>
|
||||
<requiredProperty key="author">
|
||||
<defaultValue>Adrian Cole</defaultValue>
|
||||
</requiredProperty>
|
||||
<requiredProperty key="providerName" />
|
||||
<requiredProperty key="providerEndpoint" />
|
||||
<requiredProperty key="providerIdentity" />
|
||||
<requiredProperty key="providerApiVersion" />
|
||||
<requiredProperty key="providerCredential" />
|
||||
</requiredProperties>
|
||||
<fileSets>
|
||||
<fileSet filtered="true" packaged="true" encoding="UTF-8">
|
||||
<directory>src/main/java</directory>
|
||||
<includes>
|
||||
<include>**/*.java</include>
|
||||
</includes>
|
||||
</fileSet>
|
||||
<fileSet filtered="true" encoding="UTF-8">
|
||||
<directory>src/main/resources</directory>
|
||||
</fileSet>
|
||||
<fileSet filtered="true" packaged="true" encoding="UTF-8">
|
||||
<directory>src/test/java</directory>
|
||||
<includes>
|
||||
<include>**/*.java</include>
|
||||
</includes>
|
||||
</fileSet>
|
||||
<fileSet encoding="UTF-8">
|
||||
<directory>src/test/resources</directory>
|
||||
<includes>
|
||||
<include>**/*.json</include>
|
||||
<include>logback.xml</include>
|
||||
</includes>
|
||||
</fileSet>
|
||||
<fileSet filtered="true" encoding="UTF-8">
|
||||
<directory />
|
||||
<includes>
|
||||
<include>.gitignore</include>
|
||||
</includes>
|
||||
</fileSet>
|
||||
</fileSets>
|
||||
</archetype-descriptor>
|
|
@ -1,9 +0,0 @@
|
|||
# use glob syntax.
|
||||
syntax: glob
|
||||
target
|
||||
.settings
|
||||
.classpath
|
||||
.project
|
||||
jclouds-${artifactId}.iml
|
||||
jclouds-${artifactId}.ipr
|
||||
jclouds-${artifactId}.iws
|
|
@ -1,8 +0,0 @@
|
|||
In this module, you can run just unit tests, or run tests that connect directly to the service. To run against the service, you'll need to specify the maven profile live.
|
||||
When live is enabled, any tests that have "LiveTest" suffix will be run during the integration-test phase. In order for this to operate, you must specify the following
|
||||
properties:
|
||||
* test.${lcaseProviderName}.identity
|
||||
* test.${lcaseProviderName}.credential
|
||||
|
||||
Note that this module is intentionally incomplete. You should global replace and create your own client from this example. Make sure that you use tests propertly. For
|
||||
example, tests ending in *ExpectTest will help ensure that your annotations parse in the way you expect.
|
|
@ -1,122 +0,0 @@
|
|||
#set( $lcaseProviderName = ${providerName.toLowerCase()} )
|
||||
#set(
|
||||
$symbol_dollar = '$' )
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
|
||||
Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. jclouds licenses this file
|
||||
to you 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.apache.jclouds</groupId>
|
||||
<artifactId>jclouds-project</artifactId>
|
||||
<version>1.7.0-SNAPSHOT</version>
|
||||
<relativePath>../../project/pom.xml</relativePath>
|
||||
</parent>
|
||||
<groupId>${groupId}</groupId>
|
||||
<artifactId>${artifactId}</artifactId>
|
||||
<name>jclouds ${providerName} core</name>
|
||||
<description>jclouds components to access ${providerName}</description>
|
||||
|
||||
<scm>
|
||||
<connection>scm:git:git@github.com:jclouds/jclouds.git</connection>
|
||||
<developerConnection>scm:git:git@github.com:jclouds/jclouds.git</developerConnection>
|
||||
<url>http://github.com/jclouds/jclouds/tree/master/labs/${lcaseProviderName}</url>
|
||||
</scm>
|
||||
|
||||
<!-- bootstrapping: need to fetch the project POM -->
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>sonatype-nexus-snapshots</id>
|
||||
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
|
||||
<releases>
|
||||
<enabled>false</enabled>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<properties>
|
||||
<jclouds.version>1.7.0-SNAPSHOT</jclouds.version>
|
||||
<test.${lcaseProviderName}.identity>${providerIdentity}</test.${lcaseProviderName}.identity>
|
||||
<test.${lcaseProviderName}.credential>${providerCredential}</test.${lcaseProviderName}.credential>
|
||||
<test.${lcaseProviderName}.api-version>${providerApiVersion}</test.${lcaseProviderName}.api-version>
|
||||
<test.${lcaseProviderName}.build-version></test.${lcaseProviderName}.build-version>
|
||||
<test.${lcaseProviderName}.endpoint>${providerEndpoint}</test.${lcaseProviderName}.endpoint>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.jclouds</groupId>
|
||||
<artifactId>jclouds-core</artifactId>
|
||||
<version>${symbol_dollar}{jclouds.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.jclouds</groupId>
|
||||
<artifactId>jclouds-core</artifactId>
|
||||
<version>${symbol_dollar}{jclouds.version}</version>
|
||||
<type>test-jar</type>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.jclouds.driver</groupId>
|
||||
<artifactId>jclouds-slf4j</artifactId>
|
||||
<version>${symbol_dollar}{jclouds.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-classic</artifactId>
|
||||
<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>
|
||||
<systemPropertyVariables>
|
||||
<test.${lcaseProviderName}.identity>\$\{test.${lcaseProviderName}.identity\}</test.${lcaseProviderName}.identity>
|
||||
<test.${lcaseProviderName}.credential>\$\{test.${lcaseProviderName}.credential\}</test.${lcaseProviderName}.credential>
|
||||
<test.${lcaseProviderName}.endpoint>\$\{test.${lcaseProviderName}.endpoint\}</test.${lcaseProviderName}.endpoint>
|
||||
<test.${lcaseProviderName}.api-version>\$\{test.${lcaseProviderName}.api-version\}</test.${lcaseProviderName}.api-version>
|
||||
<test.${lcaseProviderName}.build-version>\$\{test.${lcaseProviderName}.build-version\}</test.${lcaseProviderName}.build-version>
|
||||
</systemPropertyVariables>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
</profiles>
|
||||
</project>
|
|
@ -1,43 +0,0 @@
|
|||
#set( $symbol_pound = '#' )
|
||||
#set( $symbol_dollar = '$' )
|
||||
#set( $symbol_escape = '\' )
|
||||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you 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 ${package};
|
||||
|
||||
import ${package}.features.KeyApi;
|
||||
import org.jclouds.rest.annotations.Delegate;
|
||||
|
||||
/**
|
||||
* Provides synchronous access to ${providerName}.
|
||||
* <p/>
|
||||
*
|
||||
* @see ${providerName}AsyncApi
|
||||
* @see <a href="TODO: docs!">api doc</a>
|
||||
* @author ${author}
|
||||
*/
|
||||
public interface ${providerName}Api {
|
||||
|
||||
/**
|
||||
* Provides synchronous access to Key features.
|
||||
*/
|
||||
@Delegate
|
||||
KeyApi getKeyApi();
|
||||
|
||||
}
|
|
@ -1,97 +0,0 @@
|
|||
#set( $lcaseProviderName = ${providerName.toLowerCase()} )
|
||||
#set( $symbol_pound = '#' )
|
||||
#set( $symbol_dollar = '$' )
|
||||
#set( $symbol_escape = '\' )
|
||||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you 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 ${package};
|
||||
|
||||
import static java.util.concurrent.TimeUnit.SECONDS;
|
||||
import static org.jclouds.Constants.PROPERTY_TIMEOUTS_PREFIX;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.jclouds.apis.ApiMetadata;
|
||||
import ${package}.config.${providerName}RestClientModule;
|
||||
import org.jclouds.rest.RestContext;
|
||||
import org.jclouds.rest.internal.BaseRestApiMetadata;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.reflect.TypeToken;
|
||||
import com.google.inject.Module;
|
||||
|
||||
/**
|
||||
* Implementation of {@link ApiMetadata} for ${providerName} ${providerApiVersion} API
|
||||
*
|
||||
* @author ${author}
|
||||
*/
|
||||
public class ${providerName}ApiMetadata extends BaseRestApiMetadata {
|
||||
|
||||
public static final TypeToken<RestContext<${providerName}Api, ${providerName}AsyncApi>> CONTEXT_TOKEN = new TypeToken<RestContext<${providerName}Api, ${providerName}AsyncApi>>() {
|
||||
};
|
||||
|
||||
@Override
|
||||
public Builder toBuilder() {
|
||||
return new Builder().fromApiMetadata(this);
|
||||
}
|
||||
|
||||
public ${providerName}ApiMetadata() {
|
||||
this(new Builder());
|
||||
}
|
||||
|
||||
protected ${providerName}ApiMetadata(Builder builder) {
|
||||
super(builder);
|
||||
}
|
||||
|
||||
public static Properties defaultProperties() {
|
||||
Properties properties = BaseRestApiMetadata.defaultProperties();
|
||||
properties.setProperty(PROPERTY_TIMEOUTS_PREFIX + "default", SECONDS.toMillis(30) + "");
|
||||
return properties;
|
||||
}
|
||||
|
||||
public static class Builder extends BaseRestApiMetadata.Builder {
|
||||
|
||||
protected Builder() {
|
||||
super(${providerName}Api.class, ${providerName}AsyncApi.class);
|
||||
id("${lcaseProviderName}")
|
||||
.name("${providerName} API")
|
||||
.identityName("${providerIdentity}")
|
||||
.credentialName("${providerCredential}")
|
||||
.documentation(URI.create("TODO"))
|
||||
.version("${providerApiVersion}")
|
||||
.defaultEndpoint("${providerEndpoint}")
|
||||
.defaultProperties(${providerName}ApiMetadata.defaultProperties())
|
||||
.defaultModules(ImmutableSet.<Class<? extends Module>> of(${providerName}RestClientModule.class));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ${providerName}ApiMetadata build() {
|
||||
return new ${providerName}ApiMetadata(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Builder fromApiMetadata(ApiMetadata in) {
|
||||
super.fromApiMetadata(in);
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
#set( $symbol_pound = '#' )
|
||||
#set( $symbol_dollar = '$' )
|
||||
#set( $symbol_escape = '\' )
|
||||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you 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 ${package};
|
||||
|
||||
import ${package}.features.KeyAsyncApi;
|
||||
import org.jclouds.rest.annotations.Delegate;
|
||||
|
||||
/**
|
||||
* Provides asynchronous access to ${providerName} via their REST API.
|
||||
* <p/>
|
||||
*
|
||||
* @see ${providerName}Api
|
||||
* @see <a href="TODO: docs!">api doc</a>
|
||||
* @author ${author}
|
||||
*/
|
||||
public interface ${providerName}AsyncApi {
|
||||
|
||||
/**
|
||||
* Provides asynchronous access to Key features.
|
||||
*/
|
||||
@Delegate
|
||||
KeyAsyncApi getKeyApi();
|
||||
|
||||
}
|
|
@ -1,82 +0,0 @@
|
|||
#set( $symbol_pound = '#' )
|
||||
#set( $symbol_dollar = '$' )
|
||||
#set( $symbol_escape = '\' )
|
||||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you 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 ${package};
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.DELETE;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
|
||||
import org.jclouds.http.filters.BasicAuthentication;
|
||||
import ${package}.${providerName}Client;
|
||||
import org.jclouds.rest.annotations.ExceptionParser;
|
||||
import org.jclouds.rest.annotations.RequestFilters;
|
||||
import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404;
|
||||
import org.jclouds.rest.functions.NullOnNotFoundOr404;
|
||||
import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
|
||||
|
||||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
|
||||
/**
|
||||
* Provides asynchronous access to ${providerName} via their REST API.
|
||||
* <p/>
|
||||
*
|
||||
* @see ${providerName}Client
|
||||
* @see <a href="TODO: insert URL of provider documentation" />
|
||||
* @author ${author}
|
||||
*/
|
||||
@RequestFilters(BasicAuthentication.class)
|
||||
public interface ${providerName}AsyncClient {
|
||||
public static final String API_VERSION = "${providerApiVersion}";
|
||||
|
||||
/*
|
||||
* TODO: define interface methods for ${providerName}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @see ${providerName}Client#list()
|
||||
*/
|
||||
@GET
|
||||
@Path("/items")
|
||||
@Consumes(MediaType.TEXT_PLAIN)
|
||||
@Fallback(EmptySetOnNotFoundOr404.class)
|
||||
ListenableFuture<String> list();
|
||||
|
||||
/**
|
||||
* @see ${providerName}Client#get(long)
|
||||
*/
|
||||
@GET
|
||||
@Fallback(NullOnNotFoundOr404.class)
|
||||
@Consumes(MediaType.TEXT_PLAIN)
|
||||
@Path("/items/{itemId}")
|
||||
ListenableFuture<String> get(@PathParam("itemId") long id);
|
||||
|
||||
/**
|
||||
* @see ${providerName}Client#delete
|
||||
*/
|
||||
@DELETE
|
||||
@Path("/items/{itemId}")
|
||||
@Fallback(VoidOnNotFoundOr404.class)
|
||||
ListenableFuture<Void> delete(@PathParam("itemId") long id);
|
||||
}
|
|
@ -1,48 +0,0 @@
|
|||
#set( $symbol_pound = '#' )
|
||||
#set( $symbol_dollar = '$' )
|
||||
#set( $symbol_escape = '\' )
|
||||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you 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 ${package};
|
||||
|
||||
/**
|
||||
* Provides synchronous access to ${providerName}.
|
||||
* <p/>
|
||||
*
|
||||
* @see ${providerName}AsyncClient
|
||||
* @see <a href="TODO: insert URL of ${providerName} documentation" />
|
||||
* @author ${author}
|
||||
*/
|
||||
public interface ${providerName}Client {
|
||||
/*
|
||||
* Note all these delegate to methods in ${providerName}AsyncClient with a specified or inherited timeout.
|
||||
* The signatures should match those of ${providerName}AsyncClient, except the returnvals should not be
|
||||
* wrapped in a Future
|
||||
*/
|
||||
|
||||
String list();
|
||||
|
||||
/**
|
||||
* @return null, if not found
|
||||
*/
|
||||
String get(long id);
|
||||
|
||||
void delete(long id);
|
||||
|
||||
}
|
|
@ -1,70 +0,0 @@
|
|||
#set( $symbol_pound = '#' )
|
||||
#set( $symbol_dollar = '$' )
|
||||
#set( $symbol_escape = '\' )
|
||||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you 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 ${package}.config;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.jclouds.http.HttpErrorHandler;
|
||||
import org.jclouds.http.annotation.ClientError;
|
||||
import org.jclouds.http.annotation.Redirection;
|
||||
import org.jclouds.http.annotation.ServerError;
|
||||
import ${package}.${providerName}AsyncApi;
|
||||
import ${package}.${providerName}Api;
|
||||
import ${package}.features.KeyAsyncApi;
|
||||
import ${package}.features.KeyApi;
|
||||
import ${package}.handlers.${providerName}ErrorHandler;
|
||||
import org.jclouds.json.config.GsonModule.DateAdapter;
|
||||
import org.jclouds.json.config.GsonModule.Iso8601DateAdapter;
|
||||
import org.jclouds.rest.ConfiguresRestClient;
|
||||
import org.jclouds.rest.config.RestClientModule;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
/**
|
||||
* Configures the ${providerName} connection.
|
||||
*
|
||||
* @author ${author}
|
||||
*/
|
||||
@ConfiguresRestClient
|
||||
public class ${providerName}RestClientModule extends RestClientModule<${providerName}Api, ${providerName}AsyncApi> {
|
||||
public static final Map<Class<?>, Class<?>> DELEGATE_MAP = ImmutableMap.<Class<?>, Class<?>> builder()
|
||||
.put(KeyApi.class, KeyAsyncApi.class)
|
||||
.build();
|
||||
|
||||
public ${providerName}RestClientModule() {
|
||||
super(DELEGATE_MAP);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(DateAdapter.class).to(Iso8601DateAdapter.class);
|
||||
super.configure();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void bindErrorHandlers() {
|
||||
bind(HttpErrorHandler.class).annotatedWith(Redirection.class).to(${providerName}ErrorHandler.class);
|
||||
bind(HttpErrorHandler.class).annotatedWith(ClientError.class).to(${providerName}ErrorHandler.class);
|
||||
bind(HttpErrorHandler.class).annotatedWith(ServerError.class).to(${providerName}ErrorHandler.class);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,151 +0,0 @@
|
|||
#set( $symbol_pound = '#' )
|
||||
#set( $symbol_dollar = '$' )
|
||||
#set( $symbol_escape = '\' )
|
||||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you 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 ${package}.domain;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
import java.util.Date;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.collect.ComparisonChain;
|
||||
|
||||
/**
|
||||
* Example
|
||||
*
|
||||
* @author ${author}
|
||||
* @see <a href="TODO!">api doc</a>
|
||||
*/
|
||||
public class Key implements Comparable<Key> {
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
public Builder toBuilder() {
|
||||
return builder().fromKey(this);
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
private String name;
|
||||
private String key;
|
||||
private Date created = new Date();
|
||||
|
||||
/**
|
||||
* @see Key#getName()
|
||||
*/
|
||||
public Builder name(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Key#get()
|
||||
*/
|
||||
public Builder key(String key) {
|
||||
this.key = key;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Key#getCreated()
|
||||
*/
|
||||
public Builder created(Date created) {
|
||||
this.created = created;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Key build() {
|
||||
return new Key(name, key, created);
|
||||
}
|
||||
|
||||
public Builder fromKey(Key in) {
|
||||
return name(in.getName()).key(in.get()).created(in.getCreated());
|
||||
}
|
||||
}
|
||||
|
||||
protected final String name;
|
||||
protected final String key;
|
||||
// don't include created in the http request
|
||||
transient protected final Date created;
|
||||
|
||||
@ConstructorProperties({ "name", "key", "created" })
|
||||
public Key(String name, String key, Date created) {
|
||||
this.name = checkNotNull(name, "name");
|
||||
this.key = checkNotNull(key, "key: OpenSSH formatted public key of key(%s)", name);
|
||||
this.created = checkNotNull(created, "created date of key(%s)", name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Name for this key
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* OpenSSH formatted public key
|
||||
*/
|
||||
public String get() {
|
||||
return key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Date the key was created
|
||||
*/
|
||||
public Date getCreated() {
|
||||
return created;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
if (this == object) {
|
||||
return true;
|
||||
}
|
||||
if (object instanceof Key) {
|
||||
Key that = Key.class.cast(object);
|
||||
return Objects.equal(name, that.name);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return Objects.toStringHelper("").omitNullValues()
|
||||
.add("name", name)
|
||||
.add("key", key)
|
||||
.add("created", created).toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Key that) {
|
||||
return ComparisonChain.start()
|
||||
.compare(this.name, that.name)
|
||||
.compare(this.created, that.created).result();
|
||||
}
|
||||
}
|
|
@ -1,56 +0,0 @@
|
|||
#set( $symbol_pound = '#' )
|
||||
#set( $symbol_dollar = '$' )
|
||||
#set( $symbol_escape = '\' )
|
||||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you 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 ${package}.features;
|
||||
|
||||
import java.util.Set;
|
||||
import ${package}.domain.Key;
|
||||
|
||||
/**
|
||||
* Description here
|
||||
*
|
||||
* @author ${author}
|
||||
* @see KeyAsyncApi
|
||||
* @see <a href="TODO!">api doc</a>
|
||||
*/
|
||||
public interface KeyApi {
|
||||
|
||||
/**
|
||||
* Lists all public keys we have on record for the specified account.
|
||||
*/
|
||||
Set<Key> list();
|
||||
|
||||
/**
|
||||
* Retrieves an individual key record.
|
||||
*/
|
||||
Key get(String name);
|
||||
|
||||
/**
|
||||
* Uploads a new OpenSSH key to SmartDataCenter for use in SSH and HTTP
|
||||
* signing.
|
||||
*/
|
||||
Key create(Key key);
|
||||
|
||||
/**
|
||||
* Deletes an SSH key by name.
|
||||
*/
|
||||
void delete(String name);
|
||||
}
|
|
@ -1,90 +0,0 @@
|
|||
#set( $symbol_pound = '#' )
|
||||
#set( $symbol_dollar = '$' )
|
||||
#set( $symbol_escape = '\' )
|
||||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you 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 ${package}.features;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.DELETE;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
|
||||
import org.jclouds.http.filters.BasicAuthentication;
|
||||
import ${package}.domain.Key;
|
||||
import org.jclouds.rest.annotations.BinderParam;
|
||||
import org.jclouds.rest.annotations.ExceptionParser;
|
||||
import org.jclouds.rest.annotations.Headers;
|
||||
import org.jclouds.rest.annotations.RequestFilters;
|
||||
import org.jclouds.rest.binders.BindToJsonPayload;
|
||||
import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404;
|
||||
import org.jclouds.rest.functions.NullOnNotFoundOr404;
|
||||
import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
|
||||
|
||||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
|
||||
/**
|
||||
* @author ${author}
|
||||
* @see KeyApi
|
||||
* @see <a href="TODO!">api doc</a>
|
||||
*/
|
||||
@Headers(keys = "X-Api-Version", values = "{jclouds.api-version}")
|
||||
@RequestFilters(BasicAuthentication.class)
|
||||
public interface KeyAsyncApi {
|
||||
/**
|
||||
* @see KeyApi#list
|
||||
*/
|
||||
@GET
|
||||
@Path("/my/keys")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@Fallback(EmptySetOnNotFoundOr404.class)
|
||||
ListenableFuture<Set<Key>> list();
|
||||
|
||||
/**
|
||||
* @see KeyApi#get
|
||||
*/
|
||||
@GET
|
||||
@Path("/my/keys/{name}")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@Fallback(NullOnNotFoundOr404.class)
|
||||
ListenableFuture<Key> get(@PathParam("name") String name);
|
||||
|
||||
/**
|
||||
* @see KeyApi#create
|
||||
*/
|
||||
@POST
|
||||
@Path("/my/keys")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
ListenableFuture<Key> create(@BinderParam(BindToJsonPayload.class) Key key);
|
||||
|
||||
/**
|
||||
* @see KeyApi#delete
|
||||
*/
|
||||
@DELETE
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@Path("/my/keys/{name}")
|
||||
@Fallback(VoidOnNotFoundOr404.class)
|
||||
ListenableFuture<Void> delete(@PathParam("name") String name);
|
||||
|
||||
}
|
|
@ -1,70 +0,0 @@
|
|||
#set( $symbol_pound = '#' )
|
||||
#set( $symbol_dollar = '$' )
|
||||
#set( $symbol_escape = '\' )
|
||||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you 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 ${package}.handlers;
|
||||
|
||||
import static org.jclouds.http.HttpUtils.closeClientButKeepContentStream;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.http.HttpCommand;
|
||||
import org.jclouds.http.HttpErrorHandler;
|
||||
import org.jclouds.http.HttpResponse;
|
||||
import org.jclouds.http.HttpResponseException;
|
||||
import org.jclouds.rest.AuthorizationException;
|
||||
import org.jclouds.rest.ResourceNotFoundException;
|
||||
|
||||
/**
|
||||
* This will parse and set an appropriate exception on the command object.
|
||||
*
|
||||
* @author ${author}
|
||||
*
|
||||
*/
|
||||
@Singleton
|
||||
public class ${providerName}ErrorHandler implements HttpErrorHandler {
|
||||
public void handleError(HttpCommand command, HttpResponse response) {
|
||||
// it is important to always read fully and close streams
|
||||
byte[] data = closeClientButKeepContentStream(response);
|
||||
String message = data != null ? new String(data) : null;
|
||||
|
||||
Exception exception = message != null ? new HttpResponseException(command, response, message)
|
||||
: new HttpResponseException(command, response);
|
||||
message = message != null ? message : String.format("%s -> %s", command.getCurrentRequest().getRequestLine(),
|
||||
response.getStatusLine());
|
||||
switch (response.getStatusCode()) {
|
||||
case 400:
|
||||
break;
|
||||
case 401:
|
||||
case 403:
|
||||
exception = new AuthorizationException(message, exception);
|
||||
break;
|
||||
case 404:
|
||||
if (!command.getCurrentRequest().getMethod().equals("DELETE")) {
|
||||
exception = new ResourceNotFoundException(message, exception);
|
||||
}
|
||||
break;
|
||||
case 409:
|
||||
exception = new IllegalStateException(message, exception);
|
||||
break;
|
||||
}
|
||||
command.setException(exception);
|
||||
}
|
||||
}
|
|
@ -1 +0,0 @@
|
|||
${package}.${providerName}ApiMetadata
|
|
@ -1,45 +0,0 @@
|
|||
#set( $symbol_pound = '#' )
|
||||
#set( $symbol_dollar = '$' )
|
||||
#set( $symbol_escape = '\' )
|
||||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you 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 ${package};
|
||||
|
||||
import org.jclouds.View;
|
||||
import org.jclouds.apis.internal.BaseApiMetadataTest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.reflect.TypeToken;
|
||||
|
||||
/**
|
||||
* Tests that ${providerName}ApiMetadata is properly registered in ServiceLoader
|
||||
*
|
||||
* <pre>
|
||||
* META-INF/services/org.jclouds.apis.ApiMetadata
|
||||
* </pre>
|
||||
*
|
||||
* @author ${author}
|
||||
*/
|
||||
@Test(groups = "unit", testName = "${providerName}ApiMetadataTest")
|
||||
public class ${providerName}ApiMetadataTest extends BaseApiMetadataTest {
|
||||
public ${providerName}ApiMetadataTest() {
|
||||
super(new ${providerName}ApiMetadata(), ImmutableSet.<TypeToken<? extends View>> of());
|
||||
}
|
||||
}
|
|
@ -1,86 +0,0 @@
|
|||
#set( $symbol_pound = '#' )
|
||||
#set( $symbol_dollar = '$' )
|
||||
#set( $symbol_escape = '\' )
|
||||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you 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 ${package}.features;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.http.HttpResponse;
|
||||
import ${package}.${providerName}Api;
|
||||
import ${package}.internal.Base${providerName}ApiExpectTest;
|
||||
import ${package}.parse.ParseKeyListTest;
|
||||
import ${package}.parse.ParseKeyTest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
/**
|
||||
* @author ${author}
|
||||
*/
|
||||
@Test(groups = "unit", testName = "KeyApiExpectTest")
|
||||
public class KeyApiExpectTest extends Base${providerName}ApiExpectTest {
|
||||
public HttpRequest list = HttpRequest.builder().method("GET")
|
||||
.endpoint("${providerEndpoint}/my/keys")
|
||||
.addHeader("X-Api-Version", "${providerApiVersion}")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==").build();
|
||||
|
||||
public HttpResponse listResponse = HttpResponse.builder().statusCode(200).payload(
|
||||
payloadFromResource("/key_list.json")).build();
|
||||
|
||||
public void testListKeysWhenResponseIs2xx() {
|
||||
|
||||
${providerName}Api apiWhenKeysExists = requestSendsResponse(list, listResponse);
|
||||
|
||||
assertEquals(apiWhenKeysExists.getKeyApi().list(), new ParseKeyListTest().expected());
|
||||
}
|
||||
|
||||
public void testListKeysWhenResponseIs404() {
|
||||
HttpResponse listResponse = HttpResponse.builder().statusCode(404).build();
|
||||
|
||||
${providerName}Api listWhenNone = requestSendsResponse(list, listResponse);
|
||||
|
||||
assertEquals(listWhenNone.getKeyApi().list(), ImmutableSet.of());
|
||||
}
|
||||
|
||||
public void testCreateKeyWhenResponseIs202() throws Exception {
|
||||
HttpRequest create = HttpRequest.builder()
|
||||
.method("POST")
|
||||
.endpoint("${providerEndpoint}/my/keys")
|
||||
.addHeader("X-Api-Version", "${providerApiVersion}")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==")
|
||||
.payload(
|
||||
payloadFromStringWithContentType(
|
||||
"{\"name\":\"rsa\",\"key\":\"ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA0A5Pf5Cq...\"}",
|
||||
"application/json")).build();
|
||||
|
||||
HttpResponse createResponse = HttpResponse.builder().statusCode(202).message("HTTP/1.1 202 Accepted")
|
||||
.payload(payloadFromResourceWithContentType("/key.json", "application/json; charset=UTF-8"))
|
||||
.build();
|
||||
|
||||
${providerName}Api apiWithNewKey = requestSendsResponse(create, createResponse);
|
||||
|
||||
assertEquals(apiWithNewKey.getKeyApi().create(new ParseKeyTest().expected())
|
||||
.toString(), new ParseKeyTest().expected().toString());
|
||||
}
|
||||
}
|
|
@ -1,90 +0,0 @@
|
|||
#set( $symbol_pound = '#' )
|
||||
#set( $symbol_dollar = '$' )
|
||||
#set( $symbol_escape = '\' )
|
||||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you 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 ${package}.features;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.jclouds.crypto.SshKeys;
|
||||
import ${package}.domain.Key;
|
||||
import ${package}.features.KeyApi;
|
||||
import ${package}.internal.Base${providerName}ApiLiveTest;
|
||||
import org.testng.annotations.BeforeTest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* @author ${author}
|
||||
*/
|
||||
@Test(groups = "live", singleThreaded = true, testName = "KeyApiLiveTest")
|
||||
public class KeyApiLiveTest extends Base${providerName}ApiLiveTest {
|
||||
|
||||
@Test
|
||||
public void testListAndGetKeys() throws Exception {
|
||||
KeyApi api = context.getApi().getKeyApi();
|
||||
Set<Key> response = api.list();
|
||||
assert null != response;
|
||||
for (Key key : response) {
|
||||
Key newDetails = api.get(key.getName());
|
||||
assertEquals(newDetails.getName(), key.getName());
|
||||
assertEquals(newDetails.get(), key.get());
|
||||
assertEquals(newDetails.getCreated(), key.getCreated());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private String keyText;
|
||||
private String fingerprint;
|
||||
|
||||
@BeforeTest
|
||||
public void initKeys() {
|
||||
keyText = SshKeys.generate().get("public");
|
||||
fingerprint = SshKeys.fingerprintPublicKey(keyText);
|
||||
}
|
||||
|
||||
public void testCreateKey() {
|
||||
KeyApi api = context.getApi().getKeyApi();
|
||||
|
||||
Key newKey = api.create(Key.builder().name(fingerprint).key(keyText).build());
|
||||
assertEquals(newKey.getName(), fingerprint);
|
||||
assertEquals(newKey.get(), keyText);
|
||||
|
||||
newKey = api.get(fingerprint);
|
||||
assertEquals(newKey.getName(), fingerprint);
|
||||
assertEquals(newKey.get(), keyText);
|
||||
}
|
||||
|
||||
@Test(dependsOnMethods = "testCreateKey", expectedExceptions = IllegalStateException.class)
|
||||
public void testDuplicateKey() {
|
||||
KeyApi api = context.getApi().getKeyApi();
|
||||
api.create(Key.builder().name(fingerprint).key(keyText).build());
|
||||
}
|
||||
|
||||
@Test(dependsOnMethods = "testDuplicateKey")
|
||||
public void testDestroyKey() {
|
||||
final KeyApi api = context.getApi().getKeyApi();
|
||||
api.delete(fingerprint);
|
||||
// not that eventhough the key is destroyed it is visible via GET for at
|
||||
// least 45 seconds. This may be a cache issue on the server
|
||||
}
|
||||
|
||||
}
|
|
@ -1,100 +0,0 @@
|
|||
#set( $symbol_pound = '#' )
|
||||
#set( $symbol_dollar = '$' )
|
||||
#set( $symbol_escape = '\' )
|
||||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you 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 ${package}.handlers;
|
||||
|
||||
import static org.easymock.EasyMock.createMock;
|
||||
import static org.easymock.EasyMock.expect;
|
||||
import static org.easymock.EasyMock.replay;
|
||||
import static org.easymock.EasyMock.reportMatcher;
|
||||
import static org.easymock.EasyMock.verify;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import org.easymock.IArgumentMatcher;
|
||||
import org.jclouds.http.HttpCommand;
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.http.HttpResponse;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author ${author}
|
||||
*/
|
||||
@Test(groups = "unit", testName = "${providerName}ErrorHandlerTest")
|
||||
public class ${providerName}ErrorHandlerTest {
|
||||
|
||||
@Test
|
||||
public void test409MakesIllegalStateException() {
|
||||
assertCodeMakes(
|
||||
"POST",
|
||||
URI.create("${providerEndpoint}"),
|
||||
409,
|
||||
"HTTP/1.1 409 Conflict",
|
||||
"\"{\"code\":\"InvalidState\",\"message\":\"An incompatible transition has already been queued for this resource\"}\"",
|
||||
IllegalStateException.class);
|
||||
}
|
||||
|
||||
private void assertCodeMakes(String method, URI uri, int statusCode, String message, String content,
|
||||
Class<? extends Exception> expected) {
|
||||
assertCodeMakes(method, uri, statusCode, message, "application/json", content, expected);
|
||||
}
|
||||
|
||||
private void assertCodeMakes(String method, URI uri, int statusCode, String message, String contentType,
|
||||
String content, Class<? extends Exception> expected) {
|
||||
|
||||
${providerName}ErrorHandler function = new ${providerName}ErrorHandler();
|
||||
|
||||
HttpCommand command = createMock(HttpCommand.class);
|
||||
HttpRequest request = HttpRequest.builder().method(method).endpoint(uri).build();
|
||||
HttpResponse response = HttpResponse.builder().statusCode(statusCode).message(message).payload(content).build();
|
||||
response.getPayload().getContentMetadata().setContentType(contentType);
|
||||
|
||||
expect(command.getCurrentRequest()).andReturn(request).atLeastOnce();
|
||||
command.setException(classEq(expected));
|
||||
|
||||
replay(command);
|
||||
|
||||
function.handleError(command, response);
|
||||
|
||||
verify(command);
|
||||
}
|
||||
|
||||
public static Exception classEq(final Class<? extends Exception> in) {
|
||||
reportMatcher(new IArgumentMatcher() {
|
||||
|
||||
@Override
|
||||
public void appendTo(StringBuffer buffer) {
|
||||
buffer.append("classEq(");
|
||||
buffer.append(in);
|
||||
buffer.append(")");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(Object arg) {
|
||||
return arg.getClass() == in;
|
||||
}
|
||||
|
||||
});
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,31 +0,0 @@
|
|||
#set( $symbol_pound = '#' )
|
||||
#set( $symbol_dollar = '$' )
|
||||
#set( $symbol_escape = '\' )
|
||||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you 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 ${package}.internal;
|
||||
|
||||
import ${package}.${providerName}Api;
|
||||
|
||||
/**
|
||||
* @author ${author}
|
||||
*/
|
||||
public class Base${providerName}ApiExpectTest extends Base${providerName}ExpectTest<${providerName}Api> {
|
||||
|
||||
}
|
|
@ -1,49 +0,0 @@
|
|||
#set( $lcaseProviderName = ${providerName.toLowerCase()} )
|
||||
#set( $symbol_pound = '#' )
|
||||
#set( $symbol_dollar = '$' )
|
||||
#set( $symbol_escape = '\' )
|
||||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you 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 ${package}.internal;
|
||||
|
||||
import org.jclouds.apis.BaseContextLiveTest;
|
||||
import ${package}.${providerName}ApiMetadata;
|
||||
import ${package}.${providerName}AsyncApi;
|
||||
import ${package}.${providerName}Api;
|
||||
import org.jclouds.rest.RestContext;
|
||||
|
||||
import com.google.common.reflect.TypeToken;
|
||||
|
||||
|
||||
/**
|
||||
* @author ${author}
|
||||
*/
|
||||
public class Base${providerName}ApiLiveTest extends BaseContextLiveTest<RestContext<${providerName}Api, ${providerName}AsyncApi>> {
|
||||
|
||||
public Base${providerName}ApiLiveTest() {
|
||||
provider = "${lcaseProviderName}";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected TypeToken<RestContext<${providerName}Api, ${providerName}AsyncApi>> contextType() {
|
||||
return ${providerName}ApiMetadata.CONTEXT_TOKEN;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,40 +0,0 @@
|
|||
#set( $symbol_pound = '#' )
|
||||
#set( $symbol_dollar = '$' )
|
||||
#set( $symbol_escape = '\' )
|
||||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you 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 ${package}.internal;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.http.HttpResponse;
|
||||
import ${package}.${providerName}AsyncApi;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.inject.Module;
|
||||
|
||||
/**
|
||||
* @author ${author}
|
||||
*/
|
||||
public class Base${providerName}AsyncApiExpectTest extends Base${providerName}ExpectTest<${providerName}AsyncApi> {
|
||||
public ${providerName}AsyncApi createClient(Function<HttpRequest, HttpResponse> fn, Module module, Properties props) {
|
||||
return createInjector(fn, module, props).getInstance(${providerName}AsyncApi.class);
|
||||
}
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
#set( $lcaseProviderName = ${providerName.toLowerCase()} )
|
||||
#set( $symbol_pound = '#' )
|
||||
#set( $symbol_dollar = '$' )
|
||||
#set( $symbol_escape = '\' )
|
||||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you 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 ${package}.internal;
|
||||
|
||||
import org.jclouds.rest.internal.BaseRestApiExpectTest;
|
||||
|
||||
/**
|
||||
* @author ${author}
|
||||
*/
|
||||
public class Base${providerName}ExpectTest<T> extends BaseRestApiExpectTest<T> {
|
||||
|
||||
public Base${providerName}ExpectTest() {
|
||||
provider = "${lcaseProviderName}";
|
||||
}
|
||||
}
|
|
@ -1,70 +0,0 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you 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 ${package}.parse;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
|
||||
import org.jclouds.date.internal.SimpleDateFormatDateService;
|
||||
import ${package}.domain.Key;
|
||||
import org.jclouds.json.BaseSetParserTest;
|
||||
import org.jclouds.json.config.GsonModule;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
|
||||
/**
|
||||
* @author ${author}
|
||||
*/
|
||||
@Test(groups = "unit", testName = "ParseKeyListTest")
|
||||
public class ParseKeyListTest extends BaseSetParserTest<Key> {
|
||||
|
||||
@Override
|
||||
public String resource() {
|
||||
return "/key_list.json";
|
||||
}
|
||||
|
||||
@Override
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public Set<Key> expected() {
|
||||
return ImmutableSet.of(
|
||||
Key.builder()
|
||||
.name("rsa")
|
||||
.key("ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA0A5Pf5Cq...")
|
||||
.created(new SimpleDateFormatDateService().iso8601SecondsDateParse("2011-04-13T22:14:46+00:00"))
|
||||
.build()
|
||||
);
|
||||
}
|
||||
|
||||
protected Injector injector() {
|
||||
return Guice.createInjector(new GsonModule() {
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(DateAdapter.class).to(Iso8601DateAdapter.class);
|
||||
super.configure();
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
}
|
|
@ -1,65 +0,0 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you 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 ${package}.parse;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
|
||||
import org.jclouds.date.internal.SimpleDateFormatDateService;
|
||||
import ${package}.domain.Key;
|
||||
import org.jclouds.json.BaseItemParserTest;
|
||||
import org.jclouds.json.config.GsonModule;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
|
||||
/**
|
||||
* @author ${author}
|
||||
*/
|
||||
@Test(groups = "unit", testName = "ParseKeyTest")
|
||||
public class ParseKeyTest extends BaseItemParserTest<Key> {
|
||||
|
||||
@Override
|
||||
public String resource() {
|
||||
return "/key.json";
|
||||
}
|
||||
|
||||
@Override
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public Key expected() {
|
||||
return Key.builder()
|
||||
.name("rsa")
|
||||
.key("ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA0A5Pf5Cq...")
|
||||
.created(new SimpleDateFormatDateService().iso8601SecondsDateParse("2011-04-13T22:14:46+00:00"))
|
||||
.build();
|
||||
}
|
||||
|
||||
protected Injector injector() {
|
||||
return Guice.createInjector(new GsonModule() {
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(DateAdapter.class).to(Iso8601DateAdapter.class);
|
||||
super.configure();
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
{
|
||||
"name": "rsa",
|
||||
"key": "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA0A5Pf5Cq...",
|
||||
"created": "2011-04-13T22:14:46+00:00"
|
||||
}
|
|
@ -1,7 +0,0 @@
|
|||
[
|
||||
{
|
||||
"name": "rsa",
|
||||
"key": "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA0A5Pf5Cq...",
|
||||
"created": "2011-04-13T22:14:46+00:00"
|
||||
}
|
||||
]
|
|
@ -1,38 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
<configuration scan="false">
|
||||
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
|
||||
<file>target/test-data/jclouds.log</file>
|
||||
|
||||
<encoder>
|
||||
<Pattern>%d %-5p [%c] [%thread] %m%n</Pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<appender name="WIREFILE" class="ch.qos.logback.core.FileAppender">
|
||||
<file>target/test-data/jclouds-wire.log</file>
|
||||
|
||||
<encoder>
|
||||
<Pattern>%d %-5p [%c] [%thread] %m%n</Pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<root>
|
||||
<level value="warn" />
|
||||
</root>
|
||||
|
||||
<logger name="org.jclouds">
|
||||
<level value="DEBUG" />
|
||||
<appender-ref ref="FILE" />
|
||||
</logger>
|
||||
|
||||
<logger name="jclouds.wire">
|
||||
<level value="DEBUG" />
|
||||
<appender-ref ref="WIREFILE" />
|
||||
</logger>
|
||||
|
||||
<logger name="jclouds.headers">
|
||||
<level value="DEBUG" />
|
||||
<appender-ref ref="WIREFILE" />
|
||||
</logger>
|
||||
|
||||
</configuration>
|
|
@ -1,35 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
|
||||
Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. jclouds licenses this file
|
||||
to you 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.apache.jclouds</groupId>
|
||||
<version>1.7.0-SNAPSHOT</version>
|
||||
<relativePath>../project/pom.xml</relativePath>
|
||||
</parent>
|
||||
<artifactId>jclouds-assemblies</artifactId>
|
||||
<name>jclouds shared Maven assembly descriptors</name>
|
||||
|
||||
<!-- Cannot be run with '-Pdistribution' on a clean repo, because of a
|
||||
self-dependency. Install into the local repo with 'mvn clean install' first. -->
|
||||
</project>
|
|
@ -1,40 +0,0 @@
|
|||
<!--
|
||||
|
||||
Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. jclouds licenses this file
|
||||
to you 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.
|
||||
|
||||
-->
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<assembly>
|
||||
<id>jar-with-dependencies</id>
|
||||
<formats>
|
||||
<format>jar</format>
|
||||
</formats>
|
||||
<includeBaseDirectory>false</includeBaseDirectory>
|
||||
<dependencySets>
|
||||
<dependencySet>
|
||||
<unpack>true</unpack>
|
||||
<scope>runtime</scope>
|
||||
</dependencySet>
|
||||
</dependencySets>
|
||||
<fileSets>
|
||||
<fileSet>
|
||||
<directory>${project.build.outputDirectory}</directory>
|
||||
<outputDirectory />
|
||||
</fileSet>
|
||||
</fileSets>
|
||||
</assembly>
|
|
@ -1,60 +0,0 @@
|
|||
<!--
|
||||
|
||||
Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. jclouds licenses this file
|
||||
to you 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.
|
||||
|
||||
-->
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<assembly>
|
||||
<id>jar-with-dependencies</id>
|
||||
<formats>
|
||||
<format>jar</format>
|
||||
</formats>
|
||||
<includeBaseDirectory>false</includeBaseDirectory>
|
||||
<dependencySets>
|
||||
<dependencySet>
|
||||
<unpack>true</unpack>
|
||||
<scope>runtime</scope>
|
||||
<excludes>
|
||||
<exclude>org.jclouds:jclouds-core</exclude>
|
||||
<exclude>org.jclouds:jclouds-blobstore</exclude>
|
||||
<exclude>org.jclouds:jclouds-compute</exclude>
|
||||
<exclude>org.jclouds:jclouds-loadbalancer</exclude>
|
||||
<exclude>org.jclouds.api:*</exclude>
|
||||
<!-- excluding optional Clojure dependencies -->
|
||||
<exclude>org.clojure:clojure*</exclude>
|
||||
</excludes>
|
||||
<!-- exclude all transitive dependencies of core too -->
|
||||
<useTransitiveFiltering>true</useTransitiveFiltering>
|
||||
<useProjectArtifact>false</useProjectArtifact>
|
||||
</dependencySet>
|
||||
</dependencySets>
|
||||
<fileSets>
|
||||
<fileSet>
|
||||
<directory>${project.build.outputDirectory}</directory>
|
||||
<outputDirectory />
|
||||
</fileSet>
|
||||
<!-- Hack to get Maven assembly to build even if there are no files to include.
|
||||
See http://jira.codehaus.org/browse/MASSEMBLY-457. -->
|
||||
<fileSet>
|
||||
<includes>
|
||||
<include>pom.xml</include>
|
||||
</includes>
|
||||
<outputDirectory>META-INF/maven/${project.groupId}/${project.artifactId}</outputDirectory>
|
||||
</fileSet>
|
||||
</fileSets>
|
||||
</assembly>
|
File diff suppressed because it is too large
Load Diff
|
@ -1,44 +0,0 @@
|
|||
<!--
|
||||
|
||||
Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. jclouds licenses this file
|
||||
to you 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.
|
||||
|
||||
-->
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<assembly>
|
||||
<id>provided-dependencies</id>
|
||||
<formats>
|
||||
<format>dir</format>
|
||||
</formats>
|
||||
<includeBaseDirectory>false</includeBaseDirectory>
|
||||
<dependencySets>
|
||||
<dependencySet>
|
||||
<scope>provided</scope>
|
||||
<useProjectArtifact>false</useProjectArtifact>
|
||||
</dependencySet>
|
||||
</dependencySets>
|
||||
<fileSets>
|
||||
<!-- Hack to get Maven assembly to build even if there are no files to include.
|
||||
See http://jira.codehaus.org/browse/MASSEMBLY-457. -->
|
||||
<fileSet>
|
||||
<includes>
|
||||
<include>pom.xml</include>
|
||||
</includes>
|
||||
<outputDirectory>META-INF/maven/${project.groupId}/${project.artifactId}</outputDirectory>
|
||||
</fileSet>
|
||||
</fileSets>
|
||||
</assembly>
|
|
@ -1,41 +0,0 @@
|
|||
<!--
|
||||
|
||||
Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. jclouds licenses this file
|
||||
to you 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.
|
||||
|
||||
-->
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<assembly>
|
||||
<id>src</id>
|
||||
<includeBaseDirectory>false</includeBaseDirectory>
|
||||
<formats>
|
||||
<format>dir</format>
|
||||
</formats>
|
||||
<fileSets>
|
||||
<fileSet>
|
||||
<includes>
|
||||
<include>README*</include>
|
||||
<include>LICENSE*</include>
|
||||
<include>NOTICE*</include>
|
||||
<include>pom.xml</include>
|
||||
</includes>
|
||||
</fileSet>
|
||||
<fileSet>
|
||||
<directory>src</directory>
|
||||
</fileSet>
|
||||
</fileSets>
|
||||
</assembly>
|
|
@ -1,109 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
|
||||
Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. jclouds licenses this file
|
||||
to you 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 name="shrinkblob" default="shrinkblob" basedir="." xmlns:artifact="urn:maven-artifact-ant">
|
||||
|
||||
<!-- maven must be available before we use it -->
|
||||
<get src="http://opensource.become.com/apache//maven/binaries/maven-ant-tasks-2.1.1.jar" dest="maven-ant-tasks.jar"/>
|
||||
|
||||
<!-- initialize maven tasks -->
|
||||
<path id="maven-ant-tasks.classpath" path="maven-ant-tasks.jar" />
|
||||
<typedef resource="org/apache/maven/artifact/ant/antlib.xml" uri="urn:maven-artifact-ant"
|
||||
classpathref="maven-ant-tasks.classpath" />
|
||||
|
||||
<artifact:localRepository id="local.repository" path="${user.home}/.m2/repository" />
|
||||
<artifact:remoteRepository id="jclouds-snapshot.repository" url="https://oss.sonatype.org/content/repositories/snapshots" />
|
||||
<artifact:remoteRepository id="shrinkwrap.repository" url="https://repository.jboss.org/nexus/content/groups/public" />
|
||||
|
||||
<!-- Setup maven so that we can get latest version of jclouds, shrinkwrap, and jruby -->
|
||||
<artifact:dependencies pathId="shrinkwrap.classpath">
|
||||
<dependency groupId="org.jboss.shrinkwrap" artifactId="shrinkwrap-impl-base" version="1.0.0-alpha-11" />
|
||||
<dependency groupId="org.jruby" artifactId="jruby" version="1.5.2"/>
|
||||
<dependency groupId="org.jclouds" artifactId="jclouds-allblobstore" version="1.0-SNAPSHOT" />
|
||||
<remoteRepository refid="shrinkwrap.repository" />
|
||||
<remoteRepository refid="jclouds-snapshot.repository" />
|
||||
<localRepository refid="local.repository" />
|
||||
</artifact:dependencies>
|
||||
|
||||
<input
|
||||
message="What is the directory you'd like to upload?"
|
||||
addproperty="dir"
|
||||
/>
|
||||
|
||||
<input
|
||||
message="What is the name of the zip you'd like ${dir} stored to?"
|
||||
addproperty="zip"
|
||||
/>
|
||||
|
||||
<input
|
||||
message="What is the container you wish to store ${zip} in?"
|
||||
addproperty="container"
|
||||
/>
|
||||
|
||||
<input
|
||||
message="Which provider would you like to use (transient,googlestorage,cloudonestorage,synaptic-storage,azureblob,cloudfiles-us,cloudfiles-uk,aws-s3,eucalyptus-partnercloud-s3,scaleup-storage)?"
|
||||
validargs="transient,googlestorage,cloudonestorage,synaptic-storage,azureblob,cloudfiles-us,cloudfiles-uk,aws-s3,eucalyptus-partnercloud-s3,scaleup-storage"
|
||||
addproperty="provider"
|
||||
/>
|
||||
|
||||
<input
|
||||
message="What is your identity on ${provider}?"
|
||||
addproperty="identity"
|
||||
/>
|
||||
|
||||
<input
|
||||
message="What is the credential for ${identity}?"
|
||||
addproperty="credential"
|
||||
/>
|
||||
|
||||
<property name="location" value="default" />
|
||||
|
||||
<target name="shrinkblob">
|
||||
<script language="jruby" classpathref="shrinkwrap.classpath"> <![CDATA[
|
||||
require 'java'
|
||||
require 'jruby/core_ext'
|
||||
include_class 'org.apache.tools.ant.Task'
|
||||
include_class 'org.jclouds.blobstore.BlobStoreContextFactory'
|
||||
include_class 'org.jboss.shrinkwrap.api.ShrinkWrap'
|
||||
include_class 'org.jboss.shrinkwrap.api.exporter.ZipExporter'
|
||||
include_class 'org.jboss.shrinkwrap.api.importer.ExplodedImporter'
|
||||
include_class 'org.jboss.shrinkwrap.impl.base.ServiceExtensionLoader'
|
||||
|
||||
# correct the ant classloader so that extensions can be found
|
||||
java.lang.Thread.currentThread().setContextClassLoader(ServiceExtensionLoader.new().getClass().getClassLoader())
|
||||
|
||||
print "creating the archive from ",$dir,"\n"
|
||||
zipStream = ShrinkWrap.create(ExplodedImporter.java_class, $zip).importDirectory($dir).as(ZipExporter.java_class).exportZip()
|
||||
|
||||
print "connecting to provider ",$provider,"/",$container,"\n"
|
||||
|
||||
context = BlobStoreContextFactory.new().createContext($provider, $identity, $credential)
|
||||
context.getBlobStore().createContainerInLocation(nil, $container)
|
||||
|
||||
print "uploading to ",$provider,"/",$container,"/",$zip,"\n"
|
||||
context.createInputStreamMap($container).put($zip,zipStream);
|
||||
|
||||
context.close();
|
||||
|
||||
]]></script>
|
||||
</target>
|
||||
|
||||
</project>
|
|
@ -1,25 +0,0 @@
|
|||
====
|
||||
Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. jclouds licenses this file
|
||||
to you 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.
|
||||
====
|
||||
|
||||
#
|
||||
# this is a simple command line client that obtains the contents of a container
|
||||
# 1. execute 'mvn install' to build the sample
|
||||
# 2. invoke the jar, passing your credentials and the container you wish to get
|
||||
# ex.
|
||||
# java -jar target/jclouds-getpath-jar-with-dependencies.jar accesskey secretkey container/path
|
|
@ -1,118 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
|
||||
Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. jclouds licenses this file
|
||||
to you 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.apache.jclouds</groupId>
|
||||
<artifactId>jclouds-demos-project</artifactId>
|
||||
<version>1.7.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>jclouds-demo-getpath</artifactId>
|
||||
<name>jclouds getpath</name>
|
||||
<description>jclouds blobstore tool that downloads a container path to a local directory</description>
|
||||
<properties>
|
||||
<jclouds.getpath.container>jclouds-getpath</jclouds.getpath.container>
|
||||
<jclouds.getpath.path>1</jclouds.getpath.path>
|
||||
<jclouds.test.listener></jclouds.test.listener>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>jclouds-allblobstore</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<finalName>${project.artifactId}</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifest>
|
||||
<mainClass>org.jclouds.blobstore.GetPath</mainClass>
|
||||
</manifest>
|
||||
</archive>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<configuration>
|
||||
<descriptorRefs>
|
||||
<descriptorRef>jar-with-dependencies</descriptorRef>
|
||||
</descriptorRefs>
|
||||
<archive>
|
||||
<manifest>
|
||||
<mainClass>org.jclouds.blobstore.GetPath</mainClass>
|
||||
</manifest>
|
||||
</archive>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>make-assembly</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>single</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>live</id>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>integration</id>
|
||||
<phase>integration-test</phase>
|
||||
<goals>
|
||||
<goal>test</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<systemPropertyVariables>
|
||||
<test.identity.azureblob>${jclouds.azure.storage.account}</test.identity.azureblob>
|
||||
<test.credential.azureblob>${jclouds.azure.storage.key}</test.credential.azureblob>
|
||||
<test.identity.cloudfiles>${jclouds.rackspace.user}</test.identity.cloudfiles>
|
||||
<test.credential.cloudfiles>${jclouds.rackspace.key}</test.credential.cloudfiles>
|
||||
<test.identity.s3>${jclouds.aws.accesskeyid}</test.identity.s3>
|
||||
<test.credential.s3>${jclouds.aws.secretaccesskey}</test.credential.s3>
|
||||
<jclouds.getpath.container>${jclouds.getpath.container}</jclouds.getpath.container>
|
||||
<jclouds.getpath.path>${jclouds.getpath.path}</jclouds.getpath.path>
|
||||
</systemPropertyVariables>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
||||
</project>
|
|
@ -1,110 +0,0 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you 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.blobstore;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkState;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.URI;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.jclouds.blobstore.util.BlobStoreUtils;
|
||||
import org.jclouds.domain.Credentials;
|
||||
import org.jclouds.http.HttpUtils;
|
||||
|
||||
import com.google.common.io.ByteStreams;
|
||||
import com.google.common.io.Closeables;
|
||||
|
||||
/**
|
||||
*
|
||||
* Usage is: java GetPath blobstore://identity:key@service/container/path destinationPath
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class GetPath {
|
||||
|
||||
public static String INVALID_SYNTAX = "Invalid parameters. Syntax is: blobstore://identity:key@service/container/path destinationPath";
|
||||
|
||||
public static void main(String... args) throws IOException {
|
||||
if (args.length < 2)
|
||||
throw new IllegalArgumentException(INVALID_SYNTAX);
|
||||
URI uri;
|
||||
try {
|
||||
uri = HttpUtils.createUri(args[0]);
|
||||
checkArgument(uri.getScheme().equals("blobstore"), "wrong scheme");
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw new IllegalArgumentException(String.format("%s%n%s", e.getMessage(), INVALID_SYNTAX));
|
||||
}
|
||||
checkArgument(args[1] != null, String.format("destination must be specified%n%s",
|
||||
INVALID_SYNTAX));
|
||||
|
||||
File destinationDir = new File(args[1]);
|
||||
destinationDir.mkdirs();
|
||||
|
||||
String provider = uri.getHost();
|
||||
Credentials creds = Credentials.parse(uri);
|
||||
|
||||
BlobStoreContext context = new BlobStoreContextFactory().createContext(provider,
|
||||
creds.identity, creds.credential);
|
||||
|
||||
String path = uri.getPath();
|
||||
if (path.startsWith("/"))
|
||||
path = path.substring(1);
|
||||
String container = BlobStoreUtils.parseContainerFromPath(path);
|
||||
String directory = BlobStoreUtils.parsePrefixFromPath(path);
|
||||
copyDirectoryToDestination(context, container, directory, destinationDir);
|
||||
}
|
||||
|
||||
private static void copyDirectoryToDestination(BlobStoreContext context, String container,
|
||||
String directory, File destinationDir) throws FileNotFoundException, IOException {
|
||||
InputStream input = null;
|
||||
|
||||
try {
|
||||
checkState(context.getBlobStore().containerExists(container), String.format(
|
||||
"source container %s does not exist", directory, container));
|
||||
checkState(context.getBlobStore().directoryExists(container, directory), String.format(
|
||||
"source directory %s does not exist in container %s", directory, container));
|
||||
|
||||
String path = container + "/" + directory;
|
||||
InputStreamMap map = context.createInputStreamMap(path);
|
||||
System.out.printf("fetching %d entries from %s %s%n", map.size(), context
|
||||
.getProviderSpecificContext().getIdentity(), path);
|
||||
for (Entry<String, InputStream> entry : map.entrySet()) {
|
||||
System.out.printf("getting file: %s/%s%n", path, entry.getKey());
|
||||
input = entry.getValue();
|
||||
File file = new File(destinationDir, entry.getKey());
|
||||
OutputStream out = new FileOutputStream(file);
|
||||
ByteStreams.copy(input, out);
|
||||
out.flush();
|
||||
out.close();
|
||||
}
|
||||
|
||||
} finally {
|
||||
// Close connection
|
||||
Closeables.closeQuietly(input);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,169 +0,0 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you 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.blobstore;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
|
||||
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
|
||||
import org.testng.annotations.AfterTest;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Optional;
|
||||
import org.testng.annotations.Parameters;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.common.io.Files;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "live", sequential = true)
|
||||
public class GetPathLiveTest {
|
||||
|
||||
public static final String PROPERTY_GETPATH_CONTAINER = "jclouds.getpath.container";
|
||||
public static final String PROPERTY_GETPATH_PATH = "jclouds.getpath.path";
|
||||
|
||||
private Set<BlobStoreContext> contexts;
|
||||
private String container;
|
||||
private String path;
|
||||
|
||||
private String tmpDirectory;
|
||||
|
||||
protected static final String XML_STRING_FORMAT = "<apples><apple name=\"%s\"></apple> </apples>";
|
||||
|
||||
protected Map<String, String> fiveStrings = ImmutableMap.of("one.txt", String.format(
|
||||
XML_STRING_FORMAT, "apple"), "two.txt", String.format(XML_STRING_FORMAT, "bear"),
|
||||
"three.txt", String.format(XML_STRING_FORMAT, "candy"), "four.txt", String.format(
|
||||
XML_STRING_FORMAT, "dogma"), "five.txt", String.format(XML_STRING_FORMAT,
|
||||
"emma"));
|
||||
|
||||
List<String> urisToTest = Lists.newArrayList();
|
||||
|
||||
@BeforeClass(groups = { "integration", "live" })
|
||||
void clearAndCreateContainers() throws InterruptedException, ExecutionException,
|
||||
TimeoutException {
|
||||
container = checkNotNull(System.getProperty(PROPERTY_GETPATH_CONTAINER));
|
||||
path = checkNotNull(System.getProperty(PROPERTY_GETPATH_PATH));
|
||||
|
||||
contexts = Sets.newLinkedHashSet();
|
||||
BlobStoreContextFactory factory = new BlobStoreContextFactory();
|
||||
for (String provider : new String[] { "s3", "cloudfiles", "azureblob" }) {
|
||||
String identity = checkNotNull(System.getProperty("test.identity." + provider),
|
||||
"test.identity." + provider);
|
||||
String credential = checkNotNull(
|
||||
System.getProperty("test.credential." + provider),
|
||||
"test.credential." + provider);
|
||||
|
||||
contexts.add(factory.createContext(provider, identity, credential, ImmutableSet
|
||||
.of(new Log4JLoggingModule())));
|
||||
|
||||
urisToTest.add(String.format("blobstore://%s:%s@%s/%s/%s", identity, credential,
|
||||
provider, container, path));
|
||||
|
||||
}
|
||||
|
||||
boolean deleted = false;
|
||||
for (BlobStoreContext context : contexts) {
|
||||
if (context.getBlobStore().containerExists(container)) {
|
||||
System.err.printf("deleting container %s at %s%n", container, context
|
||||
.getProviderSpecificContext().getEndpoint());
|
||||
context.getBlobStore().deleteContainer(container);
|
||||
deleted = true;
|
||||
}
|
||||
}
|
||||
if (deleted) {
|
||||
System.err.println("sleeping 30 seconds to allow containers to clear");
|
||||
Thread.sleep(30000);
|
||||
}
|
||||
for (BlobStoreContext context : contexts) {
|
||||
System.err.printf("creating container %s at %s%n", container, context
|
||||
.getProviderSpecificContext().getEndpoint());
|
||||
context.getBlobStore().createContainerInLocation(null, container);
|
||||
}
|
||||
if (deleted) {
|
||||
System.err.println("sleeping 5 seconds to allow containers to create");
|
||||
Thread.sleep(30000);
|
||||
}
|
||||
for (BlobStoreContext context : contexts) {
|
||||
System.err.printf("creating directory %s in container %s at %s%n", container, path,
|
||||
context.getProviderSpecificContext().getEndpoint());
|
||||
context.getBlobStore().createDirectory(container, path);
|
||||
}
|
||||
}
|
||||
|
||||
@BeforeClass(dependsOnMethods = "clearAndCreateContainers", groups = { "integration", "live" })
|
||||
protected void addFiles() {
|
||||
for (BlobStoreContext context : contexts) {
|
||||
System.err.printf("adding files to container %s at %s%n", container, context
|
||||
.getProviderSpecificContext().getEndpoint());
|
||||
context.createInputStreamMap(container + "/" + path).putAllStrings(fiveStrings);
|
||||
}
|
||||
}
|
||||
|
||||
@BeforeClass(groups = { "integration", "live" })
|
||||
@Parameters( { "basedir" })
|
||||
protected void setUpTempDir(@Optional String basedir) throws InterruptedException,
|
||||
ExecutionException, FileNotFoundException, IOException, TimeoutException {
|
||||
if (basedir == null) {
|
||||
basedir = System.getProperty("java.io.tmpdir");
|
||||
}
|
||||
tmpDirectory = basedir + File.separator + "target" + File.separator + "testFiles"
|
||||
+ File.separator + getClass().getSimpleName();
|
||||
new File(tmpDirectory).mkdirs();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAllContainers() throws IOException, InterruptedException {
|
||||
|
||||
for (String uriKey : urisToTest) {
|
||||
System.out.println("storing at context: " + uriKey);
|
||||
new File(tmpDirectory).delete();
|
||||
new File(tmpDirectory).mkdirs();
|
||||
GetPath.main(uriKey, tmpDirectory);
|
||||
for (Entry<String, String> entry : fiveStrings.entrySet()) {
|
||||
assertEquals(Files.toString(new File(tmpDirectory, entry.getKey()),
|
||||
Charsets.UTF_8), entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@AfterTest
|
||||
public void closeContexts() {
|
||||
for (BlobStoreContext context : contexts) {
|
||||
context.close();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
|
@ -1,28 +0,0 @@
|
|||
# googleappengine
|
||||
This example will list the current instances and buckets in your Amazon account, using portable apis. This example runs inside Google AppEngine as a war file.
|
||||
|
||||
## Prepare
|
||||
|
||||
Please unzip http://googleappengine.googlecode.com/files/appengine-java-sdk-1.4.0.zip and export the system variable APPENGINE_HOME accordingly.
|
||||
|
||||
## Build
|
||||
|
||||
To install your test on your remote appengine application, first prepare locally via the below instructions:
|
||||
mvn -Dappengine.applicationid=YOUR_APPLICATION -Dtest.aws.identity=YOUR_ACCESS_KEY_ID -Dtest.aws.credential=YOUR_SECRET_KEY -Plive install
|
||||
|
||||
## Deploy
|
||||
|
||||
then, you can upload this to google appengine like below:
|
||||
appcfg.sh -e YOUR_EMAIL update target//jclouds-googleappengine-example
|
||||
|
||||
## Test
|
||||
|
||||
finally, you can verify with a web url:
|
||||
http://YOUR_APPLICATION_ID.appspot.com/guice/status.check
|
||||
|
||||
## License
|
||||
|
||||
Copyright (C) 2009-2011 jclouds, Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0
|
||||
|
|
@ -1,396 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
|
||||
Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. jclouds licenses this file
|
||||
to you 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.apache.jclouds</groupId>
|
||||
<artifactId>jclouds-demos-project</artifactId>
|
||||
<version>1.7.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>jclouds-demo-googleappengine</artifactId>
|
||||
<packaging>war</packaging>
|
||||
<name>JClouds Sample for Google App Engine</name>
|
||||
<description>JClouds Sample for Google App Engine</description>
|
||||
|
||||
<properties>
|
||||
<!--
|
||||
note you must set the property ${appengine.sdk.root} to a valid
|
||||
extraction of appengine-java-sdk
|
||||
-->
|
||||
<appengine.applicationid>jclouds-hpcloud-demo</appengine.applicationid>
|
||||
<appengine.sdk.version>1.6.5</appengine.sdk.version>
|
||||
<devappserver.address>localhost</devappserver.address>
|
||||
<devappserver.port>8088</devappserver.port>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.jclouds</groupId>
|
||||
<artifactId>jclouds-blobstore</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.jclouds</groupId>
|
||||
<artifactId>jclouds-compute</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.jclouds.provider</groupId>
|
||||
<artifactId>hpcloud-objectstorage</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.jclouds.driver</groupId>
|
||||
<artifactId>jclouds-gae</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.inject.extensions</groupId>
|
||||
<artifactId>guice-servlet</artifactId>
|
||||
<version>3.0</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Google App Engine API -->
|
||||
<dependency>
|
||||
<groupId>com.google.appengine</groupId>
|
||||
<artifactId>appengine-api-1.0-sdk</artifactId>
|
||||
<version>${appengine.sdk.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.appengine</groupId>
|
||||
<artifactId>appengine-tools-sdk</artifactId>
|
||||
<version>${appengine.sdk.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- WAR Dependencies: need to be validated -->
|
||||
<dependency>
|
||||
<groupId>displaytag</groupId>
|
||||
<artifactId>displaytag</artifactId>
|
||||
<version>1.2</version>
|
||||
<scope>runtime</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-log4j12</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-jdk14</artifactId>
|
||||
<version>1.5.6</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<artifactId>jstl</artifactId>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<version>1.1.2</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<artifactId>standard</artifactId>
|
||||
<groupId>taglibs</groupId>
|
||||
<version>1.1.2</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>servlet-api</artifactId>
|
||||
<version>2.5</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<finalName>${project.artifactId}</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-remote-resources-plugin</artifactId>
|
||||
<configuration>
|
||||
<!-- prevents the maven-war-plugin from including the resources in WEB-INF/classes -->
|
||||
<attached>false</attached>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-war-plugin</artifactId>
|
||||
<version>2.1.1</version>
|
||||
<configuration>
|
||||
<!-- see http://jira.codehaus.org/browse/MWAR-248 -->
|
||||
<packagingExcludes>WEB-INF/web.xml</packagingExcludes>
|
||||
<webResources>
|
||||
<resource>
|
||||
<directory>src/main/appengine</directory>
|
||||
<targetPath>WEB-INF</targetPath>
|
||||
<filtering>true</filtering>
|
||||
<excludes>
|
||||
<exclude>.gitignore</exclude>
|
||||
</excludes>
|
||||
</resource>
|
||||
</webResources>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>com.ning.maven.plugins</groupId>
|
||||
<artifactId>maven-duplicate-finder-plugin</artifactId>
|
||||
<version>1.0.3</version>
|
||||
<configuration>
|
||||
<exceptions>
|
||||
<exception>
|
||||
<!-- Google App Engine Deps, some google classes are duplicated between packages -->
|
||||
<conflictingDependencies>
|
||||
<dependency>
|
||||
<groupId>com.google.appengine</groupId>
|
||||
<artifactId>appengine-api-1.0-sdk</artifactId>
|
||||
<version>1.6.5</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.appengine</groupId>
|
||||
<artifactId>appengine-tools-sdk</artifactId>
|
||||
<version>1.6.5</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</conflictingDependencies>
|
||||
<packages>
|
||||
<package>com.google</package>
|
||||
</packages>
|
||||
</exception>
|
||||
<exception>
|
||||
<!-- Tomcat bundles the JSR250 annotations too -->
|
||||
<conflictingDependencies>
|
||||
<dependency>
|
||||
<groupId>javax.annotation</groupId>
|
||||
<artifactId>jsr250-api</artifactId>
|
||||
<version>1.0</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.tomcat</groupId>
|
||||
<artifactId>annotations-api</artifactId>
|
||||
<version>6.0.32</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</conflictingDependencies>
|
||||
<packages>
|
||||
<package>javax.annotation</package>
|
||||
</packages>
|
||||
</exception>
|
||||
<exception>
|
||||
<!-- commons-beanutils and commons-collections duplicate classes -->
|
||||
<conflictingDependencies>
|
||||
<dependency>
|
||||
<groupId>commons-beanutils</groupId>
|
||||
<artifactId>commons-beanutils</artifactId>
|
||||
<version>1.7.0</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-collections</groupId>
|
||||
<artifactId>commons-collections</artifactId>
|
||||
<version>3.1</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
</conflictingDependencies>
|
||||
<packages>
|
||||
<package>org.apache.commons.collections</package>
|
||||
</packages>
|
||||
</exception>
|
||||
<exception>
|
||||
<!-- javax.servlet is included in the appengine-tools-sdk, with Tomcat and Jetty -->
|
||||
<conflictingDependencies>
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>servlet-api</artifactId>
|
||||
<version>2.5</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.appengine</groupId>
|
||||
<artifactId>appengine-tools-sdk</artifactId>
|
||||
<version>1.6.5</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.tomcat</groupId>
|
||||
<artifactId>servlet-api</artifactId>
|
||||
<version>6.0.32</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mortbay.jetty</groupId>
|
||||
<artifactId>jetty-runner</artifactId>
|
||||
<version>7.5.4.v20111024</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</conflictingDependencies>
|
||||
<packages>
|
||||
<package>javax.servlet</package>
|
||||
</packages>
|
||||
<resources>
|
||||
<!-- javax.servlet is included in the appengine-tools-sdk and Tomcat -->
|
||||
<resource>javax/servlet/resources/XMLSchema.dtd</resource>
|
||||
<resource>javax/servlet/resources/datatypes.dtd</resource>
|
||||
<resource>javax/servlet/resources/j2ee_1_4.xsd</resource>
|
||||
<resource>javax/servlet/resources/j2ee_web_services_client_1_1.xsd</resource>
|
||||
<resource>javax/servlet/resources/javaee_5.xsd</resource>
|
||||
<resource>javax/servlet/resources/javaee_web_services_client_1_2.xsd</resource>
|
||||
<resource>javax/servlet/resources/jsp_2_0.xsd</resource>
|
||||
<resource>javax/servlet/resources/jsp_2_1.xsd</resource>
|
||||
<resource>javax/servlet/resources/web-app_2_2.dtd</resource>
|
||||
<resource>javax/servlet/resources/web-app_2_3.dtd</resource>
|
||||
<resource>javax/servlet/resources/web-app_2_4.xsd</resource>
|
||||
<resource>javax/servlet/resources/web-app_2_5.xsd</resource>
|
||||
<resource>javax/servlet/resources/xml.xsd</resource>
|
||||
<resource>javax/servlet/LocalStrings.properties</resource>
|
||||
<resource>javax/servlet/LocalStrings_fr.properties</resource>
|
||||
<resource>javax/servlet/LocalStrings_ja.properties</resource>
|
||||
<resource>javax/servlet/http/LocalStrings.properties</resource>
|
||||
<resource>javax/servlet/http/LocalStrings_es.properties</resource>
|
||||
<resource>javax/servlet/http/LocalStrings_fr.properties</resource>
|
||||
<resource>javax/servlet/http/LocalStrings_ja.properties</resource>
|
||||
</resources>
|
||||
</exception>
|
||||
<exception>
|
||||
<!-- Jasper and Catalina duplicate some classes -->
|
||||
<conflictingDependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.tomcat</groupId>
|
||||
<artifactId>catalina</artifactId>
|
||||
<version>6.0.32</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.tomcat</groupId>
|
||||
<artifactId>jasper</artifactId>
|
||||
<version>6.0.32</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</conflictingDependencies>
|
||||
<classes>
|
||||
<class>org.apache.AnnotationProcessor</class>
|
||||
<class>org.apache.PeriodicEventListener</class>
|
||||
</classes>
|
||||
</exception>
|
||||
<exception>
|
||||
<!-- Jetty Runner includes taglibs and jstl -->
|
||||
<conflictingDependencies>
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>jstl</artifactId>
|
||||
<version>1.1.2</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>taglibs</groupId>
|
||||
<artifactId>standard</artifactId>
|
||||
<version>1.1.2</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mortbay.jetty</groupId>
|
||||
<artifactId>jetty-runner</artifactId>
|
||||
<version>7.5.4.v20111024</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</conflictingDependencies>
|
||||
<packages>
|
||||
<package>javax.servlet.jsp.jstl</package>
|
||||
<package>org.apache.taglibs</package>
|
||||
</packages>
|
||||
<resources>
|
||||
<resource>META-INF/c-1_0-rt.tld</resource>
|
||||
<resource>META-INF/c-1_0.tld</resource>
|
||||
<resource>META-INF/c.tld</resource>
|
||||
<resource>META-INF/fmt-1_0-rt.tld</resource>
|
||||
<resource>META-INF/fmt-1_0.tld</resource>
|
||||
<resource>META-INF/fmt.tld</resource>
|
||||
<resource>META-INF/fn.tld</resource>
|
||||
<resource>META-INF/permittedTaglibs.tld</resource>
|
||||
<resource>META-INF/scriptfree.tld</resource>
|
||||
<resource>META-INF/sql-1_0-rt.tld</resource>
|
||||
<resource>META-INF/sql-1_0.tld</resource>
|
||||
<resource>META-INF/sql.tld</resource>
|
||||
<resource>META-INF/x-1_0-rt.tld</resource>
|
||||
<resource>META-INF/x-1_0.tld</resource>
|
||||
<resource>META-INF/x.tld</resource>
|
||||
<resource>org/apache/taglibs/standard/lang/jstl/Resources.properties</resource>
|
||||
<resource>org/apache/taglibs/standard/lang/jstl/Resources_ja.properties</resource>
|
||||
<resource>org/apache/taglibs/standard/resources/Resources.properties</resource>
|
||||
<resource>org/apache/taglibs/standard/resources/Resources_ja.properties</resource>
|
||||
</resources>
|
||||
</exception>
|
||||
</exceptions>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>live</id>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>integration</id>
|
||||
<phase>integration-test</phase>
|
||||
<goals>
|
||||
<goal>test</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<systemPropertyVariables>
|
||||
<!-- note you can add support for new clouds by adding more entries here
|
||||
after adding maven dependency -->
|
||||
<test.hpcloud-objectstorage.identity>${test.hpcloud-objectstorage.identity}</test.hpcloud-objectstorage.identity>
|
||||
<test.hpcloud-objectstorage.credential>${test.hpcloud-objectstorage.credential}</test.hpcloud-objectstorage.credential>
|
||||
<appengine.sdk.root>${appengine.sdk.root}</appengine.sdk.root>
|
||||
<devappserver.address>${devappserver.address}</devappserver.address>
|
||||
<devappserver.port>${devappserver.port}</devappserver.port>
|
||||
<warfile>${project.build.directory}/${project.artifactId}</warfile>
|
||||
</systemPropertyVariables>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>deploy</id>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>net.kindleit</groupId>
|
||||
<artifactId>maven-gae-plugin</artifactId>
|
||||
<version>0.9.2</version>
|
||||
<configuration>
|
||||
<serverId>google-appengine</serverId>
|
||||
<sdkDir>${appengine.sdk.root}</sdkDir>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
</profiles>
|
||||
</project>
|
|
@ -1,30 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
|
||||
Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. jclouds licenses this file
|
||||
to you 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.
|
||||
|
||||
-->
|
||||
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
|
||||
<application>${appengine.applicationid}</application>
|
||||
<version>1</version>
|
||||
<system-properties>
|
||||
<property name="java.util.logging.config.file" value="WEB-INF/logging.properties" />
|
||||
</system-properties>
|
||||
<!-- potential race condition in GuiceServletConfig -->
|
||||
<threadsafe>false</threadsafe>
|
||||
</appengine-web-app>
|
|
@ -1,37 +0,0 @@
|
|||
#
|
||||
# Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
# contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. jclouds licenses this file
|
||||
# to you 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.
|
||||
#
|
||||
|
||||
# Set the default logging level for all loggers to WARNING
|
||||
.level = INFO
|
||||
|
||||
# Set the default logging level for ORM, specifically, to WARNING
|
||||
org.jclouds.level=INFO
|
||||
DataNucleus.JDO.level=WARNING
|
||||
DataNucleus.Persistence.level=WARNING
|
||||
DataNucleus.Cache.level=WARNING
|
||||
DataNucleus.MetaData.level=WARNING
|
||||
DataNucleus.General.level=WARNING
|
||||
DataNucleus.Utility.level=WARNING
|
||||
DataNucleus.Transaction.level=WARNING
|
||||
DataNucleus.Datastore.level=WARNING
|
||||
DataNucleus.ClassLoading.level=WARNING
|
||||
DataNucleus.Plugin.level=WARNING
|
||||
DataNucleus.ValueGeneration.level=WARNING
|
||||
DataNucleus.Enhancer.level=WARNING
|
||||
DataNucleus.SchemaTool.level=WARNING
|
|
@ -1,169 +0,0 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you 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.samples.googleappengine;
|
||||
|
||||
import static com.google.common.collect.Iterables.concat;
|
||||
import static com.google.common.collect.Iterables.size;
|
||||
import static com.google.common.collect.Iterables.transform;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CancellationException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Provider;
|
||||
import javax.inject.Singleton;
|
||||
import javax.servlet.RequestDispatcher;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.jclouds.View;
|
||||
import org.jclouds.domain.ResourceMetadata;
|
||||
import org.jclouds.logging.Logger;
|
||||
import org.jclouds.samples.googleappengine.domain.ResourceResult;
|
||||
import org.jclouds.samples.googleappengine.functions.ResourceMetadataToResourceResult;
|
||||
import org.jclouds.samples.googleappengine.functions.ViewToAsyncResources;
|
||||
import org.jclouds.samples.googleappengine.functions.ViewToId;
|
||||
|
||||
import com.google.common.base.Stopwatch;
|
||||
import com.google.common.collect.FluentIterable;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.ImmutableSet.Builder;
|
||||
import com.google.common.util.concurrent.FutureCallback;
|
||||
import com.google.common.util.concurrent.Futures;
|
||||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
import com.google.common.util.concurrent.ListeningExecutorService;
|
||||
|
||||
/**
|
||||
* Shows an example of how to list all resources from all views!
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Singleton
|
||||
public class GetAllResourcesController extends HttpServlet {
|
||||
|
||||
private final ListeningExecutorService currentRequestExecutorService;
|
||||
private final Iterable<View> views;
|
||||
private final ViewToAsyncResources viewToAsyncResources;
|
||||
private final ResourceMetadataToResourceResult resourceMetadataToStatusResult;
|
||||
private final Provider<Long> remainingMillis;
|
||||
|
||||
@Resource
|
||||
protected Logger logger = Logger.NULL;
|
||||
|
||||
@Inject
|
||||
GetAllResourcesController(ListeningExecutorService currentRequestExecutorService, Iterable<View> views,
|
||||
ViewToAsyncResources viewToAsyncResources, ResourceMetadataToResourceResult resourceMetadataToStatusResult,
|
||||
Provider<Long> remainingMillis) {
|
||||
this.currentRequestExecutorService = currentRequestExecutorService;
|
||||
this.views = views;
|
||||
this.viewToAsyncResources = viewToAsyncResources;
|
||||
this.resourceMetadataToStatusResult = resourceMetadataToStatusResult;
|
||||
this.remainingMillis = remainingMillis;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
try {
|
||||
addResourcesToRequest(request);
|
||||
RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/WEB-INF/jsp/resources.jsp");
|
||||
dispatcher.forward(request, response);
|
||||
} catch (Exception e) {
|
||||
logger.error(e, "Error listing resources");
|
||||
throw new ServletException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void addResourcesToRequest(HttpServletRequest request) {
|
||||
Stopwatch watch = new Stopwatch().start();
|
||||
logger.info("ready to list views: %s", transform(views, ViewToId.INSTANCE));
|
||||
Iterable<ListenableFuture<? extends Iterable<? extends ResourceMetadata<?>>>> asyncResources = transform(views,
|
||||
viewToAsyncResources);
|
||||
logger.info("launched %s tasks with %sms remaining", size(asyncResources), remainingMillis.get());
|
||||
|
||||
Set<Iterable<? extends ResourceMetadata<?>>> done = allResourcesWithinDeadline(asyncResources);
|
||||
logger.info("%s tasks completed in %sms with %sms remaining", size(done), watch.stop().elapsedMillis(),
|
||||
remainingMillis.get());
|
||||
|
||||
Iterable<ResourceMetadata<?>> flattened = concat(done);
|
||||
|
||||
Set<ResourceResult> results = FluentIterable.from(flattened).transform(resourceMetadataToStatusResult)
|
||||
.toImmutableSet();
|
||||
|
||||
request.setAttribute("resources", results);
|
||||
}
|
||||
|
||||
private <T> Set<T> allResourcesWithinDeadline(Iterable<ListenableFuture<? extends T>> asyncResources) {
|
||||
Builder<T> resourcesWeCanList = addToBuilderOnComplete(asyncResources);
|
||||
|
||||
// only serve resources that made it by the timeout
|
||||
blockUntilAllDoneOrCancelOnTimeout(asyncResources);
|
||||
|
||||
return resourcesWeCanList.build();
|
||||
}
|
||||
|
||||
private <T> Builder<T> addToBuilderOnComplete(Iterable<ListenableFuture<? extends T>> asyncResources) {
|
||||
|
||||
final Builder<T> resourcesWeCanList = ImmutableSet.<T> builder();
|
||||
|
||||
for (final ListenableFuture<? extends T> asyncResource : asyncResources) {
|
||||
Futures.addCallback(asyncResource, new FutureCallback<T>() {
|
||||
public void onSuccess(T result) {
|
||||
if (result != null)
|
||||
resourcesWeCanList.add(result);
|
||||
}
|
||||
|
||||
public void onFailure(Throwable t) {
|
||||
if (!(t instanceof CancellationException))
|
||||
logger.error(t, "exception getting resource %s: %s", asyncResource, t.getMessage());
|
||||
}
|
||||
}, currentRequestExecutorService);
|
||||
|
||||
}
|
||||
return resourcesWeCanList;
|
||||
}
|
||||
|
||||
// ensure we don't violate our request timeouts.
|
||||
private void blockUntilAllDoneOrCancelOnTimeout(Iterable<? extends ListenableFuture<?>> asyncResources) {
|
||||
try {
|
||||
for (ListenableFuture<?> asyncResource : asyncResources) {
|
||||
if (remainingMillis.get() > 0) {
|
||||
try {
|
||||
asyncResource.get(remainingMillis.get(), TimeUnit.MILLISECONDS);
|
||||
} catch (Exception e) {
|
||||
logger.info("exception getting resource %s: %s", asyncResource, e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
if (remainingMillis.get() < 0) {
|
||||
for (ListenableFuture<?> asyncResource : asyncResources) {
|
||||
if (!asyncResource.isDone())
|
||||
asyncResource.cancel(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,167 +0,0 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you 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.samples.googleappengine.config;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.google.common.collect.Iterables.filter;
|
||||
import static com.google.common.collect.Iterables.get;
|
||||
import static com.google.common.collect.Iterables.transform;
|
||||
import static com.google.common.io.Closeables.closeQuietly;
|
||||
import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_RUNNING;
|
||||
import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_TERMINATED;
|
||||
import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_PORT_OPEN;
|
||||
import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_SCRIPT_COMPLETE;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Properties;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
import javax.servlet.ServletContextEvent;
|
||||
|
||||
import org.jclouds.ContextBuilder;
|
||||
import org.jclouds.View;
|
||||
import org.jclouds.gae.config.AsyncGoogleAppEngineConfigurationModule;
|
||||
import org.jclouds.logging.jdk.config.JDKLoggingModule;
|
||||
import org.jclouds.providers.ProviderMetadata;
|
||||
import org.jclouds.providers.Providers;
|
||||
import org.jclouds.samples.googleappengine.GetAllResourcesController;
|
||||
|
||||
import com.google.appengine.api.ThreadManager;
|
||||
import com.google.apphosting.api.ApiProxy;
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.reflect.TypeToken;
|
||||
import com.google.common.util.concurrent.ListeningExecutorService;
|
||||
import com.google.common.util.concurrent.MoreExecutors;
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
import com.google.inject.Module;
|
||||
import com.google.inject.Provides;
|
||||
import com.google.inject.TypeLiteral;
|
||||
import com.google.inject.servlet.GuiceServletContextListener;
|
||||
import com.google.inject.servlet.ServletModule;
|
||||
|
||||
/**
|
||||
* Setup Logging and create {@link Injector} for use in testing Views
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class GuiceServletConfig extends GuiceServletContextListener {
|
||||
|
||||
private Iterable<View> views;
|
||||
|
||||
@Override
|
||||
public void contextInitialized(ServletContextEvent servletContextEvent) {
|
||||
final Properties overrides = loadJCloudsProperties(servletContextEvent);
|
||||
// until there's a global skip image parse option
|
||||
overrides.setProperty("jclouds.ec2.ami-query", "");
|
||||
overrides.setProperty("jclouds.ec2.cc-ami-query", "");
|
||||
|
||||
// ensure requests don't take longer than GAE timeout
|
||||
overrides.setProperty(TIMEOUT_NODE_TERMINATED, "25000");
|
||||
overrides.setProperty(TIMEOUT_NODE_RUNNING, "25000");
|
||||
overrides.setProperty(TIMEOUT_SCRIPT_COMPLETE, "25000");
|
||||
overrides.setProperty(TIMEOUT_PORT_OPEN, "25000");
|
||||
|
||||
// correct the classloader so that extensions can be found
|
||||
Thread.currentThread().setContextClassLoader(Providers.class.getClassLoader());
|
||||
|
||||
Iterable<ProviderMetadata> identityInProperties = providersWeHaveIdentitiesFor(overrides);
|
||||
|
||||
final ImmutableSet<Module> modules = ImmutableSet.<Module> of(new AsyncGoogleAppEngineConfigurationModule());
|
||||
views = transform(identityInProperties, new Function<ProviderMetadata, View>() {
|
||||
|
||||
@Override
|
||||
public View apply(ProviderMetadata input) {
|
||||
TypeToken<? extends View> defaultView = get(input.getApiMetadata().getViews(), 0);
|
||||
return ContextBuilder.newBuilder(input).modules(modules).overrides(overrides).buildView(defaultView);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
super.contextInitialized(servletContextEvent);
|
||||
}
|
||||
|
||||
protected Iterable<ProviderMetadata> providersWeHaveIdentitiesFor(final Properties overrides) {
|
||||
// there's a chance serviceloader is being lazy, and we don't want
|
||||
// ConcurrentModificationException, so copy into a set.
|
||||
return ImmutableSet.copyOf(filter(Providers.all(), new Predicate<ProviderMetadata>() {
|
||||
|
||||
@Override
|
||||
public boolean apply(ProviderMetadata input) {
|
||||
return overrides.containsKey(input.getId() + ".identity");
|
||||
}
|
||||
|
||||
}));
|
||||
}
|
||||
|
||||
private Properties loadJCloudsProperties(ServletContextEvent servletContextEvent) {
|
||||
InputStream input = servletContextEvent.getServletContext().getResourceAsStream("/WEB-INF/jclouds.properties");
|
||||
Properties props = new Properties();
|
||||
try {
|
||||
props.load(input);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
closeQuietly(input);
|
||||
}
|
||||
return props;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Injector getInjector() {
|
||||
return Guice.createInjector(new JDKLoggingModule(), new ServletModule() {
|
||||
@Override
|
||||
protected void configureServlets() {
|
||||
bind(new TypeLiteral<Iterable<View>>() {
|
||||
}).toInstance(GuiceServletConfig.this.views);
|
||||
serve("*.check").with(GetAllResourcesController.class);
|
||||
requestInjection(this);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Provides
|
||||
long remainingMillis() {
|
||||
// leave 100ms for any post processing
|
||||
return ApiProxy.getCurrentEnvironment().getRemainingMillis() - 100;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Provides
|
||||
@Singleton
|
||||
ListeningExecutorService currentRequestExecutorService() {
|
||||
ThreadFactory factory = checkNotNull(ThreadManager.currentRequestThreadFactory(),
|
||||
"ThreadManager.currentRequestThreadFactory()");
|
||||
return MoreExecutors.listeningDecorator(Executors.newCachedThreadPool(factory));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void contextDestroyed(ServletContextEvent servletContextEvent) {
|
||||
for (View view : views) {
|
||||
view.unwrap().close();
|
||||
}
|
||||
super.contextDestroyed(servletContextEvent);
|
||||
}
|
||||
}
|
|
@ -1,128 +0,0 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you 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.samples.googleappengine.domain;
|
||||
|
||||
import static com.google.common.base.Objects.equal;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class ResourceResult {
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
protected String provider;
|
||||
protected String location;
|
||||
protected String type;
|
||||
protected String id;
|
||||
protected String name;
|
||||
|
||||
public Builder provider(String provider) {
|
||||
this.provider = provider;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder location(String location) {
|
||||
this.location = location;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder type(String type) {
|
||||
this.type = type;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder id(String id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder name(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ResourceResult build() {
|
||||
return new ResourceResult(provider, location, type, id, name);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private final String provider;
|
||||
private final String location;
|
||||
private final String type;
|
||||
private final String id;
|
||||
private final String name;
|
||||
|
||||
protected ResourceResult(String provider, String location, String type, String id, String name) {
|
||||
this.provider = provider;
|
||||
this.type = type;
|
||||
this.location = location;
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getProvider() {
|
||||
return provider;
|
||||
}
|
||||
|
||||
public String getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (o == null || getClass() != o.getClass())
|
||||
return false;
|
||||
ResourceResult that = ResourceResult.class.cast(o);
|
||||
return equal(this.provider, that.provider) && equal(this.location, that.location) && equal(this.type, that.type)
|
||||
&& equal(this.id, that.id) && equal(this.name, that.name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(provider, location, type, id, name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return Objects.toStringHelper("").add("provider", provider).add("location", location).add("type", type)
|
||||
.add("id", id).add("name", name).toString();
|
||||
}
|
||||
}
|
|
@ -1,45 +0,0 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you 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.samples.googleappengine.functions;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.blobstore.BlobStoreContext;
|
||||
import org.jclouds.domain.ResourceMetadata;
|
||||
import org.jclouds.logging.Logger;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Singleton
|
||||
public class BlobStoreContextToAsyncResources implements
|
||||
Function<BlobStoreContext, ListenableFuture<? extends Iterable<? extends ResourceMetadata<?>>>> {
|
||||
@Resource
|
||||
protected Logger logger = Logger.NULL;
|
||||
|
||||
public ListenableFuture<? extends Iterable<? extends ResourceMetadata<?>>> apply(BlobStoreContext in) {
|
||||
logger.info("listing containers on %s: ", in.unwrap().getId());
|
||||
return in.getAsyncBlobStore().list();
|
||||
}
|
||||
}
|
|
@ -1,69 +0,0 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you 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.samples.googleappengine.functions;
|
||||
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.compute.ComputeServiceContext;
|
||||
import org.jclouds.domain.ResourceMetadata;
|
||||
import org.jclouds.logging.Logger;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
import com.google.common.util.concurrent.ListeningExecutorService;
|
||||
import com.google.inject.Inject;
|
||||
|
||||
/**
|
||||
* ComputeService doesn't currently have an Async counterpart
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Singleton
|
||||
public class ComputeServiceContextToAsyncResources implements
|
||||
Function<ComputeServiceContext, ListenableFuture<? extends Iterable<? extends ResourceMetadata<?>>>> {
|
||||
|
||||
@Resource
|
||||
protected Logger logger = Logger.NULL;
|
||||
|
||||
private final ListeningExecutorService currentRequestExecutorService;
|
||||
|
||||
@Inject
|
||||
public ComputeServiceContextToAsyncResources(ListeningExecutorService currentRequestExecutorService) {
|
||||
this.currentRequestExecutorService = currentRequestExecutorService;
|
||||
}
|
||||
|
||||
public ListenableFuture<? extends Iterable<? extends ResourceMetadata<?>>> apply(final ComputeServiceContext in) {
|
||||
return currentRequestExecutorService.submit(new Callable<Iterable<? extends ResourceMetadata<?>>>() {
|
||||
|
||||
@Override
|
||||
public Iterable<? extends ResourceMetadata<?>> call() throws Exception {
|
||||
logger.info("listing nodes on %s: ", in.unwrap().getId());
|
||||
return in.getComputeService().listNodes();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return in.toString();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
|
@ -1,54 +0,0 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you 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.samples.googleappengine.functions;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.domain.Location;
|
||||
import org.jclouds.domain.ResourceMetadata;
|
||||
import org.jclouds.logging.Logger;
|
||||
import org.jclouds.samples.googleappengine.domain.ResourceResult;
|
||||
import org.jclouds.samples.googleappengine.domain.ResourceResult.Builder;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Singleton
|
||||
public class ResourceMetadataToResourceResult implements Function<ResourceMetadata<?>, ResourceResult> {
|
||||
|
||||
@Resource
|
||||
protected Logger logger = Logger.NULL;
|
||||
|
||||
public ResourceResult apply(ResourceMetadata<?> in) {
|
||||
Builder builder = ResourceResult.builder();
|
||||
Location provider = in.getLocation();
|
||||
while (provider.getParent() != null)
|
||||
provider = provider.getParent();
|
||||
builder.provider(provider.getId());
|
||||
builder.location(in.getLocation().getId());
|
||||
builder.type(in.getType().toString().toLowerCase());
|
||||
builder.id(in.getProviderId());
|
||||
builder.name(in.getName());
|
||||
return builder.build();
|
||||
}
|
||||
}
|
|
@ -1,59 +0,0 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you 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.samples.googleappengine.functions;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.View;
|
||||
import org.jclouds.blobstore.BlobStoreContext;
|
||||
import org.jclouds.compute.ComputeServiceContext;
|
||||
import org.jclouds.domain.ResourceMetadata;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Singleton
|
||||
public class ViewToAsyncResources implements Function<View, ListenableFuture<? extends Iterable<? extends ResourceMetadata<?>>>> {
|
||||
private final BlobStoreContextToAsyncResources blobStoreContextToAsyncResources;
|
||||
private final ComputeServiceContextToAsyncResources computeServiceContextToAsyncResources;
|
||||
|
||||
@Inject
|
||||
public ViewToAsyncResources(BlobStoreContextToAsyncResources blobStoreContextToAsyncResources,
|
||||
ComputeServiceContextToAsyncResources computeServiceContextToAsyncResources) {
|
||||
this.blobStoreContextToAsyncResources = blobStoreContextToAsyncResources;
|
||||
this.computeServiceContextToAsyncResources = computeServiceContextToAsyncResources;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ListenableFuture<? extends Iterable<? extends ResourceMetadata<?>>> apply(View input) {
|
||||
if (input instanceof BlobStoreContext) {
|
||||
return blobStoreContextToAsyncResources.apply(BlobStoreContext.class.cast(input));
|
||||
} else if (input instanceof ComputeServiceContext) {
|
||||
return computeServiceContextToAsyncResources.apply(ComputeServiceContext.class.cast(input));
|
||||
}
|
||||
throw new UnsupportedOperationException("unknown view type: " + input);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,31 +0,0 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you 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.samples.googleappengine.functions;
|
||||
|
||||
import org.jclouds.View;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
|
||||
public enum ViewToId implements Function<View, String> {
|
||||
INSTANCE;
|
||||
@Override
|
||||
public String apply(View input) {
|
||||
return input.unwrap().getId();
|
||||
}
|
||||
}
|
|
@ -1,104 +0,0 @@
|
|||
<%--
|
||||
|
||||
Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. jclouds licenses this file
|
||||
to you 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.
|
||||
|
||||
--%>
|
||||
<%@ page buffer="100kb"%>
|
||||
<%@ taglib uri="http://displaytag.sf.net" prefix="display"%>
|
||||
<html>
|
||||
<head>
|
||||
<title>jclouds: multi-cloud library</title>
|
||||
<style type="text/css">
|
||||
<!--
|
||||
table.staticheader {
|
||||
text-decoration: none;
|
||||
border: 1px solid #CCC;
|
||||
width: 98%;
|
||||
}
|
||||
|
||||
table.staticheader th {
|
||||
padding: 3px 3px 3px 3px !important;
|
||||
text-align:center;
|
||||
}
|
||||
|
||||
table.staticheader td {
|
||||
padding: 3px 3px 3px 3px !important;
|
||||
}
|
||||
|
||||
table.staticheader thead tr {
|
||||
position: relative;
|
||||
height: 10px;
|
||||
background-color: #D7E5F3;
|
||||
}
|
||||
|
||||
table.staticheader tbody {
|
||||
height:800px;
|
||||
overflow-x:hidden;
|
||||
overflow-y: auto;
|
||||
overflow:scroll;
|
||||
}
|
||||
|
||||
table.staticheader tbody tr {
|
||||
height: auto;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
table.staticheader tbody tr.odd {
|
||||
background-color: #eee
|
||||
}
|
||||
|
||||
table.staticheader tbody tr.tableRowEven,tr.even {
|
||||
background-color: #ddd
|
||||
}
|
||||
|
||||
table.staticheader tbody tr td:last-child {
|
||||
padding-right: 20px;
|
||||
}
|
||||
|
||||
table.staticheader tbody td {
|
||||
padding: 2px 4px 2px 4px !important;
|
||||
|
||||
}
|
||||
|
||||
div.TableContainer {
|
||||
height: 800px;
|
||||
overflow-x:hidden;
|
||||
overflow-y:auto;
|
||||
}
|
||||
-->
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h2>Resource List</h2>
|
||||
<table width="100%" border="0">
|
||||
<tr>
|
||||
<td>
|
||||
<div class="TableContainer">
|
||||
<display:table name="resources" defaultsort="1" cellpadding="5" cellspacing="1" class="staticheader">
|
||||
<display:column property="provider" title="Provider" />
|
||||
<display:column property="location" title="Location" />
|
||||
<display:column property="type" title="Type" />
|
||||
<display:column property="id" title="Id" />
|
||||
<display:column property="name" title="Name" />
|
||||
</display:table>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
|
@ -1,47 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
|
||||
Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. jclouds licenses this file
|
||||
to you 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.
|
||||
|
||||
-->
|
||||
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_5.xsd"
|
||||
version="2.5">
|
||||
<display-name>jclouds-aws-demo-googleappengine</display-name>
|
||||
|
||||
<!-- Servlets -->
|
||||
<filter>
|
||||
<filter-name>guiceFilter</filter-name>
|
||||
<filter-class>com.google.inject.servlet.GuiceFilter</filter-class>
|
||||
</filter>
|
||||
|
||||
<filter-mapping>
|
||||
<filter-name>guiceFilter</filter-name>
|
||||
<url-pattern>/guice/*</url-pattern>
|
||||
</filter-mapping>
|
||||
|
||||
|
||||
<listener>
|
||||
<listener-class>org.jclouds.samples.googleappengine.config.GuiceServletConfig</listener-class>
|
||||
</listener>
|
||||
|
||||
<welcome-file-list>
|
||||
<welcome-file>index.jsp</welcome-file>
|
||||
</welcome-file-list>
|
||||
|
||||
</web-app>
|
|
@ -1,30 +0,0 @@
|
|||
<%--
|
||||
|
||||
Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. jclouds licenses this file
|
||||
to you 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.
|
||||
|
||||
--%>
|
||||
<html>
|
||||
<head>
|
||||
<title>jclouds: multi-cloud framework</title>
|
||||
</head>
|
||||
<body>
|
||||
<h2>Welcome!</h2>
|
||||
Click
|
||||
<a href="/guice/resources.check">here</a> to list all your cloud resources!
|
||||
</body>
|
||||
</html>
|
|
@ -1,109 +0,0 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you 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.samples.googleappengine.functest;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.jclouds.blobstore.BlobStore;
|
||||
import org.jclouds.compute.ComputeService;
|
||||
import org.jclouds.util.Maps2;
|
||||
import org.jclouds.util.Strings2;
|
||||
import org.testng.annotations.BeforeTest;
|
||||
import org.testng.annotations.Parameters;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
/**
|
||||
* Starts up the Google App Engine for Java Development environment and deploys an application which
|
||||
* tests {@link ComputeService} and {@link BlobStore}.
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "live", singleThreaded = true)
|
||||
public class GoogleAppEngineLiveTest {
|
||||
|
||||
GoogleDevServer server;
|
||||
private URL url;
|
||||
|
||||
@BeforeTest
|
||||
@Parameters( { "warfile", "devappserver.address", "devappserver.port" })
|
||||
public void startDevAppServer(final String warfile, final String address, final String port)
|
||||
throws Exception {
|
||||
url = new URL(String.format("http://%s:%s", address, port));
|
||||
|
||||
Properties props = new Properties();
|
||||
props.putAll(stripTestPrefix(selectPropertiesForIdentityAndCredential()));
|
||||
server = new GoogleDevServer();
|
||||
server.writePropertiesAndStartServer(address, port, warfile, props);
|
||||
}
|
||||
|
||||
Map<String, String> stripTestPrefix(Map<String, String> identityCrendential) {
|
||||
return Maps2.transformKeys(identityCrendential, new Function<String, String>() {
|
||||
|
||||
@Override
|
||||
public String apply(String arg0) {
|
||||
return arg0.replace("test.", "");
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
Map<String, String> selectPropertiesForIdentityAndCredential() {
|
||||
return Maps.filterKeys((Map) System.getProperties(), new Predicate<String>() {
|
||||
|
||||
@Override
|
||||
public boolean apply(String input) {
|
||||
// TODO Auto-generated method stub
|
||||
return input.matches("^test\\.[a-z0-9-]+\\.(identity|credential)$");
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldPass() throws InterruptedException, IOException {
|
||||
InputStream i = url.openStream();
|
||||
String string = Strings2.toStringAndClose(i);
|
||||
assert string.indexOf("Welcome") >= 0 : string;
|
||||
}
|
||||
|
||||
@Test(invocationCount = 5, enabled = true)
|
||||
public void testGuiceJCloudsSerial() throws InterruptedException, IOException {
|
||||
URL gurl = new URL(url, "/guice/resources.check");
|
||||
InputStream i = gurl.openStream();
|
||||
String string = Strings2.toStringAndClose(i);
|
||||
assert string.indexOf("List") >= 0 : string;
|
||||
}
|
||||
|
||||
@Test(invocationCount = 10, enabled = false, threadPoolSize = 3)
|
||||
public void testGuiceJCloudsParallel() throws InterruptedException, IOException {
|
||||
URL gurl = new URL(url, "/guice/resources.check");
|
||||
InputStream i = gurl.openStream();
|
||||
String string = Strings2.toStringAndClose(i);
|
||||
assert string.indexOf("List") >= 0 : string;
|
||||
}
|
||||
}
|
|
@ -1,76 +0,0 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you 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.samples.googleappengine.functest;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static java.lang.String.format;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Properties;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import com.google.appengine.tools.KickStart;
|
||||
import com.google.appengine.tools.info.SdkInfo;
|
||||
|
||||
/**
|
||||
* Basic functionality to start a local google app engine instance.
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class GoogleDevServer {
|
||||
|
||||
Thread server;
|
||||
|
||||
public void writePropertiesAndStartServer(final String address,
|
||||
final String port, final String warfile, Properties props)
|
||||
throws IOException, InterruptedException {
|
||||
String filename = String.format("%1$s/WEB-INF/jclouds.properties", warfile);
|
||||
System.err.println("file: " + filename);
|
||||
props.store(new FileOutputStream(filename), "test");
|
||||
assert new File(filename).exists();
|
||||
this.server = new Thread(new Runnable() {
|
||||
public void run() {
|
||||
String sdkRoot = checkNotNull(System.getProperty(SdkInfo.SDK_ROOT_PROPERTY), SdkInfo.SDK_ROOT_PROPERTY);
|
||||
KickStart.main(new String[] {
|
||||
KickStarter.systemProperty("java.util.logging.config.file",
|
||||
format("%s/WEB-INF/logging.properties", warfile)),
|
||||
KickStarter.systemProperty(SdkInfo.SDK_ROOT_PROPERTY, sdkRoot),
|
||||
"com.google.appengine.tools.development.DevAppServerMain",
|
||||
"--disable_update_check",
|
||||
format("--sdk_root=%s", sdkRoot),
|
||||
"-a", address, "-p", port, warfile });
|
||||
}
|
||||
});
|
||||
server.start();
|
||||
TimeUnit.SECONDS.sleep(30);
|
||||
}
|
||||
|
||||
public void stop() throws Exception {
|
||||
// KickStart.main opens a process and calls process.waitFor(), which is interruptable
|
||||
server.interrupt();
|
||||
}
|
||||
|
||||
private static class KickStarter {
|
||||
private static String systemProperty(String key, String value) {
|
||||
return format("--jvm_flag=-D%s=%s", key, value);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,60 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
|
||||
Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. jclouds licenses this file
|
||||
to you 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">
|
||||
<parent>
|
||||
<artifactId>jclouds-project</artifactId>
|
||||
<groupId>org.apache.jclouds</groupId>
|
||||
<version>1.7.0-SNAPSHOT</version>
|
||||
<relativePath>../project/pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>jclouds-demos-project</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<name>jclouds demos project</name>
|
||||
<modules>
|
||||
<module>getpath</module>
|
||||
<module>googleappengine</module>
|
||||
<module>speedtest-azurequeue</module>
|
||||
<module>speedtest-sqs</module>
|
||||
<module>simpledb</module>
|
||||
</modules>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>jclouds-core</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<type>test-jar</type>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.jclouds.driver</groupId>
|
||||
<artifactId>jclouds-log4j</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
|
@ -1,29 +0,0 @@
|
|||
====
|
||||
Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. jclouds licenses this file
|
||||
to you 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.
|
||||
====
|
||||
|
||||
#
|
||||
# this is a simple example command line client to test usage of simpledb
|
||||
# functions like putAttribute is tested and then it select and retrieve results.
|
||||
# 1. execute 'mvn install' to build the sample
|
||||
# 2. invoke the jar, passing your aws credentials and the bucket you wish to create
|
||||
# ex.
|
||||
# java -jar target/jclouds-aws-demo-simpledb-jar-with-dependencies.jar $AWS_USER $AWS_PWD simpledbtest
|
||||
|
||||
|
||||
# Further information: Luís A. astião Silva bastiao@ua.pt>
|
|
@ -1,79 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
|
||||
Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. jclouds licenses this file
|
||||
to you 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.apache.jclouds</groupId>
|
||||
<artifactId>jclouds-demos-project</artifactId>
|
||||
<version>1.7.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>jclouds-demo-simpledb</artifactId>
|
||||
<name>jclouds simpledb sample that putAttributes and select it</name>
|
||||
<description>jclouds simpledb sample that putAttributes and select it</description>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.jclouds.provider</groupId>
|
||||
<artifactId>aws-simpledb</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<finalName>${project.artifactId}</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifest>
|
||||
<mainClass>org.jclouds.simpledb.samples.MainApp</mainClass>
|
||||
</manifest>
|
||||
</archive>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<configuration>
|
||||
<descriptorRefs>
|
||||
<descriptorRef>jar-with-dependencies</descriptorRef>
|
||||
</descriptorRefs>
|
||||
<archive>
|
||||
<manifest>
|
||||
<mainClass>org.jclouds.simpledb.samples.MainApp</mainClass>
|
||||
</manifest>
|
||||
</archive>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>make-assembly</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>single</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
|
@ -1,79 +0,0 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you 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.samples;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.jclouds.aws.domain.Region;
|
||||
import org.jclouds.rest.RestContext;
|
||||
import org.jclouds.rest.RestContextFactory;
|
||||
import org.jclouds.simpledb.SimpleDBAsyncClient;
|
||||
import org.jclouds.simpledb.SimpleDBClient;
|
||||
import org.jclouds.simpledb.domain.AttributePair;
|
||||
import org.jclouds.simpledb.domain.Item;
|
||||
import org.jclouds.simpledb.options.ListDomainsOptions;
|
||||
|
||||
import com.google.common.collect.LinkedHashMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
|
||||
|
||||
/**
|
||||
* This the Main class of an Application that demonstrates the use of the simpledb.
|
||||
*
|
||||
* Usage is: java MainApp \"accesskeyid\" \"secretkey\"
|
||||
*
|
||||
* @author Luís A. Bastião Silva <bastiao@ua.pt>
|
||||
*
|
||||
*/
|
||||
public class MainApp
|
||||
{
|
||||
|
||||
public static int PARAMETERS = 3;
|
||||
public static String INVALID_SYNTAX = "Invalid number of parameters. Syntax is: \"accesskeyid\" \"secretkey\" \"bucketName\" ";
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
|
||||
|
||||
// Args
|
||||
String accesskeyid = args[0];
|
||||
String secretkey = args[1];
|
||||
Properties properties = new Properties();
|
||||
properties.setProperty("simpledb.identity", accesskeyid);
|
||||
properties.setProperty("simpledb.credential", secretkey);
|
||||
|
||||
|
||||
RestContext<SimpleDBClient, SimpleDBAsyncClient> context = new RestContextFactory().createContext("simpledb", "AKIAJODKICBEKG7MM4XA", "FfqiNSiC88B6tJPDIOKUWUJGY68BQaQpkNz6Fsgq", new Properties());
|
||||
AttributePair p = new AttributePair("AccessNumber", "1213123", true);
|
||||
Multimap<String,AttributePair> m =LinkedHashMultimap.create();
|
||||
m.put("AccessNumber", p);
|
||||
Item attributes = new Item(m);
|
||||
|
||||
// Use Provider API
|
||||
context.getApi().putAttributes(Region.EU_WEST_1, "tse", "AccessNumber", attributes );
|
||||
//context.getApi().createDomainInRegion(Region.EU_WEST_1, "tse");
|
||||
Map<String, Item> results = context.getApi().select(Region.EU_WEST_1, "select * from tse");
|
||||
System.out.println(results);
|
||||
ListDomainsOptions [] list = new ListDomainsOptions[100];
|
||||
//context.getApi().listDomainsInRegion(Region.EU_WEST_1, list);
|
||||
System.out.println(list[0]);
|
||||
context.close();
|
||||
}
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
====
|
||||
Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. jclouds licenses this file
|
||||
to you 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.
|
||||
====
|
||||
|
||||
#
|
||||
# this is a simple example command line client that creates a queue, then tracks performance of it
|
||||
# 1. execute 'mvn install' to build the sample
|
||||
# 2. invoke the jar, passing your azure credentials and the bucket you wish to create
|
||||
# ex.
|
||||
# java -jar target/jclouds-demo-speedtest-azurequeue-jar-with-dependencies.jar $AZURE_USER $AZURE_PWD testqueue 1000
|
|
@ -1,83 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
|
||||
Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. jclouds licenses this file
|
||||
to you 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.apache.jclouds</groupId>
|
||||
<artifactId>jclouds-demos-project</artifactId>
|
||||
<version>1.7.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>jclouds-demo-speedtest-azurequeue</artifactId>
|
||||
<name>Speed tests of Azure's queue offering</name>
|
||||
<description>Creates a queue and then tests performance against it</description>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.jclouds.driver</groupId>
|
||||
<artifactId>jclouds-enterprise</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.jclouds.provider</groupId>
|
||||
<artifactId>azurequeue</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<finalName>${project.artifactId}</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifest>
|
||||
<mainClass>org.jclouds.azure.azurequeue.SpeedTest</mainClass>
|
||||
</manifest>
|
||||
</archive>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<configuration>
|
||||
<descriptorRefs>
|
||||
<descriptorRef>jar-with-dependencies</descriptorRef>
|
||||
</descriptorRefs>
|
||||
<archive>
|
||||
<manifest>
|
||||
<mainClass>org.jclouds.azure.azurequeue.SpeedTest</mainClass>
|
||||
</manifest>
|
||||
</archive>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>make-assembly</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>single</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
|
@ -1,171 +0,0 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you 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.azure.azurequeue;
|
||||
|
||||
import static org.jclouds.concurrent.FutureIterables.awaitCompletion;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.SortedSet;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import org.jclouds.azure.storage.options.ListOptions;
|
||||
import org.jclouds.azure.storage.queue.AzureQueueAsyncClient;
|
||||
import org.jclouds.azure.storage.queue.AzureQueueClient;
|
||||
import org.jclouds.azure.storage.queue.domain.QueueMetadata;
|
||||
import org.jclouds.concurrent.MoreExecutors;
|
||||
import org.jclouds.enterprise.config.EnterpriseConfigurationModule;
|
||||
import org.jclouds.logging.ConsoleLogger;
|
||||
import org.jclouds.logging.Logger;
|
||||
import org.jclouds.logging.config.NullLoggingModule;
|
||||
import org.jclouds.rest.RestContext;
|
||||
import org.jclouds.rest.RestContextFactory;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.inject.Module;
|
||||
|
||||
/**
|
||||
* This the Main class of an Application that tests your response time to amazon AzureQueue.
|
||||
*
|
||||
* Usage is: java org.jclouds.aws.sqs.SpeedTest \"account\" \"encodedKey\" \"queueName\"
|
||||
* \"messageCount\"
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class SpeedTest {
|
||||
|
||||
public static int PARAMETERS = 4;
|
||||
public static String INVALID_SYNTAX = "Invalid number of parameters. Syntax is: \"account\" \"encodedKey\" \"queueName\" \"messageCount\" ";
|
||||
private static final Logger logger = Logger.CONSOLE;
|
||||
|
||||
private static final Logger traceLogger = new ConsoleLogger() {
|
||||
|
||||
@Override
|
||||
public boolean isTraceEnabled() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void trace(String message, Object... args) {
|
||||
super.info(message, args);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
|
||||
if (args.length < PARAMETERS)
|
||||
throw new IllegalArgumentException(INVALID_SYNTAX);
|
||||
|
||||
boolean isEnterprise = System.getProperties().containsKey("jclouds.enterprise");
|
||||
// Args
|
||||
String account = args[0];
|
||||
String encodedKey = args[1];
|
||||
String queueName = args[2];
|
||||
int messageCount = Integer.parseInt(args[3]);
|
||||
|
||||
Set<Module> modules = isEnterprise ? ImmutableSet.<Module> of(new NullLoggingModule(),
|
||||
new EnterpriseConfigurationModule()) : ImmutableSet
|
||||
.<Module> of(new NullLoggingModule());
|
||||
|
||||
RestContext<AzureQueueClient, AzureQueueAsyncClient> context = new RestContextFactory()
|
||||
.createContext("azurequeue", account, encodedKey, modules);
|
||||
|
||||
try {
|
||||
if (purgeQueues(queueName, context)) {
|
||||
logger.info("pausing 60 seconds before recreating queues");
|
||||
Thread.sleep(60 * 1000);
|
||||
}
|
||||
createQueue(queueName, context);
|
||||
runTests(queueName, messageCount, isEnterprise ? "enterprise" : "default", context);
|
||||
} finally {
|
||||
purgeQueues(queueName, context);
|
||||
// Close connections
|
||||
context.close();
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static class QueueMessage {
|
||||
final String queue;
|
||||
final String message;
|
||||
|
||||
QueueMessage(String queue, String message) {
|
||||
this.queue = queue;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[queue=" + queue + ", message=" + message + "]";
|
||||
}
|
||||
}
|
||||
|
||||
private static void runTests(String queueName, int messageCount, String contextName,
|
||||
RestContext<AzureQueueClient, AzureQueueAsyncClient> context)
|
||||
throws InterruptedException {
|
||||
String message = "1";
|
||||
long timeOut = messageCount * 200; // minimum rate should be at least 5/second
|
||||
|
||||
logger.info("context: %s, queueName: %s", contextName, queueName);
|
||||
|
||||
// fire off all the messages for the test
|
||||
Map<QueueMessage, Future<Void>> responses = Maps.newHashMap();
|
||||
for (int i = 0; i < messageCount; i++) {
|
||||
responses.put(new QueueMessage(queueName, message), context.getAsyncApi().putMessage(
|
||||
queueName, message));
|
||||
}
|
||||
|
||||
Map<QueueMessage, Exception> exceptions = awaitCompletion(responses, MoreExecutors.sameThreadExecutor(),
|
||||
timeOut, traceLogger, String.format("context: %s", contextName));
|
||||
|
||||
if (exceptions.size() > 0)
|
||||
logger.error("problems in context: %s: %s", contextName, exceptions);
|
||||
|
||||
System.gc();
|
||||
logger.info("pausing 5 seconds before the next run");
|
||||
Thread.sleep(5000);// let the network quiet down
|
||||
}
|
||||
|
||||
private static void createQueue(String queueName,
|
||||
RestContext<AzureQueueClient, AzureQueueAsyncClient> nullLoggingDefaultContext) {
|
||||
logger.info("creating queue: %s", queueName);
|
||||
nullLoggingDefaultContext.getApi().createQueue(queueName);
|
||||
}
|
||||
|
||||
private static boolean purgeQueues(String queueName,
|
||||
RestContext<AzureQueueClient, AzureQueueAsyncClient> nullLoggingDefaultContext) {
|
||||
boolean deleted = false;
|
||||
try {
|
||||
SortedSet<QueueMetadata> result = Sets.newTreeSet(nullLoggingDefaultContext.getApi()
|
||||
.listQueues(ListOptions.Builder.prefix(queueName)));
|
||||
if (result.size() >= 1) {
|
||||
nullLoggingDefaultContext.getApi().deleteQueue(result.last().getName());
|
||||
System.out.printf("deleted queue: %s%n", queueName);
|
||||
deleted = true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
return deleted;
|
||||
}
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
====
|
||||
Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. jclouds licenses this file
|
||||
to you 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.
|
||||
====
|
||||
|
||||
#
|
||||
# this is a simple example command line client that creates a queue in all regions, then tracks performance of it
|
||||
# 1. execute 'mvn install' to build the sample
|
||||
# 2. invoke the jar, passing your aws credentials and the bucket you wish to create
|
||||
# ex.
|
||||
# java -jar target/jclouds-speedtest-sqs-jar-with-dependencies.jar $AWS_USER $AWS_PWD testqueue 1000
|
|
@ -1,84 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
|
||||
Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. jclouds licenses this file
|
||||
to you 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.apache.jclouds</groupId>
|
||||
<artifactId>jclouds-demos-project</artifactId>
|
||||
<version>1.7.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>jclouds-demo-speedtest-sqs</artifactId>
|
||||
<name>Speed tests of SQS across regions</name>
|
||||
<description>Creates a queue in all amazon regions and then tests performance against it</description>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.jclouds.api</groupId>
|
||||
<artifactId>sqs</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.jclouds.driver</groupId>
|
||||
<artifactId>jclouds-enterprise</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<finalName>${project.artifactId}</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifest>
|
||||
<mainClass>org.jclouds.aws.sqs.SpeedTest</mainClass>
|
||||
</manifest>
|
||||
</archive>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<configuration>
|
||||
<descriptorRefs>
|
||||
<descriptorRef>jar-with-dependencies</descriptorRef>
|
||||
</descriptorRefs>
|
||||
<archive>
|
||||
<manifest>
|
||||
<mainClass>org.jclouds.aws.sqs.SpeedTest</mainClass>
|
||||
</manifest>
|
||||
</archive>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>make-assembly</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>single</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
|
@ -1,177 +0,0 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you 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.aws.sqs;
|
||||
|
||||
import static org.jclouds.concurrent.FutureIterables.awaitCompletion;
|
||||
import static org.jclouds.sqs.options.ListQueuesOptions.Builder.queuePrefix;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.SortedSet;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import org.jclouds.aws.domain.Region;
|
||||
import org.jclouds.concurrent.MoreExecutors;
|
||||
import org.jclouds.enterprise.config.EnterpriseConfigurationModule;
|
||||
import org.jclouds.logging.ConsoleLogger;
|
||||
import org.jclouds.logging.Logger;
|
||||
import org.jclouds.logging.config.NullLoggingModule;
|
||||
import org.jclouds.rest.RestContext;
|
||||
import org.jclouds.rest.RestContextFactory;
|
||||
import org.jclouds.sqs.SQSAsyncClient;
|
||||
import org.jclouds.sqs.SQSClient;
|
||||
import org.jclouds.sqs.domain.Queue;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.inject.Module;
|
||||
|
||||
/**
|
||||
* This the Main class of an Application that tests your response time to amazon SQS.
|
||||
*
|
||||
* Usage is: java org.jclouds.aws.sqs.SpeedTest \"accesskeyid\" \"secretkey\" \"queueName\"
|
||||
* \"messageCount\"
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class SpeedTest {
|
||||
private static final ImmutableSet<String> REGIONS = ImmutableSet.of(Region.EU_WEST_1, Region.US_EAST_1,
|
||||
Region.US_WEST_1, Region.AP_SOUTHEAST_1);
|
||||
public static final int PARAMETERS = 4;
|
||||
public static final String INVALID_SYNTAX = "Invalid number of parameters. Syntax is: \"accesskeyid\" \"secretkey\" \"queueName\" \"messageCount\" ";
|
||||
|
||||
private static final Logger logger = Logger.CONSOLE;
|
||||
|
||||
private static final Logger traceLogger = new ConsoleLogger() {
|
||||
|
||||
@Override
|
||||
public boolean isTraceEnabled() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void trace(String message, Object... args) {
|
||||
super.info(message, args);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
|
||||
if (args.length < PARAMETERS)
|
||||
throw new IllegalArgumentException(INVALID_SYNTAX);
|
||||
|
||||
boolean isEnterprise = System.getProperties().containsKey("jclouds.enterprise");
|
||||
// Args
|
||||
String accesskeyid = args[0];
|
||||
String secretkey = args[1];
|
||||
String queueName = args[2];
|
||||
int messageCount = Integer.parseInt(args[3]);
|
||||
|
||||
Set<Module> modules = isEnterprise ? ImmutableSet.<Module> of(new NullLoggingModule(),
|
||||
new EnterpriseConfigurationModule()) : ImmutableSet.<Module> of(new NullLoggingModule());
|
||||
|
||||
RestContext<SQSClient, SQSAsyncClient> context = new RestContextFactory().createContext("sqs", accesskeyid,
|
||||
secretkey, modules);
|
||||
|
||||
try {
|
||||
Set<Queue> queues = Sets.newHashSet();
|
||||
if (purgeQueues(queueName, context)) {
|
||||
logger.info("pausing 60 seconds before recreating queues");
|
||||
Thread.sleep(60 * 1000);
|
||||
}
|
||||
createQueues(queueName, context, queues);
|
||||
runTests(messageCount, isEnterprise ? "enterprise" : "default", context, queues);
|
||||
} finally {
|
||||
purgeQueues(queueName, context);
|
||||
// Close connections
|
||||
context.close();
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static class QueueMessage {
|
||||
final Queue queue;
|
||||
final String message;
|
||||
|
||||
QueueMessage(Queue queue, String message) {
|
||||
this.queue = queue;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[queue=" + queue + ", message=" + message + "]";
|
||||
}
|
||||
}
|
||||
|
||||
private static void runTests(int messageCount, String contextName, RestContext<SQSClient, SQSAsyncClient> context,
|
||||
Set<Queue> queues) throws InterruptedException {
|
||||
String message = "1";
|
||||
long timeOut = messageCount * 200; // minimum rate should be at least 5/second
|
||||
|
||||
for (Queue queue : queues) {
|
||||
logger.info("context: %s, region: %s, queueName: %s", contextName, queue.getRegion(), queue.getName());
|
||||
|
||||
// fire off all the messages for the test
|
||||
Map<QueueMessage, Future<byte[]>> responses = Maps.newHashMap();
|
||||
for (int i = 0; i < messageCount; i++) {
|
||||
responses.put(new QueueMessage(queue, message), context.getAsyncApi().sendMessage(queue, message));
|
||||
}
|
||||
|
||||
Map<QueueMessage, Exception> exceptions = awaitCompletion(responses, MoreExecutors.sameThreadExecutor(),
|
||||
timeOut, traceLogger, String.format("context: %s, region: %s", contextName, queue.getRegion()));
|
||||
|
||||
if (exceptions.size() > 0)
|
||||
logger.error("problems in context: %s, region: %s: %s", contextName, queue.getRegion(), exceptions);
|
||||
|
||||
System.gc();
|
||||
logger.info("pausing 5 seconds before the next run");
|
||||
Thread.sleep(5000);// let the network quiet down
|
||||
}
|
||||
}
|
||||
|
||||
private static void createQueues(String queueName, RestContext<SQSClient, SQSAsyncClient> nullLoggingDefaultContext,
|
||||
Set<Queue> queues) {
|
||||
for (String region : REGIONS) {
|
||||
logger.info("creating queue: %s in region %s", queueName, region);
|
||||
queues.add(nullLoggingDefaultContext.getApi().createQueueInRegion(region, queueName));
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean purgeQueues(String queueName, RestContext<SQSClient, SQSAsyncClient> nullLoggingDefaultContext) {
|
||||
boolean deleted = false;
|
||||
for (String region : REGIONS) {
|
||||
try {
|
||||
SortedSet<Queue> result = Sets.newTreeSet(nullLoggingDefaultContext.getApi().listQueuesInRegion(region,
|
||||
queuePrefix(queueName)));
|
||||
if (result.size() >= 1) {
|
||||
nullLoggingDefaultContext.getApi().deleteQueue(result.last());
|
||||
logger.info("deleted queue: %s in region %s", queueName, region);
|
||||
deleted = true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
}
|
||||
return deleted;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue