Skip to content

Commit 759f122

Browse files
Karthikeyanscb01
authored andcommitted
[S3] Add IntelligentTiering storage class (#755)
1 parent 8b08b50 commit 759f122

File tree

4 files changed

+120
-29
lines changed

4 files changed

+120
-29
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Change Log - AWS SDK for Android
22

3+
## [Release 2.12.2](https://github.com/aws/aws-sdk-android/releases/tag/release_v2.12.2)
4+
5+
### Misc. Updates
6+
7+
* Model updates for the following services
8+
* Amazon S3
9+
310
## [Release 2.12.1](https://github.com/aws/aws-sdk-android/releases/tag/release_v2.12.1)
411

512
### Bug Fixes

aws-android-sdk-s3-test/src/androidTest/java/com/amazonaws/services/s3/MultiThreadedDownloadIntegrationTest.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,15 @@
1515

1616
package com.amazonaws.services.s3;
1717

18+
import android.util.Log;
19+
1820
import static org.junit.Assert.assertTrue;
1921

2022
import com.amazonaws.services.s3.model.S3Object;
2123
import com.amazonaws.testutils.util.RandomTempFile;
2224

25+
import junit.framework.Assert;
26+
2327
import org.junit.After;
2428
import org.junit.Test;
2529

@@ -43,6 +47,8 @@
4347
*/
4448
public class MultiThreadedDownloadIntegrationTest extends S3IntegrationTestBase {
4549

50+
private static final String TAG = MultiThreadedDownloadIntegrationTest.class.getSimpleName();
51+
4652
/** The total number of GET object requests made to Amazon S3 */
4753
private static final int TOTAL_REQUESTS = 1000;
4854

@@ -63,10 +69,14 @@ public void tearDown() {
6369
try {
6470
s3.deleteObject(bucketName, key);
6571
} catch (Exception e) {
72+
Log.e(TAG, "Error in deleting the object: " + key);
73+
Assert.assertTrue("Error in deleting the object: " + key, false);
6674
}
6775
try {
6876
s3.deleteBucket(bucketName);
6977
} catch (Exception e) {
78+
Log.e(TAG, "Error in deleting the bucket: " + bucketName);
79+
Assert.assertTrue("Error in deleting the bucket: " + bucketName, false);
7080
}
7181
}
7282

aws-android-sdk-s3-test/src/androidTest/java/com/amazonaws/services/s3/StorageClassIntegrationTest.java

Lines changed: 92 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2010-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
* Copyright 2010-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -15,6 +15,9 @@
1515

1616
package com.amazonaws.services.s3;
1717

18+
import android.util.Log;
19+
20+
import static junit.framework.Assert.assertTrue;
1821
import static org.junit.Assert.assertEquals;
1922
import static org.junit.Assert.fail;
2023

@@ -27,65 +30,122 @@
2730
import com.amazonaws.services.s3.model.VersionListing;
2831
import com.amazonaws.testutils.util.RandomInputStream;
2932

30-
import org.junit.After;
33+
import org.junit.AfterClass;
34+
import org.junit.BeforeClass;
3135
import org.junit.Test;
3236

3337
/**
3438
* Integration test for S3 storage class related operations.
3539
*/
3640
public class StorageClassIntegrationTest extends S3IntegrationTestBase {
3741

38-
private String bucketName = "java-storage-class-integ-test-" + System.currentTimeMillis();
42+
private static final String BUCKET_NAME = "java-storage-class-integ-test-" + System.currentTimeMillis();
43+
44+
private static final String TAG = StorageClassIntegrationTest.class.getSimpleName();
45+
46+
@BeforeClass
47+
public static void setUp() {
48+
try {
49+
S3IntegrationTestBase.setUp();
50+
s3.createBucket(BUCKET_NAME);
51+
waitForBucketCreation(BUCKET_NAME);
52+
} catch (Exception ex) {
53+
Log.e(TAG, "Error in creating the bucket: " + BUCKET_NAME);
54+
assertTrue("Error in creating the bucket: " + BUCKET_NAME, false);
55+
}
56+
}
3957

4058
/**
4159
* Releases all resources allocated by this test.
4260
*/
43-
@After
44-
public void tearDown() throws Exception {
45-
deleteBucketAndAllVersionedContents(bucketName);
61+
@AfterClass
62+
public static void tearDown() {
63+
try {
64+
deleteBucketAndAllVersionedContents(BUCKET_NAME);
65+
} catch (Exception ex) {
66+
Log.e(TAG, "Error in deleting the bucket: " + BUCKET_NAME);
67+
}
4668
}
4769

4870
/**
4971
* Tests that we can change an object's storage class, upload objects in a
50-
* specific storage class, and retrive an object's storage class, both for
51-
* versioned and unversioned objects.
72+
* specific storage class, and retrieve an object's storage class, both for
73+
* versioned and non-versioned objects.
5274
*/
5375
@Test
5476
public void testStorageClasses() throws Exception {
55-
s3.createBucket(bucketName);
56-
5777
// Upload an object with standard storage
58-
putObject(bucketName, "key", StorageClass.Standard.toString());
59-
assertStorageClass(bucketName, "key", StorageClass.Standard);
78+
putObject(BUCKET_NAME, "key", StorageClass.Standard.toString());
79+
assertStorageClass(BUCKET_NAME, "key", StorageClass.Standard);
6080

6181
// Upload an object with reduced redundancy storage
62-
putObject(bucketName, "key", StorageClass.ReducedRedundancy.toString());
63-
assertStorageClass(bucketName, "key", StorageClass.ReducedRedundancy);
82+
putObject(BUCKET_NAME, "key", StorageClass.ReducedRedundancy.toString());
83+
assertStorageClass(BUCKET_NAME, "key", StorageClass.ReducedRedundancy);
6484

65-
// Move to regular storage
66-
s3.changeObjectStorageClass(bucketName, "key", StorageClass.Standard);
67-
assertStorageClass(bucketName, "key", StorageClass.Standard);
85+
// Move to Standard storage
86+
s3.changeObjectStorageClass(BUCKET_NAME, "key", StorageClass.Standard);
87+
assertStorageClass(BUCKET_NAME, "key", StorageClass.Standard);
6888

6989
// Move back to reduced redundancy storage
70-
s3.changeObjectStorageClass(bucketName, "key", StorageClass.ReducedRedundancy);
71-
assertStorageClass(bucketName, "key", StorageClass.ReducedRedundancy);
90+
s3.changeObjectStorageClass(BUCKET_NAME, "key", StorageClass.ReducedRedundancy);
91+
assertStorageClass(BUCKET_NAME, "key", StorageClass.ReducedRedundancy);
7292

7393
// Turn on versioning
7494
s3.setBucketVersioningConfiguration(new SetBucketVersioningConfigurationRequest(
75-
bucketName,
95+
BUCKET_NAME,
7696
new BucketVersioningConfiguration(BucketVersioningConfiguration.ENABLED)));
7797

7898
// Upload a new version with standard storage
79-
putObject(bucketName, "key", StorageClass.Standard.toString());
80-
assertStorageClass(bucketName, "key", StorageClass.Standard);
99+
putObject(BUCKET_NAME, "key", StorageClass.Standard.toString());
100+
assertStorageClass(BUCKET_NAME, "key", StorageClass.Standard);
81101

82102
// Move to reduced redundancy storage
83-
s3.changeObjectStorageClass(bucketName, "key", StorageClass.ReducedRedundancy);
84-
assertStorageClass(bucketName, "key", StorageClass.ReducedRedundancy);
103+
s3.changeObjectStorageClass(BUCKET_NAME, "key", StorageClass.ReducedRedundancy);
104+
assertStorageClass(BUCKET_NAME, "key", StorageClass.ReducedRedundancy);
85105

86106
// And move back to standard storage
87-
s3.changeObjectStorageClass(bucketName, "key", StorageClass.Standard);
88-
assertStorageClass(bucketName, "key", StorageClass.Standard);
107+
s3.changeObjectStorageClass(BUCKET_NAME, "key", StorageClass.Standard);
108+
assertStorageClass(BUCKET_NAME, "key", StorageClass.Standard);
109+
}
110+
111+
/**
112+
* Tests that we can change an object's storage class, upload objects in a
113+
* specific storage class, and retrive an object's storage class.
114+
*/
115+
@Test
116+
public void testStorageClasseIntelligentTiering() throws Exception {
117+
// Upload an object with IntelligentTiering storage
118+
putObject(BUCKET_NAME, "key", StorageClass.IntelligentTiering.toString());
119+
assertStorageClass(BUCKET_NAME, "key", StorageClass.IntelligentTiering);
120+
121+
// Upload an object with reduced redundancy storage
122+
putObject(BUCKET_NAME, "key", StorageClass.ReducedRedundancy.toString());
123+
assertStorageClass(BUCKET_NAME, "key", StorageClass.ReducedRedundancy);
124+
125+
// Move to Standard storage
126+
s3.changeObjectStorageClass(BUCKET_NAME, "key", StorageClass.Standard);
127+
assertStorageClass(BUCKET_NAME, "key", StorageClass.Standard);
128+
129+
// Move back to IntelligentTiering storage
130+
s3.changeObjectStorageClass(BUCKET_NAME, "key", StorageClass.IntelligentTiering);
131+
assertStorageClass(BUCKET_NAME, "key", StorageClass.IntelligentTiering);
132+
133+
// Turn on versioning
134+
s3.setBucketVersioningConfiguration(new SetBucketVersioningConfigurationRequest(
135+
BUCKET_NAME,
136+
new BucketVersioningConfiguration(BucketVersioningConfiguration.ENABLED)));
137+
138+
// Upload a new version with IntelligentTiering storage
139+
putObject(BUCKET_NAME, "key", StorageClass.IntelligentTiering.toString());
140+
assertStorageClass(BUCKET_NAME, "key", StorageClass.IntelligentTiering);
141+
142+
// Move to reduced redundancy storage
143+
s3.changeObjectStorageClass(BUCKET_NAME, "key", StorageClass.ReducedRedundancy);
144+
assertStorageClass(BUCKET_NAME, "key", StorageClass.ReducedRedundancy);
145+
146+
// And move back to IntelligentTiering storage
147+
s3.changeObjectStorageClass(BUCKET_NAME, "key", StorageClass.IntelligentTiering);
148+
assertStorageClass(BUCKET_NAME, "key", StorageClass.IntelligentTiering);
89149
}
90150

91151
/*
@@ -96,7 +156,9 @@ public void testStorageClasses() throws Exception {
96156
* Uploads some random test data to the object stored in the specified
97157
* bucket and key, and uses the specified storage class.
98158
*/
99-
private void putObject(String bucketName, String key, String storageClass) {
159+
private void putObject(String bucketName,
160+
String key,
161+
String storageClass) {
100162
ObjectMetadata metadata = new ObjectMetadata();
101163
metadata.setContentLength(1230);
102164
PutObjectRequest request = new PutObjectRequest(bucketName, key,
@@ -109,7 +171,9 @@ private void putObject(String bucketName, String key, String storageClass) {
109171
* Asserts that the latest version for the specified object is stored in the
110172
* expected storage class, otherwise this method fails the current test.
111173
*/
112-
private void assertStorageClass(String bucketName, String key, StorageClass expectedStorageClass)
174+
private void assertStorageClass(String bucketName,
175+
String key,
176+
StorageClass expectedStorageClass)
113177
throws Exception {
114178
// Short pause for eventual consistency
115179
Thread.sleep(1000 * 3);

aws-android-sdk-s3/src/main/java/com/amazonaws/services/s3/model/StorageClass.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,17 @@ public enum StorageClass {
6666
* One Zone Infrequent Access storage class stores object data in only one Availability Zone at a lower price than
6767
* STANDARD_IA.
6868
*/
69-
OneZoneInfrequentAccess("ONEZONE_IA")
69+
OneZoneInfrequentAccess("ONEZONE_IA"),
70+
71+
/**
72+
* IntelligentTiering makes it easy to lower your overall cost of storage by automatically placing data in the storage
73+
* class that best matches the access patterns for the storage. With IntelligentTiering, you don’t need to define
74+
* and manage individual policies for lifecycle data management or write code to transition objects
75+
* between storage classes. Instead, you can use IntelligentTiering to manage transitions between Standard and
76+
* S-IA without writing any application code. IntelligentTiering also manages transitions automatically to
77+
* Glacier for long term archive in addition to S3 storage classes.
78+
*/
79+
IntelligentTiering("INTELLIGENT_TIERING")
7080
;
7181

7282
/**

0 commit comments

Comments
 (0)