summaryrefslogtreecommitdiff
path: root/core/src/test/java/org/elasticsearch/action/support
diff options
context:
space:
mode:
authorTim Brooks <tim@uncontended.net>2017-05-03 10:30:54 -0500
committerGitHub <noreply@github.com>2017-05-03 10:30:54 -0500
commit855b64b0ee23f537efd7073c1e49d17e52b5ce93 (patch)
treeb3d8630f489b2f479d96d34014f301368a2e5ed2 /core/src/test/java/org/elasticsearch/action/support
parent7311aaa2eb6b67d9bce873728b60c251682b5ba3 (diff)
Add non-dispatching listenable action future (#24412)
Currently the only implementation of `ListenableActionFuture` requires dispatching listener execution to a thread pool. This commit renames that variant to `DispatchingListenableActionFuture` and converts `AbstractListenableActionFuture` to be a variant that does not require dispatching. That class is now named `PlainListenableActionFuture`.
Diffstat (limited to 'core/src/test/java/org/elasticsearch/action/support')
-rw-r--r--core/src/test/java/org/elasticsearch/action/support/ListenableActionFutureTests.java7
-rw-r--r--core/src/test/java/org/elasticsearch/action/support/TransportActionFilterChainTests.java4
2 files changed, 9 insertions, 2 deletions
diff --git a/core/src/test/java/org/elasticsearch/action/support/ListenableActionFutureTests.java b/core/src/test/java/org/elasticsearch/action/support/ListenableActionFutureTests.java
index 8169a674be..0dbf460345 100644
--- a/core/src/test/java/org/elasticsearch/action/support/ListenableActionFutureTests.java
+++ b/core/src/test/java/org/elasticsearch/action/support/ListenableActionFutureTests.java
@@ -34,7 +34,12 @@ public class ListenableActionFutureTests extends ESTestCase {
public void testListenerIsCallableFromNetworkThreads() throws Throwable {
ThreadPool threadPool = new TestThreadPool("testListenerIsCallableFromNetworkThreads");
try {
- final PlainListenableActionFuture<Object> future = new PlainListenableActionFuture<>(threadPool);
+ final PlainListenableActionFuture<Object> future;
+ if (randomBoolean()) {
+ future = PlainListenableActionFuture.newDispatchingListenableFuture(threadPool);
+ } else {
+ future = PlainListenableActionFuture.newListenableFuture();
+ }
final CountDownLatch listenerCalled = new CountDownLatch(1);
final AtomicReference<Throwable> error = new AtomicReference<>();
final Object response = new Object();
diff --git a/core/src/test/java/org/elasticsearch/action/support/TransportActionFilterChainTests.java b/core/src/test/java/org/elasticsearch/action/support/TransportActionFilterChainTests.java
index d5aab07f24..3eb1616348 100644
--- a/core/src/test/java/org/elasticsearch/action/support/TransportActionFilterChainTests.java
+++ b/core/src/test/java/org/elasticsearch/action/support/TransportActionFilterChainTests.java
@@ -91,7 +91,8 @@ public class TransportActionFilterChainTests extends ESTestCase {
}
}
- PlainActionFuture<TestResponse> future = new PlainActionFuture<>();
+ PlainActionFuture<TestResponse> future = PlainActionFuture.newFuture();
+
transportAction.execute(new TestRequest(), future);
try {
assertThat(future.get(), notNullValue());
@@ -104,6 +105,7 @@ public class TransportActionFilterChainTests extends ESTestCase {
for (ActionFilter actionFilter : actionFilters.filters()) {
testFiltersByLastExecution.add((RequestTestFilter) actionFilter);
}
+
testFiltersByLastExecution.sort(Comparator.comparingInt(o -> o.executionToken));
ArrayList<RequestTestFilter> finalTestFilters = new ArrayList<>();