Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
import org.elasticsearch.common.util.CollectionUtils;
import org.elasticsearch.common.util.MockPageCacheRecycler;
import org.elasticsearch.common.util.concurrent.AbstractRunnable;
import org.elasticsearch.common.util.concurrent.EsExecutors;
import org.elasticsearch.common.util.concurrent.EsThreadPoolExecutor;
import org.elasticsearch.common.util.concurrent.RunOnce;
import org.elasticsearch.core.AbstractRefCounted;
import org.elasticsearch.core.IOUtils;
Expand Down Expand Up @@ -81,6 +83,7 @@
import java.util.function.Supplier;

import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.spy;

/**
Expand Down Expand Up @@ -206,6 +209,7 @@ public static MockTransportService getInstance(String nodeName) {
}

private final Transport original;
private final EsThreadPoolExecutor testExecutor;

/**
* Build the service.
Expand Down Expand Up @@ -302,6 +306,16 @@ private MockTransportService(
Tracer.NOOP
);
this.original = transport.getDelegate();
this.testExecutor = EsExecutors.newScaling(
"mock-transport",
0,
4,
30,
TimeUnit.SECONDS,
true,
EsExecutors.daemonThreadFactory("mock-transport"),
threadPool.getThreadContext()
);
}

private static TransportAddress[] extractTransportAddresses(TransportService transportService) {
Expand Down Expand Up @@ -617,7 +631,7 @@ protected void doRun() throws IOException {
delay
)
);
threadPool.schedule(runnable, delay, threadPool.generic());
threadPool.schedule(runnable, delay, testExecutor);
}
}
}
Expand Down Expand Up @@ -795,6 +809,8 @@ protected void doClose() throws IOException {
}
} catch (InterruptedException e) {
throw new IllegalStateException(e);
} finally {
assertTrue(ThreadPool.terminate(testExecutor, 10, TimeUnit.SECONDS));
}
}

Expand Down