public class BraveExecutorService extends Object implements ExecutorService, Closeable
ExecutorService that wraps around an existing ExecutorService and that makes sure the threads are executed
in the same Span/Trace context as the the thread that invoked execution of the threads.
It uses ServerTracer and ServerSpanThreadBinder to accomplish this in a transparent way for the user.
It also implements Closeable, calling shutdown(), so the executor service is
shut down properly when for example using Spring.BraveCallable,
BraveRunnable| Constructor and Description |
|---|
BraveExecutorService(ExecutorService wrappedExecutor,
ServerSpanThreadBinder threadBinder)
Creates a new instance.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
awaitTermination(long timeout,
TimeUnit unit) |
void |
close()
Convenience for try-with-resources, or frameworks such as Spring that automatically process this.
|
void |
execute(Runnable arg0) |
<T> List<Future<T>> |
invokeAll(Collection<? extends Callable<T>> arg0) |
<T> List<Future<T>> |
invokeAll(Collection<? extends Callable<T>> arg0,
long arg1,
TimeUnit arg2) |
<T> T |
invokeAny(Collection<? extends Callable<T>> arg0) |
<T> T |
invokeAny(Collection<? extends Callable<T>> arg0,
long arg1,
TimeUnit arg2) |
boolean |
isShutdown() |
boolean |
isTerminated() |
void |
shutdown() |
List<Runnable> |
shutdownNow() |
<T> Future<T> |
submit(Callable<T> arg0) |
Future<?> |
submit(Runnable arg0) |
<T> Future<T> |
submit(Runnable arg0,
T arg1) |
public BraveExecutorService(ExecutorService wrappedExecutor, ServerSpanThreadBinder threadBinder)
wrappedExecutor - Wrapped ExecutorService to which execution will be delegated.threadBinder - Thread binder.public boolean awaitTermination(long timeout,
TimeUnit unit)
throws InterruptedException
awaitTermination in interface ExecutorServiceInterruptedExceptionpublic <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> arg0) throws InterruptedException
invokeAll in interface ExecutorServiceInterruptedExceptionpublic <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> arg0, long arg1, TimeUnit arg2) throws InterruptedException
invokeAll in interface ExecutorServiceInterruptedExceptionpublic <T> T invokeAny(Collection<? extends Callable<T>> arg0) throws InterruptedException, ExecutionException
invokeAny in interface ExecutorServiceInterruptedExceptionExecutionExceptionpublic <T> T invokeAny(Collection<? extends Callable<T>> arg0, long arg1, TimeUnit arg2) throws InterruptedException, ExecutionException, TimeoutException
invokeAny in interface ExecutorServiceInterruptedExceptionExecutionExceptionTimeoutExceptionpublic boolean isShutdown()
isShutdown in interface ExecutorServicepublic boolean isTerminated()
isTerminated in interface ExecutorServicepublic void shutdown()
shutdown in interface ExecutorServicepublic List<Runnable> shutdownNow()
shutdownNow in interface ExecutorServicepublic <T> Future<T> submit(Callable<T> arg0)
submit in interface ExecutorServicepublic Future<?> submit(Runnable arg0)
submit in interface ExecutorServicepublic <T> Future<T> submit(Runnable arg0, T arg1)
submit in interface ExecutorServicepublic void close()
close in interface Closeableclose in interface AutoCloseableCopyright © 2016. All rights reserved.