Upgrade to Atomix 3.0-rc5
* Upgrade Raft primitives to Atomix 3.0
* Replace cluster store and messaging implementations with Atomix cluster management/messaging
* Add test scripts for installing/starting Atomix cluster
* Replace core primitives with Atomix primitives.
Change-Id: I7623653c81292a34f21b01f5f38ca11b5ef15cad
diff --git a/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/AtomixWorkQueue.java b/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/AtomixWorkQueue.java
new file mode 100644
index 0000000..d3b9907
--- /dev/null
+++ b/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/AtomixWorkQueue.java
@@ -0,0 +1,81 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.store.primitives.impl;
+
+import java.util.Collection;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.Executor;
+import java.util.function.Consumer;
+import java.util.stream.Collectors;
+
+import org.onosproject.store.service.Task;
+import org.onosproject.store.service.WorkQueue;
+import org.onosproject.store.service.WorkQueueStats;
+
+/**
+ * Atomix work queue.
+ */
+public class AtomixWorkQueue<E> implements WorkQueue<E> {
+ private final io.atomix.core.workqueue.AsyncWorkQueue<E> atomixWorkQueue;
+
+ public AtomixWorkQueue(io.atomix.core.workqueue.AsyncWorkQueue<E> atomixWorkQueue) {
+ this.atomixWorkQueue = atomixWorkQueue;
+ }
+
+ @Override
+ public String name() {
+ return atomixWorkQueue.name();
+ }
+
+ @Override
+ public CompletableFuture<Void> addMultiple(Collection<E> items) {
+ return atomixWorkQueue.addMultiple(items);
+ }
+
+ @Override
+ public CompletableFuture<Collection<Task<E>>> take(int maxItems) {
+ return atomixWorkQueue.take(maxItems)
+ .thenApply(tasks -> tasks.stream()
+ .map(task -> new Task<>(task.taskId(), task.payload()))
+ .collect(Collectors.toList()));
+ }
+
+ @Override
+ public CompletableFuture<Void> complete(Collection<String> taskIds) {
+ return atomixWorkQueue.complete(taskIds);
+ }
+
+ @Override
+ public CompletableFuture<Void> registerTaskProcessor(
+ Consumer<E> taskProcessor, int parallelism, Executor executor) {
+ return atomixWorkQueue.registerTaskProcessor(taskProcessor, parallelism, executor);
+ }
+
+ @Override
+ public CompletableFuture<Void> stopProcessing() {
+ return atomixWorkQueue.stopProcessing();
+ }
+
+ @Override
+ public CompletableFuture<WorkQueueStats> stats() {
+ return atomixWorkQueue.stats()
+ .thenApply(stats -> WorkQueueStats.builder()
+ .withTotalCompleted(stats.totalCompleted())
+ .withTotalInProgress(stats.totalInProgress())
+ .withTotalPending(stats.totalPending())
+ .build());
+ }
+}