当前位置: 首页>>代码示例>>Java>>正文


Java ThreadPool类代码示例

本文整理汇总了Java中org.elasticsearch.threadpool.ThreadPool的典型用法代码示例。如果您正苦于以下问题:Java ThreadPool类的具体用法?Java ThreadPool怎么用?Java ThreadPool使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ThreadPool类属于org.elasticsearch.threadpool包,在下文中一共展示了ThreadPool类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setUp

import org.elasticsearch.threadpool.ThreadPool; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    super.setUp();
    transport = new CapturingTransport();
    clusterService = createClusterService(THREAD_POOL);
    final TransportService transportService = new TransportService(clusterService.getSettings(), transport, THREAD_POOL,
        TransportService.NOOP_TRANSPORT_INTERCEPTOR, x -> clusterService.localNode(), null);
    transportService.start();
    transportService.acceptIncomingRequests();
    setClusterState(clusterService, TEST_INDEX);
    action = new TestTransportBroadcastByNodeAction(
            Settings.EMPTY,
            transportService,
            new ActionFilters(new HashSet<>()),
            new MyResolver(),
            Request::new,
            ThreadPool.Names.SAME
    );
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:20,代码来源:TransportBroadcastByNodeActionTests.java

示例2: TransportDistributedResultAction

import org.elasticsearch.threadpool.ThreadPool; //导入依赖的package包/类
@Inject
public TransportDistributedResultAction(Transports transports,
                                        JobContextService jobContextService,
                                        ThreadPool threadPool,
                                        TransportService transportService,
                                        Settings settings) {
    super(settings);
    this.transports = transports;
    this.jobContextService = jobContextService;
    scheduler = threadPool.scheduler();

    transportService.registerRequestHandler(DISTRIBUTED_RESULT_ACTION,
            DistributedResultRequest.class,
            ThreadPool.Names.GENERIC,
            new NodeActionRequestHandler<DistributedResultRequest, DistributedResultResponse>(this) { });
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:17,代码来源:TransportDistributedResultAction.java

示例3: NodeService

import org.elasticsearch.threadpool.ThreadPool; //导入依赖的package包/类
@Inject
public NodeService(Settings settings, ThreadPool threadPool, MonitorService monitorService, Discovery discovery,
                   TransportService transportService, IndicesService indicesService,
                   PluginsService pluginService, CircuitBreakerService circuitBreakerService,
                   Version version) {
    super(settings);
    this.threadPool = threadPool;
    this.monitorService = monitorService;
    this.transportService = transportService;
    this.indicesService = indicesService;
    this.discovery = discovery;
    discovery.setNodeService(this);
    this.version = version;
    this.pluginService = pluginService;
    this.circuitBreakerService = circuitBreakerService;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:17,代码来源:NodeService.java

示例4: SearchServiceTransportAction

import org.elasticsearch.threadpool.ThreadPool; //导入依赖的package包/类
@Inject
public SearchServiceTransportAction(Settings settings, TransportService transportService, SearchService searchService) {
    super(settings);
    this.transportService = transportService;
    this.searchService = searchService;

    transportService.registerRequestHandler(FREE_CONTEXT_SCROLL_ACTION_NAME, ScrollFreeContextRequest.class, ThreadPool.Names.SAME, new FreeContextTransportHandler<>());
    transportService.registerRequestHandler(FREE_CONTEXT_ACTION_NAME, SearchFreeContextRequest.class, ThreadPool.Names.SAME, new FreeContextTransportHandler<SearchFreeContextRequest>());
    transportService.registerRequestHandler(CLEAR_SCROLL_CONTEXTS_ACTION_NAME, ClearScrollContextsRequest.class, ThreadPool.Names.SAME, new ClearScrollContextsTransportHandler());
    transportService.registerRequestHandler(DFS_ACTION_NAME, ShardSearchTransportRequest.class, ThreadPool.Names.SEARCH, new SearchDfsTransportHandler());
    transportService.registerRequestHandler(QUERY_ACTION_NAME, ShardSearchTransportRequest.class, ThreadPool.Names.SEARCH, new SearchQueryTransportHandler());
    transportService.registerRequestHandler(QUERY_ID_ACTION_NAME, QuerySearchRequest.class, ThreadPool.Names.SEARCH, new SearchQueryByIdTransportHandler());
    transportService.registerRequestHandler(QUERY_SCROLL_ACTION_NAME, InternalScrollSearchRequest.class, ThreadPool.Names.SEARCH, new SearchQueryScrollTransportHandler());
    transportService.registerRequestHandler(QUERY_FETCH_ACTION_NAME, ShardSearchTransportRequest.class, ThreadPool.Names.SEARCH, new SearchQueryFetchTransportHandler());
    transportService.registerRequestHandler(QUERY_QUERY_FETCH_ACTION_NAME, QuerySearchRequest.class, ThreadPool.Names.SEARCH, new SearchQueryQueryFetchTransportHandler());
    transportService.registerRequestHandler(QUERY_FETCH_SCROLL_ACTION_NAME, InternalScrollSearchRequest.class, ThreadPool.Names.SEARCH, new SearchQueryFetchScrollTransportHandler());
    transportService.registerRequestHandler(FETCH_ID_SCROLL_ACTION_NAME, ShardFetchRequest.class, ThreadPool.Names.SEARCH, new FetchByIdTransportHandler<>());
    transportService.registerRequestHandler(FETCH_ID_ACTION_NAME, ShardFetchSearchRequest.class, ThreadPool.Names.SEARCH, new FetchByIdTransportHandler<ShardFetchSearchRequest>());
    transportService.registerRequestHandler(SCAN_ACTION_NAME, ShardSearchTransportRequest.class, ThreadPool.Names.SEARCH, new SearchScanTransportHandler());
    transportService.registerRequestHandler(SCAN_SCROLL_ACTION_NAME, InternalScrollSearchRequest.class, ThreadPool.Names.SEARCH, new SearchScanScrollTransportHandler());
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:22,代码来源:SearchServiceTransportAction.java

示例5: ContextPreparer

import org.elasticsearch.threadpool.ThreadPool; //导入依赖的package包/类
@Inject
public ContextPreparer(Settings settings,
                       MapSideDataCollectOperation collectOperation,
                       ClusterService clusterService,
                       CrateCircuitBreakerService breakerService,
                       CountOperation countOperation,
                       ThreadPool threadPool,
                       PageDownstreamFactory pageDownstreamFactory,
                       RowDownstreamFactory rowDownstreamFactory) {
    super(settings);
    nlContextLogger = Loggers.getLogger(NestedLoopContext.class, settings);
    pageDownstreamContextLogger = Loggers.getLogger(PageDownstreamContext.class, settings);
    this.collectOperation = collectOperation;
    this.clusterService = clusterService;
    this.countOperation = countOperation;
    this.threadPool = threadPool;
    circuitBreaker = breakerService.getBreaker(CrateCircuitBreakerService.QUERY);
    this.pageDownstreamFactory = pageDownstreamFactory;
    this.rowDownstreamFactory = rowDownstreamFactory;
    innerPreparer = new InnerPreparer();
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:22,代码来源:ContextPreparer.java

示例6: ReferenceInfos

import org.elasticsearch.threadpool.ThreadPool; //导入依赖的package包/类
@Inject
public ReferenceInfos(Map<String, SchemaInfo> builtInSchemas,
                      ClusterService clusterService,
                      IndexNameExpressionResolver indexNameExpressionResolver,
                      ThreadPool threadPool,
                      Provider<TransportPutIndexTemplateAction> transportPutIndexTemplateAction,
                      Functions functions) {
    this.clusterService = clusterService;
    this.indexNameExpressionResolver = indexNameExpressionResolver;
    this.transportPutIndexTemplateAction = transportPutIndexTemplateAction;
    this.functions = functions;
    this.executorService = (ExecutorService) threadPool.executor(ThreadPool.Names.SUGGEST);
    schemas.putAll(builtInSchemas);
    schemas.remove(BlobSchemaInfo.NAME); // remove blob schema name
    this.builtInSchemas = builtInSchemas;
    clusterService.add(this);
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:18,代码来源:ReferenceInfos.java

示例7: DelayedPrepareBulkRequest

import org.elasticsearch.threadpool.ThreadPool; //导入依赖的package包/类
DelayedPrepareBulkRequest(ThreadPool threadPool, float requestsPerSecond, TimeValue delay, AbstractRunnable command) {
    this.threadPool = threadPool;
    this.requestsPerSecond = requestsPerSecond;
    this.command = command;
    this.future = threadPool.schedule(delay, ThreadPool.Names.GENERIC, new AbstractRunnable() {
        @Override
        protected void doRun() throws Exception {
            throttledNanos.addAndGet(delay.nanos());
            command.run();
        }

        @Override
        public void onFailure(Exception e) {
            command.onFailure(e);
        }
    });
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:18,代码来源:WorkingBulkByScrollTask.java

示例8: AckCountDownListener

import org.elasticsearch.threadpool.ThreadPool; //导入依赖的package包/类
AckCountDownListener(AckedClusterStateTaskListener ackedTaskListener, long clusterStateVersion, DiscoveryNodes nodes, ThreadPool threadPool) {
    this.ackedTaskListener = ackedTaskListener;
    this.clusterStateVersion = clusterStateVersion;
    this.nodes = nodes;
    int countDown = 0;
    for (DiscoveryNode node : nodes) {
        if (ackedTaskListener.mustAck(node)) {
            countDown++;
        }
    }
    //we always wait for at least 1 node (the master)
    countDown = Math.max(1, countDown);
    logger.trace("expecting {} acknowledgements for cluster_state update (version: {})", countDown, clusterStateVersion);
    this.countDown = new CountDown(countDown);
    this.ackTimeoutCallback = threadPool.schedule(ackedTaskListener.ackTimeout(), ThreadPool.Names.GENERIC, new Runnable() {
        @Override
        public void run() {
            onTimeout();
        }
    });
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:22,代码来源:InternalClusterService.java

示例9: sendSetBanRequest

import org.elasticsearch.threadpool.ThreadPool; //导入依赖的package包/类
private void sendSetBanRequest(DiscoveryNodes nodes, BanParentTaskRequest request, ActionListener<Void> listener) {
    for (ObjectObjectCursor<String, DiscoveryNode> node : nodes.getNodes()) {
        logger.trace("Sending ban for tasks with the parent [{}] to the node [{}], ban [{}]", request.parentTaskId, node.key,
            request.ban);
        transportService.sendRequest(node.value, BAN_PARENT_ACTION_NAME, request,
            new EmptyTransportResponseHandler(ThreadPool.Names.SAME) {
                @Override
                public void handleResponse(TransportResponse.Empty response) {
                    listener.onResponse(null);
                }

                @Override
                public void handleException(TransportException exp) {
                    logger.warn("Cannot send ban for tasks with the parent [{}] to the node [{}]", request.parentTaskId, node.key);
                    listener.onFailure(exp);
                }
            });
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:20,代码来源:TransportCancelTasksAction.java

示例10: handlePingRequest

import org.elasticsearch.threadpool.ThreadPool; //导入依赖的package包/类
private UnicastPingResponse handlePingRequest(final UnicastPingRequest request) {
    if (!lifecycle.started()) {
        throw new IllegalStateException("received ping request while not started");
    }
    temporalResponses.add(request.pingResponse);
    threadPool.schedule(TimeValue.timeValueMillis(request.timeout.millis() * 2), ThreadPool.Names.SAME, new Runnable() {
        @Override
        public void run() {
            temporalResponses.remove(request.pingResponse);
        }
    });

    List<PingResponse> pingResponses = CollectionUtils.iterableAsArrayList(temporalResponses);
    pingResponses.add(createPingResponse(contextProvider.nodes()));


    UnicastPingResponse unicastPingResponse = new UnicastPingResponse();
    unicastPingResponse.id = request.id;
    unicastPingResponse.pingResponses = pingResponses.toArray(new PingResponse[pingResponses.size()]);

    return unicastPingResponse;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:23,代码来源:UnicastZenPing.java

示例11: PeerRecoveryTargetService

import org.elasticsearch.threadpool.ThreadPool; //导入依赖的package包/类
public PeerRecoveryTargetService(Settings settings, ThreadPool threadPool, TransportService transportService, RecoverySettings
        recoverySettings, ClusterService clusterService) {
    super(settings);
    this.threadPool = threadPool;
    this.transportService = transportService;
    this.recoverySettings = recoverySettings;
    this.clusterService = clusterService;
    this.onGoingRecoveries = new RecoveriesCollection(logger, threadPool, this::waitForClusterState);

    transportService.registerRequestHandler(Actions.FILES_INFO, RecoveryFilesInfoRequest::new, ThreadPool.Names.GENERIC, new
            FilesInfoRequestHandler());
    transportService.registerRequestHandler(Actions.FILE_CHUNK, RecoveryFileChunkRequest::new, ThreadPool.Names.GENERIC, new
            FileChunkTransportRequestHandler());
    transportService.registerRequestHandler(Actions.CLEAN_FILES, RecoveryCleanFilesRequest::new, ThreadPool.Names.GENERIC, new
            CleanFilesRequestHandler());
    transportService.registerRequestHandler(Actions.PREPARE_TRANSLOG, RecoveryPrepareForTranslogOperationsRequest::new, ThreadPool
            .Names.GENERIC, new PrepareForTranslogOperationsRequestHandler());
    transportService.registerRequestHandler(Actions.TRANSLOG_OPS, RecoveryTranslogOperationsRequest::new, ThreadPool.Names.GENERIC,
            new TranslogOperationsRequestHandler());
    transportService.registerRequestHandler(Actions.FINALIZE, RecoveryFinalizeRecoveryRequest::new, ThreadPool.Names.GENERIC, new
            FinalizeRecoveryRequestHandler());
    transportService.registerRequestHandler(Actions.WAIT_CLUSTERSTATE, RecoveryWaitForClusterStateRequest::new,
        ThreadPool.Names.GENERIC, new WaitForClusterStateRequestHandler());
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:25,代码来源:PeerRecoveryTargetService.java

示例12: TransportCloseIndexAction

import org.elasticsearch.threadpool.ThreadPool; //导入依赖的package包/类
@Inject
public TransportCloseIndexAction(Settings settings, TransportService transportService, ClusterService clusterService,
                                 ThreadPool threadPool, MetaDataIndexStateService indexStateService,
                                 ClusterSettings clusterSettings, ActionFilters actionFilters,
                                 IndexNameExpressionResolver indexNameExpressionResolver, DestructiveOperations destructiveOperations) {
    super(settings, CloseIndexAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, CloseIndexRequest::new);
    this.indexStateService = indexStateService;
    this.destructiveOperations = destructiveOperations;
    this.closeIndexEnabled = CLUSTER_INDICES_CLOSE_ENABLE_SETTING.get(settings);
    clusterSettings.addSettingsUpdateConsumer(CLUSTER_INDICES_CLOSE_ENABLE_SETTING, this::setCloseIndexEnabled);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:12,代码来源:TransportCloseIndexAction.java

示例13: testTimeoutCleanup

import org.elasticsearch.threadpool.ThreadPool; //导入依赖的package包/类
public void testTimeoutCleanup() throws Exception {
    ThreadPool threadPool = new TestThreadPool("test");
    final ScheduledThreadPoolExecutor timer = (ScheduledThreadPoolExecutor) threadPool.scheduler();
    final AtomicBoolean timeoutCalled = new AtomicBoolean();
    PrioritizedEsThreadPoolExecutor executor = EsExecutors.newSinglePrioritizing(getTestName(), EsExecutors.daemonThreadFactory(getTestName()), holder);
    final CountDownLatch invoked = new CountDownLatch(1);
    executor.execute(new Runnable() {
                         @Override
                         public void run() {
                             invoked.countDown();
                         }
                     }, timer, TimeValue.timeValueHours(1), new Runnable() {
                @Override
                public void run() {
                    // We should never get here
                    timeoutCalled.set(true);
                }
            }
    );
    invoked.await();

    // the timeout handler is added post execution (and quickly cancelled). We have allow for this
    // and use assert busy
    assertBusy(new Runnable() {
        @Override
        public void run() {
            assertThat(timer.getQueue().size(), equalTo(0));
        }
    }, 5, TimeUnit.SECONDS);
    assertThat(timeoutCalled.get(), equalTo(false));
    assertTrue(terminate(executor));
    assertTrue(terminate(threadPool));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:34,代码来源:PrioritizedExecutorsTests.java

示例14: testThatDefaultProfileInheritsFromStandardSettings

import org.elasticsearch.threadpool.ThreadPool; //导入依赖的package包/类
public void testThatDefaultProfileInheritsFromStandardSettings() throws Exception {
    Settings settings = Settings.builder()
        .put("network.host", host)
        .put(TransportSettings.PORT.getKey(), 0)
        .put("transport.profiles.client1.port", 0)
        .build();

    ThreadPool threadPool = new TestThreadPool("tst");
    try (TcpTransport<?> transport = startTransport(settings, threadPool)) {
        assertEquals(1, transport.profileBoundAddresses().size());
        assertEquals(1, transport.boundAddress().boundAddresses().length);
    } finally {
        terminate(threadPool);
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:16,代码来源:NettyTransportMultiPortTests.java

示例15: TransportDfsOnlyAction

import org.elasticsearch.threadpool.ThreadPool; //导入依赖的package包/类
@Inject
public TransportDfsOnlyAction(Settings settings, ThreadPool threadPool, ClusterService clusterService, TransportService transportService,
                              ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver, SearchService searchService, SearchPhaseController searchPhaseController) {
    super(settings, NAME, threadPool, clusterService, transportService, actionFilters, indexNameExpressionResolver,
            DfsOnlyRequest.class, ShardDfsOnlyRequest.class, ThreadPool.Names.SEARCH);
    this.searchService = searchService;
    this.searchPhaseController = searchPhaseController;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:9,代码来源:TransportDfsOnlyAction.java


注:本文中的org.elasticsearch.threadpool.ThreadPool类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。