[ONOS-6267] Detect and complete blocked futures on I/O threads.
Change-Id: I0488dc5096f9e610b97405ad05c02d0ff3854b5f
diff --git a/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/ExecutingAsyncDocumentTree.java b/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/ExecutingAsyncDocumentTree.java
index 352ee7a..f6fc3d1 100644
--- a/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/ExecutingAsyncDocumentTree.java
+++ b/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/ExecutingAsyncDocumentTree.java
@@ -20,7 +20,6 @@
import java.util.concurrent.Executor;
import com.google.common.collect.Maps;
-import org.onlab.util.Tools;
import org.onosproject.store.service.AsyncDocumentTree;
import org.onosproject.store.service.DocumentPath;
import org.onosproject.store.service.DocumentTreeListener;
@@ -32,13 +31,14 @@
*/
public class ExecutingAsyncDocumentTree<V> extends ExecutingDistributedPrimitive implements AsyncDocumentTree<V> {
private final AsyncDocumentTree<V> delegateTree;
- private final Executor executor;
+ private final Executor orderedExecutor;
private final Map<DocumentTreeListener<V>, DocumentTreeListener<V>> listenerMap = Maps.newConcurrentMap();
- public ExecutingAsyncDocumentTree(AsyncDocumentTree<V> delegateTree, Executor executor) {
- super(delegateTree, executor);
+ public ExecutingAsyncDocumentTree(
+ AsyncDocumentTree<V> delegateTree, Executor orderedExecutor, Executor threadPoolExecutor) {
+ super(delegateTree, orderedExecutor, threadPoolExecutor);
this.delegateTree = delegateTree;
- this.executor = executor;
+ this.orderedExecutor = orderedExecutor;
}
@Override
@@ -48,56 +48,56 @@
@Override
public CompletableFuture<Map<String, Versioned<V>>> getChildren(DocumentPath path) {
- return Tools.asyncFuture(delegateTree.getChildren(path), executor);
+ return asyncFuture(delegateTree.getChildren(path));
}
@Override
public CompletableFuture<Versioned<V>> get(DocumentPath path) {
- return Tools.asyncFuture(delegateTree.get(path), executor);
+ return asyncFuture(delegateTree.get(path));
}
@Override
public CompletableFuture<Versioned<V>> set(DocumentPath path, V value) {
- return Tools.asyncFuture(delegateTree.set(path, value), executor);
+ return asyncFuture(delegateTree.set(path, value));
}
@Override
public CompletableFuture<Boolean> create(DocumentPath path, V value) {
- return Tools.asyncFuture(delegateTree.create(path, value), executor);
+ return asyncFuture(delegateTree.create(path, value));
}
@Override
public CompletableFuture<Boolean> createRecursive(DocumentPath path, V value) {
- return Tools.asyncFuture(delegateTree.createRecursive(path, value), executor);
+ return asyncFuture(delegateTree.createRecursive(path, value));
}
@Override
public CompletableFuture<Boolean> replace(DocumentPath path, V newValue, long version) {
- return Tools.asyncFuture(delegateTree.replace(path, newValue, version), executor);
+ return asyncFuture(delegateTree.replace(path, newValue, version));
}
@Override
public CompletableFuture<Boolean> replace(DocumentPath path, V newValue, V currentValue) {
- return Tools.asyncFuture(delegateTree.replace(path, newValue, currentValue), executor);
+ return asyncFuture(delegateTree.replace(path, newValue, currentValue));
}
@Override
public CompletableFuture<Versioned<V>> removeNode(DocumentPath path) {
- return Tools.asyncFuture(delegateTree.removeNode(path), executor);
+ return asyncFuture(delegateTree.removeNode(path));
}
@Override
public CompletableFuture<Void> addListener(DocumentPath path, DocumentTreeListener<V> listener) {
- DocumentTreeListener<V> wrappedListener = e -> executor.execute(() -> listener.event(e));
+ DocumentTreeListener<V> wrappedListener = e -> orderedExecutor.execute(() -> listener.event(e));
listenerMap.put(listener, wrappedListener);
- return Tools.asyncFuture(delegateTree.addListener(path, wrappedListener), executor);
+ return asyncFuture(delegateTree.addListener(path, wrappedListener));
}
@Override
public CompletableFuture<Void> removeListener(DocumentTreeListener<V> listener) {
DocumentTreeListener<V> wrappedListener = listenerMap.remove(listener);
if (wrappedListener != null) {
- return Tools.asyncFuture(delegateTree.removeListener(wrappedListener), executor);
+ return asyncFuture(delegateTree.removeListener(wrappedListener));
}
return CompletableFuture.completedFuture(null);
}