regression in last commit; guice child injector locks up under threading; also added new ec2 instance size

This commit is contained in:
Adrian Cole 2010-07-13 16:56:38 -05:00
parent 891484a2aa
commit 4098c4bd0a
39 changed files with 549 additions and 392 deletions

View File

@ -34,7 +34,7 @@ import org.jclouds.rest.annotations.Delegate;
* @author Adrian Cole
*/
public interface EC2AsyncClient {
public final static String VERSION = "2009-11-30";
public final static String VERSION = "2010-06-15";
/**
* Provides asynchronous access to AMI services.

View File

@ -21,6 +21,7 @@ package org.jclouds.aws.ec2;
import static org.jclouds.Constants.PROPERTY_API_VERSION;
import static org.jclouds.Constants.PROPERTY_ENDPOINT;
import static org.jclouds.aws.ec2.reference.EC2Constants.PROPERTY_EC2_AMI_OWNERS;
import static org.jclouds.aws.ec2.reference.EC2Constants.PROPERTY_EC2_CC_AMIs;
import static org.jclouds.aws.ec2.reference.EC2Constants.PROPERTY_ELB_ENDPOINT;
import static org.jclouds.aws.reference.AWSConstants.PROPERTY_AUTH_TAG;
import static org.jclouds.aws.reference.AWSConstants.PROPERTY_HEADER_TAG;
@ -46,6 +47,8 @@ public class EC2PropertiesBuilder extends PropertiesBuilder {
"https://elasticloadbalancing.us-east-1.amazonaws.com");
// alestic, canonical, and rightscale
properties.setProperty(PROPERTY_EC2_AMI_OWNERS, "063491364108,099720109477,411009282317");
// amis that work with the cluster instances
properties.setProperty(PROPERTY_EC2_CC_AMIs, "us-east-1/ami-7ea24a17");
// auth fail sometimes happens in EC2, as the rc.local script that injects the
// authorized key executes after ssh has started
properties.setProperty("jclouds.ssh.max_retries", "6");

View File

@ -20,6 +20,7 @@ package org.jclouds.aws.ec2;
import static org.jclouds.Constants.PROPERTY_ENDPOINT;
import static org.jclouds.aws.ec2.reference.EC2Constants.PROPERTY_EC2_AMI_OWNERS;
import static org.jclouds.aws.ec2.reference.EC2Constants.PROPERTY_EC2_CC_AMIs;
import static org.jclouds.compute.reference.ComputeServiceConstants.PROPERTY_TIMEOUT_PORT_OPEN;
import java.util.Properties;
@ -39,6 +40,8 @@ public class EucalyptusPropertiesBuilder extends EC2PropertiesBuilder {
// properties.setProperty(PROPERTY_ELB_ENDPOINT,
// "https://elasticloadbalancing.us-east-1.amazonaws.com");
properties.setProperty(PROPERTY_EC2_AMI_OWNERS, "admin");
// amis that work with the cluster instances
properties.setProperty(PROPERTY_EC2_CC_AMIs, "");
properties.setProperty(PROPERTY_TIMEOUT_PORT_OPEN, 5 * 60 * 1000 + "");
return properties;

View File

@ -18,8 +18,10 @@
*/
package org.jclouds.aws.ec2.compute.config;
import static org.jclouds.aws.ec2.options.DescribeImagesOptions.Builder.imageIds;
import static org.jclouds.aws.ec2.options.DescribeImagesOptions.Builder.ownedBy;
import static org.jclouds.aws.ec2.reference.EC2Constants.PROPERTY_EC2_AMI_OWNERS;
import static org.jclouds.aws.ec2.reference.EC2Constants.PROPERTY_EC2_CC_AMIs;
import static org.jclouds.aws.ec2.util.EC2Utils.getAllRunningInstancesInRegion;
import static org.jclouds.aws.ec2.util.EC2Utils.parseHandle;
import static org.jclouds.compute.domain.OsFamily.CENTOS;
@ -62,6 +64,7 @@ import org.jclouds.aws.ec2.compute.strategy.EC2DestroyLoadBalancerStrategy;
import org.jclouds.aws.ec2.compute.strategy.EC2DestroyNodeStrategy;
import org.jclouds.aws.ec2.compute.strategy.EC2LoadBalanceNodesStrategy;
import org.jclouds.aws.ec2.compute.strategy.EC2RunNodesAndAddToSetStrategy;
import org.jclouds.aws.ec2.domain.InstanceType;
import org.jclouds.aws.ec2.domain.KeyPair;
import org.jclouds.aws.ec2.domain.RunningInstance;
import org.jclouds.aws.ec2.domain.Image.ImageType;
@ -116,7 +119,8 @@ import com.google.inject.TypeLiteral;
import com.google.inject.name.Names;
/**
* Configures the {@link ComputeServiceContext}; requires {@link EC2ComputeService} bound.
* Configures the {@link ComputeServiceContext}; requires
* {@link EC2ComputeService} bound.
*
* @author Adrian Cole
*/
@ -126,32 +130,39 @@ public class EC2ComputeServiceContextModule extends AbstractModule {
@Singleton
@Named("PRESENT")
protected Predicate<RunningInstance> instancePresent(InstancePresent present) {
return new RetryablePredicate<RunningInstance>(present, 3000, 200, TimeUnit.MILLISECONDS);
return new RetryablePredicate<RunningInstance>(present, 3000, 200,
TimeUnit.MILLISECONDS);
}
@Override
protected void configure() {
install(new ComputeServiceTimeoutsModule());
bind(Location.class).toProvider(DefaultLocationProvider.class).in(Scopes.SINGLETON);
bind(Location.class).toProvider(DefaultLocationProvider.class).in(
Scopes.SINGLETON);
bind(TemplateBuilder.class).to(EC2TemplateBuilderImpl.class);
bind(TemplateOptions.class).to(EC2TemplateOptions.class);
bind(ComputeService.class).to(EC2ComputeService.class);
bind(new TypeLiteral<ComputeServiceContext>() {
}).to(new TypeLiteral<ComputeServiceContextImpl<EC2Client, EC2AsyncClient>>() {
})
.to(
new TypeLiteral<ComputeServiceContextImpl<EC2Client, EC2AsyncClient>>() {
}).in(Scopes.SINGLETON);
bind(new TypeLiteral<RestContext<EC2Client, EC2AsyncClient>>() {
}).to(new TypeLiteral<RestContextImpl<EC2Client, EC2AsyncClient>>() {
}).in(Scopes.SINGLETON);
bind(LoadBalanceNodesStrategy.class).to(EC2LoadBalanceNodesStrategy.class);
bind(DestroyLoadBalancerStrategy.class).to(EC2DestroyLoadBalancerStrategy.class);
bind(RunNodesAndAddToSetStrategy.class).to(EC2RunNodesAndAddToSetStrategy.class);
bind(LoadBalanceNodesStrategy.class)
.to(EC2LoadBalanceNodesStrategy.class);
bind(DestroyLoadBalancerStrategy.class).to(
EC2DestroyLoadBalancerStrategy.class);
bind(RunNodesAndAddToSetStrategy.class).to(
EC2RunNodesAndAddToSetStrategy.class);
bind(ListNodesStrategy.class).to(EC2ListNodesStrategy.class);
bind(GetNodeMetadataStrategy.class).to(EC2GetNodeMetadataStrategy.class);
bind(RebootNodeStrategy.class).to(EC2RebootNodeStrategy.class);
bind(DestroyNodeStrategy.class).to(EC2DestroyNodeStrategy.class);
bind(new TypeLiteral<Function<RunningInstance, Map<String, String>>>() {
}).annotatedWith(Names.named("volumeMapping")).to(RunningInstanceToStorageMappingUnix.class)
.in(Scopes.SINGLETON);
}).annotatedWith(Names.named("volumeMapping")).to(
RunningInstanceToStorageMappingUnix.class).in(Scopes.SINGLETON);
}
@Provides
@ -170,10 +181,12 @@ public class EC2ComputeServiceContextModule extends AbstractModule {
@Provides
@Named("DEFAULT")
protected TemplateBuilder provideTemplate(@Region String region, TemplateBuilder template) {
return "Eucalyptus".equals(region) ? template.osFamily(CENTOS).smallest() : template
.architecture(Architecture.X86_32).osFamily(UBUNTU).imageNameMatches(".*10\\.?04.*")
.osDescriptionMatches("^ubuntu-images.*");
protected TemplateBuilder provideTemplate(@Region String region,
TemplateBuilder template) {
return "Eucalyptus".equals(region) ? template.osFamily(CENTOS).smallest()
: template.architecture(Architecture.X86_32).osFamily(UBUNTU)
.imageNameMatches(".*10\\.?04.*").osDescriptionMatches(
"^ubuntu-images.*");
}
// TODO make this more efficient for listNodes(); currently
@ -191,7 +204,8 @@ public class EC2ComputeServiceContextModule extends AbstractModule {
private final ExecutorService executor;
@Inject
protected EC2ListNodesStrategy(EC2Client client, @Region Map<String, URI> regionMap,
protected EC2ListNodesStrategy(EC2Client client,
@Region Map<String, URI> regionMap,
RunningInstanceToNodeMetadata runningInstanceToNodeMetadata,
@Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor) {
this.client = client;
@ -213,29 +227,31 @@ public class EC2ComputeServiceContextModule extends AbstractModule {
Map<String, ListenableFuture<?>> parallelResponses = Maps.newHashMap();
for (final String region : regionMap.keySet()) {
parallelResponses.put(region, ConcurrentUtils.makeListenable(executor
.submit(new Callable<Void>() {
parallelResponses.put(region, ConcurrentUtils.makeListenable(
executor.submit(new Callable<Void>() {
@Override
public Void call() throws Exception {
Iterables.addAll(nodes, Iterables.transform(Iterables.concat(client
.getInstanceServices().describeInstancesInRegion(region)),
Iterables.addAll(nodes, Iterables.transform(Iterables
.concat(client.getInstanceServices()
.describeInstancesInRegion(region)),
runningInstanceToNodeMetadata));
return null;
}
}), executor));
}
Map<String, Exception> exceptions = awaitCompletion(parallelResponses, executor, null,
logger, "nodes");
Map<String, Exception> exceptions = awaitCompletion(parallelResponses,
executor, null, logger, "nodes");
if (exceptions.size() > 0)
throw new RuntimeException(String.format("error parsing nodes in regions: %s",
exceptions));
throw new RuntimeException(String.format(
"error parsing nodes in regions: %s", exceptions));
return Iterables.filter(nodes, filter);
}
}
@Singleton
public static class EC2GetNodeMetadataStrategy implements GetNodeMetadataStrategy {
public static class EC2GetNodeMetadataStrategy implements
GetNodeMetadataStrategy {
private final EC2Client client;
private final RunningInstanceToNodeMetadata runningInstanceToNodeMetadata;
@ -254,8 +270,8 @@ public class EC2ComputeServiceContextModule extends AbstractModule {
String instanceId = parts[1];
try {
RunningInstance runningInstance = Iterables
.getOnlyElement(getAllRunningInstancesInRegion(client.getInstanceServices(),
region, instanceId));
.getOnlyElement(getAllRunningInstancesInRegion(client
.getInstanceServices(), region, instanceId));
return runningInstanceToNodeMetadata.apply(runningInstance);
} catch (NoSuchElementException e) {
return null;
@ -270,7 +286,8 @@ public class EC2ComputeServiceContextModule extends AbstractModule {
private final GetNodeMetadataStrategy getNode;
@Inject
protected EC2RebootNodeStrategy(EC2Client client, GetNodeMetadataStrategy getNode) {
protected EC2RebootNodeStrategy(EC2Client client,
GetNodeMetadataStrategy getNode) {
this.client = client.getInstanceServices();
this.getNode = getNode;
}
@ -288,7 +305,8 @@ public class EC2ComputeServiceContextModule extends AbstractModule {
@Provides
@Singleton
protected final Map<RegionAndName, KeyPair> credentialsMap(CreateUniqueKeyPair in) {
protected final Map<RegionAndName, KeyPair> credentialsMap(
CreateUniqueKeyPair in) {
// doesn't seem to clear when someone issues remove(key)
// return new MapMaker().makeComputingMap(in);
return Maps.newLinkedHashMap();
@ -296,7 +314,8 @@ public class EC2ComputeServiceContextModule extends AbstractModule {
@Provides
@Singleton
protected final Map<RegionAndName, String> securityGroupMap(CreateSecurityGroupIfNeeded in) {
protected final Map<RegionAndName, String> securityGroupMap(
CreateSecurityGroupIfNeeded in) {
// doesn't seem to clear when someone issues remove(key)
// return new MapMaker().makeComputingMap(in);
return Maps.newLinkedHashMap();
@ -315,23 +334,45 @@ public class EC2ComputeServiceContextModule extends AbstractModule {
@Provides
@Singleton
Set<? extends Size> provideSizes() {
return ImmutableSet.of(EC2Size.C1_MEDIUM, EC2Size.C1_XLARGE, EC2Size.M1_LARGE,
EC2Size.M1_SMALL, EC2Size.M1_XLARGE, EC2Size.M2_XLARGE, EC2Size.M2_2XLARGE,
EC2Size.M2_4XLARGE);
Set<? extends Size> provideSizes(Set<? extends Location> locations,
@Named(PROPERTY_EC2_CC_AMIs) String[] ccAmis) {
Set<Size> sizes = Sets.newHashSet();
for (String ccAmi : ccAmis) {
final String region = ccAmi.split("/")[0];
Location location = Iterables.find(locations,
new Predicate<Location>() {
@Override
public boolean apply(Location input) {
return input.getScope() == LocationScope.REGION
&& input.getId().equals(region);
}
});
sizes.add(new EC2Size(location, InstanceType.CC1_4XLARGE, 33.5,
23 * 1024, 1690, ccAmis));
}
sizes.addAll(ImmutableSet.<Size> of(EC2Size.C1_MEDIUM, EC2Size.C1_XLARGE,
EC2Size.M1_LARGE, EC2Size.M1_SMALL, EC2Size.M1_XLARGE,
EC2Size.M2_XLARGE, EC2Size.M2_2XLARGE, EC2Size.M2_4XLARGE));
return sizes;
}
@Provides
@Singleton
Set<? extends Location> provideLocations(Map<String, String> availabilityZoneToRegionMap,
Set<? extends Location> provideLocations(
Map<String, String> availabilityZoneToRegionMap,
@Provider String providerName) {
Location ec2 = new LocationImpl(LocationScope.PROVIDER, providerName, providerName, null);
Location ec2 = new LocationImpl(LocationScope.PROVIDER, providerName,
providerName, null);
Set<Location> locations = Sets.newLinkedHashSet();
for (String zone : availabilityZoneToRegionMap.keySet()) {
Location region = new LocationImpl(LocationScope.REGION, availabilityZoneToRegionMap
.get(zone), availabilityZoneToRegionMap.get(zone), ec2);
Location region = new LocationImpl(LocationScope.REGION,
availabilityZoneToRegionMap.get(zone),
availabilityZoneToRegionMap.get(zone), ec2);
locations.add(region);
locations.add(new LocationImpl(LocationScope.ZONE, zone, zone, region));
locations
.add(new LocationImpl(LocationScope.ZONE, zone, zone, region));
}
return locations;
}
@ -352,7 +393,17 @@ public class EC2ComputeServiceContextModule extends AbstractModule {
}
@Provides
protected Set<? extends Image> provideImages(Map<RegionAndName, ? extends Image> map) {
@Singleton
@Named(PROPERTY_EC2_CC_AMIs)
String[] ccAmis(@Named(PROPERTY_EC2_CC_AMIs) String ccAmis) {
if (ccAmis.trim().equals(""))
return new String[] {};
return Iterables.toArray(Splitter.on(',').split(ccAmis), String.class);
}
@Provides
protected Set<? extends Image> provideImages(
Map<RegionAndName, ? extends Image> map) {
return ImmutableSet.copyOf(map.values());
}
@ -365,10 +416,12 @@ public class EC2ComputeServiceContextModule extends AbstractModule {
@Provides
@Singleton
protected Map<RegionAndName, ? extends Image> provideImages(final EC2Client sync,
@Region Map<String, URI> regionMap, final LogHolder holder,
Function<ComputeMetadata, String> indexer,
@Named(PROPERTY_EC2_AMI_OWNERS) final String[] amiOwners, final ImageParser parser,
protected Map<RegionAndName, ? extends Image> provideImages(
final EC2Client sync, @Region Map<String, URI> regionMap,
final LogHolder holder, Function<ComputeMetadata, String> indexer,
@Named(PROPERTY_EC2_CC_AMIs) String[] ccAmis,
@Named(PROPERTY_EC2_AMI_OWNERS) final String[] amiOwners,
final ImageParser parser,
final ConcurrentMap<RegionAndName, Image> images,
@Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor)
throws InterruptedException, ExecutionException, TimeoutException {
@ -384,30 +437,40 @@ public class EC2ComputeServiceContextModule extends AbstractModule {
else
options = ownedBy(amiOwners);
for (final String region : regionMap.keySet()) {
parallelResponses.put(region, ConcurrentUtils.makeListenable(executor
.submit(new Callable<Void>() {
parallelResponses.put(region, ConcurrentUtils.makeListenable(
executor.submit(new Callable<Void>() {
@Override
public Void call() throws Exception {
for (final org.jclouds.aws.ec2.domain.Image from : sync.getAMIServices()
.describeImagesInRegion(region, options)) {
for (final org.jclouds.aws.ec2.domain.Image from : sync
.getAMIServices().describeImagesInRegion(region,
options)) {
Image image = parser.apply(from);
if (image != null)
images
.put(new RegionAndName(region, image.getProviderId()),
image);
images.put(new RegionAndName(region, image
.getProviderId()), image);
else if (from.getImageType() == ImageType.MACHINE)
holder.logger.trace("<< image(%s) didn't parse", from.getId());
holder.logger.trace("<< image(%s) didn't parse",
from.getId());
}
return null;
}
}), executor));
}
Map<String, Exception> exceptions = awaitCompletion(parallelResponses, executor, null,
holder.logger, "images");
Map<String, Exception> exceptions = awaitCompletion(parallelResponses,
executor, null, holder.logger, "images");
for (String ccAmi : ccAmis) {
String region = ccAmi.split("/")[0];
org.jclouds.aws.ec2.domain.Image from = Iterables
.getOnlyElement(sync.getAMIServices().describeImagesInRegion(
region, imageIds(ccAmi.split("/")[1])));
Image image = parser.apply(from);
if (image != null)
images.put(new RegionAndName(region, image.getProviderId()),
image);
}
if (exceptions.size() > 0)
throw new RuntimeException(String.format("error parsing images in regions: %s",
exceptions));
throw new RuntimeException(String.format(
"error parsing images in regions: %s", exceptions));
holder.logger.debug("<< images(%d)", images.size());
}

View File

@ -19,10 +19,15 @@
package org.jclouds.aws.ec2.compute.domain;
import static org.jclouds.compute.predicates.ImagePredicates.architectureIn;
import static org.jclouds.compute.predicates.ImagePredicates.idIn;
import java.util.Arrays;
import java.util.Collections;
import org.jclouds.aws.ec2.domain.InstanceType;
import org.jclouds.compute.domain.Architecture;
import org.jclouds.compute.domain.internal.SizeImpl;
import org.jclouds.domain.Location;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
@ -39,13 +44,18 @@ public class EC2Size extends SizeImpl {
EC2Size(String instanceType, Double cores, Integer ram, Integer disk,
Iterable<Architecture> supportedArchitectures) {
super(instanceType, instanceType, instanceType, null, null, ImmutableMap
.<String, String> of(), cores, ram, disk, architectureIn(supportedArchitectures));
.<String, String> of(), cores, ram, disk,
architectureIn(supportedArchitectures));
this.instanceType = instanceType;
}
EC2Size(String instanceType, Integer cores, Integer ram, Integer disk,
Iterable<Architecture> supportedArchitectures) {
this(instanceType, cores.doubleValue(), ram, disk, supportedArchitectures);
public EC2Size(Location location, String instanceType, Double cores,
Integer ram, Integer disk, String[] ids) {
super(instanceType, instanceType, instanceType, location, null,
ImmutableMap.<String, String> of(), cores, ram, disk,
(ids.length == 0 ? architectureIn(Collections
.singleton(Architecture.X86_64)) : idIn(Arrays.asList(ids))));
this.instanceType = instanceType;
}
/**
@ -58,49 +68,53 @@ public class EC2Size extends SizeImpl {
/**
* @see InstanceType#M1_SMALL
*/
public static final EC2Size M1_SMALL = new EC2Size(InstanceType.M1_SMALL, 1, 1740, 160,
ImmutableSet.of(Architecture.X86_32));
public static final EC2Size M1_SMALL = new EC2Size(InstanceType.M1_SMALL,
1.0, 1740, 160, ImmutableSet.of(Architecture.X86_32));
/**
* @see InstanceType#M1_LARGE
*/
public static final EC2Size M1_LARGE = new EC2Size(InstanceType.M1_LARGE, 4, 7680, 850,
ImmutableSet.of(Architecture.X86_64));
public static final EC2Size M1_LARGE = new EC2Size(InstanceType.M1_LARGE,
4.0, 7680, 850, ImmutableSet.of(Architecture.X86_64));
/**
* @see InstanceType#M1_XLARGE
*/
public static final EC2Size M1_XLARGE = new EC2Size(InstanceType.M1_XLARGE, 8, 15360, 1690,
ImmutableSet.of(Architecture.X86_64));
public static final EC2Size M1_XLARGE = new EC2Size(InstanceType.M1_XLARGE,
8.0, 15360, 1690, ImmutableSet.of(Architecture.X86_64));
/**
* @see InstanceType#M2_XLARGE
*/
public static final EC2Size M2_XLARGE = new EC2Size(InstanceType.M2_XLARGE, 6.5, 17510, 420,
ImmutableSet.of(Architecture.X86_64));
public static final EC2Size M2_XLARGE = new EC2Size(InstanceType.M2_XLARGE,
6.5, 17510, 420, ImmutableSet.of(Architecture.X86_64));
/**
* @see InstanceType#M2_2XLARGE
*/
public static final EC2Size M2_2XLARGE = new EC2Size(InstanceType.M2_2XLARGE, 13, 35020, 850,
ImmutableSet.of(Architecture.X86_64));
public static final EC2Size M2_2XLARGE = new EC2Size(
InstanceType.M2_2XLARGE, 13.0, 35020, 850, ImmutableSet
.of(Architecture.X86_64));
/**
* @see InstanceType#M2_4XLARGE
*/
public static final EC2Size M2_4XLARGE = new EC2Size(InstanceType.M2_4XLARGE, 26, 70041, 1690,
ImmutableSet.of(Architecture.X86_64));
public static final EC2Size M2_4XLARGE = new EC2Size(
InstanceType.M2_4XLARGE, 26.0, 70041, 1690, ImmutableSet
.of(Architecture.X86_64));
/**
* @see InstanceType#C1_MEDIUM
*/
public static final EC2Size C1_MEDIUM = new EC2Size(InstanceType.C1_MEDIUM, 5, 1740, 350,
ImmutableSet.of(Architecture.X86_32));
public static final EC2Size C1_MEDIUM = new EC2Size(InstanceType.C1_MEDIUM,
5.0, 1740, 350, ImmutableSet.of(Architecture.X86_32));
/**
* @see InstanceType#C1_XLARGE
*/
public static final EC2Size C1_XLARGE = new EC2Size(InstanceType.C1_XLARGE, 20, 7168, 1690,
ImmutableSet.of(Architecture.X86_64));
public static final EC2Size C1_XLARGE = new EC2Size(InstanceType.C1_XLARGE,
20.0, 7168, 1690, ImmutableSet.of(Architecture.X86_64));
@Override
public int hashCode() {
final int prime = 31;
int result = super.hashCode();
result = prime * result + ((instanceType == null) ? 0 : instanceType.hashCode());
result = prime * result
+ ((instanceType == null) ? 0 : instanceType.hashCode());
return result;
}

View File

@ -58,14 +58,22 @@ public class Image implements Comparable<Image> {
private final RootDeviceType rootDeviceType;
@Nullable
private final String rootDeviceName;
private final Map<String, EbsBlockDevice> ebsBlockDevices = Maps.newHashMap();
private final Map<String, EbsBlockDevice> ebsBlockDevices = Maps
.newHashMap();
private final String virtualizationType;
public Image(String region, Architecture architecture, @Nullable String name,
@Nullable String description, String imageId, String imageLocation,
String imageOwnerId, ImageState imageState, ImageType imageType, boolean isPublic,
Iterable<String> productCodes, @Nullable String kernelId, @Nullable String platform,
public String getVirtualizationType() {
return virtualizationType;
}
public Image(String region, Architecture architecture,
@Nullable String name, @Nullable String description, String imageId,
String imageLocation, String imageOwnerId, ImageState imageState,
ImageType imageType, boolean isPublic, Iterable<String> productCodes,
@Nullable String kernelId, @Nullable String platform,
@Nullable String ramdiskId, RootDeviceType rootDeviceType,
@Nullable String rootDeviceName, Map<String, EbsBlockDevice> ebsBlockDevices) {
@Nullable String rootDeviceName,
Map<String, EbsBlockDevice> ebsBlockDevices, String virtualizationType) {
this.region = checkNotNull(region, "region");
this.architecture = checkNotNull(architecture, "architecture");
this.imageId = checkNotNull(imageId, "imageId");
@ -79,10 +87,14 @@ public class Image implements Comparable<Image> {
this.isPublic = isPublic;
this.kernelId = kernelId;
this.platform = platform;
Iterables.addAll(this.productCodes, checkNotNull(productCodes, "productCodes"));
Iterables.addAll(this.productCodes, checkNotNull(productCodes,
"productCodes"));
this.ramdiskId = ramdiskId;
this.rootDeviceType = checkNotNull(rootDeviceType, "rootDeviceType");
this.ebsBlockDevices.putAll(checkNotNull(ebsBlockDevices, "ebsBlockDevices"));
this.ebsBlockDevices.putAll(checkNotNull(ebsBlockDevices,
"ebsBlockDevices"));
this.virtualizationType = checkNotNull(virtualizationType,
"virtualizationType");
}
/** The serialVersionUID */
@ -160,7 +172,8 @@ public class Image implements Comparable<Image> {
final int prime = 31;
int result = 1;
result = prime * result + (deleteOnTermination ? 1231 : 1237);
result = prime * result + ((snapshotId == null) ? 0 : snapshotId.hashCode());
result = prime * result
+ ((snapshotId == null) ? 0 : snapshotId.hashCode());
result = prime * result + (int) (volumeSize ^ (volumeSize >>> 32));
return result;
}
@ -188,8 +201,9 @@ public class Image implements Comparable<Image> {
@Override
public String toString() {
return "EbsBlockDevice [deleteOnTermination=" + deleteOnTermination + ", snapshotId="
+ snapshotId + ", volumeSize=" + volumeSize + "]";
return "EbsBlockDevice [deleteOnTermination=" + deleteOnTermination
+ ", snapshotId=" + snapshotId + ", volumeSize=" + volumeSize
+ "]";
}
}
@ -231,9 +245,10 @@ public class Image implements Comparable<Image> {
}
/**
* Current state of the AMI. If the operation returns available, the image is successfully
* registered and avail able for launching. If the operation returns deregistered, the image is
* deregistered and no longer available for launching.
* Current state of the AMI. If the operation returns available, the image is
* successfully registered and avail able for launching. If the operation
* returns deregistered, the image is deregistered and no longer available
* for launching.
*/
public ImageState getImageState() {
return imageState;
@ -247,15 +262,16 @@ public class Image implements Comparable<Image> {
}
/**
* Returns true if this image has public launch permissions. Returns false if it only has
* implicit and explicit launch permissions.
* Returns true if this image has public launch permissions. Returns false if
* it only has implicit and explicit launch permissions.
*/
public boolean isPublic() {
return isPublic;
}
/**
* The kernel associated with the image, if any. Only applicable for machine images.
* The kernel associated with the image, if any. Only applicable for machine
* images.
*/
public String getKernelId() {
return kernelId;
@ -276,7 +292,8 @@ public class Image implements Comparable<Image> {
}
/**
* The RAM disk associated with the image, if any. Only applicable for machine images.
* The RAM disk associated with the image, if any. Only applicable for
* machine images.
*/
public String getRamdiskId() {
return ramdiskId;
@ -291,8 +308,8 @@ public class Image implements Comparable<Image> {
/**
*
* @return The root device type used by the AMI. The AMI can use an Amazon EBS or instance store
* root device.
* @return The root device type used by the AMI. The AMI can use an Amazon
* EBS or instance store root device.
*/
public RootDeviceType getRootDeviceType() {
return rootDeviceType;
@ -318,23 +335,37 @@ public class Image implements Comparable<Image> {
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((architecture == null) ? 0 : architecture.hashCode());
result = prime * result + ((description == null) ? 0 : description.hashCode());
result = prime * result + ((ebsBlockDevices == null) ? 0 : ebsBlockDevices.hashCode());
result = prime * result
+ ((architecture == null) ? 0 : architecture.hashCode());
result = prime * result
+ ((description == null) ? 0 : description.hashCode());
result = prime * result
+ ((ebsBlockDevices == null) ? 0 : ebsBlockDevices.hashCode());
result = prime * result + ((imageId == null) ? 0 : imageId.hashCode());
result = prime * result + ((imageLocation == null) ? 0 : imageLocation.hashCode());
result = prime * result + ((imageOwnerId == null) ? 0 : imageOwnerId.hashCode());
result = prime * result + ((imageState == null) ? 0 : imageState.hashCode());
result = prime * result + ((imageType == null) ? 0 : imageType.hashCode());
result = prime * result
+ ((imageLocation == null) ? 0 : imageLocation.hashCode());
result = prime * result
+ ((imageOwnerId == null) ? 0 : imageOwnerId.hashCode());
result = prime * result
+ ((imageState == null) ? 0 : imageState.hashCode());
result = prime * result
+ ((imageType == null) ? 0 : imageType.hashCode());
result = prime * result + (isPublic ? 1231 : 1237);
result = prime * result + ((kernelId == null) ? 0 : kernelId.hashCode());
result = prime * result + ((name == null) ? 0 : name.hashCode());
result = prime * result + ((platform == null) ? 0 : platform.hashCode());
result = prime * result + ((productCodes == null) ? 0 : productCodes.hashCode());
result = prime * result + ((ramdiskId == null) ? 0 : ramdiskId.hashCode());
result = prime * result
+ ((productCodes == null) ? 0 : productCodes.hashCode());
result = prime * result
+ ((ramdiskId == null) ? 0 : ramdiskId.hashCode());
result = prime * result + ((region == null) ? 0 : region.hashCode());
result = prime * result + ((rootDeviceName == null) ? 0 : rootDeviceName.hashCode());
result = prime * result + ((rootDeviceType == null) ? 0 : rootDeviceType.hashCode());
result = prime * result
+ ((rootDeviceName == null) ? 0 : rootDeviceName.hashCode());
result = prime * result
+ ((rootDeviceType == null) ? 0 : rootDeviceType.hashCode());
result = prime
* result
+ ((virtualizationType == null) ? 0 : virtualizationType.hashCode());
return result;
}
@ -429,19 +460,26 @@ public class Image implements Comparable<Image> {
return false;
} else if (!rootDeviceType.equals(other.rootDeviceType))
return false;
if (virtualizationType == null) {
if (other.virtualizationType != null)
return false;
} else if (!virtualizationType.equals(other.virtualizationType))
return false;
return true;
}
@Override
public String toString() {
return "Image [architecture=" + architecture + ", description=" + description
+ ", ebsBlockDevices=" + ebsBlockDevices + ", imageId=" + imageId
+ ", imageLocation=" + imageLocation + ", imageOwnerId=" + imageOwnerId
+ ", imageState=" + imageState + ", imageType=" + imageType + ", isPublic="
+ isPublic + ", kernelId=" + kernelId + ", name=" + name + ", platform=" + platform
+ ", productCodes=" + productCodes + ", ramdiskId=" + ramdiskId + ", region="
+ region + ", rootDeviceName=" + rootDeviceName + ", rootDeviceType="
+ rootDeviceType + "]";
return "Image [architecture=" + architecture + ", description="
+ description + ", ebsBlockDevices=" + ebsBlockDevices
+ ", imageId=" + imageId + ", imageLocation=" + imageLocation
+ ", imageOwnerId=" + imageOwnerId + ", imageState=" + imageState
+ ", imageType=" + imageType + ", isPublic=" + isPublic
+ ", kernelId=" + kernelId + ", name=" + name + ", platform="
+ platform + ", productCodes=" + productCodes + ", ramdiskId="
+ ramdiskId + ", region=" + region + ", rootDeviceName="
+ rootDeviceName + ", rootDeviceType=" + rootDeviceType
+ ", virtualizationType=" + virtualizationType + "]";
}
}

View File

@ -18,8 +18,6 @@
*/
package org.jclouds.aws.ec2.domain;
import static com.google.common.base.Preconditions.checkNotNull;
import org.jclouds.aws.ec2.EC2AsyncClient;
/**
@ -70,7 +68,8 @@ public class InstanceType {
* High-Memory Extra Large Instance
* <ul>
* <li>17.1 GB of memory</li>
* <li>6.5 EC2 Compute Units (2 virtual cores with 3.25 EC2 Compute Units each)</li>
* <li>6.5 EC2 Compute Units (2 virtual cores with 3.25 EC2 Compute Units
* each)</li>
* <li>420 GB of instance storage</li>
* <li>64-bit platform</li>
* <li>I/O Performance: Moderate</li>
@ -81,7 +80,8 @@ public class InstanceType {
* High-Memory Double Extra Large Instance
* <ul>
* <li>34.2 GB of memory</li>
* <li>13 EC2 Compute Units (4 virtual cores with 3.25 EC2 Compute Units each)</li>
* <li>13 EC2 Compute Units (4 virtual cores with 3.25 EC2 Compute Units
* each)</li>
* <li>850 GB of instance storage</li>
* <li>64-bit platform</li>
* <li>I/O Performance: High</li>
@ -92,7 +92,8 @@ public class InstanceType {
* High-Memory Quadruple Extra Large Instance
* <ul>
* <li>68.4 GB of memory</li>
* <li>26 EC2 Compute Units (8 virtual cores with 3.25 EC2 Compute Units each)</li>
* <li>26 EC2 Compute Units (8 virtual cores with 3.25 EC2 Compute Units
* each)</li>
* <li>1690 GB of instance storage</li>
* <li>64-bit platform</li>
* <li>I/O Performance: High</li>
@ -114,7 +115,8 @@ public class InstanceType {
* High-CPU Extra Large Instance
* <ul>
* <li>7 GB of memory</li>
* <li>20 EC2 Compute Units (8 virtual cores with 2.5 EC2 Compute Units each)</li>
* <li>20 EC2 Compute Units (8 virtual cores with 2.5 EC2 Compute Units each)
* </li>
* <li>1690 GB of instance storage</li>
* <li>64-bit platform</li>
* <li>I/O Performance: High</li>
@ -122,12 +124,18 @@ public class InstanceType {
*/
public static final String C1_XLARGE = "c1.xlarge";
public static String fromValue(String type) {
return checkNotNull(type, "type").replaceAll("\\.", "_").toUpperCase();
}
public static String toDotSeparatorLowercaseNotation(String type) {
return checkNotNull(type, "type").replaceAll("_", "\\.").toLowerCase();
}
/**
* Cluster Compute Instance
* <ul>
* <li>23 GB of memory</li>
* <li>33.5 EC2 Compute Units (2 x Intel Xeon X5570, quad-core "Nehalem"
* architecture)</li>
* <li>1690 GB of 64-bit storage (2 x 840 GB, plus 10 GB root partition)</li>
* <li>10 Gbps Ethernet</li>
* <li>64-bit platform</li>
* <li>I/O Performance: High</li>
* </ul>
*/
public static final String CC1_4XLARGE = "cc1.4xlarge";
}

View File

@ -208,7 +208,7 @@ public class RunningInstance implements Comparable<RunningInstance> {
* more information, go to the Metadata section of the Amazon Elastic Compute Cloud Developer
* Guide.
*
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/2009-11-30/DeveloperGuide/" />
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/2010-06-15/DeveloperGuide/" />
*/
public String getAmiLaunchIndex() {
return amiLaunchIndex;

View File

@ -34,7 +34,7 @@ import static org.jclouds.compute.reference.ComputeServiceConstants.LOCAL_PARTIT
* describe what partitions are formatted initially. To format/mount an available device, refer to
* <a href="http://meinit.nl/howto-use-amazon-elastic-compute-cloud-ec2">this article</a>.
*
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/2009-11-30/UserGuide/index.html?instance-storage-concepts.html" />
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/2010-06-15/UserGuide/index.html?instance-storage-concepts.html" />
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/UserGuide/index.html?instance-types.html" />
*
* @author Oleksiy Yarmula
@ -76,7 +76,7 @@ public class RunningInstanceToStorageMappingUnix implements Function<RunningInst
* @param instanceType for which the root partition size is to be determined
* @return size in GB
*
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/2009-11-30/UserGuide/index.html?instance-storage-concepts.html" />
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/2010-06-15/UserGuide/index.html?instance-storage-concepts.html" />
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/UserGuide/index.html?instance-types.html" />
*/
public int getRootPartitionSizeForInstanceType(String instanceType) {

View File

@ -33,4 +33,11 @@ public interface EC2Constants{
public static final String PROPERTY_EC2_AMI_OWNERS = "jclouds.ec2.ami-owners";
public static final String PROPERTY_ELB_ENDPOINT = "jclouds.elb.endpoint";
/**
* amis that work on the cluster instance type
*
* @see InstanceType.CC1_4XLARGE
*/
public static final String PROPERTY_EC2_CC_AMIs = "jclouds.ec2.cc-amis";
}

View File

@ -43,7 +43,7 @@ import com.google.common.collect.Sets;
/**
* Parses the following XML document:
* <p/>
* DescribeImagesResponse xmlns="http://ec2.amazonaws.com/doc/2009-11-30/"
* DescribeImagesResponse xmlns="http://ec2.amazonaws.com/doc/2010-06-15/"
*
* @author Adrian Cole
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeImages.html"
@ -83,6 +83,8 @@ public class DescribeImagesResponseHandler extends
private Map<String, EbsBlockDevice> ebsBlockDevices = Maps.newHashMap();
private String deviceName;
private String snapshotId;
private String virtualizationType = "paravirtual";
private int volumeSize;
private boolean deleteOnTermination = true;// correct default is true.
@ -143,6 +145,8 @@ public class DescribeImagesResponseHandler extends
rootDeviceType = RootDeviceType.fromValue(currentText.toString().trim());
} else if (qName.equals("rootDeviceName")) {
rootDeviceName = currentText.toString().trim();
} else if (qName.equals("virtualizationType")) {
virtualizationType = currentText.toString().trim();
} else if (qName.equals("item")) {
if (inBlockDeviceMapping) {
ebsBlockDevices.put(deviceName, new Image.EbsBlockDevice(snapshotId, volumeSize,
@ -159,7 +163,7 @@ public class DescribeImagesResponseHandler extends
contents.add(new Image(region, architecture, this.name, description, imageId,
imageLocation, imageOwnerId, imageState, imageType, isPublic, productCodes,
kernelId, platform, ramdiskId, rootDeviceType, rootDeviceName,
ebsBlockDevices));
ebsBlockDevices, virtualizationType));
} catch (NullPointerException e) {
logger.warn(e, "malformed image: %s", imageId);
}
@ -179,6 +183,7 @@ public class DescribeImagesResponseHandler extends
this.rootDeviceType = null;
this.rootDeviceName = null;
this.ebsBlockDevices = Maps.newHashMap();
this.virtualizationType = "paravirtual";
}
}

View File

@ -31,7 +31,7 @@ import org.jclouds.rest.internal.GeneratedHttpRequest;
import com.google.common.collect.Sets;
/**
* Parses: DescribeKeyPairsResponse xmlns="http://ec2.amazonaws.com/doc/2009-11-30/"
* Parses: DescribeKeyPairsResponse xmlns="http://ec2.amazonaws.com/doc/2010-06-15/"
*
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeKeyPairs.html"
* />

View File

@ -35,7 +35,7 @@ import org.xml.sax.Attributes;
import com.google.common.collect.Sets;
/**
* Parses: DescribeSecurityGroupsResponse xmlns="http://ec2.amazonaws.com/doc/2009-11-30/"
* Parses: DescribeSecurityGroupsResponse xmlns="http://ec2.amazonaws.com/doc/2010-06-15/"
*
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/index.html?ApiReference-query-DescribeSecurityGroups.html"
* />

View File

@ -35,9 +35,9 @@ import com.google.common.collect.Sets;
/**
* Parses the following XML document:
* <p/>
* TerminateInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2009-11-30/"
* StartInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2009-11-30/" StopInstancesResponse
* xmlns="http://ec2.amazonaws.com/doc/2009-11-30/"
* TerminateInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2010-06-15/"
* StartInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2010-06-15/" StopInstancesResponse
* xmlns="http://ec2.amazonaws.com/doc/2010-06-15/"
*
* @author Adrian Cole
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-ItemType-TerminateInstancesResponseInfoType.html"

View File

@ -24,6 +24,7 @@ import java.util.Set;
import org.jclouds.aws.ec2.EC2Client;
import org.jclouds.aws.ec2.compute.options.EC2TemplateOptions;
import org.jclouds.aws.ec2.domain.InstanceType;
import org.jclouds.aws.ec2.domain.IpProtocol;
import org.jclouds.aws.ec2.domain.KeyPair;
import org.jclouds.aws.ec2.domain.RunningInstance;
@ -32,7 +33,10 @@ import org.jclouds.aws.ec2.services.InstanceClient;
import org.jclouds.aws.ec2.services.KeyPairClient;
import org.jclouds.aws.ec2.services.SecurityGroupClient;
import org.jclouds.compute.BaseComputeServiceLiveTest;
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.options.TemplateOptions;
import org.jclouds.compute.predicates.NodePredicates;
import org.jclouds.domain.Credentials;
@ -40,6 +44,7 @@ import org.jclouds.ssh.jsch.config.JschSshClientModule;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import com.google.common.base.Predicate;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
@ -61,6 +66,33 @@ public class EC2ComputeServiceLiveTest extends BaseComputeServiceLiveTest {
}
@Test(enabled = true, dependsOnMethods = "testCorrectAuthException")
public void testTemplateChoiceForInstanceByCCSizeId() throws Exception {
Set<? extends Size> sizes = context.getComputeService().listSizes();
assert Iterables.any(sizes, new Predicate<Size>() {
@Override
public boolean apply(Size arg0) {
return arg0.getProviderId().equals(InstanceType.CC1_4XLARGE);
}
}) : sizes;
Set<? extends Image> images = context.getComputeService().listImages();
assert Iterables.any(images, new Predicate<Image>() {
@Override
public boolean apply(Image arg0) {
return arg0.getId().equals("us-east-1/ami-7ea24a17");
}
}) : images;
Template template = context.getComputeService().templateBuilder()
.fastest().build();
assert template != null : "The returned template was null, but it should have a value.";
assertEquals(template.getSize().getProviderId(), InstanceType.CC1_4XLARGE);
assertEquals(template.getImage().getId(), "us-east-1/ami-7ea24a17");
}
@Test(enabled = true, dependsOnMethods = "testTemplateChoiceForInstanceByCCSizeId")
public void testExtendedOptionsAndLogin() throws Exception {
SecurityGroupClient securityGroupClient = EC2Client.class.cast(
context.getProviderSpecificContext().getApi())
@ -132,7 +164,7 @@ public class EC2ComputeServiceLiveTest extends BaseComputeServiceLiveTest {
}
}
@Test(enabled = true, dependsOnMethods = "testCorrectAuthException")
@Test(enabled = true, dependsOnMethods = "testTemplateChoiceForInstanceByCCSizeId")
public void testExtendedOptionsNoKeyPair() throws Exception {
SecurityGroupClient securityGroupClient = EC2Client.class.cast(
context.getProviderSpecificContext().getApi())
@ -190,13 +222,12 @@ public class EC2ComputeServiceLiveTest extends BaseComputeServiceLiveTest {
}
}
@Test(enabled = true, dependsOnMethods = "testCorrectAuthException")
@Test(enabled = true, dependsOnMethods = "testTemplateChoiceForInstanceByCCSizeId")
public void testExtendedOptionsWithSubnetId() throws Exception {
String subnetId = System.getProperty("jclouds.test.subnetId");
if(subnetId == null)
{
//Skip test and return
if (subnetId == null) {
// Skip test and return
return;
}
SecurityGroupClient securityGroupClient = EC2Client.class.cast(
@ -214,7 +245,7 @@ public class EC2ComputeServiceLiveTest extends BaseComputeServiceLiveTest {
TemplateOptions options = client.templateOptions();
//options.as(EC2TemplateOptions.class).securityGroups(tag);
// options.as(EC2TemplateOptions.class).securityGroups(tag);
options.as(EC2TemplateOptions.class).keyPair(tag);
options.as(EC2TemplateOptions.class).subnetId(subnetId);
@ -224,7 +255,7 @@ public class EC2ComputeServiceLiveTest extends BaseComputeServiceLiveTest {
cleanupExtendedStuff(securityGroupClient, keyPairClient, tag);
// create the security group
//securityGroupClient.createSecurityGroupInRegion(null, tag, tag);
// securityGroupClient.createSecurityGroupInRegion(null, tag, tag);
// create a keypair to pass in as well
keyPairClient.createKeyPairInRegion(null, tag);

View File

@ -34,6 +34,7 @@ import java.util.Set;
import javax.inject.Provider;
import org.jclouds.aws.ec2.compute.domain.EC2Size;
import org.jclouds.aws.ec2.domain.InstanceType;
import org.jclouds.compute.domain.Architecture;
import org.jclouds.compute.domain.ComputeMetadata;
import org.jclouds.compute.domain.Image;
@ -65,6 +66,10 @@ import com.google.inject.util.Providers;
* @author Oleksiy Yarmula
*/
public class EC2ComputeServiceTest {
private static final Location location = new LocationImpl(LocationScope.REGION, "us-east-1", "us east", null);
private static final EC2Size CC1_4XLARGE = new EC2Size(location,
InstanceType.CC1_4XLARGE, 33.5, 23 * 1024, 1690, new String[]{"us-east-1/cc-image"});
/**
* Verifies that {@link TemplateBuilderImpl} would choose the correct size of the instance, based
@ -83,6 +88,17 @@ public class EC2ComputeServiceTest {
String.valueOf(template.getSize()));
}
@Test
public void testTemplateChoiceForInstanceByCCSizeId() throws Exception {
Template template = newTemplateBuilder().fastest().build();
assert template != null : "The returned template was null, but it should have a value.";
assert CC1_4XLARGE.equals(template.getSize()) : format(
"Incorrect image determined by the template. Expected: %s. Found: %s.", CC1_4XLARGE.getId(),
String.valueOf(template.getSize()));
}
/**
* Verifies that {@link TemplateBuilderImpl} would choose the correct size of the instance, based
* on physical attributes (# of cores, ram, etc).
@ -121,7 +137,6 @@ public class EC2ComputeServiceTest {
@SuppressWarnings("unchecked")
private TemplateBuilder newTemplateBuilder() {
Location location = new LocationImpl(LocationScope.REGION, "us-east-1", "us east", null);
Provider<TemplateOptions> optionsProvider = createMock(Provider.class);
Provider<TemplateBuilder> templateBuilderProvider = createMock(Provider.class);
@ -129,7 +144,7 @@ public class EC2ComputeServiceTest {
expect(optionsProvider.get()).andReturn(defaultOptions);
Image image = new ImageImpl("ami-image", "image", "us-east-1/ami-image", location, null, Maps
Image image = new ImageImpl("cc-image", "image", "us-east-1/cc-image", location, null, Maps
.<String, String> newHashMap(), "description", "1.0", null, "ubuntu",
Architecture.X86_64, new Credentials("root", null));
replay(optionsProvider);
@ -141,7 +156,7 @@ public class EC2ComputeServiceTest {
Provider<Set<? extends Size>> sizes = Providers.<Set<? extends Size>> of(ImmutableSet
.<Size> of(EC2Size.C1_MEDIUM, EC2Size.C1_XLARGE, EC2Size.M1_LARGE, EC2Size.M1_SMALL,
EC2Size.M1_XLARGE, EC2Size.M2_XLARGE, EC2Size.M2_2XLARGE,
EC2Size.M2_4XLARGE));
EC2Size.M2_4XLARGE, CC1_4XLARGE ));
return new TemplateBuilderImpl(locations, images, sizes, location, optionsProvider,
templateBuilderProvider) {

View File

@ -59,7 +59,7 @@ public class AMIAsyncClientTest extends BaseEC2AsyncClientTest<AMIAsyncClient> {
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(request,
"Version=2009-11-30&Action=CreateImage&InstanceId=instanceId&Name=name",
"Version=2010-06-15&Action=CreateImage&InstanceId=instanceId&Name=name",
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ParseSax.class);
assertSaxResponseParserClassEquals(method, ImageIdHandler.class);
@ -80,7 +80,7 @@ public class AMIAsyncClientTest extends BaseEC2AsyncClientTest<AMIAsyncClient> {
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(
request,
"Version=2009-11-30&Action=CreateImage&InstanceId=instanceId&Name=name&Description=description&NoReboot=true",
"Version=2010-06-15&Action=CreateImage&InstanceId=instanceId&Name=name&Description=description&NoReboot=true",
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ParseSax.class);
@ -97,12 +97,12 @@ public class AMIAsyncClientTest extends BaseEC2AsyncClientTest<AMIAsyncClient> {
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(request, "Version=2009-11-30&Action=DescribeImages",
assertPayloadEquals(request, "Version=2010-06-15&Action=DescribeImages",
"application/x-www-form-urlencoded", false);
filter.filter(request);
assertPayloadEquals(
request,
"Action=DescribeImages&Signature=IYist5Mfzd44GO3%2BX8WJ4Ti%2BWe3UmrZQC10XdCkT5Fk%3D&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2009-11-08T15%3A54%3A08.897Z&Version=2009-11-30&AWSAccessKeyId=identity",
"Action=DescribeImages&Signature=qE4vexSFJqS0UWK%2BccV3s%2BP9woL3M5HI5bTBoM7s%2FLY%3D&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2009-11-08T15%3A54%3A08.897Z&Version=2010-06-15&AWSAccessKeyId=identity",
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ParseSax.class);
@ -123,7 +123,7 @@ public class AMIAsyncClientTest extends BaseEC2AsyncClientTest<AMIAsyncClient> {
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(
request,
"Version=2009-11-30&Action=DescribeImages&ExecutableBy=me&Owner.1=fred&Owner.2=nancy&ImageId.1=1&ImageId.2=2",
"Version=2010-06-15&Action=DescribeImages&ExecutableBy=me&Owner.1=fred&Owner.2=nancy&ImageId.1=1&ImageId.2=2",
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ParseSax.class);
@ -140,7 +140,7 @@ public class AMIAsyncClientTest extends BaseEC2AsyncClientTest<AMIAsyncClient> {
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(request, "Version=2009-11-30&Action=DeregisterImage&ImageId=imageId",
assertPayloadEquals(request, "Version=2010-06-15&Action=DeregisterImage&ImageId=imageId",
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
@ -160,7 +160,7 @@ public class AMIAsyncClientTest extends BaseEC2AsyncClientTest<AMIAsyncClient> {
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(request,
"Version=2009-11-30&Action=RegisterImage&ImageLocation=pathToManifest&Name=name",
"Version=2010-06-15&Action=RegisterImage&ImageLocation=pathToManifest&Name=name",
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ParseSax.class);
assertSaxResponseParserClassEquals(method, ImageIdHandler.class);
@ -181,7 +181,7 @@ public class AMIAsyncClientTest extends BaseEC2AsyncClientTest<AMIAsyncClient> {
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(
request,
"Version=2009-11-30&Action=RegisterImage&ImageLocation=pathToManifest&Name=name&Description=description",
"Version=2010-06-15&Action=RegisterImage&ImageLocation=pathToManifest&Name=name&Description=description",
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ParseSax.class);
@ -202,7 +202,7 @@ public class AMIAsyncClientTest extends BaseEC2AsyncClientTest<AMIAsyncClient> {
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(
request,
"Version=2009-11-30&Action=RegisterImage&RootDeviceName=%2Fdev%2Fsda1&BlockDeviceMapping.0.DeviceName=%2Fdev%2Fsda1&BlockDeviceMapping.0.Ebs.SnapshotId=snapshotId&Name=imageName",
"Version=2010-06-15&Action=RegisterImage&RootDeviceName=%2Fdev%2Fsda1&BlockDeviceMapping.0.DeviceName=%2Fdev%2Fsda1&BlockDeviceMapping.0.Ebs.SnapshotId=snapshotId&Name=imageName",
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ParseSax.class);
assertSaxResponseParserClassEquals(method, ImageIdHandler.class);
@ -225,7 +225,7 @@ public class AMIAsyncClientTest extends BaseEC2AsyncClientTest<AMIAsyncClient> {
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(
request,
"Version=2009-11-30&Action=RegisterImage&RootDeviceName=%2Fdev%2Fsda1&BlockDeviceMapping.0.DeviceName=%2Fdev%2Fsda1&BlockDeviceMapping.0.Ebs.SnapshotId=snapshotId&Name=imageName&Description=description&BlockDeviceMapping.1.Ebs.DeleteOnTermination=false&BlockDeviceMapping.1.DeviceName=%2Fdev%2Fdevice&BlockDeviceMapping.1.Ebs.SnapshotId=snapshot&BlockDeviceMapping.2.Ebs.DeleteOnTermination=false&BlockDeviceMapping.2.DeviceName=%2Fdev%2Fnewdevice&BlockDeviceMapping.2.VirtualName=newblock&BlockDeviceMapping.2.Ebs.VolumeSize=100",
"Version=2010-06-15&Action=RegisterImage&RootDeviceName=%2Fdev%2Fsda1&BlockDeviceMapping.0.DeviceName=%2Fdev%2Fsda1&BlockDeviceMapping.0.Ebs.SnapshotId=snapshotId&Name=imageName&Description=description&BlockDeviceMapping.1.Ebs.DeleteOnTermination=false&BlockDeviceMapping.1.DeviceName=%2Fdev%2Fdevice&BlockDeviceMapping.1.Ebs.SnapshotId=snapshot&BlockDeviceMapping.2.Ebs.DeleteOnTermination=false&BlockDeviceMapping.2.DeviceName=%2Fdev%2Fnewdevice&BlockDeviceMapping.2.VirtualName=newblock&BlockDeviceMapping.2.Ebs.VolumeSize=100",
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ParseSax.class);
@ -245,7 +245,7 @@ public class AMIAsyncClientTest extends BaseEC2AsyncClientTest<AMIAsyncClient> {
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(
request,
"Version=2009-11-30&Action=DescribeImageAttribute&Attribute=productCodes&ImageId=imageId",
"Version=2010-06-15&Action=DescribeImageAttribute&Attribute=productCodes&ImageId=imageId",
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ParseSax.class);
@ -265,7 +265,7 @@ public class AMIAsyncClientTest extends BaseEC2AsyncClientTest<AMIAsyncClient> {
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(
request,
"Version=2009-11-30&Action=DescribeImageAttribute&Attribute=blockDeviceMapping&ImageId=imageId",
"Version=2010-06-15&Action=DescribeImageAttribute&Attribute=blockDeviceMapping&ImageId=imageId",
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ParseSax.class);
@ -285,7 +285,7 @@ public class AMIAsyncClientTest extends BaseEC2AsyncClientTest<AMIAsyncClient> {
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(
request,
"Version=2009-11-30&Action=DescribeImageAttribute&Attribute=launchPermission&ImageId=imageId",
"Version=2010-06-15&Action=DescribeImageAttribute&Attribute=launchPermission&ImageId=imageId",
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ParseSax.class);
@ -306,12 +306,12 @@ public class AMIAsyncClientTest extends BaseEC2AsyncClientTest<AMIAsyncClient> {
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(
request,
"Version=2009-11-30&Action=ModifyImageAttribute&OperationType=add&Attribute=launchPermission&ImageId=imageId&UserGroup.1=all&UserId.1=bob&UserId.2=sue",
"Version=2010-06-15&Action=ModifyImageAttribute&OperationType=add&Attribute=launchPermission&ImageId=imageId&UserGroup.1=all&UserId.1=bob&UserId.2=sue",
"application/x-www-form-urlencoded", false);
filter.filter(request);
assertPayloadEquals(
request,
"Action=ModifyImageAttribute&Attribute=launchPermission&ImageId=imageId&OperationType=add&Signature=Nf2oLuEQ%2BDgwhAxNt7Cdicjacz3PYTVR08%2BaGuXMfwU%3D&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2009-11-08T15%3A54%3A08.897Z&UserGroup.1=all&UserId.1=bob&UserId.2=sue&Version=2009-11-30&AWSAccessKeyId=identity",
"Action=ModifyImageAttribute&Attribute=launchPermission&ImageId=imageId&OperationType=add&Signature=WZzNWOC1KHbuySvXEuLTiBA%2BVUfKpSBN2Lud6MrhlCQ%3D&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2009-11-08T15%3A54%3A08.897Z&UserGroup.1=all&UserId.1=bob&UserId.2=sue&Version=2010-06-15&AWSAccessKeyId=identity",
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
@ -332,7 +332,7 @@ public class AMIAsyncClientTest extends BaseEC2AsyncClientTest<AMIAsyncClient> {
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(
request,
"Version=2009-11-30&Action=ModifyImageAttribute&OperationType=remove&Attribute=launchPermission&ImageId=imageId&UserGroup.1=all&UserId.1=bob&UserId.2=sue",
"Version=2010-06-15&Action=ModifyImageAttribute&OperationType=remove&Attribute=launchPermission&ImageId=imageId&UserGroup.1=all&UserId.1=bob&UserId.2=sue",
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
assertSaxResponseParserClassEquals(method, null);
@ -351,7 +351,7 @@ public class AMIAsyncClientTest extends BaseEC2AsyncClientTest<AMIAsyncClient> {
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(
request,
"Version=2009-11-30&Action=ResetImageAttribute&Attribute=launchPermission&ImageId=imageId",
"Version=2010-06-15&Action=ResetImageAttribute&Attribute=launchPermission&ImageId=imageId",
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
assertSaxResponseParserClassEquals(method, null);
@ -371,7 +371,7 @@ public class AMIAsyncClientTest extends BaseEC2AsyncClientTest<AMIAsyncClient> {
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(
request,
"Version=2009-11-30&Action=ModifyImageAttribute&OperationType=add&Attribute=productCodes&ImageId=imageId&ProductCode.1=code1&ProductCode.2=code2",
"Version=2010-06-15&Action=ModifyImageAttribute&OperationType=add&Attribute=productCodes&ImageId=imageId&ProductCode.1=code1&ProductCode.2=code2",
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
@ -392,7 +392,7 @@ public class AMIAsyncClientTest extends BaseEC2AsyncClientTest<AMIAsyncClient> {
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(
request,
"Version=2009-11-30&Action=ModifyImageAttribute&OperationType=remove&Attribute=productCodes&ImageId=imageId&ProductCode.1=code1&ProductCode.2=code2",
"Version=2010-06-15&Action=ModifyImageAttribute&OperationType=remove&Attribute=productCodes&ImageId=imageId&ProductCode.1=code1&ProductCode.2=code2",
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);

View File

@ -56,7 +56,7 @@ public class AvailabilityZoneAndRegionAsyncClientTest extends
assertRequestLineEquals(request, "POST https://ec2.us-west-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.us-west-1.amazonaws.com\n");
assertPayloadEquals(request, "Version=2009-11-30&Action=DescribeAvailabilityZones",
assertPayloadEquals(request, "Version=2010-06-15&Action=DescribeAvailabilityZones",
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ParseSax.class);
@ -78,7 +78,7 @@ public class AvailabilityZoneAndRegionAsyncClientTest extends
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(
request,
"Version=2009-11-30&Action=DescribeAvailabilityZones&ZoneName.1=us-east-1a&ZoneName.2=us-east-1b",
"Version=2010-06-15&Action=DescribeAvailabilityZones&ZoneName.1=us-east-1a&ZoneName.2=us-east-1b",
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ParseSax.class);
@ -95,7 +95,7 @@ public class AvailabilityZoneAndRegionAsyncClientTest extends
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(request, "Version=2009-11-30&Action=DescribeRegions",
assertPayloadEquals(request, "Version=2010-06-15&Action=DescribeRegions",
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ParseSax.class);
@ -116,7 +116,7 @@ public class AvailabilityZoneAndRegionAsyncClientTest extends
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(
request,
"Version=2009-11-30&Action=DescribeRegions&RegionName.1=us-east-1&RegionName.2=us-west-1",
"Version=2010-06-15&Action=DescribeRegions&RegionName.1=us-east-1&RegionName.2=us-west-1",
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ParseSax.class);

View File

@ -62,7 +62,7 @@ public class ElasticBlockStoreAsyncClientTest extends
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(request,
"Version=2009-11-30&Action=CreateVolume&AvailabilityZone=us-east-1a&Size=20",
"Version=2010-06-15&Action=CreateVolume&AvailabilityZone=us-east-1a&Size=20",
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ParseSax.class);
@ -83,7 +83,7 @@ public class ElasticBlockStoreAsyncClientTest extends
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(
request,
"Version=2009-11-30&Action=CreateVolume&AvailabilityZone=us-east-1a&SnapshotId=snapshotId",
"Version=2010-06-15&Action=CreateVolume&AvailabilityZone=us-east-1a&SnapshotId=snapshotId",
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ParseSax.class);
@ -104,7 +104,7 @@ public class ElasticBlockStoreAsyncClientTest extends
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(
request,
"Version=2009-11-30&Action=CreateVolume&AvailabilityZone=us-east-1a&SnapshotId=snapshotId&Size=15",
"Version=2010-06-15&Action=CreateVolume&AvailabilityZone=us-east-1a&SnapshotId=snapshotId&Size=15",
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ParseSax.class);
@ -121,7 +121,7 @@ public class ElasticBlockStoreAsyncClientTest extends
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(request, "Version=2009-11-30&Action=DeleteVolume&VolumeId=id",
assertPayloadEquals(request, "Version=2010-06-15&Action=DeleteVolume&VolumeId=id",
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
@ -138,7 +138,7 @@ public class ElasticBlockStoreAsyncClientTest extends
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(request, "Version=2009-11-30&Action=DescribeVolumes",
assertPayloadEquals(request, "Version=2010-06-15&Action=DescribeVolumes",
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ParseSax.class);
@ -157,7 +157,7 @@ public class ElasticBlockStoreAsyncClientTest extends
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(request,
"Version=2009-11-30&Action=DescribeVolumes&VolumeId.1=1&VolumeId.2=2",
"Version=2010-06-15&Action=DescribeVolumes&VolumeId.1=1&VolumeId.2=2",
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ParseSax.class);
@ -176,7 +176,7 @@ public class ElasticBlockStoreAsyncClientTest extends
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(
request,
"Version=2009-11-30&Action=AttachVolume&InstanceId=instanceId&VolumeId=id&Device=%2Fdevice",
"Version=2010-06-15&Action=AttachVolume&InstanceId=instanceId&VolumeId=id&Device=%2Fdevice",
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ParseSax.class);
@ -195,7 +195,7 @@ public class ElasticBlockStoreAsyncClientTest extends
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(request,
"Version=2009-11-30&Action=DetachVolume&Force=false&VolumeId=id",
"Version=2010-06-15&Action=DetachVolume&Force=false&VolumeId=id",
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
@ -217,7 +217,7 @@ public class ElasticBlockStoreAsyncClientTest extends
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(
request,
"Version=2009-11-30&Action=DetachVolume&Force=true&VolumeId=id&InstanceId=instanceId&Device=%2Fdevice",
"Version=2010-06-15&Action=DetachVolume&Force=true&VolumeId=id&InstanceId=instanceId&Device=%2Fdevice",
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
@ -235,7 +235,7 @@ public class ElasticBlockStoreAsyncClientTest extends
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(request, "Version=2009-11-30&Action=CreateSnapshot&VolumeId=volumeId",
assertPayloadEquals(request, "Version=2010-06-15&Action=CreateSnapshot&VolumeId=volumeId",
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ParseSax.class);
@ -257,7 +257,7 @@ public class ElasticBlockStoreAsyncClientTest extends
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(
request,
"Version=2009-11-30&Action=CreateSnapshot&VolumeId=volumeId&Description=description",
"Version=2010-06-15&Action=CreateSnapshot&VolumeId=volumeId&Description=description",
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ParseSax.class);
@ -274,7 +274,7 @@ public class ElasticBlockStoreAsyncClientTest extends
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(request, "Version=2009-11-30&Action=DescribeSnapshots",
assertPayloadEquals(request, "Version=2010-06-15&Action=DescribeSnapshots",
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ParseSax.class);
@ -295,7 +295,7 @@ public class ElasticBlockStoreAsyncClientTest extends
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(
request,
"Version=2009-11-30&Action=DescribeSnapshots&Owner.1=o1&Owner.2=o2&RestorableBy.1=r1&RestorableBy.2=r2&SnapshotId.1=s1&SnapshotId.2=s2",
"Version=2010-06-15&Action=DescribeSnapshots&Owner.1=o1&Owner.2=o2&RestorableBy.1=r1&RestorableBy.2=r2&SnapshotId.1=s1&SnapshotId.2=s2",
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ParseSax.class);
@ -315,7 +315,7 @@ public class ElasticBlockStoreAsyncClientTest extends
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(
request,
"Version=2009-11-30&Action=DescribeSnapshotAttribute&Attribute=createVolumePermission&SnapshotId=snapshotId",
"Version=2010-06-15&Action=DescribeSnapshotAttribute&Attribute=createVolumePermission&SnapshotId=snapshotId",
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ParseSax.class);
@ -337,7 +337,7 @@ public class ElasticBlockStoreAsyncClientTest extends
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(
request,
"Version=2009-11-30&Action=ModifySnapshotAttribute&OperationType=add&Attribute=createVolumePermission&SnapshotId=snapshotId&UserGroup.1=all&UserId.1=bob&UserId.2=sue",
"Version=2010-06-15&Action=ModifySnapshotAttribute&OperationType=add&Attribute=createVolumePermission&SnapshotId=snapshotId&UserGroup.1=all&UserId.1=bob&UserId.2=sue",
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
@ -359,7 +359,7 @@ public class ElasticBlockStoreAsyncClientTest extends
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(
request,
"Version=2009-11-30&Action=ModifySnapshotAttribute&OperationType=remove&Attribute=createVolumePermission&SnapshotId=snapshotId&UserGroup.1=all&UserId.1=bob&UserId.2=sue",
"Version=2010-06-15&Action=ModifySnapshotAttribute&OperationType=remove&Attribute=createVolumePermission&SnapshotId=snapshotId&UserGroup.1=all&UserId.1=bob&UserId.2=sue",
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
assertSaxResponseParserClassEquals(method, null);
@ -378,7 +378,7 @@ public class ElasticBlockStoreAsyncClientTest extends
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(
request,
"Version=2009-11-30&Action=ResetSnapshotAttribute&Attribute=createVolumePermission&SnapshotId=snapshotId",
"Version=2010-06-15&Action=ResetSnapshotAttribute&Attribute=createVolumePermission&SnapshotId=snapshotId",
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
assertSaxResponseParserClassEquals(method, null);

View File

@ -50,7 +50,7 @@ public class ElasticIPAddressAsyncClientTest extends
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(request,
"Version=2009-11-30&Action=DisassociateAddress&PublicIp=127.0.0.1",
"Version=2010-06-15&Action=DisassociateAddress&PublicIp=127.0.0.1",
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
@ -68,7 +68,7 @@ public class ElasticIPAddressAsyncClientTest extends
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(request,
"Version=2009-11-30&Action=AssociateAddress&InstanceId=me&PublicIp=127.0.0.1",
"Version=2010-06-15&Action=AssociateAddress&InstanceId=me&PublicIp=127.0.0.1",
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
@ -85,7 +85,7 @@ public class ElasticIPAddressAsyncClientTest extends
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(request, "Version=2009-11-30&Action=ReleaseAddress&PublicIp=127.0.0.1",
assertPayloadEquals(request, "Version=2010-06-15&Action=ReleaseAddress&PublicIp=127.0.0.1",
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
@ -103,7 +103,7 @@ public class ElasticIPAddressAsyncClientTest extends
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(request,
"Version=2009-11-30&Action=DescribeAddresses&PublicIp.1=127.0.0.1",
"Version=2010-06-15&Action=DescribeAddresses&PublicIp.1=127.0.0.1",
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ParseSax.class);
@ -120,7 +120,7 @@ public class ElasticIPAddressAsyncClientTest extends
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(request, "Version=2009-11-30&Action=AllocateAddress",
assertPayloadEquals(request, "Version=2010-06-15&Action=AllocateAddress",
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ParseSax.class);

View File

@ -60,7 +60,7 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest<InstanceAsyn
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(request, "Version=2009-11-30&Action=DescribeInstances",
assertPayloadEquals(request, "Version=2010-06-15&Action=DescribeInstances",
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ParseSax.class);
@ -79,7 +79,7 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest<InstanceAsyn
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(request,
"Version=2009-11-30&Action=DescribeInstances&InstanceId.1=1&InstanceId.2=2",
"Version=2010-06-15&Action=DescribeInstances&InstanceId.1=1&InstanceId.2=2",
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ParseSax.class);
@ -98,7 +98,7 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest<InstanceAsyn
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(request,
"Version=2009-11-30&Action=TerminateInstances&InstanceId.1=1&InstanceId.2=2",
"Version=2010-06-15&Action=TerminateInstances&InstanceId.1=1&InstanceId.2=2",
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ParseSax.class);
@ -117,7 +117,7 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest<InstanceAsyn
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(request,
"Version=2009-11-30&Action=RunInstances&ImageId=ami-voo&MinCount=1&MaxCount=1",
"Version=2010-06-15&Action=RunInstances&ImageId=ami-voo&MinCount=1&MaxCount=1",
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ParseSax.class);
@ -141,7 +141,7 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest<InstanceAsyn
assertNonPayloadHeadersEqual(request, "Host: ec2.eu-west-1.amazonaws.com\n");
assertPayloadEquals(
request,
"Version=2009-11-30&Action=RunInstances&ImageId=ami-voo&MinCount=1&MaxCount=5&KernelId=kernelId&Monitoring.Enabled=true&SecurityGroup.1=group1&SecurityGroup.2=group2&Placement.AvailabilityZone=eu-west-1a",
"Version=2010-06-15&Action=RunInstances&ImageId=ami-voo&MinCount=1&MaxCount=5&KernelId=kernelId&Monitoring.Enabled=true&SecurityGroup.1=group1&SecurityGroup.2=group2&Placement.AvailabilityZone=eu-west-1a",
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ParseSax.class);
@ -159,7 +159,7 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest<InstanceAsyn
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(request,
"Version=2009-11-30&Action=StopInstances&Force=true&InstanceId.1=1&InstanceId.2=2",
"Version=2010-06-15&Action=StopInstances&Force=true&InstanceId.1=1&InstanceId.2=2",
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ParseSax.class);
@ -177,7 +177,7 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest<InstanceAsyn
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(request,
"Version=2009-11-30&Action=RebootInstances&InstanceId.1=1&InstanceId.2=2",
"Version=2010-06-15&Action=RebootInstances&InstanceId.1=1&InstanceId.2=2",
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
@ -195,7 +195,7 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest<InstanceAsyn
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(request,
"Version=2009-11-30&Action=StartInstances&InstanceId.1=1&InstanceId.2=2",
"Version=2010-06-15&Action=StartInstances&InstanceId.1=1&InstanceId.2=2",
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ParseSax.class);
@ -215,7 +215,7 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest<InstanceAsyn
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(
request,
"Version=2009-11-30&Action=DescribeInstanceAttribute&Attribute=userData&InstanceId=1",
"Version=2010-06-15&Action=DescribeInstanceAttribute&Attribute=userData&InstanceId=1",
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ParseSax.class);
@ -235,7 +235,7 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest<InstanceAsyn
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(
request,
"Version=2009-11-30&Action=DescribeInstanceAttribute&Attribute=rootDeviceName&InstanceId=1",
"Version=2010-06-15&Action=DescribeInstanceAttribute&Attribute=rootDeviceName&InstanceId=1",
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ParseSax.class);
@ -255,7 +255,7 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest<InstanceAsyn
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(
request,
"Version=2009-11-30&Action=DescribeInstanceAttribute&Attribute=ramdisk&InstanceId=1",
"Version=2010-06-15&Action=DescribeInstanceAttribute&Attribute=ramdisk&InstanceId=1",
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ParseSax.class);
@ -275,7 +275,7 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest<InstanceAsyn
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(
request,
"Version=2009-11-30&Action=DescribeInstanceAttribute&Attribute=disableApiTermination&InstanceId=1",
"Version=2010-06-15&Action=DescribeInstanceAttribute&Attribute=disableApiTermination&InstanceId=1",
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ParseSax.class);
@ -294,7 +294,7 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest<InstanceAsyn
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(request,
"Version=2009-11-30&Action=DescribeInstanceAttribute&Attribute=kernel&InstanceId=1",
"Version=2010-06-15&Action=DescribeInstanceAttribute&Attribute=kernel&InstanceId=1",
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ParseSax.class);
@ -314,7 +314,7 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest<InstanceAsyn
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(
request,
"Version=2009-11-30&Action=DescribeInstanceAttribute&Attribute=instanceType&InstanceId=1",
"Version=2010-06-15&Action=DescribeInstanceAttribute&Attribute=instanceType&InstanceId=1",
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ParseSax.class);
@ -335,7 +335,7 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest<InstanceAsyn
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(
request,
"Version=2009-11-30&Action=DescribeInstanceAttribute&Attribute=instanceInitiatedShutdownBehavior&InstanceId=1",
"Version=2010-06-15&Action=DescribeInstanceAttribute&Attribute=instanceInitiatedShutdownBehavior&InstanceId=1",
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ParseSax.class);
@ -355,7 +355,7 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest<InstanceAsyn
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(
request,
"Version=2009-11-30&Action=DescribeInstanceAttribute&Attribute=blockDeviceMapping&InstanceId=1",
"Version=2010-06-15&Action=DescribeInstanceAttribute&Attribute=blockDeviceMapping&InstanceId=1",
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ParseSax.class);
@ -375,12 +375,12 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest<InstanceAsyn
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(
request,
"Version=2009-11-30&Action=ModifyInstanceAttribute&Attribute=userData&Value=dGVzdA%3D%3D&InstanceId=1",
"Version=2010-06-15&Action=ModifyInstanceAttribute&Attribute=userData&Value=dGVzdA%3D%3D&InstanceId=1",
"application/x-www-form-urlencoded", false);
filter.filter(request);// ensure encoding worked properly
assertPayloadEquals(
request,
"Action=ModifyInstanceAttribute&Attribute=userData&InstanceId=1&Signature=ch%2BpeYTRad241GAhjH9Wo2vKWlkgfNa3txM0lhPCBSM%3D&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2009-11-08T15%3A54%3A08.897Z&Value=dGVzdA%3D%3D&Version=2009-11-30&AWSAccessKeyId=identity",
"Action=ModifyInstanceAttribute&Attribute=userData&InstanceId=1&Signature=LfUmzLM5DsACR5nQcEfGF5FPdznOwwhJ7tjhBWfHtGs%3D&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2009-11-08T15%3A54%3A08.897Z&Value=dGVzdA%3D%3D&Version=2010-06-15&AWSAccessKeyId=identity",
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
assertSaxResponseParserClassEquals(method, null);
@ -399,7 +399,7 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest<InstanceAsyn
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(
request,
"Version=2009-11-30&Action=ModifyInstanceAttribute&Attribute=ramdisk&Value=test&InstanceId=1",
"Version=2010-06-15&Action=ModifyInstanceAttribute&Attribute=ramdisk&Value=test&InstanceId=1",
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
assertSaxResponseParserClassEquals(method, null);
@ -418,7 +418,7 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest<InstanceAsyn
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(
request,
"Version=2009-11-30&Action=ModifyInstanceAttribute&Attribute=kernel&Value=test&InstanceId=1",
"Version=2010-06-15&Action=ModifyInstanceAttribute&Attribute=kernel&Value=test&InstanceId=1",
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
assertSaxResponseParserClassEquals(method, null);
@ -438,7 +438,7 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest<InstanceAsyn
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(
request,
"Version=2009-11-30&Action=ModifyInstanceAttribute&Attribute=disableApiTermination&Value=true&InstanceId=1",
"Version=2010-06-15&Action=ModifyInstanceAttribute&Attribute=disableApiTermination&Value=true&InstanceId=1",
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
@ -458,7 +458,7 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest<InstanceAsyn
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(
request,
"Version=2009-11-30&Action=ModifyInstanceAttribute&Attribute=instanceType&Value=c1.medium&InstanceId=1",
"Version=2010-06-15&Action=ModifyInstanceAttribute&Attribute=instanceType&Value=c1.medium&InstanceId=1",
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
@ -480,7 +480,7 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest<InstanceAsyn
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(
request,
"Version=2009-11-30&Action=ModifyInstanceAttribute&Attribute=instanceInitiatedShutdownBehavior&Value=terminate&InstanceId=1",
"Version=2010-06-15&Action=ModifyInstanceAttribute&Attribute=instanceInitiatedShutdownBehavior&Value=terminate&InstanceId=1",
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
@ -505,12 +505,12 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest<InstanceAsyn
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(
request,
"Version=2009-11-30&Action=ModifyInstanceAttribute&InstanceId=1&BlockDeviceMapping.1.Ebs.VolumeId=vol-test1&BlockDeviceMapping.1.DeviceName=%2Fdev%2Fsda1&BlockDeviceMapping.1.Ebs.DeleteOnTermination=true",
"Version=2010-06-15&Action=ModifyInstanceAttribute&InstanceId=1&BlockDeviceMapping.1.Ebs.VolumeId=vol-test1&BlockDeviceMapping.1.DeviceName=%2Fdev%2Fsda1&BlockDeviceMapping.1.Ebs.DeleteOnTermination=true",
"application/x-www-form-urlencoded", false);
filter.filter(request);// ensure encoding worked properly
assertPayloadEquals(
request,
"Action=ModifyInstanceAttribute&BlockDeviceMapping.1.DeviceName=%2Fdev%2Fsda1&BlockDeviceMapping.1.Ebs.DeleteOnTermination=true&BlockDeviceMapping.1.Ebs.VolumeId=vol-test1&InstanceId=1&Signature=QOd9dFUmgBAsz3b5rWOE2wWgoB85vmhsVM9yNO2s7cE%3D&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2009-11-08T15%3A54%3A08.897Z&Version=2009-11-30&AWSAccessKeyId=identity",
"Action=ModifyInstanceAttribute&BlockDeviceMapping.1.DeviceName=%2Fdev%2Fsda1&BlockDeviceMapping.1.Ebs.DeleteOnTermination=true&BlockDeviceMapping.1.Ebs.VolumeId=vol-test1&InstanceId=1&Signature=RwY8lVPHSQxQkd5efUKccHdSTkN4OxMIMFiYAe3rrUE%3D&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2009-11-08T15%3A54%3A08.897Z&Version=2010-06-15&AWSAccessKeyId=identity",
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
assertSaxResponseParserClassEquals(method, null);

View File

@ -46,7 +46,7 @@ public class KeyPairAsyncClientTest extends BaseEC2AsyncClientTest<KeyPairAsyncC
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(request, "Version=2009-11-30&Action=DeleteKeyPair&KeyName=mykey",
assertPayloadEquals(request, "Version=2010-06-15&Action=DeleteKeyPair&KeyName=mykey",
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
@ -63,7 +63,7 @@ public class KeyPairAsyncClientTest extends BaseEC2AsyncClientTest<KeyPairAsyncC
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(request, "Version=2009-11-30&Action=DescribeKeyPairs",
assertPayloadEquals(request, "Version=2010-06-15&Action=DescribeKeyPairs",
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ParseSax.class);
@ -82,7 +82,7 @@ public class KeyPairAsyncClientTest extends BaseEC2AsyncClientTest<KeyPairAsyncC
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(request,
"Version=2009-11-30&Action=DescribeKeyPairs&KeyName.1=1&KeyName.2=2",
"Version=2010-06-15&Action=DescribeKeyPairs&KeyName.1=1&KeyName.2=2",
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ParseSax.class);

View File

@ -45,7 +45,7 @@ public class MonitoringAsyncClientTest extends BaseEC2AsyncClientTest<Monitoring
HttpRequest request = processor.createRequest(method, null, "instance1", "instance2");
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
String payload = "Version=2009-11-30&Action=UnmonitorInstances&InstanceId.0=instance1&InstanceId.1=instance2";
String payload = "Version=2010-06-15&Action=UnmonitorInstances&InstanceId.0=instance1&InstanceId.1=instance2";
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(request, payload, "application/x-www-form-urlencoded", false);
@ -65,7 +65,7 @@ public class MonitoringAsyncClientTest extends BaseEC2AsyncClientTest<Monitoring
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(
request,
"Version=2009-11-30&Action=MonitorInstances&InstanceId.0=instance1&InstanceId.1=instance2",
"Version=2010-06-15&Action=MonitorInstances&InstanceId.0=instance1&InstanceId.1=instance2",
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ParseSax.class);

View File

@ -50,7 +50,7 @@ public class SecurityGroupAsyncClientTest extends BaseEC2AsyncClientTest<Securit
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(request, "Version=2009-11-30&Action=DeleteSecurityGroup&GroupName=name",
assertPayloadEquals(request, "Version=2010-06-15&Action=DeleteSecurityGroup&GroupName=name",
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
@ -70,7 +70,7 @@ public class SecurityGroupAsyncClientTest extends BaseEC2AsyncClientTest<Securit
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(
request,
"Version=2009-11-30&Action=CreateSecurityGroup&GroupDescription=description&GroupName=name",
"Version=2010-06-15&Action=CreateSecurityGroup&GroupDescription=description&GroupName=name",
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
@ -88,7 +88,7 @@ public class SecurityGroupAsyncClientTest extends BaseEC2AsyncClientTest<Securit
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(request, "Version=2009-11-30&Action=DescribeSecurityGroups",
assertPayloadEquals(request, "Version=2010-06-15&Action=DescribeSecurityGroups",
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ParseSax.class);
@ -107,7 +107,7 @@ public class SecurityGroupAsyncClientTest extends BaseEC2AsyncClientTest<Securit
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(request,
"Version=2009-11-30&Action=DescribeSecurityGroups&GroupName.1=1&GroupName.2=2",
"Version=2010-06-15&Action=DescribeSecurityGroups&GroupName.1=1&GroupName.2=2",
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ParseSax.class);
@ -129,7 +129,7 @@ public class SecurityGroupAsyncClientTest extends BaseEC2AsyncClientTest<Securit
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(
request,
"Version=2009-11-30&Action=AuthorizeSecurityGroupIngress&GroupName=group&SourceSecurityGroupOwnerId=sourceUser&SourceSecurityGroupName=sourceGroup",
"Version=2010-06-15&Action=AuthorizeSecurityGroupIngress&GroupName=group&SourceSecurityGroupOwnerId=sourceUser&SourceSecurityGroupName=sourceGroup",
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
@ -151,7 +151,7 @@ public class SecurityGroupAsyncClientTest extends BaseEC2AsyncClientTest<Securit
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(
request,
"Version=2009-11-30&Action=AuthorizeSecurityGroupIngress&CidrIp=0.0.0.0%2F0&IpProtocol=tcp&GroupName=group&FromPort=6000&ToPort=7000",
"Version=2010-06-15&Action=AuthorizeSecurityGroupIngress&CidrIp=0.0.0.0%2F0&IpProtocol=tcp&GroupName=group&FromPort=6000&ToPort=7000",
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
@ -173,7 +173,7 @@ public class SecurityGroupAsyncClientTest extends BaseEC2AsyncClientTest<Securit
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(
request,
"Version=2009-11-30&Action=RevokeSecurityGroupIngress&GroupName=group&SourceSecurityGroupOwnerId=sourceUser&SourceSecurityGroupName=sourceGroup",
"Version=2010-06-15&Action=RevokeSecurityGroupIngress&GroupName=group&SourceSecurityGroupOwnerId=sourceUser&SourceSecurityGroupName=sourceGroup",
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
@ -195,7 +195,7 @@ public class SecurityGroupAsyncClientTest extends BaseEC2AsyncClientTest<Securit
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(
request,
"Version=2009-11-30&Action=RevokeSecurityGroupIngress&CidrIp=0.0.0.0%2F0&IpProtocol=tcp&GroupName=group&FromPort=6000&ToPort=7000",
"Version=2010-06-15&Action=RevokeSecurityGroupIngress&CidrIp=0.0.0.0%2F0&IpProtocol=tcp&GroupName=group&FromPort=6000&ToPort=7000",
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);

View File

@ -56,7 +56,7 @@ public class DescribeImagesResponseHandlerTest extends BaseEC2HandlerTest {
"ec2-public-images/fedora-8-i386-base-v1.04.manifest.xml", "206029621532",
ImageState.AVAILABLE, ImageType.MACHINE, false,
Sets.<String> newHashSet("9961934F"), "aki-4438dd2d", null, "ari-4538dd2c",
RootDeviceType.INSTANCE_STORE, null, ImmutableMap.<String, EbsBlockDevice> of()));
RootDeviceType.INSTANCE_STORE, null, ImmutableMap.<String, EbsBlockDevice> of(),"paravirtual"));
Set<Image> result = parseImages(is);
@ -71,7 +71,7 @@ public class DescribeImagesResponseHandlerTest extends BaseEC2HandlerTest {
"aws-solutions-amis/SqlSvrStd2003r2-x86_64-Win_SFWBasic5.1-v1.0.manifest.xml",
"771350841976", ImageState.AVAILABLE, ImageType.MACHINE, true, Sets
.<String> newHashSet("5771E9A6"), null, "windows", null,
RootDeviceType.INSTANCE_STORE, null, ImmutableMap.<String, EbsBlockDevice> of()));
RootDeviceType.INSTANCE_STORE, null, ImmutableMap.<String, EbsBlockDevice> of(),"paravirtual"));
Set<Image> result = parseImages(is);
@ -88,7 +88,7 @@ public class DescribeImagesResponseHandlerTest extends BaseEC2HandlerTest {
"windows", null, RootDeviceType.EBS, "/dev/sda1", ImmutableMap
.<String, EbsBlockDevice> of("/dev/sda1", new EbsBlockDevice(
"snap-d01272b9", 30, true), "xvdf", new EbsBlockDevice(
"snap-d31272ba", 250, false))));
"snap-d31272ba", 250, false)),"hvm"));
Set<Image> result = parseImages(is);

View File

@ -83,7 +83,7 @@ public class DescribeRegionsResponseHandlerTest extends BaseHandlerTest {
public void testEuc() {
InputStream is = Utils
.toInputStream("<DescribeRegionsResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-11-30/\"><requestId>6a3b36f9-9ff4-47cf-87e3-285b08fbe5e5</requestId><regionInfo><item><regionName>Eucalyptus</regionName><regionEndpoint>http://173.205.188.130:8773/services/Eucalyptus</regionEndpoint></item><item><regionName>Walrus</regionName><regionEndpoint>http://173.205.188.130:8773/services/Walrus</regionEndpoint></item></regionInfo></DescribeRegionsResponse>");
.toInputStream("<DescribeRegionsResponse xmlns=\"http://ec2.amazonaws.com/doc/2010-06-15/\"><requestId>6a3b36f9-9ff4-47cf-87e3-285b08fbe5e5</requestId><regionInfo><item><regionName>Eucalyptus</regionName><regionEndpoint>http://173.205.188.130:8773/services/Eucalyptus</regionEndpoint></item><item><regionName>Walrus</regionName><regionEndpoint>http://173.205.188.130:8773/services/Walrus</regionEndpoint></item></regionInfo></DescribeRegionsResponse>");
Map<String, URI> expected = ImmutableMap.<String, URI> of("Eucalyptus",
URI.create("http://173.205.188.130:8773/services/Eucalyptus"));

View File

@ -37,8 +37,8 @@ public class FormSignerTest extends BaseEC2AsyncClientTest<String> {
"AWSAccessKeyId", "foo").put("Action", "DescribeImages").put("Expires",
"2008-02-10T12:00:00Z").put("ImageId.1", "ami-2bb65342").put(
"SignatureMethod", "HmacSHA256").put("SignatureVersion", "2").put(
"Version", "2009-11-30").build()),
"AWSAccessKeyId=foo&Action=DescribeImages&Expires=2008-02-10T12%3A00%3A00Z&ImageId.1=ami-2bb65342&SignatureMethod=HmacSHA256&SignatureVersion=2&Version=2009-11-30");
"Version", "2010-06-15").build()),
"AWSAccessKeyId=foo&Action=DescribeImages&Expires=2008-02-10T12%3A00%3A00Z&ImageId.1=ami-2bb65342&SignatureMethod=HmacSHA256&SignatureVersion=2&Version=2010-06-15");
}
@Override

View File

@ -17,6 +17,7 @@
<ramdiskId>ari-4538dd2c</ramdiskId>
<rootDeviceType>instance-store</rootDeviceType>
<blockDeviceMapping />
<virtualizationType>paravirtual</virtualizationType>
</item>
</imagesSet>
</DescribeImagesResponse>

View File

@ -34,6 +34,7 @@
</ebs>
</item>
</blockDeviceMapping>
<virtualizationType>hvm</virtualizationType>
</item>
</imagesSet>
</DescribeImagesResponse>

View File

@ -16,6 +16,7 @@
<platform>windows</platform>
<rootDeviceType>instance-store</rootDeviceType>
<blockDeviceMapping/>
<virtualizationType>paravirtual</virtualizationType>
</item>
</imagesSet>
</DescribeImagesResponse>

View File

@ -37,7 +37,7 @@ public enum OsFamily {
/**
* Oracle Enterprise Linux
*/
OEL, RHEL, FEDORA, DEBIAN, UBUNTU, TTYLINUX, ARCH, SUSE, GENTOO, WINDOWS;
OEL, RHEL, FEDORA, DEBIAN, UBUNTU, TTYLINUX, ARCH, SUSE, SOLARIS, GENTOO, WINDOWS;
public String value() {
return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_HYPHEN, name());
}
@ -48,7 +48,7 @@ public enum OsFamily {
}
public static OsFamily fromValue(String operatingSystem) {
return valueOf(CaseFormat.LOWER_HYPHEN.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(
operatingSystem, "region")));
return valueOf(CaseFormat.LOWER_HYPHEN.to(CaseFormat.UPPER_UNDERSCORE,
checkNotNull(operatingSystem, "region")));
}
}

View File

@ -462,7 +462,13 @@ public class TemplateBuilderImpl implements TemplateBuilder {
@Override
public boolean apply(Image input) {
return size.supportsImage(input);
boolean returnVal = size
.supportsImage(input);
if (!returnVal && input.getId().equals("us-east-1/ami-7ea24a17")) {
System.err.println("goo");
}
return returnVal;
}
});

View File

@ -38,6 +38,28 @@ import com.google.common.collect.Sets;
* @author Adrian Cole
*/
public class ImagePredicates {
/**
* evaluates true if the Image
*
* @param ids
* ids of the images
* @return predicate
*/
public static Predicate<Image> idIn(Iterable<String> ids) {
checkNotNull(ids, "ids must be defined");
final Set<String> search = Sets.newHashSet(ids);
return new Predicate<Image>() {
@Override
public boolean apply(Image image) {
return search.contains(image.getId());
}
@Override
public String toString() {
return "idIn(" + search + ")";
}
};
}
/**
* evaluates true if the Image
@ -61,7 +83,8 @@ public class ImagePredicates {
};
}
public static Predicate<Image> architectureIn(Iterable<Architecture> architectures) {
public static Predicate<Image> architectureIn(
Iterable<Architecture> architectures) {
checkNotNull(architectures, "architectures must be defined");
final Set<Architecture> search = Sets.newHashSet(architectures);
return new Predicate<Image>() {

View File

@ -1,38 +0,0 @@
/**
*
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ====================================================================
*/
package org.jclouds.rest.annotations;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import javax.inject.Qualifier;
/**
* Apply this to implementation classes when you want Access to items from the
* scope of a delegate.
*
* @author Adrian Cole
*/
@Target( { ElementType.TYPE, ElementType.METHOD, ElementType.PARAMETER , ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
@Qualifier
public @interface Caller {
}

View File

@ -18,7 +18,6 @@
*/
package org.jclouds.rest.config;
import java.net.URI;
import java.util.concurrent.ConcurrentMap;
import javax.inject.Named;
@ -36,7 +35,6 @@ import org.jclouds.internal.ClassMethodArgs;
import org.jclouds.rest.AsyncClientFactory;
import org.jclouds.rest.HttpAsyncClient;
import org.jclouds.rest.HttpClient;
import org.jclouds.rest.annotations.Caller;
import org.jclouds.rest.internal.AsyncRestClientProxy;
import org.jclouds.rest.internal.RestAnnotationProcessor;
@ -47,7 +45,6 @@ import com.google.inject.AbstractModule;
import com.google.inject.Inject;
import com.google.inject.Injector;
import com.google.inject.Key;
import com.google.inject.Module;
import com.google.inject.Provides;
import com.google.inject.Scopes;
import com.google.inject.TypeLiteral;
@ -85,10 +82,6 @@ public class RestModule extends AbstractModule {
private final Injector injector;
private final AsyncRestClientProxy.Factory factory;
@Caller
@Inject(optional = true)
Module callerModule = new CallerScopedBindingModule();
@Inject
CreateAsyncClientForCaller(Injector injector,
AsyncRestClientProxy.Factory factory) {
@ -101,22 +94,12 @@ public class RestModule extends AbstractModule {
public Object apply(final ClassMethodArgs from) {
Class clazz = from.getAsyncClass();
TypeLiteral typeLiteral = TypeLiteral.get(clazz);
Injector injector = this.injector.createChildInjector(callerModule,
new AbstractModule() {
@Override
protected void configure() {
bind(ClassMethodArgs.class).annotatedWith(Caller.class)
.toInstance(from);
install(callerModule);
}
});
RestAnnotationProcessor util = (RestAnnotationProcessor) injector
.getInstance(Key.get(TypeLiteral.get(Types.newParameterizedType(
RestAnnotationProcessor.class, clazz))));
// not sure why we have to go back and re-inject this...
injector.injectMembers(util);
// cannot use child injectors due to the super coarse guice lock on
// Singleton
util.setCaller(from);
ConcurrentMap<ClassMethodArgs, Object> delegateMap = injector
.getInstance(Key.get(
new TypeLiteral<ConcurrentMap<ClassMethodArgs, Object>>() {
@ -128,26 +111,6 @@ public class RestModule extends AbstractModule {
}
}
@Singleton
public static class CallerScopedBindingModule extends AbstractModule {
@Provides
@Caller
URI provideCallerScopedURI(Injector injector, @Caller ClassMethodArgs args) {
try {
return RestAnnotationProcessor.getEndpointFor(args.getMethod(),
args.getArgs(), injector);
} catch (IllegalStateException e) {
return null;
}
}
@Override
protected void configure() {
}
}
private static class Factory implements AsyncRestClientProxy.Factory {
@Inject
private TransformingHttpCommandExecutorService executorService;

View File

@ -69,8 +69,8 @@ public class AsyncRestClientProxy<T> implements InvocationHandler {
@SuppressWarnings("unchecked")
@Inject
public AsyncRestClientProxy(Injector injector, Factory factory, RestAnnotationProcessor<T> util,
TypeLiteral<T> typeLiteral,
public AsyncRestClientProxy(Injector injector, Factory factory,
RestAnnotationProcessor<T> util, TypeLiteral<T> typeLiteral,
@Named("async") ConcurrentMap<ClassMethodArgs, Object> delegateMap) {
this.injector = injector;
this.annotationProcessor = util;
@ -79,7 +79,8 @@ public class AsyncRestClientProxy<T> implements InvocationHandler {
this.delegateMap = delegateMap;
}
public Object invoke(Object o, Method method, Object[] args) throws Throwable {
public Object invoke(Object o, Method method, Object[] args)
throws Throwable {
if (method.getName().equals("equals")) {
return this.equals(o);
} else if (method.getName().equals("toString")) {
@ -89,22 +90,27 @@ public class AsyncRestClientProxy<T> implements InvocationHandler {
} else if (method.getName().startsWith("new")) {
return injector.getInstance(method.getReturnType());
} else if (method.isAnnotationPresent(Delegate.class)) {
return delegateMap.get(new ClassMethodArgs(method.getReturnType(), method, args));
return delegateMap.get(new ClassMethodArgs(method.getReturnType(),
method, args));
} else if (annotationProcessor.getDelegateOrNull(method) != null
&& ListenableFuture.class.isAssignableFrom(method.getReturnType())) {
return createFuture(method, args);
} else {
throw new RuntimeException("method is intended solely to set constants: " + method);
throw new RuntimeException(
"method is intended solely to set constants: " + method);
}
}
@SuppressWarnings("unchecked")
private ListenableFuture<?> createFuture(Method method, Object[] args) throws ExecutionException {
private ListenableFuture<?> createFuture(Method method, Object[] args)
throws ExecutionException {
method = annotationProcessor.getDelegateOrNull(method);
logger.trace("Converting %s.%s", declaring.getSimpleName(), method.getName());
logger.trace("Converting %s.%s", declaring.getSimpleName(), method
.getName());
Function<Exception, ?> exceptionParser = annotationProcessor
.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method);
// in case there is an exception creating the request, we should at least pass in args
// in case there is an exception creating the request, we should at least
// pass in args
if (exceptionParser instanceof InvocationContext) {
((InvocationContext) exceptionParser).setContext(null);
}
@ -112,7 +118,8 @@ public class AsyncRestClientProxy<T> implements InvocationHandler {
try {
request = annotationProcessor.createRequest(method, args);
if (exceptionParser instanceof InvocationContext) {
((InvocationContext) exceptionParser).setContext((GeneratedHttpRequest<T>) request);
((InvocationContext) exceptionParser)
.setContext((GeneratedHttpRequest<T>) request);
}
} catch (RuntimeException e) {
if (exceptionParser != null) {
@ -124,20 +131,24 @@ public class AsyncRestClientProxy<T> implements InvocationHandler {
}
return Futures.immediateFailedFuture(e);
}
logger.trace("Converted %s.%s to %s", declaring.getSimpleName(), method.getName(), request
.getRequestLine());
logger.trace("Converted %s.%s to %s", declaring.getSimpleName(), method
.getName(), request.getRequestLine());
Function<HttpResponse, ?> transformer = annotationProcessor.createResponseParser(method,
request);
logger.trace("Response from %s.%s is parsed by %s", declaring.getSimpleName(), method
.getName(), transformer.getClass().getSimpleName());
Function<HttpResponse, ?> transformer = annotationProcessor
.createResponseParser(method, request);
logger.trace("Response from %s.%s is parsed by %s", declaring
.getSimpleName(), method.getName(), transformer.getClass()
.getSimpleName());
logger.debug("Invoking %s.%s", declaring.getSimpleName(), method.getName());
ListenableFuture<?> result = commandFactory.create(request, transformer).execute();
logger.debug("Invoking %s.%s", declaring.getSimpleName(), method
.getName());
ListenableFuture<?> result = commandFactory.create(request, transformer)
.execute();
if (exceptionParser != null) {
logger.trace("Exceptions from %s.%s are parsed by %s", declaring.getSimpleName(), method
.getName(), exceptionParser.getClass().getSimpleName());
logger.trace("Exceptions from %s.%s are parsed by %s", declaring
.getSimpleName(), method.getName(), exceptionParser.getClass()
.getSimpleName());
result = new FutureExceptionParser(result, exceptionParser);
}
return result;

View File

@ -90,7 +90,6 @@ import org.jclouds.rest.Binder;
import org.jclouds.rest.InputParamValidator;
import org.jclouds.rest.InvocationContext;
import org.jclouds.rest.annotations.BinderParam;
import org.jclouds.rest.annotations.Caller;
import org.jclouds.rest.annotations.Delegate;
import org.jclouds.rest.annotations.Endpoint;
import org.jclouds.rest.annotations.EndpointParam;
@ -375,18 +374,18 @@ public class RestAnnotationProcessor<T> {
final Injector injector;
ClassMethodArgs caller;
private ClassMethodArgs caller;
private URI callerEndpoint;
@Inject(optional = true)
public void setCaller(@Caller ClassMethodArgs caller) {
public void setCaller(ClassMethodArgs caller) {
seedCache(caller.getMethod().getDeclaringClass());
this.caller = caller;
try {
callerEndpoint = getEndpointFor(caller.getMethod(), caller.getArgs(),
injector);
} catch (IllegalStateException e) {
}
}
@Inject(optional = true)
@Caller
@Nullable
URI callerEndpoint;
public GeneratedHttpRequest<T> createRequest(Method method, Object... args) {
inputParamValidator.validateMethodParametersOrThrow(method, args);
@ -680,7 +679,8 @@ public class RestAnnotationProcessor<T> {
return null;
}
public static URI getEndpointFor(Method method, Object[] args, Injector injector) {
public static URI getEndpointFor(Method method, Object[] args,
Injector injector) {
URI endpoint = getEndpointInParametersOrNull(method, args, injector);
if (endpoint == null) {
Endpoint annotation;

View File

@ -61,14 +61,14 @@ public class HttpUtilsTest extends PerformanceTest {
public void testParseBase64InForm() {
Multimap<String, String> expects = LinkedListMultimap.create();
expects.put("Version", "2009-11-30");
expects.put("Version", "2010-06-15");
expects.put("Action", "ModifyInstanceAttribute");
expects.put("Attribute", "userData");
expects.put("Value", "dGVzdA==");
expects.put("InstanceId", "1");
assertEquals(
expects,
parseQueryToMap("Version=2009-11-30&Action=ModifyInstanceAttribute&Attribute=userData&Value=dGVzdA%3D%3D&InstanceId=1"));
parseQueryToMap("Version=2010-06-15&Action=ModifyInstanceAttribute&Attribute=userData&Value=dGVzdA%3D%3D&InstanceId=1"));
}
@Test

View File

@ -25,6 +25,7 @@ import java.lang.reflect.Type;
import java.util.Map;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.jclouds.domain.Credentials;
import org.jclouds.gogrid.domain.Server;
@ -39,6 +40,7 @@ import com.google.gson.reflect.TypeToken;
/**
* @author Oleksiy Yarmula
*/
@Singleton
public class ParseServerNameToCredentialsMapFromJsonResponse extends
ParseJson<Map<String, Credentials>> {