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());
}
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());
}
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");
}
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;
}
}
}
}
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);
}
}
}
Aggregations