Search in sources :

Example 1 with Queue

use of corejava.chapter2.lab16_17.Queue in project kubernetes-client by fabric8io.

the class V1Beta1VolcanoTest method testV1Beta1Queue.

@Test
void testV1Beta1Queue() {
    Queue queue = new QueueBuilder().editOrNewMetadata().withName("queue1").endMetadata().build();
    client.v1beta1().queues().create(queue);
    QueueList queueList = client.v1beta1().queues().list();
    assertNotNull(queueList);
    assertEquals(1, queueList.getItems().size());
}
Also used : QueueBuilder(io.fabric8.volcano.scheduling.v1beta1.QueueBuilder) Queue(io.fabric8.volcano.scheduling.v1beta1.Queue) QueueList(io.fabric8.volcano.scheduling.v1beta1.QueueList) Test(org.junit.jupiter.api.Test)

Example 2 with Queue

use of corejava.chapter2.lab16_17.Queue in project kubernetes-client by fabric8io.

the class QueueTest method testCreate.

@Test
@DisplayName("Should create a queue")
void testCreate() {
    Queue queue = createQueue();
    server.expect().post().withPath("/apis/scheduling.volcano.sh/v1beta1/queues").andReturn(HttpURLConnection.HTTP_CREATED, queue).once();
    queue = client.v1beta1().queues().create(queue);
    assertNotNull(queue);
    assertEquals("q1", queue.getMetadata().getName());
}
Also used : Queue(io.fabric8.volcano.scheduling.v1beta1.Queue) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 3 with Queue

use of corejava.chapter2.lab16_17.Queue in project algorithms-sedgewick-wayne by reneargento.

the class Exercise41_CopyQueue method main.

public static void main(String[] args) {
    Queue<Integer> originalQueue = new Queue<>();
    originalQueue.enqueue(1);
    originalQueue.enqueue(2);
    originalQueue.enqueue(3);
    originalQueue.enqueue(4);
    Exercise41_CopyQueue<Integer> queueCopy = new Exercise41_CopyQueue<>(originalQueue);
    queueCopy.enqueue(5);
    queueCopy.enqueue(99);
    originalQueue.dequeue();
    queueCopy.dequeue();
    queueCopy.dequeue();
    StringJoiner originalQueueItems = new StringJoiner(" ");
    for (int item : originalQueue) {
        originalQueueItems.add(String.valueOf(item));
    }
    StdOut.println("Original Queue: " + originalQueueItems.toString());
    StdOut.println("Expected: 2 3 4");
    StdOut.println();
    StringJoiner copyQueueItems = new StringJoiner(" ");
    for (int item : queueCopy) {
        copyQueueItems.add(String.valueOf(item));
    }
    StdOut.println("Queue Copy: " + copyQueueItems.toString());
    StdOut.println("Expected: 3 4 5 99");
}
Also used : Queue(edu.princeton.cs.algs4.Queue) StringJoiner(java.util.StringJoiner)

Example 4 with Queue

use of corejava.chapter2.lab16_17.Queue in project algorithms-sedgewick-wayne by reneargento.

the class Exercise7 method keyIndexedCountWithQueue.

public void keyIndexedCountWithQueue(String[] array, int stringsLength) {
    // Extended ASCII characters
    int alphabetSize = 256;
    Queue<String>[] count = new Queue[alphabetSize + 1];
    for (int r = 0; r < count.length; r++) {
        count[r] = new Queue();
    }
    for (int digit = stringsLength - 1; digit >= 0; digit--) {
        // Compute frequency counts
        for (int i = 0; i < array.length; i++) {
            int digitIndex = array[i].charAt(digit);
            count[digitIndex].enqueue(array[i]);
        }
        // Distribute and copy back
        int indexArray = 0;
        for (int r = 0; r < count.length; r++) {
            while (!count[r].isEmpty()) {
                String string = count[r].dequeue();
                array[indexArray++] = string;
            }
        }
    }
}
Also used : Queue(chapter1.section3.Queue)

Example 5 with Queue

use of corejava.chapter2.lab16_17.Queue in project java-docs-samples by GoogleCloudPlatform.

the class RetryTask method retryTask.

public static void retryTask(String projectId, String locationId, String fooqueue, String barqueue, String bazqueue) throws Exception {
    try (CloudTasksClient client = CloudTasksClient.create()) {
        // TODO(developer): Uncomment these lines and replace with your values.
        // String projectId = "your-project-id";
        // String locationId = "us-central1";
        // String fooqueue = "fooqueue";
        // String barqueue = "barqueue";
        // String bazqueue = "bazqueue";
        LocationName parent = LocationName.of(projectId, locationId);
        Duration retryDuration = Duration.newBuilder().setSeconds(2 * 60 * 60 * 24).build();
        Duration min = Duration.newBuilder().setSeconds(10).build();
        Duration max1 = Duration.newBuilder().setSeconds(200).build();
        Duration max2 = Duration.newBuilder().setSeconds(300).build();
        Queue foo = Queue.newBuilder().setName(QueueName.of(projectId, locationId, fooqueue).toString()).setRateLimits(RateLimits.newBuilder().setMaxDispatchesPerSecond(1.0)).setRetryConfig(RetryConfig.newBuilder().setMaxAttempts(7).setMaxRetryDuration(retryDuration)).build();
        Queue bar = Queue.newBuilder().setName(QueueName.of(projectId, locationId, barqueue).toString()).setRateLimits(RateLimits.newBuilder().setMaxDispatchesPerSecond(1.0)).setRetryConfig(RetryConfig.newBuilder().setMinBackoff(min).setMaxBackoff(max1).setMaxDoublings(0)).build();
        Queue baz = Queue.newBuilder().setName(QueueName.of(projectId, locationId, bazqueue).toString()).setRateLimits(RateLimits.newBuilder().setMaxDispatchesPerSecond(1.0)).setRetryConfig(RetryConfig.newBuilder().setMinBackoff(min).setMaxBackoff(max2).setMaxDoublings(3)).build();
        Queue[] queues = new Queue[] { foo, bar, baz };
        for (Queue queue : queues) {
            Queue response = client.createQueue(parent, queue);
            System.out.println(response);
        }
    }
}
Also used : CloudTasksClient(com.google.cloud.tasks.v2.CloudTasksClient) Duration(com.google.protobuf.Duration) Queue(com.google.cloud.tasks.v2.Queue) LocationName(com.google.cloud.tasks.v2.LocationName)

Aggregations

Queue (com.google.cloud.tasks.v2.Queue)10 CloudTasksClient (com.google.cloud.tasks.v2.CloudTasksClient)7 Queue (io.fabric8.volcano.scheduling.v1beta1.Queue)6 LocationName (com.google.cloud.tasks.v2.LocationName)5 In (edu.princeton.cs.algs4.In)5 Queue (edu.princeton.cs.algs4.Queue)5 Queue (chapter1.section3.Queue)4 QueueList (io.fabric8.volcano.scheduling.v1beta1.QueueList)4 Test (org.junit.jupiter.api.Test)4 CreateQueueRequest (com.google.cloud.tasks.v2.CreateQueueRequest)3 Task (com.google.cloud.tasks.v2.Task)3 HashSet (chapter3.section5.HashSet)2 HttpRequest (com.google.cloud.tasks.v2.HttpRequest)2 QueueName (com.google.cloud.tasks.v2.QueueName)2 Transaction (edu.princeton.cs.algs4.Transaction)2 DefaultVolcanoClient (io.fabric8.volcano.client.DefaultVolcanoClient)2 NamespacedVolcanoClient (io.fabric8.volcano.client.NamespacedVolcanoClient)2 QueueBuilder (io.fabric8.volcano.scheduling.v1beta1.QueueBuilder)2 StringJoiner (java.util.StringJoiner)2 Test (org.junit.Test)2