[ONOS-6267] Support configurable Executors for primitives
- Support user-provided Executors in primitive builders
- Implement default per-partition per-primitive serial executor using a shared thread pool
- Implement Executor wrappers for all primitive types
Change-Id: I53acfb173a9b49a992a9a388983791d9735ed54a
diff --git a/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/StoragePartition.java b/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/StoragePartition.java
index a68b793..e9261c8 100644
--- a/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/StoragePartition.java
+++ b/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/StoragePartition.java
@@ -24,6 +24,7 @@
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.Executor;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.stream.Collectors;
@@ -47,6 +48,7 @@
private final AtomicBoolean isOpened = new AtomicBoolean(false);
private final Serializer serializer;
+ private final Executor sharedExecutor;
private final MessagingService messagingService;
private final ClusterService clusterService;
private final File logFolder;
@@ -63,12 +65,14 @@
MessagingService messagingService,
ClusterService clusterService,
Serializer serializer,
+ Executor sharedExecutor,
File logFolder) {
this.partition = partition;
this.messagingService = messagingService;
this.clusterService = clusterService;
this.localNodeId = clusterService.getLocalNode().id();
this.serializer = serializer;
+ this.sharedExecutor = sharedExecutor;
this.logFolder = logFolder;
}
@@ -156,7 +160,8 @@
private CompletableFuture<StoragePartitionClient> openClient() {
client = new StoragePartitionClient(this,
serializer,
- new CopycatTransport(partition.getId(), messagingService));
+ new CopycatTransport(partition.getId(), messagingService),
+ sharedExecutor);
return client.open().thenApply(v -> client);
}