Java Code Examples for java.util.concurrent.Executor#getClass()

The following examples show how to use java.util.concurrent.Executor#getClass() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WatchdogChecks.java    From arcusplatform with Apache License 2.0 5 votes vote down vote up
public static void addExecutorWatchdog(String name, Executor exec) {
   if (exec instanceof ThreadPoolExecutor) {
      WatchdogService.addWatchdogCheck(new ThreadPoolExecutorWatchdog(name,(ThreadPoolExecutor)exec));
   } else {
      throw new RuntimeException("cannot monitor executor of type: " + exec.getClass());
   }
}
 
Example 2
Source File: GrpcClient.java    From etcd-java with Apache License 2.0 5 votes vote down vote up
public static Executor serialized(Executor parent, int bufferSize) {
    return parent instanceof SerializingExecutor
            || parent instanceof io.grpc.internal.SerializingExecutor
            || parent instanceof OrderedEventExecutor
            || parent.getClass() == GSE_CLASS
            ? parent : new SerializingExecutor(parent, bufferSize);
}
 
Example 3
Source File: CompletableSearchServer.java    From vind with Apache License 2.0 5 votes vote down vote up
private CompletableSearchServer(SearchServer backend, Executor executor, boolean shutdownExecutorOnClose) {
    if(shutdownExecutorOnClose && !(executor instanceof ExecutorService)) {
        throw new IllegalArgumentException("shutdownExecutorOnClose requires 'executor' being an 'ExecutorService', actually got: " + executor.getClass());
    }
    this.backend = backend;
    this.executor = executor;
    this.shutdownExecutorOnClose = shutdownExecutorOnClose;
}
 
Example 4
Source File: ThreadedRequestHandler.java    From vespa with Apache License 2.0 3 votes vote down vote up
/**
 * Creates a threaded request handler
 *
 * @param executor the executor to use to execute requests
 * @param metric the metric object to which event in this are to be collected
 * @param allowAsyncResponse true to allow the response header to be created asynchronously.
 *                           If false (default), this will create an error response if the response header
 *                           is not returned by the subclass of this before handleRequest returns.
 */
@Inject
protected ThreadedRequestHandler(Executor executor, Metric metric, boolean allowAsyncResponse) {
    executor.getClass(); // throws NullPointerException
    this.executor = executor;
    this.metric = (metric == null) ? new NullRequestMetric() : metric;
    this.allowAsyncResponse = allowAsyncResponse;
}