@@ -0,0 +1,3490 @@
+/*%0A * Licensed to Elastic Search and Shay Banon under one%0A * or more contributor license agreements.  See the NOTICE file%0A * distributed with this work for additional information%0A * regarding copyright ownership. Elastic Search licenses this%0A * file to you under the Apache License, Version 2.0 (the%0A * %22License%22); you may not use this file except in compliance%0A * with the License.  You may obtain a copy of the License at%0A *%0A *    http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing,%0A * software distributed under the License is distributed on an%0A * %22AS IS%22 BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY%0A * KIND, either express or implied.  See the License for the%0A * specific language governing permissions and limitations%0A * under the License.%0A */%0A%0Apackage org.elasticsearch.threadpool.forkjoin;%0A%0Aimport org.elasticsearch.common.inject.Inject;%0Aimport org.elasticsearch.common.settings.Settings;%0Aimport org.elasticsearch.common.unit.TimeValue;%0Aimport org.elasticsearch.common.util.concurrent.EsExecutors;%0Aimport org.elasticsearch.common.util.concurrent.jsr166y.ForkJoinPool;%0Aimport org.elasticsearch.threadpool.support.AbstractThreadPool;%0A%0Aimport java.util.concurrent.Executors;%0Aimport java.util.concurrent.ThreadPoolExecutor;%0A%0Aimport static org.elasticsearch.common.settings.ImmutableSettings.Builder.*;%0Aimport static org.elasticsearch.common.unit.TimeValue.*;%0A%0A/**%0A *%0A */%0Apublic class ForkjoinThreadPool extends AbstractThreadPool %7B%0A%0A    final int parallelism;%0A    final TimeValue keepAlive;%0A%0A    final int scheduledSize;%0A%0A    public ForkjoinThreadPool() %7B%0A        this(EMPTY_SETTINGS);%0A    %7D%0A%0A    @Inject public ForkjoinThreadPool(Settings settings) %7B%0A        super(settings);%0A        this.parallelism = componentSettings.getAsInt(%22parallelism%22, Runtime.getRuntime().availableProcessors() * 5);%0A        this.keepAlive = componentSettings.getAsTime(%22keep_alive%22, timeValueMinutes(5));%0A        this.scheduledSize = componentSettings.getAsInt(%22scheduled_size%22, 1);%0A        logger.debug(%22Initializing %7B%7D thread pool with parallelism%5B%7B%7D%5D, keep_alive%5B%7B%7D%5D, scheduled_size%5B%7B%7D%5D%22, getType(), parallelism, keepAlive, scheduledSize);%0A        scheduledExecutorService = Executors.newScheduledThreadPool(scheduledSize, EsExecutors.daemonThreadFactory(settings, %22%5Bsc%5D%22));%0A//        executorService = TransferThreadPoolExecutor.newScalingExecutor(min, max, keepAlive.nanos(), TimeUnit.NANOSECONDS, EsExecutors.daemonThreadFactory(settings, %22%5Btp%5D%22));%0A        executorService = new ForkJoinPool(parallelism, ForkJoinPool.defaultForkJoinWorkerThreadFactory, null, true);%0A        cached = EsExecutors.newCachedThreadPool(keepAlive, EsExecutors.daemonThreadFactory(settings, %22%5Bcached%5D%22));%0A        started = true;%0A    %7D%0A%0A    @Override public int getMinThreads() %7B%0A        return parallelism;%0A    %7D%0A%0A    @Override public int getMaxThreads() %7B%0A        return parallelism;%0A    %7D%0A%0A    @Override public int getSchedulerThreads() %7B%0A        return scheduledSize;%0A    %7D%0A%0A    @Override public int getPoolSize() %7B%0A        return -1;%0A    %7D%0A%0A    @Override public int getActiveCount() %7B%0A        return -1;%0A    %7D%0A%0A    @Override public int getSchedulerPoolSize() %7B%0A        return ((ThreadPoolExecutor) scheduledExecutorService).getPoolSize();%0A    %7D%0A%0A    @Override public int getSchedulerActiveCount() %7B%0A        return ((ThreadPoolExecutor) scheduledExecutorService).getActiveCount();%0A    %7D%0A%0A    @Override public String getType() %7B%0A        return %22forkjoin%22;%0A    %7D%0A%7D

add forkjoin TP