全部文档
当前文档

暂无内容

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

文档中心

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

最近更新时间:2026-11-03 19:37:39

设置存储空间 QoS 配置

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

public void putBucketQos() {
    // 初始化 Ks3Client,参见“初始化”文档
    Ks3Client ks3Client = initKs3Client();
    try {
        // HDD 存储介质的配额(标准及更冷类型存储在 HDD 上),单位 Gbps
        Quota normalQuota = new Quota();
        normalQuota.setStorageMedium(StorageMedium.Normal);
        normalQuota.setExtranetUploadBandwidth(10);
        normalQuota.setIntranetUploadBandwidth(8);
        normalQuota.setExtranetDownloadBandwidth(5);
        normalQuota.setIntranetDownloadBandwidth(4);
        // 内网上行与下行总带宽限速,单位 Gbps
        normalQuota.setIntranetTotalBandwidth(12);
        // 外网上行与下行总带宽限速,单位 Gbps
        normalQuota.setExtranetTotalBandwidth(15);

        // SSD 存储介质的配额(EXTREME_* 类型存储在 SSD 上),单位 Gbps
        Quota extremeQuota = new Quota();
        extremeQuota.setStorageMedium(StorageMedium.Extreme);
        extremeQuota.setExtranetUploadBandwidth(20);
        extremeQuota.setIntranetUploadBandwidth(16);
        extremeQuota.setExtranetDownloadBandwidth(10);
        extremeQuota.setIntranetDownloadBandwidth(8);
        extremeQuota.setIntranetTotalBandwidth(24);
        extremeQuota.setExtranetTotalBandwidth(30);

        BucketQosConfiguration bucketQosConfiguration = new BucketQosConfiguration();
        bucketQosConfiguration.addQuota(normalQuota);
        bucketQosConfiguration.addQuota(extremeQuota);

        ks3Client.putBucketQos("example-bucket", bucketQosConfiguration);
        System.out.println("存储空间 QoS 配置设置成功");
    } 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 {
        BucketQosConfiguration bucketQosConfiguration = ks3Client.getBucketQos("example-bucket");

        List<Quota> quotaList = bucketQosConfiguration.getQuotaList();
        if (quotaList == null || quotaList.isEmpty()) {
            System.out.println("该桶没有 QoS 配置");
            return;
        }

        for (Quota quota : quotaList) {
            System.out.println("StorageMedium: " + quota.getStorageMedium());
            System.out.println("ExtranetUploadBandwidth: " + quota.getExtranetUploadBandwidth());
            System.out.println("IntranetUploadBandwidth: " + quota.getIntranetUploadBandwidth());
            System.out.println("ExtranetDownloadBandwidth: " + quota.getExtranetDownloadBandwidth());
            System.out.println("IntranetDownloadBandwidth: " + quota.getIntranetDownloadBandwidth());
            System.out.println("OccupyExtranetUploadBandwidth: " + quota.getOccupyExtranetUploadBandwidth());
            System.out.println("OccupyIntranetUploadBandwidth: " + quota.getOccupyIntranetUploadBandwidth());
            System.out.println("OccupyExtranetDownloadBandwidth: " + quota.getOccupyExtranetDownloadBandwidth());
            System.out.println("OccupyIntranetDownloadBandwidth: " + quota.getOccupyIntranetDownloadBandwidth());
            System.out.println("IntranetTotalBandwidth: " + quota.getIntranetTotalBandwidth());
            System.out.println("ExtranetTotalBandwidth: " + quota.getExtranetTotalBandwidth());
        }
    } 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("example-bucket");
    } 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();
    }
}
文档导读
纯净模式常规模式

纯净模式

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