Java Code Examples for org.elasticsearch.common.settings.Setting#intSetting()

The following examples show how to use org.elasticsearch.common.settings.Setting#intSetting() . 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: IndexMetaData.java    From crate with Apache License 2.0 5 votes vote down vote up
static Setting<Integer> buildNumberOfShardsSetting() {
    /* This is a safety limit that should only be exceeded in very rare and special cases. The assumption is that
     * 99% of the users have less than 1024 shards per index. We also make it a hard check that requires restart of nodes
     * if a cluster should allow to create more than 1024 shards per index. NOTE: this does not limit the number of shards per cluster.
     * this also prevents creating stuff like a new index with millions of shards by accident which essentially kills the entire cluster
     * with OOM on the spot.*/
    final int maxNumShards = Integer.parseInt(System.getProperty("es.index.max_number_of_shards", "1024"));
    if (maxNumShards < 1) {
        throw new IllegalArgumentException("es.index.max_number_of_shards must be > 0");
    }
    return Setting.intSetting(SETTING_NUMBER_OF_SHARDS, Math.min(5, maxNumShards), 1, maxNumShards,
        Property.IndexScope, Property.Final);
}
 
Example 2
Source File: FixedExecutorBuilder.java    From crate with Apache License 2.0 5 votes vote down vote up
/**
 * Construct a fixed executor builder.
 *
 * @param settings  the node-level settings
 * @param name      the name of the executor
 * @param size      the fixed number of threads
 * @param queueSize the size of the backing queue, -1 for unbounded
 * @param prefix    the prefix for the settings keys
 */
public FixedExecutorBuilder(final Settings settings, final String name, final int size, final int queueSize, final String prefix) {
    super(name);
    final String sizeKey = settingsKey(prefix, "size");
    this.sizeSetting = new Setting<>(
        sizeKey,
        s -> Integer.toString(size),
        s -> Setting.parseInt(s, 1, applyHardSizeLimit(settings, name), sizeKey),
        Setting.Property.NodeScope
    );
    final String queueSizeKey = settingsKey(prefix, "queue_size");
    this.queueSizeSetting = Setting.intSetting(queueSizeKey, queueSize, Setting.Property.NodeScope);
}
 
Example 3
Source File: ScalingExecutorBuilder.java    From crate with Apache License 2.0 3 votes vote down vote up
/**
 * Construct a scaling executor builder; the settings will have the
 * specified key prefix.
 *
 * @param name      the name of the executor
 * @param core      the minimum number of threads in the pool
 * @param max       the maximum number of threads in the pool
 * @param keepAlive the time that spare threads above {@code core}
 *                  threads will be kept alive
 * @param prefix    the prefix for the settings keys
 */
public ScalingExecutorBuilder(final String name, final int core, final int max, final TimeValue keepAlive, final String prefix) {
    super(name);
    this.coreSetting =
        Setting.intSetting(settingsKey(prefix, "core"), core, Setting.Property.NodeScope);
    this.maxSetting = Setting.intSetting(settingsKey(prefix, "max"), max, Setting.Property.NodeScope);
    this.keepAliveSetting =
        Setting.timeSetting(settingsKey(prefix, "keep_alive"), keepAlive, Setting.Property.NodeScope);
}