Skip to content

Commit 20e1ef1

Browse files
YangSen-qnYangSen-qn
and
YangSen-qn
authored
support intelligent tiering (#614)
Co-authored-by: YangSen-qn <yangsen@qiniu.com>
1 parent 63ac56c commit 20e1ef1

File tree

3 files changed

+52
-0
lines changed

3 files changed

+52
-0
lines changed

src/main/java/com/qiniu/storage/model/FileInfo.java

+1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ public final class FileInfo {
5454
* 2 表示归档存储
5555
* 3 表示深度归档存储
5656
* 4 表示归档直读存储
57+
* 5 表示智能分层
5758
*/
5859
public int type;
5960

src/main/java/com/qiniu/storage/model/StorageType.java

+5
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,9 @@ public enum StorageType {
2828
* 归档直读存储
2929
*/
3030
ArchiveIR,
31+
32+
/**
33+
* 智能分层
34+
*/
35+
IntelligentTiering,
3136
}

src/test/java/test/com/qiniu/storage/BucketTest2.java

+46
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,52 @@ public void testBuckets() {
6868
}
6969
}
7070

71+
@Test
72+
@Tag("IntegrationTest")
73+
public void testStorageTypeIntelligentTiering() {
74+
String key = "storage_type_intelligent_tiering";
75+
String bucket = TestConfig.testBucket_z0;
76+
77+
// 清理文件
78+
try {
79+
Response response = bucketManager.delete(bucket, key);
80+
assertTrue(response.isOK(), "response is not OK");
81+
} catch (QiniuException e) {
82+
e.printStackTrace();
83+
fail();
84+
}
85+
86+
// 上传文件
87+
try {
88+
StringMap map = new StringMap();
89+
map.put("insertOnly", "1");
90+
uploadManager.put("aaa".getBytes(), key, TestConfig.testAuth.uploadToken(bucket), map, null, false);
91+
} catch (QiniuException e) {
92+
e.printStackTrace();
93+
fail();
94+
}
95+
96+
// 修改文件修类型
97+
try {
98+
Response resp = bucketManager.changeType(bucket, key, StorageType.IntelligentTiering);
99+
assertTrue(resp.isOK(), "change type failed");
100+
} catch (QiniuException e) {
101+
e.printStackTrace();
102+
fail();
103+
}
104+
105+
// 验证文件类型
106+
try {
107+
FileInfo fi = bucketManager.stat(bucket, key);
108+
assertNotNull(fi, "stat failed");
109+
assertEquals(5, fi.type, "stat failed");
110+
assertEquals(fi.type, StorageType.IntelligentTiering.ordinal(), "stat failed");
111+
} catch (QiniuException e) {
112+
e.printStackTrace();
113+
fail();
114+
}
115+
}
116+
71117
/**
72118
* 测试列举空间域名
73119
*/

0 commit comments

Comments
 (0)