全部文档
当前文档

暂无内容

如果没有找到您期望的内容,请尝试其他搜索词

文档中心

管理存储空间 QOS 配置(Java)

最近更新时间:2025-10-30 20:20:48

设置存储空间 QOS 配置

以下代码用于设置存储空间 QOS 配置:

public void putBucketQos() {
    // 初始化 Ks3Client,参见“初始化”文档
    Ks3Client ks3Client = initKs3Client();

    try {
        // 创建 Quota 对象,设置 HDD 存储介质的配额(存储类型为标准及更冷类型的数据存储在 HDD 上),单位为Gb/s
        Quota normalQuota = new Quota();
        normalQuota.setStorageMedium(StorageMedium.Normal);
        normalQuota.setExtranetUploadBandwidth(1000L);
        normalQuota.setIntranetUploadBandwidth(800L);
        normalQuota.setExtranetDownloadBandwidth(500L);
        normalQuota.setIntranetDownloadBandwidth(400L);

        // 创建 Quota 对象,设置 SSD 存储介质的配额(存储类型为 EXTREME_* 的数据存储在 SSD 上),单位为Gb/s
        Quota extremeQuota = new Quota();
        extremeQuota.setStorageMedium(StorageMedium.Extreme);
        extremeQuota.setExtranetUploadBandwidth(2000L);
        extremeQuota.setIntranetUploadBandwidth(1600L);
        extremeQuota.setExtranetDownloadBandwidth(1000L);
        extremeQuota.setIntranetDownloadBandwidth(800L);

        // 创建 BucketQosConfiguration 对象,设置存储空间的 QOS 配置
        BucketQosConfiguration bucketQosConfiguration = new BucketQosConfiguration();
        bucketQosConfiguration.addQuota(normalQuota);
        bucketQosConfiguration.addQuota(extremeQuota);
        // 发起请求,设置存储空间的 QOS 配置
        ks3Client.putBucketQos("bucketName", bucketQosConfiguration);
    } catch (Ks3ServiceException e) {
        System.out.println("Ks3ServiceException occurred, which means the request was made to KS3, but KS3 returned an error response for some reason.");
        System.out.println("Error Message: " + e.getErrorMessage());
        System.out.println("Error Code: " + e.getErrorCode());
        System.out.println("Request ID: " + e.getRequestId());
    } catch (Ks3ClientException e) {
        System.out.println("Ks3ClientException occurred, which means the client encountered an internal error while trying to communicate with KS3.");
        System.out.println("Error Message: " + e.getMessage());
    } finally {
        // 不再使用时,关闭 Ks3Client
        ks3Client.shutdown();
    }
}

获取存储空间 QOS 配置

以下代码用于获取存储空间 QOS 配置:

public void getBucketQos() {
    // 初始化 Ks3Client,参见“初始化”文档
    Ks3Client ks3Client = initKs3Client();

    try {
        // 获取存储空间的 QOS 配置
        BucketQosConfiguration bucketQosConfiguration = ks3Client.getBucketQos("bucketName");
        for (Quota quota : bucketQosConfiguration.getQuotaList()) {
            System.out.println("Storage Medium: " + quota.getStorageMedium());
            System.out.println("Extranet Upload Bandwidth: " + quota.getExtranetUploadBandwidth());
            System.out.println("Intranet Upload Bandwidth: " + quota.getIntranetUploadBandwidth());
            System.out.println("Extranet Download Bandwidth: " + quota.getExtranetDownloadBandwidth());
            System.out.println("Intranet Download Bandwidth: " + quota.getIntranetDownloadBandwidth());
        }
    } catch (Ks3ServiceException e) {
        System.out.println("Ks3ServiceException occurred, which means the request was made to KS3, but KS3 returned an error response for some reason.");
        System.out.println("Error Message: " + e.getErrorMessage());
        System.out.println("Error Code: " + e.getErrorCode());
        System.out.println("Request ID: " + e.getRequestId());
    } catch (Ks3ClientException e) {
        System.out.println("Ks3ClientException occurred, which means the client encountered an internal error while trying to communicate with KS3.");
        System.out.println("Error Message: " + e.getMessage());
    } finally {
        // 不再使用时,关闭 Ks3Client
        ks3Client.shutdown();
    }
}

删除存储空间 QOS 配置

以下代码用于删除存储空间 QOS 配置:

public void deleteBucketQos() {
    // 初始化 Ks3Client,参见“初始化”文档
    Ks3Client ks3Client = initKs3Client();

    try {
        // 删除存储空间的 QOS 配置
        ks3Client.deleteBucketQos("bucketName");
    } catch (Ks3ServiceException e) {
        System.out.println("Ks3ServiceException occurred, which means the request was made to KS3, but KS3 returned an error response for some reason.");
        System.out.println("Error Message: " + e.getErrorMessage());
        System.out.println("Error Code: " + e.getErrorCode());
        System.out.println("Request ID: " + e.getRequestId());
    } catch (Ks3ClientException e) {
        System.out.println("Ks3ClientException occurred, which means the client encountered an internal error while trying to communicate with KS3.");
        System.out.println("Error Message: " + e.getMessage());
    } finally {
        // 不再使用时,关闭 Ks3Client
        ks3Client.shutdown();
    }
}

文档导读
纯净模式常规模式

纯净模式

点击可全屏预览文档内容
文档反馈