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


Java EsExecutors.newScaling方法代码示例

本文整理汇总了Java中org.elasticsearch.common.util.concurrent.EsExecutors.newScaling方法的典型用法代码示例。如果您正苦于以下问题:Java EsExecutors.newScaling方法的具体用法?Java EsExecutors.newScaling怎么用?Java EsExecutors.newScaling使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.elasticsearch.common.util.concurrent.EsExecutors的用法示例。


在下文中一共展示了EsExecutors.newScaling方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: GridFsRepository

import org.elasticsearch.common.util.concurrent.EsExecutors; //导入方法依赖的package包/类
/**
 * Constructs new BlobStoreRepository
 * @param name                 repository name
 * @param repositorySettings   repository settings
 * @param indexShardRepository an instance of IndexShardRepository
 * @param gridFsService and instance of GridFsService
 */
@Inject
protected GridFsRepository(RepositoryName name, RepositorySettings repositorySettings, IndexShardRepository indexShardRepository, GridFsService gridFsService) {
    super(name.getName(), repositorySettings, indexShardRepository);

    String database = repositorySettings.settings().get("database", componentSettings.get("database"));
    if (database == null) {
        throw new RepositoryException(name.name(), "No database defined for GridFS repository");
    }

    String bucket = repositorySettings.settings().get("bucket", "fs");
    String host = repositorySettings.settings().get("gridfs_host", "localhost");
    int port = repositorySettings.settings().getAsInt("gridfs_port", 27017);
    String username = repositorySettings.settings().get("gridfs_username");
    String password = repositorySettings.settings().get("gridfs_password");

    int concurrentStreams = repositorySettings.settings().getAsInt("concurrent_streams", componentSettings.getAsInt("concurrent_streams", 5));
    ExecutorService concurrentStreamPool = EsExecutors.newScaling(1, concurrentStreams, 5, TimeUnit.SECONDS, EsExecutors.daemonThreadFactory(settings, "[gridfs_stream]"));
    blobStore = new GridFsBlobStore(settings, gridFsService.mongoDB(host, port, database, username, password), bucket, concurrentStreamPool);
    this.chunkSize = repositorySettings.settings().getAsBytesSize("chunk_size", componentSettings.getAsBytesSize("chunk_size", null));
    this.compress = repositorySettings.settings().getAsBoolean("compress", componentSettings.getAsBoolean("compress", true));
    this.basePath = BlobPath.cleanPath();
}
 
开发者ID:kzwang,项目名称:elasticsearch-repository-gridfs,代码行数:30,代码来源:GridFsRepository.java

示例3: 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

示例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: CloudFilesRepository

import org.elasticsearch.common.util.concurrent.EsExecutors; //导入方法依赖的package包/类
@Inject
protected CloudFilesRepository(String repositoryName, RepositorySettings repositorySettings, IndexShardRepository indexShardRepository, CloudFilesService cloudFilesService) {
    super(repositoryName, repositorySettings, indexShardRepository);

    final String container = repositorySettings.settings().get("container", componentSettings.get("container"));
    if(container == null || container.equals("")){
        throw new RepositoryException(repositoryName, "No container defined for cloud files gateway.");
    }

    final String dataCenter = repositorySettings.settings().get("region", componentSettings.get("region", "ORD"));
    final int concurrentStreams = repositorySettings.settings().getAsInt("concurrent_streams", componentSettings.getAsInt("concurrent_streams", 5));
    ExecutorService concurrentStreamPool = EsExecutors.newScaling(1, concurrentStreams, 5, TimeUnit.SECONDS, EsExecutors.daemonThreadFactory(settings, "[cloudfiles_stream]"));
    final Location location = new LocationBuilder()
            .scope(LocationScope.REGION)
            .id(dataCenter)
            .description(String.format("Rackspace's %s datacenter.", dataCenter))
            .build();

    blobStore = new CloudFilesBlobStore(settings, cloudFilesService.context(), container, location, concurrentStreamPool);
    this.chunkSize = repositorySettings.settings().getAsBytesSize("chunk_size", componentSettings.getAsBytesSize("chunk_size", new ByteSizeValue(100, ByteSizeUnit.MB)));
    this.compress = repositorySettings.settings().getAsBoolean("compress", componentSettings.getAsBoolean("compress", false));
    logger.debug("using container [{}], data center [{}], chunk_size [{}], concurrent_streams [{}]", container, dataCenter, chunkSize, concurrentStreams);
    String basePath = repositorySettings.settings().get("base_path", null);
    if (Strings.hasLength(basePath)) {
        BlobPath path = new BlobPath();
        for(String elem : Strings.splitStringToArray(basePath, '/')) {
            path = path.add(elem);
        }
        this.basePath = path;
    } else {
        this.basePath = BlobPath.cleanPath();
    }
}
 
开发者ID:jlinn,项目名称:elasticsearch-cloud-rackspace,代码行数:34,代码来源:CloudFilesRepository.java

示例6: 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

示例7: 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


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