mirror of https://github.com/apache/jclouds.git
JCLOUDS-1399: Support S3 One Zone-IA storage class
Also improve test coverage of storage classes.
This commit is contained in:
parent
c2b76d1d42
commit
dd4de2d0b8
|
@ -36,6 +36,7 @@ public interface ObjectMetadata extends Comparable<ObjectMetadata> {
|
||||||
public enum StorageClass {
|
public enum StorageClass {
|
||||||
STANDARD(Tier.STANDARD),
|
STANDARD(Tier.STANDARD),
|
||||||
STANDARD_IA(Tier.INFREQUENT),
|
STANDARD_IA(Tier.INFREQUENT),
|
||||||
|
ONEZONE_IA(Tier.INFREQUENT),
|
||||||
REDUCED_REDUNDANCY(Tier.STANDARD),
|
REDUCED_REDUNDANCY(Tier.STANDARD),
|
||||||
GLACIER(Tier.ARCHIVE);
|
GLACIER(Tier.ARCHIVE);
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,8 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.aws.s3;
|
package org.jclouds.aws.s3;
|
||||||
|
|
||||||
import static org.jclouds.aws.s3.blobstore.options.AWSS3PutOptions.Builder.storageClass;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
import static org.jclouds.aws.s3.blobstore.options.AWSS3PutObjectOptions.Builder.storageClass;
|
||||||
import static org.jclouds.s3.options.ListBucketOptions.Builder.withPrefix;
|
import static org.jclouds.s3.options.ListBucketOptions.Builder.withPrefix;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
import static org.testng.Assert.assertNotNull;
|
import static org.testng.Assert.assertNotNull;
|
||||||
|
@ -33,11 +34,11 @@ import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.HttpResponse;
|
import org.jclouds.http.HttpResponse;
|
||||||
import org.jclouds.location.predicates.LocationPredicates;
|
import org.jclouds.location.predicates.LocationPredicates;
|
||||||
import org.jclouds.rest.HttpClient;
|
import org.jclouds.rest.HttpClient;
|
||||||
import org.jclouds.s3.S3Client;
|
|
||||||
import org.jclouds.s3.S3ClientLiveTest;
|
import org.jclouds.s3.S3ClientLiveTest;
|
||||||
import org.jclouds.s3.domain.ListBucketResponse;
|
import org.jclouds.s3.domain.ListBucketResponse;
|
||||||
import org.jclouds.s3.domain.ObjectMetadata;
|
import org.jclouds.s3.domain.ObjectMetadata;
|
||||||
import org.jclouds.s3.domain.ObjectMetadata.StorageClass;
|
import org.jclouds.s3.domain.ObjectMetadata.StorageClass;
|
||||||
|
import org.jclouds.s3.domain.S3Object;
|
||||||
import org.testng.ITestContext;
|
import org.testng.ITestContext;
|
||||||
import org.testng.annotations.BeforeClass;
|
import org.testng.annotations.BeforeClass;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
@ -64,22 +65,30 @@ public class AWSS3ClientLiveTest extends S3ClientLiveTest {
|
||||||
super.setUpResourcesOnThisThread(testContext);
|
super.setUpResourcesOnThisThread(testContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testPutWithReducedRedundancyStorage() throws InterruptedException {
|
public void testPutWithStorageClass() throws Exception {
|
||||||
String containerName = getContainerName();
|
String containerName = getContainerName();
|
||||||
|
AWSS3Client s3Client = getApi();
|
||||||
try {
|
try {
|
||||||
String blobName = "test-rrs";
|
for (StorageClass storageClass : StorageClass.values()) {
|
||||||
|
if (storageClass == StorageClass.GLACIER) {
|
||||||
|
// AWS does not allow creation of Glacier objects
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
String blobName = "test-" + storageClass;
|
||||||
BlobStore blobStore = view.getBlobStore();
|
BlobStore blobStore = view.getBlobStore();
|
||||||
blobStore.createContainerInLocation(null, containerName);
|
blobStore.createContainerInLocation(null, containerName);
|
||||||
|
|
||||||
Blob blob = blobStore.blobBuilder(blobName).payload("something").build();
|
S3Object object = s3Client.newS3Object();
|
||||||
blobStore.putBlob(containerName, blob,
|
object.getMetadata().setKey(blobName);
|
||||||
storageClass(StorageClass.REDUCED_REDUNDANCY));
|
object.setPayload("something");
|
||||||
|
s3Client.putObject(containerName, object, storageClass(storageClass));
|
||||||
|
|
||||||
S3Client s3Client = view.unwrapApi(S3Client.class);
|
|
||||||
ListBucketResponse response = s3Client.listBucket(containerName, withPrefix(blobName));
|
ListBucketResponse response = s3Client.listBucket(containerName, withPrefix(blobName));
|
||||||
|
|
||||||
ObjectMetadata metadata = response.iterator().next();
|
ObjectMetadata metadata = response.iterator().next();
|
||||||
assertEquals(metadata.getStorageClass(), StorageClass.REDUCED_REDUNDANCY);
|
assertThat(metadata.getStorageClass()).isEqualTo(storageClass);
|
||||||
|
}
|
||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
returnContainer(containerName);
|
returnContainer(containerName);
|
||||||
|
|
Loading…
Reference in New Issue