Search in sources :

Example 51 with Executor

use of java.util.concurrent.Executor in project jetty.project by eclipse.

the class HttpInput method wake.

protected void wake() {
    HttpChannel channel = _channelState.getHttpChannel();
    Executor executor = channel.getConnector().getServer().getThreadPool();
    executor.execute(channel);
}
Also used : Executor(java.util.concurrent.Executor)

Example 52 with Executor

use of java.util.concurrent.Executor in project elasticsearch by elastic.

the class TransportSearchAction method searchAsyncAction.

private AbstractSearchAsyncAction searchAsyncAction(SearchTask task, SearchRequest searchRequest, GroupShardsIterator shardIterators, long startTime, Function<String, Transport.Connection> connectionLookup, long clusterStateVersion, Map<String, AliasFilter> aliasFilter, Map<String, Float> concreteIndexBoosts, ActionListener<SearchResponse> listener) {
    Executor executor = threadPool.executor(ThreadPool.Names.SEARCH);
    AbstractSearchAsyncAction searchAsyncAction;
    switch(searchRequest.searchType()) {
        case DFS_QUERY_THEN_FETCH:
            searchAsyncAction = new SearchDfsQueryThenFetchAsyncAction(logger, searchTransportService, connectionLookup, aliasFilter, concreteIndexBoosts, searchPhaseController, executor, searchRequest, listener, shardIterators, startTime, clusterStateVersion, task);
            break;
        case QUERY_THEN_FETCH:
            searchAsyncAction = new SearchQueryThenFetchAsyncAction(logger, searchTransportService, connectionLookup, aliasFilter, concreteIndexBoosts, searchPhaseController, executor, searchRequest, listener, shardIterators, startTime, clusterStateVersion, task);
            break;
        default:
            throw new IllegalStateException("Unknown search type: [" + searchRequest.searchType() + "]");
    }
    return searchAsyncAction;
}
Also used : Executor(java.util.concurrent.Executor)

Example 53 with Executor

use of java.util.concurrent.Executor in project tomcat by apache.

the class ThreadLocalLeakPreventionListener method stopIdleThreads.

/**
     * Updates each ThreadPoolExecutor with the current time, which is the time
     * when a context is being stopped.
     *
     * @param context
     *            the context being stopped, used to discover all the Connectors
     *            of its parent Service.
     */
private void stopIdleThreads(Context context) {
    if (serverStopping)
        return;
    if (!(context instanceof StandardContext) || !((StandardContext) context).getRenewThreadsWhenStoppingContext()) {
        log.debug("Not renewing threads when the context is stopping. " + "It is not configured to do it.");
        return;
    }
    Engine engine = (Engine) context.getParent().getParent();
    Service service = engine.getService();
    Connector[] connectors = service.findConnectors();
    if (connectors != null) {
        for (Connector connector : connectors) {
            ProtocolHandler handler = connector.getProtocolHandler();
            Executor executor = null;
            if (handler != null) {
                executor = handler.getExecutor();
            }
            if (executor instanceof ThreadPoolExecutor) {
                ThreadPoolExecutor threadPoolExecutor = (ThreadPoolExecutor) executor;
                threadPoolExecutor.contextStopping();
            } else if (executor instanceof StandardThreadExecutor) {
                StandardThreadExecutor stdThreadExecutor = (StandardThreadExecutor) executor;
                stdThreadExecutor.contextStopping();
            }
        }
    }
}
Also used : ProtocolHandler(org.apache.coyote.ProtocolHandler) Connector(org.apache.catalina.connector.Connector) Executor(java.util.concurrent.Executor) ThreadPoolExecutor(org.apache.tomcat.util.threads.ThreadPoolExecutor) Service(org.apache.catalina.Service) ThreadPoolExecutor(org.apache.tomcat.util.threads.ThreadPoolExecutor) Engine(org.apache.catalina.Engine)

Example 54 with Executor

use of java.util.concurrent.Executor in project tomcat by apache.

the class SocketWrapperBase method execute.

/**
     * Transfers processing to a container thread.
     *
     * @param runnable The actions to process on a container thread
     *
     * @throws RejectedExecutionException If the runnable cannot be executed
     */
public void execute(Runnable runnable) {
    Executor executor = endpoint.getExecutor();
    if (!endpoint.isRunning() || executor == null) {
        throw new RejectedExecutionException();
    }
    executor.execute(runnable);
}
Also used : Executor(java.util.concurrent.Executor) RejectedExecutionException(java.util.concurrent.RejectedExecutionException)

Example 55 with Executor

use of java.util.concurrent.Executor in project tomcat by apache.

the class AbstractEndpoint method setMaxThreads.

public void setMaxThreads(int maxThreads) {
    this.maxThreads = maxThreads;
    Executor executor = this.executor;
    if (internalExecutor && executor instanceof java.util.concurrent.ThreadPoolExecutor) {
        // The internal executor should always be an instance of
        // j.u.c.ThreadPoolExecutor but it may be null if the endpoint is
        // not running.
        // This check also avoids various threading issues.
        ((java.util.concurrent.ThreadPoolExecutor) executor).setMaximumPoolSize(maxThreads);
    }
}
Also used : ResizableExecutor(org.apache.tomcat.util.threads.ResizableExecutor) Executor(java.util.concurrent.Executor) ThreadPoolExecutor(org.apache.tomcat.util.threads.ThreadPoolExecutor) ThreadPoolExecutor(org.apache.tomcat.util.threads.ThreadPoolExecutor)

Aggregations

Executor (java.util.concurrent.Executor)302 Test (org.junit.Test)127 ArrayList (java.util.ArrayList)35 CountDownLatch (java.util.concurrent.CountDownLatch)32 IOException (java.io.IOException)29 List (java.util.List)27 ThreadPoolExecutor (java.util.concurrent.ThreadPoolExecutor)22 RejectedExecutionException (java.util.concurrent.RejectedExecutionException)17 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)16 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)16 Map (java.util.Map)15 Timeouts (org.neo4j.cluster.timeout.Timeouts)15 ExecutorService (java.util.concurrent.ExecutorService)13 InstanceId (org.neo4j.cluster.InstanceId)13 Config (org.neo4j.kernel.configuration.Config)13 File (java.io.File)12 ObjectInputStreamFactory (org.neo4j.cluster.protocol.atomicbroadcast.ObjectInputStreamFactory)12 ObjectOutputStreamFactory (org.neo4j.cluster.protocol.atomicbroadcast.ObjectOutputStreamFactory)12 HeartbeatContext (org.neo4j.cluster.protocol.heartbeat.HeartbeatContext)12 InetSocketAddress (java.net.InetSocketAddress)10