Queue-Related SDKs
Prerequisites
- You have configured the Java SDK environment by following the instructions provided Overview.
- You have initialized the DLI Client by following the instructions provided in Initializing the DLI Client.
Creating a Queue
1 2 3 4 5 6 7 8 |
private static void createQueue(DLIClient client) throws DLIException { //Call the createQueue method of the DLIClient object to create a queue. String qName = "queueName"; int cu = 16; String description = "test for sdk"; Queue queue = client.createQueue(qName, cu, mode, description); System.out.println("---------- createQueue success ---------"); } |
Deleting a Queue
1 2 3 4 5 6 7 |
private static void deleteQueue(DLIClient client) throws DLIException { //Call the getQueue(queueName) method of the DLIClient object to obtain queue queueName. String qName = "queueName"; Queue queue = client.getQueue(qName); //Call the deleteQueue() method to delete queue queueName. queue.deleteQueue(); } |
Obtaining the Default Queue
DLI provides an API for querying the default queue. You can use the default queue to submit jobs. The example code is as follows:
1 2 3 4 5 |
private static void getDefaultQueue(DLIClient client) throws DLIException{ //Call the getDefaultQueue method of the DLIClient object to query the default queue. Queue queue = client.getDefaultQueue(); System.out.println("defaultQueue is:"+ queue.getQueueName()); } |
All users can use the default queue. However, DLI limits the maximum number of times a user can use the default queue.
Querying All Queues
You can use the API provided by DLI to query the queue list and select the corresponding queue to execute the job. The example code is as follows:
1 2 3 4 5 6 7 8 9 |
private static void listAllQueues(DLIClient client) throws DLIException { System.out.println("list all queues..."); //Call the listAllQueues method of the DLIClient object to query the queue list. List<Queue> queues = client.listAllQueues(); for (Queue queue : queues) { System.out.println("Queue name:" + queue.getQueueName() + " " + "cu:" + queue.getCuCount()); } } |
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot