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


Java Setting.intSetting方法代码示例

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


在下文中一共展示了Setting.intSetting方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testRunListener

import org.elasticsearch.common.settings.Setting; //导入方法依赖的package包/类
public void testRunListener() {
    Version version = VersionUtils.getPreviousVersion();
    Settings theSettings = Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, version)
        .put(IndexMetaData.SETTING_INDEX_UUID, "0xdeadbeef").build();
    final AtomicInteger integer = new AtomicInteger(0);
    Setting<Integer> integerSetting = Setting.intSetting("index.test.setting.int", -1,
        Property.Dynamic, Property.IndexScope);
    IndexMetaData metaData = newIndexMeta("index", theSettings);
    IndexSettings settings = newIndexSettings(newIndexMeta("index", theSettings), Settings.EMPTY, integerSetting);
    settings.getScopedSettings().addSettingsUpdateConsumer(integerSetting, integer::set);

    assertEquals(version, settings.getIndexVersionCreated());
    assertEquals("0xdeadbeef", settings.getUUID());

    assertFalse(settings.updateIndexMetaData(metaData));
    assertEquals(metaData.getSettings().getAsMap(), settings.getSettings().getAsMap());
    assertEquals(0, integer.get());
    assertTrue(settings.updateIndexMetaData(newIndexMeta("index", Settings.builder().put(theSettings).put("index.test.setting.int", 42)
        .build())));
    assertEquals(42, integer.get());
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:22,代码来源:IndexSettingsTests.java

示例2: testSettingsUpdateValidator

import org.elasticsearch.common.settings.Setting; //导入方法依赖的package包/类
public void testSettingsUpdateValidator() {
    Version version = VersionUtils.getPreviousVersion();
    Settings theSettings = Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, version)
        .put(IndexMetaData.SETTING_INDEX_UUID, "0xdeadbeef").build();
    final AtomicInteger integer = new AtomicInteger(0);
    Setting<Integer> integerSetting = Setting.intSetting("index.test.setting.int", -1,
        Property.Dynamic, Property.IndexScope);
    IndexMetaData metaData = newIndexMeta("index", theSettings);
    IndexSettings settings = newIndexSettings(newIndexMeta("index", theSettings), Settings.EMPTY, integerSetting);
    settings.getScopedSettings().addSettingsUpdateConsumer(integerSetting, integer::set,
        (i) -> {if (i == 42) throw new AssertionError("boom");});

    assertEquals(version, settings.getIndexVersionCreated());
    assertEquals("0xdeadbeef", settings.getUUID());

    assertFalse(settings.updateIndexMetaData(metaData));
    assertEquals(metaData.getSettings().getAsMap(), settings.getSettings().getAsMap());
    assertEquals(0, integer.get());
    expectThrows(IllegalArgumentException.class, () -> settings.updateIndexMetaData(newIndexMeta("index",
        Settings.builder().put(theSettings).put("index.test.setting.int", 42).build())));
    assertTrue(settings.updateIndexMetaData(newIndexMeta("index", Settings.builder().put(theSettings).put("index.test.setting.int", 41)
        .build())));
    assertEquals(41, integer.get());
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:25,代码来源:IndexSettingsTests.java

示例3: buildNumberOfShardsSetting

import org.elasticsearch.common.settings.Setting; //导入方法依赖的package包/类
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);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:14,代码来源:IndexMetaData.java

示例4: FixedExecutorBuilder

import org.elasticsearch.common.settings.Setting; //导入方法依赖的package包/类
/**
 * 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);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:23,代码来源:FixedExecutorBuilder.java

示例5: testNodeSettingsAreContained

import org.elasticsearch.common.settings.Setting; //导入方法依赖的package包/类
public void testNodeSettingsAreContained() {
    final int numShards = randomIntBetween(1, 10);
    final int numReplicas = randomIntBetween(0, 10);
    Settings theSettings = Settings.builder().
            put("index.foo.bar", 0)
            .put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, numReplicas)
            .put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, numShards).build();

    Settings nodeSettings = Settings.builder().put("index.foo.bar", 43).build();
    final AtomicInteger indexValue = new AtomicInteger(0);
    Setting<Integer> integerSetting = Setting.intSetting("index.foo.bar", -1, Property.Dynamic, Property.IndexScope);
    IndexSettings settings = newIndexSettings(newIndexMeta("index", theSettings), nodeSettings, integerSetting);
    settings.getScopedSettings().addSettingsUpdateConsumer(integerSetting, indexValue::set);
    assertEquals(numReplicas, settings.getNumberOfReplicas());
    assertEquals(numShards, settings.getNumberOfShards());
    assertEquals(0, indexValue.get());

    assertTrue(settings.updateIndexMetaData(newIndexMeta("index", Settings.builder().
            put("index.foo.bar", 42)
            .put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, numReplicas + 1)
            .put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, numShards).build())));

    assertEquals(42, indexValue.get());
    assertSame(nodeSettings, settings.getNodeSettings());

    assertTrue(settings.updateIndexMetaData(newIndexMeta("index", Settings.builder()
        .put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, numReplicas + 1)
        .put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, numShards).build())));
    assertEquals(43, indexValue.get());

}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:32,代码来源:IndexSettingsTests.java

示例6: ScalingExecutorBuilder

import org.elasticsearch.common.settings.Setting; //导入方法依赖的package包/类
/**
 * 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);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:20,代码来源:ScalingExecutorBuilder.java


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