Resource pool QoS management (Java SDK V2)

Updated at:

Manage QoS configurations for resource pools, buckets, and requesters by using OSS Java SDK V2.

Usage notes

  • The sample code in this topic uses the region ID cn-hangzhou of the China (Hangzhou) region and the public endpoint by default. To access OSS from another Alibaba Cloud service that is deployed in the same region as OSS, use the internal endpoint. For more information about the mappings between the regions and endpoints supported by OSS, see Regions and endpoints.

Bucket bandwidth management

Set the QoS configuration for a bucket in a resource pool

package demo;
import com.aliyun.sdk.service.oss2.*;
import com.aliyun.sdk.service.oss2.credentials.*;
import com.aliyun.sdk.service.oss2.transport.BinaryData;
import java.util.*;
import java.nio.file.*;

public class PutBucketQoSInfo {
    public static void main(String[] args) throws Exception {
        // Specify the region in which the bucket is located. In this example, the bucket is located in the China (Hangzhou) region, whose region ID is cn-hangzhou.
        String region = "cn-hangzhou";
        // Create an OSS client by using the access credentials obtained from environment variables and the specified region
        try (OSSClient client = OSSClient.newBuilder()
                .region(region)
                .credentialsProvider(new EnvironmentVariableCredentialsProvider())
                .build()) {
            // Specify the name of the bucket
            String bucketName = "examplebucket";
            // Read the content of the QoS configuration file
            byte[] data = Files.readAllBytes(Paths.get("qos.xml"));
            // Configure the request parameters
            Map<String, String> parameters = new HashMap<>();
            parameters.put("qosInfo", "");
            // Create the operation input, which includes the operation name, HTTP method, and request parameters
            OperationInput input = OperationInput.newBuilder()
                    .opName("PutBucketQoSInfo")
                    .method("PUT")
                    .bucket(bucketName)
                    .parameters(parameters)
                    .body(BinaryData.fromBytes(data))
                    .build();
            // Send the operation request
            OperationOutput output = client.invokeOperation(input, OperationOptions.defaults());
            // Print the operation result (HTTP status code)
            System.out.println("The result of PutBucketQoSInfo: " + output.statusCode());
        }
    }
}

The following example shows the content of the qos.xml file:

<QoSConfiguration>
  <TotalUploadBandwidth>100</TotalUploadBandwidth>
  <IntranetUploadBandwidth>-1</IntranetUploadBandwidth>
  <ExtranetUploadBandwidth>20</ExtranetUploadBandwidth>
  <TotalDownloadBandwidth>100</TotalDownloadBandwidth>
  <IntranetDownloadBandwidth>-1</IntranetDownloadBandwidth>
  <ExtranetDownloadBandwidth>20</ExtranetDownloadBandwidth>
  <TotalQps>10000</TotalQps>
  <IntranetQps>-1</IntranetQps>
  <ExtranetQps>-1</ExtranetQps>
</QoSConfiguration>

Query the QoS configuration of a bucket

package demo;
import com.aliyun.sdk.service.oss2.*;
import com.aliyun.sdk.service.oss2.credentials.*;
import java.util.*;

public class GetBucketQoSInfo {
    public static void main(String[] args) throws Exception {
        // Specify the region in which the bucket is located. In this example, the bucket is located in the China (Hangzhou) region, whose region ID is cn-hangzhou.
        String region = "cn-hangzhou";
        // Create an OSS client by using the access credentials obtained from environment variables and the specified region
        try (OSSClient client = OSSClient.newBuilder()
                .region(region)
                .credentialsProvider(new EnvironmentVariableCredentialsProvider())
                .build()) {
            // Specify the name of the bucket
            String bucketName = "examplebucket";
            // Configure the request parameters
            Map<String, String> parameters = new HashMap<>();
            parameters.put("qosInfo", "");
            // Create the operation input, which includes the operation name, HTTP method, and request parameters
            OperationInput input = OperationInput.newBuilder()
                    .opName("GetBucketQoSInfo")
                    .method("GET")
                    .bucket(bucketName)
                    .parameters(parameters)
                    .build();
            // Send the operation request
            OperationOutput output = client.invokeOperation(input, OperationOptions.defaults());
            // Read and print the content of the response body
            String body = output.body().map(Object::toString).orElse("");
            System.out.println("The result of GetBucketQoSInfo: " + body);
        }
    }
}

Delete the QoS configuration of a bucket in a resource pool

package demo;
import com.aliyun.sdk.service.oss2.*;
import com.aliyun.sdk.service.oss2.credentials.*;
import java.util.*;

public class DeleteBucketQoSInfo {
    public static void main(String[] args) throws Exception {
        // Specify the region in which the bucket is located. In this example, the bucket is located in the China (Hangzhou) region, whose region ID is cn-hangzhou.
        String region = "cn-hangzhou";
        // Create an OSS client by using the access credentials obtained from environment variables and the specified region
        try (OSSClient client = OSSClient.newBuilder()
                .region(region)
                .credentialsProvider(new EnvironmentVariableCredentialsProvider())
                .build()) {
            // Specify the name of the bucket
            String bucketName = "examplebucket";
            // Configure the request parameters
            Map<String, String> parameters = new HashMap<>();
            parameters.put("qosInfo", "");
            // Create the operation input, which includes the operation name, HTTP method, and request parameters
            OperationInput input = OperationInput.newBuilder()
                    .opName("DeleteBucketQoSInfo")
                    .method("DELETE")
                    .bucket(bucketName)
                    .parameters(parameters)
                    .build();
            // Send the operation request
            OperationOutput output = client.invokeOperation(input, OperationOptions.defaults());
            // Print the operation result (HTTP status code)
            System.out.println("The result of DeleteBucketQoSInfo: " + output.statusCode());
        }
    }
}

Bandwidth management by requester at the bucket level

Set the QoS configuration for a requester at the bucket level

package demo;
import com.aliyun.sdk.service.oss2.*;
import com.aliyun.sdk.service.oss2.credentials.*;
import com.aliyun.sdk.service.oss2.transport.BinaryData;
import java.util.*;
import java.nio.file.*;

public class PutBucketRequesterQoSInfo {
    public static void main(String[] args) throws Exception {
        // Specify the region in which the bucket is located. In this example, the bucket is located in the China (Hangzhou) region, whose region ID is cn-hangzhou.
        String region = "cn-hangzhou";
        // Create an OSS client by using the access credentials obtained from environment variables and the specified region
        try (OSSClient client = OSSClient.newBuilder()
                .region(region)
                .credentialsProvider(new EnvironmentVariableCredentialsProvider())
                .build()) {
            // Specify the name of the bucket
            String bucketName = "examplebucket";
            // Read the content of the QoS configuration file
            byte[] data = Files.readAllBytes(Paths.get("qos.xml"));
            // Configure the request parameters
            Map<String, String> parameters = new HashMap<>();
            parameters.put("requesterQosInfo", "");
            // Create the operation input, which includes the operation name, HTTP method, and request parameters
            OperationInput input = OperationInput.newBuilder()
                    .opName("PutBucketRequesterQoSInfo")
                    .method("PUT")
                    .bucket(bucketName)
                    .parameters(parameters)
                    .body(BinaryData.fromBytes(data))
                    .build();
            // Send the operation request
            OperationOutput output = client.invokeOperation(input, OperationOptions.defaults());
            // Print the operation result (HTTP status code)
            System.out.println("The result of PutBucketRequesterQoSInfo: " + output.statusCode());
        }
    }
}

The following example shows the content of the qos.xml file:

<QoSConfiguration>
  <TotalUploadBandwidth>100</TotalUploadBandwidth>
  <IntranetUploadBandwidth>-1</IntranetUploadBandwidth>
  <ExtranetUploadBandwidth>20</ExtranetUploadBandwidth>
  <TotalDownloadBandwidth>100</TotalDownloadBandwidth>
  <IntranetDownloadBandwidth>-1</IntranetDownloadBandwidth>
  <ExtranetDownloadBandwidth>20</ExtranetDownloadBandwidth>
  <TotalQps>10000</TotalQps>
  <IntranetQps>-1</IntranetQps>
  <ExtranetQps>-1</ExtranetQps>
</QoSConfiguration>

Query the QoS configuration of a specific requester at the bucket level

package demo;
import com.aliyun.sdk.service.oss2.*;
import com.aliyun.sdk.service.oss2.credentials.*;
import java.util.*;

public class GetBucketRequesterQoSInfo {
    public static void main(String[] args) throws Exception {
        // Specify the region in which the bucket is located. In this example, the bucket is located in the China (Hangzhou) region, whose region ID is cn-hangzhou.
        String region = "cn-hangzhou";
        // Create an OSS client by using the access credentials obtained from environment variables and the specified region
        try (OSSClient client = OSSClient.newBuilder()
                .region(region)
                .credentialsProvider(new EnvironmentVariableCredentialsProvider())
                .build()) {
            // Specify the name of the bucket
            String bucketName = "examplebucket";
            // Configure the request parameters
            Map<String, String> parameters = new HashMap<>();
            parameters.put("requesterQosInfo", "");
            // Create the operation input, which includes the operation name, HTTP method, and request parameters
            OperationInput input = OperationInput.newBuilder()
                    .opName("GetBucketRequesterQoSInfo")
                    .method("GET")
                    .bucket(bucketName)
                    .parameters(parameters)
                    .build();
            // Send the operation request
            OperationOutput output = client.invokeOperation(input, OperationOptions.defaults());
            // Read and print the content of the response body
            String body = output.body().map(Object::toString).orElse("");
            System.out.println("The result of GetBucketRequesterQoSInfo: " + body);
        }
    }
}

Query the QoS configurations of all requesters at the bucket level

package demo;
import com.aliyun.sdk.service.oss2.*;
import com.aliyun.sdk.service.oss2.credentials.*;
import java.util.*;

public class ListBucketRequesterQoSInfos {
    public static void main(String[] args) throws Exception {
        // Specify the region in which the bucket is located. In this example, the bucket is located in the China (Hangzhou) region, whose region ID is cn-hangzhou.
        String region = "cn-hangzhou";
        // Create an OSS client by using the access credentials obtained from environment variables and the specified region
        try (OSSClient client = OSSClient.newBuilder()
                .region(region)
                .credentialsProvider(new EnvironmentVariableCredentialsProvider())
                .build()) {
            // Specify the name of the bucket
            String bucketName = "examplebucket";
            // Configure the request parameters
            Map<String, String> parameters = new HashMap<>();
            parameters.put("requesterQosInfo", "");
            parameters.put("continuation-token", "25987311111111xxxx");
            parameters.put("max-keys", "1");
            // Create the operation input, which includes the operation name, HTTP method, and request parameters
            OperationInput input = OperationInput.newBuilder()
                    .opName("ListBucketRequesterQoSInfos")
                    .method("GET")
                    .bucket(bucketName)
                    .parameters(parameters)
                    .build();
            // Send the operation request
            OperationOutput output = client.invokeOperation(input, OperationOptions.defaults());
            // Read and print the content of the response body
            String body = output.body().map(Object::toString).orElse("");
            System.out.println("The result of ListBucketRequesterQoSInfos: " + body);
        }
    }
}

Delete the QoS configuration of a requester for a bucket

package demo;
import com.aliyun.sdk.service.oss2.*;
import com.aliyun.sdk.service.oss2.credentials.*;
import java.util.*;

public class DeleteBucketRequesterQoSInfo {
    public static void main(String[] args) throws Exception {
        // Specify the region in which the bucket is located. In this example, the bucket is located in the China (Hangzhou) region, whose region ID is cn-hangzhou.
        String region = "cn-hangzhou";
        // Create an OSS client by using the access credentials obtained from environment variables and the specified region
        try (OSSClient client = OSSClient.newBuilder()
                .region(region)
                .credentialsProvider(new EnvironmentVariableCredentialsProvider())
                .build()) {
            // Specify the name of the bucket
            String bucketName = "examplebucket";
            // Configure the request parameters
            Map<String, String> parameters = new HashMap<>();
            parameters.put("requesterQosInfo", "");
            // Create the operation input, which includes the operation name, HTTP method, and request parameters
            OperationInput input = OperationInput.newBuilder()
                    .opName("DeleteBucketRequesterQoSInfo")
                    .method("DELETE")
                    .bucket(bucketName)
                    .parameters(parameters)
                    .build();
            // Send the operation request
            OperationOutput output = client.invokeOperation(input, OperationOptions.defaults());
            // Print the operation result (HTTP status code)
            System.out.println("The result of DeleteBucketRequesterQoSInfo: " + output.statusCode());
        }
    }
}

Bandwidth management by requester at the resource pool level

Query all resource pools within the current account

package demo;
import com.aliyun.sdk.service.oss2.*;
import com.aliyun.sdk.service.oss2.credentials.*;
import java.util.*;

public class ListResourcePools {
    public static void main(String[] args) throws Exception {
        // Specify the region in which the bucket is located. In this example, the bucket is located in the China (Hangzhou) region, whose region ID is cn-hangzhou.
        String region = "cn-hangzhou";
        // Create an OSS client by using the access credentials obtained from environment variables and the specified region
        try (OSSClient client = OSSClient.newBuilder()
                .region(region)
                .credentialsProvider(new EnvironmentVariableCredentialsProvider())
                .build()) {
            // Configure the request parameters
            Map<String, String> parameters = new HashMap<>();
            parameters.put("resourcePool", "");
            parameters.put("continuation-token", "example-resource-pool");
            parameters.put("max-keys", "1");
            // Create the operation input, which includes the operation name, HTTP method, and request parameters
            OperationInput input = OperationInput.newBuilder()
                    .opName("ListResourcePools")
                    .method("GET")
                    .parameters(parameters)
                    .build();
            // Send the operation request
            OperationOutput output = client.invokeOperation(input, OperationOptions.defaults());
            // Read and print the content of the response body
            String body = output.body().map(Object::toString).orElse("");
            System.out.println("The result of ListResourcePools: " + body);
        }
    }
}

Query the details of a resource pool

package demo;
import com.aliyun.sdk.service.oss2.*;
import com.aliyun.sdk.service.oss2.credentials.*;
import java.util.*;

public class GetResourcePoolInfo {
    public static void main(String[] args) throws Exception {
        // Specify the region in which the bucket is located. In this example, the bucket is located in the China (Hangzhou) region, whose region ID is cn-hangzhou.
        String region = "cn-hangzhou";
        // Create an OSS client by using the access credentials obtained from environment variables and the specified region
        try (OSSClient client = OSSClient.newBuilder()
                .region(region)
                .credentialsProvider(new EnvironmentVariableCredentialsProvider())
                .build()) {
            // Configure the request parameters
            Map<String, String> parameters = new HashMap<>();
            parameters.put("resourcePoolInfo", "");
            parameters.put("resourcePool", "example-resource-pool");
            // Create the operation input, which includes the operation name, HTTP method, and request parameters
            OperationInput input = OperationInput.newBuilder()
                    .opName("GetResourcePoolInfo")
                    .method("GET")
                    .parameters(parameters)
                    .build();
            // Send the operation request
            OperationOutput output = client.invokeOperation(input, OperationOptions.defaults());
            // Read and print the content of the response body
            String body = output.body().map(Object::toString).orElse("");
            System.out.println("The result of GetResourcePoolInfo: " + body);
        }
    }
}

List the buckets in a resource pool

package demo;
import com.aliyun.sdk.service.oss2.*;
import com.aliyun.sdk.service.oss2.credentials.*;
import java.util.*;

public class ListResourcePoolBucketGroups {
    public static void main(String[] args) throws Exception {
        // Specify the region in which the bucket is located. In this example, the bucket is located in the China (Hangzhou) region, whose region ID is cn-hangzhou.
        String region = "cn-hangzhou";
        // Create an OSS client by using the access credentials obtained from environment variables and the specified region
        try (OSSClient client = OSSClient.newBuilder()
                .region(region)
                .credentialsProvider(new EnvironmentVariableCredentialsProvider())
                .build()) {
            // Configure the request parameters
            Map<String, String> parameters = new HashMap<>();
            parameters.put("resourcePool", "example-resource-pool");
            // Create the operation input, which includes the operation name, HTTP method, and request parameters
            OperationInput input = OperationInput.newBuilder()
                    .opName("ListResourcePoolBucketGroups")
                    .method("GET")
                    .parameters(parameters)
                    .build();
            // Send the operation request
            OperationOutput output = client.invokeOperation(input, OperationOptions.defaults());
            // Read and print the content of the response body
            String body = output.body().map(Object::toString).orElse("");
            System.out.println("The result of ListResourcePoolBucketGroups: " + body);
        }
    }
}

Set the QoS configuration for a requester in a resource pool

package demo;
import com.aliyun.sdk.service.oss2.*;
import com.aliyun.sdk.service.oss2.credentials.*;
import com.aliyun.sdk.service.oss2.transport.BinaryData;
import java.util.*;
import java.nio.file.*;

public class PutResourcePoolRequesterQoSInfo {
    public static void main(String[] args) throws Exception {
        // Specify the region in which the bucket is located. In this example, the bucket is located in the China (Hangzhou) region, whose region ID is cn-hangzhou.
        String region = "cn-hangzhou";
        // Create an OSS client by using the access credentials obtained from environment variables and the specified region
        try (OSSClient client = OSSClient.newBuilder()
                .region(region)
                .credentialsProvider(new EnvironmentVariableCredentialsProvider())
                .build()) {
            // Read the content of the QoS configuration file
            byte[] data = Files.readAllBytes(Paths.get("qos.xml"));
            // Configure the request parameters
            Map<String, String> parameters = new HashMap<>();
            parameters.put("requesterQosInfo", "");
            // Create the operation input, which includes the operation name, HTTP method, and request parameters
            OperationInput input = OperationInput.newBuilder()
                    .opName("PutResourcePoolRequesterQoSInfo")
                    .method("PUT")
                    .parameters(parameters)
                    .body(BinaryData.fromBytes(data))
                    .build();
            // Send the operation request
            OperationOutput output = client.invokeOperation(input, OperationOptions.defaults());
            // Print the operation result (HTTP status code)
            System.out.println("The result of PutResourcePoolRequesterQoSInfo: " + output.statusCode());
        }
    }
}

The following example shows the content of the qos.xml file:

<QoSConfiguration>
  <TotalUploadBandwidth>100</TotalUploadBandwidth>
  <IntranetUploadBandwidth>-1</IntranetUploadBandwidth>
  <ExtranetUploadBandwidth>20</ExtranetUploadBandwidth>
  <TotalDownloadBandwidth>100</TotalDownloadBandwidth>
  <IntranetDownloadBandwidth>-1</IntranetDownloadBandwidth>
  <ExtranetDownloadBandwidth>20</ExtranetDownloadBandwidth>
  <TotalQps>10000</TotalQps>
  <IntranetQps>-1</IntranetQps>
  <ExtranetQps>-1</ExtranetQps>
</QoSConfiguration>

Query the QoS configuration of a specific requester in a resource pool

package demo;
import com.aliyun.sdk.service.oss2.*;
import com.aliyun.sdk.service.oss2.credentials.*;
import java.util.*;

public class GetResourcePoolRequesterQoSInfo {
    public static void main(String[] args) throws Exception {
        // Specify the region in which the bucket is located. In this example, the bucket is located in the China (Hangzhou) region, whose region ID is cn-hangzhou.
        String region = "cn-hangzhou";
        // Create an OSS client by using the access credentials obtained from environment variables and the specified region
        try (OSSClient client = OSSClient.newBuilder()
                .region(region)
                .credentialsProvider(new EnvironmentVariableCredentialsProvider())
                .build()) {
            // Configure the request parameters
            Map<String, String> parameters = new HashMap<>();
            parameters.put("requesterQosInfo", "");
            // Create the operation input, which includes the operation name, HTTP method, and request parameters
            OperationInput input = OperationInput.newBuilder()
                    .opName("GetResourcePoolRequesterQoSInfo")
                    .method("GET")
                    .parameters(parameters)
                    .build();
            // Send the operation request
            OperationOutput output = client.invokeOperation(input, OperationOptions.defaults());
            // Read and print the content of the response body
            String body = output.body().map(Object::toString).orElse("");
            System.out.println("The result of GetResourcePoolRequesterQoSInfo: " + body);
        }
    }
}

Query the QoS configurations of all requesters in a resource pool

package demo;
import com.aliyun.sdk.service.oss2.*;
import com.aliyun.sdk.service.oss2.credentials.*;
import java.util.*;

public class ListResourcePoolRequesterQoSInfos {
    public static void main(String[] args) throws Exception {
        // Specify the region in which the bucket is located. In this example, the bucket is located in the China (Hangzhou) region, whose region ID is cn-hangzhou.
        String region = "cn-hangzhou";
        // Create an OSS client by using the access credentials obtained from environment variables and the specified region
        try (OSSClient client = OSSClient.newBuilder()
                .region(region)
                .credentialsProvider(new EnvironmentVariableCredentialsProvider())
                .build()) {
            // Configure the request parameters
            Map<String, String> parameters = new HashMap<>();
            parameters.put("requesterQosInfo", "");
            parameters.put("continuation-token", "25987311111111xxxx");
            parameters.put("max-keys", "1");
            // Create the operation input, which includes the operation name, HTTP method, and request parameters
            OperationInput input = OperationInput.newBuilder()
                    .opName("ListResourcePoolRequesterQoSInfos")
                    .method("GET")
                    .parameters(parameters)
                    .build();
            // Send the operation request
            OperationOutput output = client.invokeOperation(input, OperationOptions.defaults());
            // Read and print the content of the response body
            String body = output.body().map(Object::toString).orElse("");
            System.out.println("The result of ListResourcePoolRequesterQoSInfos: " + body);
        }
    }
}

Delete the QoS configuration of a requester for a resource pool

package demo;
import com.aliyun.sdk.service.oss2.*;
import com.aliyun.sdk.service.oss2.credentials.*;
import java.util.*;

public class DeleteResourcePoolRequesterQoSInfo {
    public static void main(String[] args) throws Exception {
        // Specify the region in which the bucket is located. In this example, the bucket is located in the China (Hangzhou) region, whose region ID is cn-hangzhou.
        String region = "cn-hangzhou";
        // Create an OSS client by using the access credentials obtained from environment variables and the specified region
        try (OSSClient client = OSSClient.newBuilder()
                .region(region)
                .credentialsProvider(new EnvironmentVariableCredentialsProvider())
                .build()) {
            // Configure the request parameters
            Map<String, String> parameters = new HashMap<>();
            parameters.put("requesterQosInfo", "");
            // Create the operation input, which includes the operation name, HTTP method, and request parameters
            OperationInput input = OperationInput.newBuilder()
                    .opName("DeleteResourcePoolRequesterQoSInfo")
                    .method("DELETE")
                    .parameters(parameters)
                    .build();
            // Send the operation request
            OperationOutput output = client.invokeOperation(input, OperationOptions.defaults());
            // Print the operation result (HTTP status code)
            System.out.println("The result of DeleteResourcePoolRequesterQoSInfo: " + output.statusCode());
        }
    }
}

Priority QoS management for resource pools

Set the priority QoS configuration for a resource pool

package demo;
import com.aliyun.sdk.service.oss2.*;
import com.aliyun.sdk.service.oss2.credentials.*;
import com.aliyun.sdk.service.oss2.transport.BinaryData;
import java.util.*;
import java.nio.file.*;

public class PutResourcePoolPriorityQoSConfiguration {
    public static void main(String[] args) throws Exception {
        // Specify the region in which the bucket is located. In this example, the bucket is located in the China (Hangzhou) region, whose region ID is cn-hangzhou.
        String region = "cn-hangzhou";
        // Create an OSS client by using the access credentials obtained from environment variables and the specified region
        try (OSSClient client = OSSClient.newBuilder()
                .region(region)
                .credentialsProvider(new EnvironmentVariableCredentialsProvider())
                .build()) {
            // Read the content of the QoS configuration file
            byte[] data = Files.readAllBytes(Paths.get("priority-qos.xml"));
            // Configure the request parameters
            Map<String, String> parameters = new HashMap<>();
            parameters.put("priorityQos", "");
            // Create the operation input, which includes the operation name, HTTP method, and request parameters
            OperationInput input = OperationInput.newBuilder()
                    .opName("PutResourcePoolPriorityQoSConfiguration")
                    .method("PUT")
                    .parameters(parameters)
                    .body(BinaryData.fromBytes(data))
                    .build();
            // Send the operation request
            OperationOutput output = client.invokeOperation(input, OperationOptions.defaults());
            // Print the operation result (HTTP status code)
            System.out.println("The result of PutResourcePoolPriorityQoSConfiguration: " + output.statusCode());
        }
    }
}

Query the priority QoS configuration of a resource pool

package demo;
import com.aliyun.sdk.service.oss2.*;
import com.aliyun.sdk.service.oss2.credentials.*;
import java.util.*;

public class GetResourcePoolPriorityQoSConfiguration {
    public static void main(String[] args) throws Exception {
        // Specify the region in which the bucket is located. In this example, the bucket is located in the China (Hangzhou) region, whose region ID is cn-hangzhou.
        String region = "cn-hangzhou";
        // Create an OSS client by using the access credentials obtained from environment variables and the specified region
        try (OSSClient client = OSSClient.newBuilder()
                .region(region)
                .credentialsProvider(new EnvironmentVariableCredentialsProvider())
                .build()) {
            // Configure the request parameters
            Map<String, String> parameters = new HashMap<>();
            parameters.put("priorityQos", "");
            // Create the operation input, which includes the operation name, HTTP method, and request parameters
            OperationInput input = OperationInput.newBuilder()
                    .opName("GetResourcePoolPriorityQoSConfiguration")
                    .method("GET")
                    .parameters(parameters)
                    .build();
            // Send the operation request
            OperationOutput output = client.invokeOperation(input, OperationOptions.defaults());
            // Read and print the content of the response body
            String body = output.body().map(Object::toString).orElse("");
            System.out.println("The result of GetResourcePoolPriorityQoSConfiguration: " + body);
        }
    }
}

Delete the priority QoS configuration of a resource pool

package demo;
import com.aliyun.sdk.service.oss2.*;
import com.aliyun.sdk.service.oss2.credentials.*;
import com.aliyun.sdk.service.oss2.transport.BinaryData;
import java.util.*;
import java.nio.file.*;

public class DeleteResourcePoolPriorityQosConfiguration {
    public static void main(String[] args) throws Exception {
        // Specify the region in which the bucket is located. In this example, the bucket is located in the China (Hangzhou) region, whose region ID is cn-hangzhou.
        String region = "cn-hangzhou";
        // Create an OSS client by using the access credentials obtained from environment variables and the specified region
        try (OSSClient client = OSSClient.newBuilder()
                .region(region)
                .credentialsProvider(new EnvironmentVariableCredentialsProvider())
                .build()) {
            // Read the content of the QoS configuration file
            byte[] data = Files.readAllBytes(Paths.get("priority-qos.xml"));
            // Configure the request parameters
            Map<String, String> parameters = new HashMap<>();
            parameters.put("priorityQos", "");
            // Create the operation input, which includes the operation name, HTTP method, and request parameters
            OperationInput input = OperationInput.newBuilder()
                    .opName("DeleteResourcePoolPriorityQosConfiguration")
                    .method("DELETE")
                    .parameters(parameters)
                    .body(BinaryData.fromBytes(data))
                    .build();
            // Send the operation request
            OperationOutput output = client.invokeOperation(input, OperationOptions.defaults());
            // Print the operation result (HTTP status code)
            System.out.println("The result of DeleteResourcePoolPriorityQosConfiguration: " + output.statusCode());
        }
    }
}

Set the priority QoS configuration for a requester in a resource pool

package demo;
import com.aliyun.sdk.service.oss2.*;
import com.aliyun.sdk.service.oss2.credentials.*;
import com.aliyun.sdk.service.oss2.transport.BinaryData;
import java.util.*;
import java.nio.file.*;

public class PutResourcePoolRequesterPriorityQoSConfiguration {
    public static void main(String[] args) throws Exception {
        // Specify the region in which the bucket is located. In this example, the bucket is located in the China (Hangzhou) region, whose region ID is cn-hangzhou.
        String region = "cn-hangzhou";
        // Create an OSS client by using the access credentials obtained from environment variables and the specified region
        try (OSSClient client = OSSClient.newBuilder()
                .region(region)
                .credentialsProvider(new EnvironmentVariableCredentialsProvider())
                .build()) {
            // Read the content of the QoS configuration file
            byte[] data = Files.readAllBytes(Paths.get("requester-priority-qos.xml"));
            // Configure the request parameters
            Map<String, String> parameters = new HashMap<>();
            parameters.put("requesterPriorityQos", "");
            // Create the operation input, which includes the operation name, HTTP method, and request parameters
            OperationInput input = OperationInput.newBuilder()
                    .opName("PutResourcePoolRequesterPriorityQoSConfiguration")
                    .method("PUT")
                    .parameters(parameters)
                    .body(BinaryData.fromBytes(data))
                    .build();
            // Send the operation request
            OperationOutput output = client.invokeOperation(input, OperationOptions.defaults());
            // Print the operation result (HTTP status code)
            System.out.println("The result of PutResourcePoolRequesterPriorityQoSConfiguration: " + output.statusCode());
        }
    }
}

Query the priority QoS configuration of a requester in a resource pool

package demo;
import com.aliyun.sdk.service.oss2.*;
import com.aliyun.sdk.service.oss2.credentials.*;
import java.util.*;

public class GetResourcePoolRequesterPriorityQoSConfiguration {
    public static void main(String[] args) throws Exception {
        // Specify the region in which the bucket is located. In this example, the bucket is located in the China (Hangzhou) region, whose region ID is cn-hangzhou.
        String region = "cn-hangzhou";
        // Create an OSS client by using the access credentials obtained from environment variables and the specified region
        try (OSSClient client = OSSClient.newBuilder()
                .region(region)
                .credentialsProvider(new EnvironmentVariableCredentialsProvider())
                .build()) {
            // Configure the request parameters
            Map<String, String> parameters = new HashMap<>();
            parameters.put("requesterPriorityQos", "");
            // Create the operation input, which includes the operation name, HTTP method, and request parameters
            OperationInput input = OperationInput.newBuilder()
                    .opName("GetResourcePoolRequesterPriorityQoSConfiguration")
                    .method("GET")
                    .parameters(parameters)
                    .build();
            // Send the operation request
            OperationOutput output = client.invokeOperation(input, OperationOptions.defaults());
            // Read and print the content of the response body
            String body = output.body().map(Object::toString).orElse("");
            System.out.println("The result of GetResourcePoolRequesterPriorityQoSConfiguration: " + body);
        }
    }
}

Delete the priority QoS configuration of a requester in a resource pool

package demo;
import com.aliyun.sdk.service.oss2.*;
import com.aliyun.sdk.service.oss2.credentials.*;
import com.aliyun.sdk.service.oss2.transport.BinaryData;
import java.util.*;
import java.nio.file.*;

public class DeleteResourcePoolRequesterPriorityQoSConfiguration {
    public static void main(String[] args) throws Exception {
        // Specify the region in which the bucket is located. In this example, the bucket is located in the China (Hangzhou) region, whose region ID is cn-hangzhou.
        String region = "cn-hangzhou";
        // Create an OSS client by using the access credentials obtained from environment variables and the specified region
        try (OSSClient client = OSSClient.newBuilder()
                .region(region)
                .credentialsProvider(new EnvironmentVariableCredentialsProvider())
                .build()) {
            // Read the content of the QoS configuration file
            byte[] data = Files.readAllBytes(Paths.get("priority-qos.xml"));
            // Configure the request parameters
            Map<String, String> parameters = new HashMap<>();
            parameters.put("requesterPriorityQos", "");
            // Create the operation input, which includes the operation name, HTTP method, and request parameters
            OperationInput input = OperationInput.newBuilder()
                    .opName("DeleteResourcePoolRequesterPriorityQoSConfiguration")
                    .method("DELETE")
                    .parameters(parameters)
                    .body(BinaryData.fromBytes(data))
                    .build();
            // Send the operation request
            OperationOutput output = client.invokeOperation(input, OperationOptions.defaults());
            // Print the operation result (HTTP status code)
            System.out.println("The result of DeleteResourcePoolRequesterPriorityQoSConfiguration: " + output.statusCode());
        }
    }
}

Bucket group bandwidth management

Add a bucket in a resource pool to a specific bucket group

package demo;
import com.aliyun.sdk.service.oss2.*;
import com.aliyun.sdk.service.oss2.credentials.*;
import java.util.*;

public class PutBucketResourcePoolBucketGroup {
    public static void main(String[] args) throws Exception {
        // Specify the region in which the bucket is located. In this example, the bucket is located in the China (Hangzhou) region, whose region ID is cn-hangzhou.
        String region = "cn-hangzhou";
        // Create an OSS client by using the access credentials obtained from environment variables and the specified region
        try (OSSClient client = OSSClient.newBuilder()
                .region(region)
                .credentialsProvider(new EnvironmentVariableCredentialsProvider())
                .build()) {
            // Specify the name of the bucket
            String bucketName = "examplebucket";
            // Configure the request parameters
            Map<String, String> parameters = new HashMap<>();
            parameters.put("resourcePoolBucketGroup", "example-group");
            parameters.put("resourcePool", "example-resource-pool");
            // Create the operation input, which includes the operation name, HTTP method, and request parameters
            OperationInput input = OperationInput.newBuilder()
                    .opName("PutBucketResourcePoolBucketGroup")
                    .method("PUT")
                    .bucket(bucketName)
                    .parameters(parameters)
                    .build();
            // Send the operation request
            OperationOutput output = client.invokeOperation(input, OperationOptions.defaults());
            // Print the operation result (HTTP status code)
            System.out.println("The result of PutBucketResourcePoolBucketGroup: " + output.statusCode());
        }
    }
}

List the bucket groups in a specific resource pool

package demo;
import com.aliyun.sdk.service.oss2.*;
import com.aliyun.sdk.service.oss2.credentials.*;
import java.util.*;

public class ListResourcePoolBucketGroups {
    public static void main(String[] args) throws Exception {
        // Specify the region in which the bucket is located. In this example, the bucket is located in the China (Hangzhou) region, whose region ID is cn-hangzhou.
        String region = "cn-hangzhou";
        // Create an OSS client by using the access credentials obtained from environment variables and the specified region
        try (OSSClient client = OSSClient.newBuilder()
                .region(region)
                .credentialsProvider(new EnvironmentVariableCredentialsProvider())
                .build()) {
            // Configure the request parameters
            Map<String, String> parameters = new HashMap<>();
            parameters.put("resourcePool", "example-resource-pool");
            // Create the operation input, which includes the operation name, HTTP method, and request parameters
            OperationInput input = OperationInput.newBuilder()
                    .opName("ListResourcePoolBucketGroups")
                    .method("GET")
                    .parameters(parameters)
                    .build();
            // Send the operation request
            OperationOutput output = client.invokeOperation(input, OperationOptions.defaults());
            // Read and print the content of the response body
            String body = output.body().map(Object::toString).orElse("");
            System.out.println("The result of ListResourcePoolBucketGroups: " + body);
        }
    }
}

Modify the QoS configuration for a bucket group in a resource pool

package demo;
import com.aliyun.sdk.service.oss2.*;
import com.aliyun.sdk.service.oss2.credentials.*;
import com.aliyun.sdk.service.oss2.transport.BinaryData;
import java.util.*;
import java.nio.file.*;

public class PutResourcePoolBucketGroupQoSInfo {
    public static void main(String[] args) throws Exception {
        // Specify the region in which the bucket is located. In this example, the bucket is located in the China (Hangzhou) region, whose region ID is cn-hangzhou.
        String region = "cn-hangzhou";
        // Create an OSS client by using the access credentials obtained from environment variables and the specified region
        try (OSSClient client = OSSClient.newBuilder()
                .region(region)
                .credentialsProvider(new EnvironmentVariableCredentialsProvider())
                .build()) {
            // Read the content of the QoS configuration file
            byte[] data = Files.readAllBytes(Paths.get("qos.xml"));
            // Configure the request parameters
            Map<String, String> parameters = new HashMap<>();
            parameters.put("resourcePoolBucketGroupQosInfo", "");
            // Create the operation input, which includes the operation name, HTTP method, and request parameters
            OperationInput input = OperationInput.newBuilder()
                    .opName("PutResourcePoolBucketGroupQoSInfo")
                    .method("PUT")
                    .parameters(parameters)
                    .body(BinaryData.fromBytes(data))
                    .build();
            // Send the operation request
            OperationOutput output = client.invokeOperation(input, OperationOptions.defaults());
            // Print the operation result (HTTP status code)
            System.out.println("The result of PutResourcePoolBucketGroupQoSInfo: " + output.statusCode());
        }
    }
}

The following example shows the content of the qos.xml file:

<QoSConfiguration>
  <TotalUploadBandwidth>100</TotalUploadBandwidth>
  <IntranetUploadBandwidth>-1</IntranetUploadBandwidth>
  <ExtranetUploadBandwidth>20</ExtranetUploadBandwidth>
  <TotalDownloadBandwidth>100</TotalDownloadBandwidth>
  <IntranetDownloadBandwidth>-1</IntranetDownloadBandwidth>
  <ExtranetDownloadBandwidth>20</ExtranetDownloadBandwidth>
  <TotalQps>10000</TotalQps>
  <IntranetQps>-1</IntranetQps>
  <ExtranetQps>-1</ExtranetQps>
</QoSConfiguration>

Query the QoS configuration of a bucket group in a resource pool

package demo;
import com.aliyun.sdk.service.oss2.*;
import com.aliyun.sdk.service.oss2.credentials.*;
import java.util.*;

public class GetResourcePoolBucketGroupQoSInfo {
    public static void main(String[] args) throws Exception {
        // Specify the region in which the bucket is located. In this example, the bucket is located in the China (Hangzhou) region, whose region ID is cn-hangzhou.
        String region = "cn-hangzhou";
        // Create an OSS client by using the access credentials obtained from environment variables and the specified region
        try (OSSClient client = OSSClient.newBuilder()
                .region(region)
                .credentialsProvider(new EnvironmentVariableCredentialsProvider())
                .build()) {
            // Configure the request parameters
            Map<String, String> parameters = new HashMap<>();
            parameters.put("resourcePoolBucketGroupQoSInfo", "");
            // Create the operation input, which includes the operation name, HTTP method, and request parameters
            OperationInput input = OperationInput.newBuilder()
                    .opName("GetResourcePoolBucketGroupQoSInfo")
                    .method("GET")
                    .parameters(parameters)
                    .build();
            // Send the operation request
            OperationOutput output = client.invokeOperation(input, OperationOptions.defaults());
            // Read and print the content of the response body
            String body = output.body().map(Object::toString).orElse("");
            System.out.println("The result of GetResourcePoolBucketGroupQoSInfo: " + body);
        }
    }
}

List the QoS configurations of bucket groups in a resource pool

package demo;
import com.aliyun.sdk.service.oss2.*;
import com.aliyun.sdk.service.oss2.credentials.*;
import java.util.*;

public class ListResourcePoolBucketGroupQoSInfos {
    public static void main(String[] args) throws Exception {
        // Specify the region in which the bucket is located. In this example, the bucket is located in the China (Hangzhou) region, whose region ID is cn-hangzhou.
        String region = "cn-hangzhou";
        // Create an OSS client by using the access credentials obtained from environment variables and the specified region
        try (OSSClient client = OSSClient.newBuilder()
                .region(region)
                .credentialsProvider(new EnvironmentVariableCredentialsProvider())
                .build()) {
            // Configure the request parameters
            Map<String, String> parameters = new HashMap<>();
            parameters.put("continuation-token", "25987311111111xxxx");
            parameters.put("max-keys", "1");
            // Create the operation input, which includes the operation name, HTTP method, and request parameters
            OperationInput input = OperationInput.newBuilder()
                    .opName("ListResourcePoolBucketGroupQoSInfos")
                    .method("GET")
                    .parameters(parameters)
                    .build();
            // Send the operation request
            OperationOutput output = client.invokeOperation(input, OperationOptions.defaults());
            // Read and print the content of the response body
            String body = output.body().map(Object::toString).orElse("");
            System.out.println("The result of ListResourcePoolBucketGroupQoSInfos: " + body);
        }
    }
}

Delete the QoS configuration of a bucket group in a resource pool

package demo;
import com.aliyun.sdk.service.oss2.*;
import com.aliyun.sdk.service.oss2.credentials.*;
import java.util.*;

public class DeleteResourcePoolBucketGroupQoSInfo {
    public static void main(String[] args) throws Exception {
        // Specify the region in which the bucket is located. In this example, the bucket is located in the China (Hangzhou) region, whose region ID is cn-hangzhou.
        String region = "cn-hangzhou";
        // Create an OSS client by using the access credentials obtained from environment variables and the specified region
        try (OSSClient client = OSSClient.newBuilder()
                .region(region)
                .credentialsProvider(new EnvironmentVariableCredentialsProvider())
                .build()) {
            // Configure the request parameters
            Map<String, String> parameters = new HashMap<>();
            parameters.put("resourcePoolBucketGroupQoSInfo", "");
            // Create the operation input, which includes the operation name, HTTP method, and request parameters
            OperationInput input = OperationInput.newBuilder()
                    .opName("DeleteResourcePoolBucketGroupQoSInfo")
                    .method("DELETE")
                    .parameters(parameters)
                    .build();
            // Send the operation request
            OperationOutput output = client.invokeOperation(input, OperationOptions.defaults());
            // Print the operation result (HTTP status code)
            System.out.println("The result of DeleteResourcePoolBucketGroupQoSInfo: " + output.statusCode());
        }
    }
}

Related documents