Queue-Related SDKs
Creating a Queue
1 2 3 4 5 6 7 8 9 | 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;
ChargingMode mode = ChargingMode.CHARGING_MODE_CU;
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());
}
}
|
Last Article: OBS Authorization
Next Article: Resource-Related SDKs
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.