From 8bd59ef2e7c41457ef66d874c739ffb9a88aa96c Mon Sep 17 00:00:00 2001 From: YangSen-qn Date: Wed, 22 Jan 2025 14:21:51 +0800 Subject: [PATCH] support intelligent tiering --- .../com/qiniu/storage/model/FileInfo.java | 1 + .../com/qiniu/storage/model/StorageType.java | 5 ++ .../test/com/qiniu/storage/BucketTest2.java | 46 +++++++++++++++++++ 3 files changed, 52 insertions(+) diff --git a/src/main/java/com/qiniu/storage/model/FileInfo.java b/src/main/java/com/qiniu/storage/model/FileInfo.java index 8e5b83b42..1d26f9da1 100644 --- a/src/main/java/com/qiniu/storage/model/FileInfo.java +++ b/src/main/java/com/qiniu/storage/model/FileInfo.java @@ -54,6 +54,7 @@ public final class FileInfo { * 2 表示归档存储 * 3 表示深度归档存储 * 4 表示归档直读存储 + * 5 表示智能分层 */ public int type; diff --git a/src/main/java/com/qiniu/storage/model/StorageType.java b/src/main/java/com/qiniu/storage/model/StorageType.java index 2a2ff9fde..da0a45262 100644 --- a/src/main/java/com/qiniu/storage/model/StorageType.java +++ b/src/main/java/com/qiniu/storage/model/StorageType.java @@ -28,4 +28,9 @@ public enum StorageType { * 归档直读存储 */ ArchiveIR, + + /** + * 智能分层 + */ + IntelligentTiering, } diff --git a/src/test/java/test/com/qiniu/storage/BucketTest2.java b/src/test/java/test/com/qiniu/storage/BucketTest2.java index 4f97c5a88..6e578560d 100644 --- a/src/test/java/test/com/qiniu/storage/BucketTest2.java +++ b/src/test/java/test/com/qiniu/storage/BucketTest2.java @@ -68,6 +68,52 @@ public void testBuckets() { } } + @Test + @Tag("IntegrationTest") + public void testStorageTypeIntelligentTiering() { + String key = "storage_type_intelligent_tiering"; + String bucket = TestConfig.testBucket_z0; + + // 清理文件 + try { + Response response = bucketManager.delete(bucket, key); + assertTrue(response.isOK(), "response is not OK"); + } catch (QiniuException e) { + e.printStackTrace(); + fail(); + } + + // 上传文件 + try { + StringMap map = new StringMap(); + map.put("insertOnly", "1"); + uploadManager.put("aaa".getBytes(), key, TestConfig.testAuth.uploadToken(bucket), map, null, false); + } catch (QiniuException e) { + e.printStackTrace(); + fail(); + } + + // 修改文件修类型 + try { + Response resp = bucketManager.changeType(bucket, key, StorageType.IntelligentTiering); + assertTrue(resp.isOK(), "change type failed"); + } catch (QiniuException e) { + e.printStackTrace(); + fail(); + } + + // 验证文件类型 + try { + FileInfo fi = bucketManager.stat(bucket, key); + assertNotNull(fi, "stat failed"); + assertEquals(5, fi.type, "stat failed"); + assertEquals(fi.type, StorageType.IntelligentTiering.ordinal(), "stat failed"); + } catch (QiniuException e) { + e.printStackTrace(); + fail(); + } + } + /** * 测试列举空间域名 */