Java Code Examples for org.elasticsearch.common.util.concurrent.EsExecutors#boundedNumberOfProcessors()

The following examples show how to use org.elasticsearch.common.util.concurrent.EsExecutors#boundedNumberOfProcessors() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ThreadPool.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
private int applyHardSizeLimit(String name, int size) {
    int availableProcessors = EsExecutors.boundedNumberOfProcessors(settings);
    if ((name.equals(Names.BULK) || name.equals(Names.INDEX)) && size > availableProcessors) {
        // We use a hard max size for the indexing pools, because if too many threads enter Lucene's IndexWriter, it means
        // too many segments written, too frequently, too much merging, etc:
        // TODO: I would love to be loud here (throw an exception if you ask for a too-big size), but I think this is dangerous
        // because on upgrade this setting could be in cluster state and hard for the user to correct?
        logger.warn("requested thread pool size [{}] for [{}] is too large; setting to maximum [{}] instead",
                    size, name, availableProcessors);
        size = availableProcessors;
    }

    return size;
}
 
Example 2
Source File: OsService.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Inject
public OsService(Settings settings, OsProbe probe) {
    super(settings);
    this.probe = probe;

    TimeValue refreshInterval = settings.getAsTime("monitor.os.refresh_interval", TimeValue.timeValueSeconds(1));

    this.info = probe.osInfo();
    this.info.refreshInterval = refreshInterval.millis();
    this.info.allocatedProcessors = EsExecutors.boundedNumberOfProcessors(settings);

    osStatsCache = new OsStatsCache(refreshInterval, probe.osStats());
    logger.debug("Using probe [{}] with refresh_interval [{}]", probe, refreshInterval);
}