當前位置: 首頁>>代碼示例>>Java>>正文


Java EsExecutors.daemonThreadFactory方法代碼示例

本文整理匯總了Java中org.elasticsearch.common.util.concurrent.EsExecutors.daemonThreadFactory方法的典型用法代碼示例。如果您正苦於以下問題:Java EsExecutors.daemonThreadFactory方法的具體用法?Java EsExecutors.daemonThreadFactory怎麽用?Java EsExecutors.daemonThreadFactory使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.elasticsearch.common.util.concurrent.EsExecutors的用法示例。


在下文中一共展示了EsExecutors.daemonThreadFactory方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createComponents

import org.elasticsearch.common.util.concurrent.EsExecutors; //導入方法依賴的package包/類
@Override
public Collection<Object> createComponents(
        Client client,
        ClusterService clusterService,
        ThreadPool threadPool,
        ResourceWatcherService resourceWatcherService,
        ScriptService scriptService,
        NamedXContentRegistry xContentRegistry) {
    final int concurrentConnects = UnicastZenPing.DISCOVERY_ZEN_PING_UNICAST_CONCURRENT_CONNECTS_SETTING.get(settings);
    final ThreadFactory threadFactory = EsExecutors.daemonThreadFactory(settings, "[file_based_discovery_resolve]");
    fileBasedDiscoveryExecutorService = EsExecutors.newScaling(
        "file_based_discovery_resolve",
        0,
        concurrentConnects,
        60,
        TimeUnit.SECONDS,
        threadFactory,
        threadPool.getThreadContext());

    return Collections.emptyList();
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:22,代碼來源:FileBasedDiscoveryPlugin.java

示例2: UnicastZenPing

import org.elasticsearch.common.util.concurrent.EsExecutors; //導入方法依賴的package包/類
public UnicastZenPing(Settings settings, ThreadPool threadPool, TransportService transportService,
                      UnicastHostsProvider unicastHostsProvider) {
    super(settings);
    this.threadPool = threadPool;
    this.transportService = transportService;
    this.clusterName = ClusterName.CLUSTER_NAME_SETTING.get(settings);
    this.hostsProvider = unicastHostsProvider;

    this.concurrentConnects = DISCOVERY_ZEN_PING_UNICAST_CONCURRENT_CONNECTS_SETTING.get(settings);
    if (DISCOVERY_ZEN_PING_UNICAST_HOSTS_SETTING.exists(settings)) {
        configuredHosts = DISCOVERY_ZEN_PING_UNICAST_HOSTS_SETTING.get(settings);
        // we only limit to 1 addresses, makes no sense to ping 100 ports
        limitPortCounts = LIMIT_FOREIGN_PORTS_COUNT;
    } else {
        // if unicast hosts are not specified, fill with simple defaults on the local machine
        configuredHosts = transportService.getLocalAddresses();
        limitPortCounts = LIMIT_LOCAL_PORTS_COUNT;
    }
    resolveTimeout = DISCOVERY_ZEN_PING_UNICAST_HOSTS_RESOLVE_TIMEOUT.get(settings);
    logger.debug(
        "using initial hosts {}, with concurrent_connects [{}], resolve_timeout [{}]",
        configuredHosts,
        concurrentConnects,
        resolveTimeout);

    transportService.registerRequestHandler(ACTION_NAME, UnicastPingRequest::new, ThreadPool.Names.SAME,
        new UnicastPingRequestHandler());

    final ThreadFactory threadFactory = EsExecutors.daemonThreadFactory(settings, "[unicast_connect]");
    unicastZenPingExecutorService = EsExecutors.newScaling(
        "unicast_connect",
        0, concurrentConnects,
        60,
        TimeUnit.SECONDS,
        threadFactory,
        threadPool.getThreadContext());
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:38,代碼來源:UnicastZenPing.java

示例3: build

import org.elasticsearch.common.util.concurrent.EsExecutors; //導入方法依賴的package包/類
@Override
ThreadPool.ExecutorHolder build(final FixedExecutorSettings settings, final ThreadContext threadContext) {
    int size = settings.size;
    int queueSize = settings.queueSize;
    final ThreadFactory threadFactory = EsExecutors.daemonThreadFactory(EsExecutors.threadName(settings.nodeName, name()));
    final ExecutorService executor = EsExecutors.newFixed(name(), size, queueSize, threadFactory, threadContext);
    final ThreadPool.Info info =
        new ThreadPool.Info(name(), ThreadPool.ThreadPoolType.FIXED, size, size, null, queueSize < 0 ? null : new SizeValue(queueSize));
    return new ThreadPool.ExecutorHolder(executor, info);
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:11,代碼來源:FixedExecutorBuilder.java

示例4: setUp

import org.elasticsearch.common.util.concurrent.EsExecutors; //導入方法依賴的package包/類
@Before
public void setUp() throws Exception {
    super.setUp();
    threadPool = new TestThreadPool(getClass().getName());
    final ThreadFactory threadFactory = EsExecutors.daemonThreadFactory("[" + getClass().getName() + "]");
    executorService =
        EsExecutors.newScaling(getClass().getName(), 0, 2, 60, TimeUnit.SECONDS, threadFactory, threadPool.getThreadContext());
    closeables = new Stack<>();
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:10,代碼來源:UnicastZenPingTests.java

示例5: LocalTransport

import org.elasticsearch.common.util.concurrent.EsExecutors; //導入方法依賴的package包/類
@Inject
public LocalTransport(Settings settings, ThreadPool threadPool, Version version, NamedWriteableRegistry namedWriteableRegistry) {
    super(settings);
    this.threadPool = threadPool;
    this.version = version;
    int workerCount = this.settings.getAsInt(TRANSPORT_LOCAL_WORKERS, EsExecutors.boundedNumberOfProcessors(settings));
    int queueSize = this.settings.getAsInt(TRANSPORT_LOCAL_QUEUE, -1);
    logger.debug("creating [{}] workers, queue_size [{}]", workerCount, queueSize);
    final ThreadFactory threadFactory = EsExecutors.daemonThreadFactory(this.settings, LOCAL_TRANSPORT_THREAD_NAME_PREFIX);
    this.workers = EsExecutors.newFixed(LOCAL_TRANSPORT_THREAD_NAME_PREFIX, workerCount, queueSize, threadFactory);
    this.namedWriteableRegistry = namedWriteableRegistry;
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:13,代碼來源:LocalTransport.java

示例6: doStart

import org.elasticsearch.common.util.concurrent.EsExecutors; //導入方法依賴的package包/類
@Override
protected void doStart() throws ElasticsearchException {
    executorService = new ThreadPoolExecutor(2, 2, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(),
            EsExecutors.daemonThreadFactory("nlptab")) {
        @Override
        protected void afterExecute(Runnable r, Throwable t) {
            super.afterExecute(r, t);
            logger.debug("Completed running nlptab task");
            if (t == null && r instanceof Future<?>) {
                try {
                    Object result = ((Future) r).get();
                } catch (InterruptedException e) {
                    Thread.currentThread().interrupt();
                } catch (ExecutionException e) {
                    t = e.getCause();
                } catch (CancellationException ce) {
                    t = ce;
                }
            }

            if (t != null) {
                logger.error("Error while executing task.", t);
            }
        }
    };

    System.setProperty("uima.datapath", environment.tmpFile().toString());
}
 
開發者ID:nlpie,項目名稱:nlptab,代碼行數:29,代碼來源:NlptabService.java

示例7: build

import org.elasticsearch.common.util.concurrent.EsExecutors; //導入方法依賴的package包/類
ThreadPool.ExecutorHolder build(final ScalingExecutorSettings settings, final ThreadContext threadContext) {
    TimeValue keepAlive = settings.keepAlive;
    int core = settings.core;
    int max = settings.max;
    final ThreadPool.Info info = new ThreadPool.Info(name(), ThreadPool.ThreadPoolType.SCALING, core, max, keepAlive, null);
    final ThreadFactory threadFactory = EsExecutors.daemonThreadFactory(EsExecutors.threadName(settings.nodeName, name()));
    final ExecutorService executor =
        EsExecutors.newScaling(name(), core, max, keepAlive.millis(), TimeUnit.MILLISECONDS, threadFactory, threadContext);
    return new ThreadPool.ExecutorHolder(executor, info);
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:11,代碼來源:ScalingExecutorBuilder.java

示例8: UnicastZenPing

import org.elasticsearch.common.util.concurrent.EsExecutors; //導入方法依賴的package包/類
@Inject
public UnicastZenPing(Settings settings, ThreadPool threadPool, TransportService transportService, ClusterName clusterName,
                      Version version, ElectMasterService electMasterService, @Nullable Set<UnicastHostsProvider> unicastHostsProviders) {
    super(settings);
    this.threadPool = threadPool;
    this.transportService = transportService;
    this.clusterName = clusterName;
    this.electMasterService = electMasterService;

    if (unicastHostsProviders != null) {
        for (UnicastHostsProvider unicastHostsProvider : unicastHostsProviders) {
            addHostsProvider(unicastHostsProvider);
        }
    }

    this.concurrentConnects = this.settings.getAsInt("discovery.zen.ping.unicast.concurrent_connects", 10);
    String[] hostArr = this.settings.getAsArray(DISCOVERY_ZEN_PING_UNICAST_HOSTS);
    // trim the hosts
    for (int i = 0; i < hostArr.length; i++) {
        hostArr[i] = hostArr[i].trim();
    }
    List<String> hosts = CollectionUtils.arrayAsArrayList(hostArr);
    final int limitPortCounts;
    if (hosts.isEmpty()) {
        // if unicast hosts are not specified, fill with simple defaults on the local machine
        limitPortCounts = LIMIT_LOCAL_PORTS_COUNT;
        hosts.addAll(transportService.getLocalAddresses());
    } else {
        // we only limit to 1 addresses, makes no sense to ping 100 ports
        limitPortCounts = LIMIT_FOREIGN_PORTS_COUNT;
    }

    logger.debug("using initial hosts {}, with concurrent_connects [{}]", hosts, concurrentConnects);

    List<DiscoveryNode> configuredTargetNodes = new ArrayList<>();
    for (String host : hosts) {
        try {
            TransportAddress[] addresses = transportService.addressesFromString(host, limitPortCounts);
            for (TransportAddress address : addresses) {
                configuredTargetNodes.add(new DiscoveryNode(UNICAST_NODE_PREFIX + unicastNodeIdGenerator.incrementAndGet() + "#", address, version.minimumCompatibilityVersion()));
            }
        } catch (Exception e) {
            throw new IllegalArgumentException("Failed to resolve address for [" + host + "]", e);
        }
    }
    this.configuredTargetNodes = configuredTargetNodes.toArray(new DiscoveryNode[configuredTargetNodes.size()]);

    transportService.registerRequestHandler(ACTION_NAME, UnicastPingRequest.class, ThreadPool.Names.SAME, new UnicastPingRequestHandler());

    ThreadFactory threadFactory = EsExecutors.daemonThreadFactory(settings, "[unicast_connect]");
    unicastConnectExecutor = EsExecutors.newScaling("unicast_connect", 0, concurrentConnects, 60, TimeUnit.SECONDS, threadFactory);
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:53,代碼來源:UnicastZenPing.java

示例9: getSlurperThreadFactory

import org.elasticsearch.common.util.concurrent.EsExecutors; //導入方法依賴的package包/類
@Provides
@Singleton
@Named("arangodb_river_walReaderRunnable_threadfactory")
public ThreadFactory getSlurperThreadFactory(RiverSettings settings) {
	return EsExecutors.daemonThreadFactory(settings.globalSettings(), "arangodb_river_walreader");
}
 
開發者ID:arangodb,項目名稱:elasticsearch-river-arangodb,代碼行數:7,代碼來源:ArangoDbRiverModule.java

示例10: getIndexerThreadFactory

import org.elasticsearch.common.util.concurrent.EsExecutors; //導入方法依賴的package包/類
@Provides
@Singleton
@Named("arangodb_river_indexWriterRunnable_threadfactory")
public ThreadFactory getIndexerThreadFactory(RiverSettings settings) {
	return EsExecutors.daemonThreadFactory(settings.globalSettings(), "arangodb_river_indexer");
}
 
開發者ID:arangodb,項目名稱:elasticsearch-river-arangodb,代碼行數:7,代碼來源:ArangoDbRiverModule.java


注:本文中的org.elasticsearch.common.util.concurrent.EsExecutors.daemonThreadFactory方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。