当前位置: 首页>>代码示例>>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;未经允许,请勿转载。