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


Java InternalSettingsPreparer类代码示例

本文整理汇总了Java中org.elasticsearch.node.InternalSettingsPreparer的典型用法代码示例。如果您正苦于以下问题:Java InternalSettingsPreparer类的具体用法?Java InternalSettingsPreparer怎么用?Java InternalSettingsPreparer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: testReplacePromptPlaceholders

import org.elasticsearch.node.InternalSettingsPreparer; //导入依赖的package包/类
public void testReplacePromptPlaceholders() {
    MockTerminal terminal = new MockTerminal();
    terminal.addTextInput("text");
    terminal.addSecretInput("replaced");

    Settings.Builder builder = Settings.builder()
            .put(baseEnvSettings)
            .put("password.replace", InternalSettingsPreparer.SECRET_PROMPT_VALUE)
            .put("dont.replace", "prompt:secret")
            .put("dont.replace2", "_prompt:secret_")
            .put("dont.replace3", "_prompt:text__")
            .put("dont.replace4", "__prompt:text_")
            .put("dont.replace5", "prompt:secret__")
            .put("replace_me", InternalSettingsPreparer.TEXT_PROMPT_VALUE);
    Settings settings = InternalSettingsPreparer.prepareEnvironment(builder.build(), terminal).settings();

    assertThat(settings.get("password.replace"), equalTo("replaced"));
    assertThat(settings.get("replace_me"), equalTo("text"));

    // verify other values unchanged
    assertThat(settings.get("dont.replace"), equalTo("prompt:secret"));
    assertThat(settings.get("dont.replace2"), equalTo("_prompt:secret_"));
    assertThat(settings.get("dont.replace3"), equalTo("_prompt:text__"));
    assertThat(settings.get("dont.replace4"), equalTo("__prompt:text_"));
    assertThat(settings.get("dont.replace5"), equalTo("prompt:secret__"));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:27,代码来源:InternalSettingsPreparerTests.java

示例2: testMultipleSettingsFileNotAllowed

import org.elasticsearch.node.InternalSettingsPreparer; //导入依赖的package包/类
public void testMultipleSettingsFileNotAllowed() throws IOException {
    InputStream yaml = getClass().getResourceAsStream("/config/elasticsearch.yaml");
    InputStream properties = getClass().getResourceAsStream("/config/elasticsearch.properties");
    Path home = createTempDir();
    Path config = home.resolve("config");
    Files.createDirectory(config);
    Files.copy(yaml, config.resolve("elasticsearch.yaml"));
    Files.copy(properties, config.resolve("elasticsearch.properties"));

    try {
        InternalSettingsPreparer.prepareEnvironment(Settings.builder()
            .put(baseEnvSettings)
            .build(), null);
    } catch (SettingsException e) {
        assertTrue(e.getMessage(), e.getMessage().contains("multiple settings files found with suffixes"));
        assertTrue(e.getMessage(), e.getMessage().contains(".yaml"));
        assertTrue(e.getMessage(), e.getMessage().contains(".properties"));
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:20,代码来源:InternalSettingsPreparerTests.java

示例3: getTestClient

import org.elasticsearch.node.InternalSettingsPreparer; //导入依赖的package包/类
private Client getTestClient() {
    final Settings nodeSettings = Settings.builder()
            .put(TRANSPORT_TYPE_SETTING_KEY, CLUSTER_NAME_SETTING_VALUE)
            .put(TRANSPORT_TCP_PORT_SETTING_KEY, port)
            .put(PATH_HOME_SETTING_KEY, homePath)
            .put(HTTP_ENABLED_SETTING_KEY, false)
            .build();
    try {
        final Environment environment = InternalSettingsPreparer.prepareEnvironment(nodeSettings, null);
        addPlugins(environment);
        return new StandAloneNode(environment, plugins).start().client();
    } catch (final NodeValidationException e) {
        LOGGER.error("Error occurs while initializing elastic search node at {}:{} - {}", host, port, e);
        throw new EsCoreRuntimeException("Error occurs while initializing elastic search node at " + host + ":" + port, e);
    }
}
 
开发者ID:Biacode,项目名称:escommons,代码行数:17,代码来源:EsClientBuilderImpl.java

示例4: getElasticsearchNode

import org.elasticsearch.node.InternalSettingsPreparer; //导入依赖的package包/类
@Produces
@Singleton
@SuppressWarnings("resource")
public Node getElasticsearchNode() throws Exception {

    FileUtils.deleteDirectory(DATA_PATH);

    class PluginConfigurableNode extends Node {
        PluginConfigurableNode(Settings settings, Collection<Class<? extends Plugin>> classpathPlugins) {
            super(InternalSettingsPreparer.prepareEnvironment(settings, null), classpathPlugins);
        }
    }

    // create an embedded node to resume
    return new PluginConfigurableNode(Settings.builder()
        .put("http.enabled", true)
        .put("path.data", DATA_PATH)
        .put("path.home", HOME_PATH)
        .put("transport.profiles.default.port", ES_TRANSPORT_PORT)
        .build(), Arrays.asList(Netty4Plugin.class)).start();
}
 
开发者ID:wildfly-extras,项目名称:wildfly-camel,代码行数:22,代码来源:ElasticsearchNodeProducer.java

示例5: newPluginService

import org.elasticsearch.node.InternalSettingsPreparer; //导入依赖的package包/类
private static PluginsService newPluginService(final Settings settings, Collection<Class<? extends Plugin>> plugins) {
    final Settings.Builder settingsBuilder = Settings.builder()
            .put(TcpTransport.PING_SCHEDULE.getKey(), "5s") // enable by default the transport schedule ping interval
            .put(InternalSettingsPreparer.prepareSettings(settings))
            .put(NetworkService.NETWORK_SERVER.getKey(), false)
            .put(CLIENT_TYPE_SETTING_S.getKey(), CLIENT_TYPE);
    return new PluginsService(settingsBuilder.build(), null, null, plugins);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:9,代码来源:TransportClient.java

示例6: createEnvironment

import org.elasticsearch.node.InternalSettingsPreparer; //导入依赖的package包/类
private static Environment createEnvironment(boolean foreground, Path pidFile,
                                             SecureSettings secureSettings, Settings initialSettings) {
    Terminal terminal = foreground ? Terminal.DEFAULT : null;
    Settings.Builder builder = Settings.builder();
    if (pidFile != null) {
        builder.put(Environment.PIDFILE_SETTING.getKey(), pidFile);
    }
    builder.put(initialSettings);
    if (secureSettings != null) {
        builder.setSecureSettings(secureSettings);
    }
    return InternalSettingsPreparer.prepareEnvironment(builder.build(), terminal, Collections.emptyMap());
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:14,代码来源:Bootstrap.java

示例7: testEmptySettings

import org.elasticsearch.node.InternalSettingsPreparer; //导入依赖的package包/类
public void testEmptySettings() {
    Settings settings = InternalSettingsPreparer.prepareSettings(Settings.EMPTY);
    assertNull(settings.get("node.name")); // a name was not set
    assertNotNull(settings.get(ClusterName.CLUSTER_NAME_SETTING.getKey())); // a cluster name was set
    int size = settings.names().size();

    Environment env = InternalSettingsPreparer.prepareEnvironment(baseEnvSettings, null);
    settings = env.settings();
    assertNull(settings.get("node.name")); // a name was not set
    assertNotNull(settings.get(ClusterName.CLUSTER_NAME_SETTING.getKey())); // a cluster name was set
    assertEquals(settings.toString(), size + 1 /* path.home is in the base settings */, settings.names().size());
    String home = Environment.PATH_HOME_SETTING.get(baseEnvSettings);
    String configDir = env.configFile().toString();
    assertTrue(configDir, configDir.startsWith(home));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:16,代码来源:InternalSettingsPreparerTests.java

示例8: testReplaceSecretPromptPlaceholderWithNullTerminal

import org.elasticsearch.node.InternalSettingsPreparer; //导入依赖的package包/类
public void testReplaceSecretPromptPlaceholderWithNullTerminal() {
    Settings.Builder builder = Settings.builder()
            .put(baseEnvSettings)
            .put("replace_me1", InternalSettingsPreparer.SECRET_PROMPT_VALUE);
    try {
        InternalSettingsPreparer.prepareEnvironment(builder.build(), null);
        fail("an exception should have been thrown since no terminal was provided!");
    } catch (UnsupportedOperationException e) {
        assertThat(e.getMessage(), containsString("with value [" + InternalSettingsPreparer.SECRET_PROMPT_VALUE + "]"));
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:12,代码来源:InternalSettingsPreparerTests.java

示例9: testReplaceTextPromptPlaceholderWithNullTerminal

import org.elasticsearch.node.InternalSettingsPreparer; //导入依赖的package包/类
public void testReplaceTextPromptPlaceholderWithNullTerminal() {
    Settings.Builder builder = Settings.builder()
            .put(baseEnvSettings)
            .put("replace_me1", InternalSettingsPreparer.TEXT_PROMPT_VALUE);
    try {
        InternalSettingsPreparer.prepareEnvironment(builder.build(), null);
        fail("an exception should have been thrown since no terminal was provided!");
    } catch (UnsupportedOperationException e) {
        assertThat(e.getMessage(), containsString("with value [" + InternalSettingsPreparer.TEXT_PROMPT_VALUE + "]"));
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:12,代码来源:InternalSettingsPreparerTests.java

示例10: testGarbageIsNotSwallowed

import org.elasticsearch.node.InternalSettingsPreparer; //导入依赖的package包/类
public void testGarbageIsNotSwallowed() throws IOException {
    try {
        InputStream garbage = getClass().getResourceAsStream("/config/garbage/garbage.yml");
        Path home = createTempDir();
        Path config = home.resolve("config");
        Files.createDirectory(config);
        Files.copy(garbage, config.resolve("elasticsearch.yml"));
        InternalSettingsPreparer.prepareEnvironment(Settings.builder()
            .put(baseEnvSettings)
            .build(), null);
    } catch (SettingsException e) {
        assertEquals("Failed to load settings from [elasticsearch.yml]", e.getMessage());
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:15,代码来源:InternalSettingsPreparerTests.java

示例11: testSecureSettings

import org.elasticsearch.node.InternalSettingsPreparer; //导入依赖的package包/类
public void testSecureSettings() {
    MockSecureSettings secureSettings = new MockSecureSettings();
    secureSettings.setString("foo", "secret");
    Settings input = Settings.builder().put(baseEnvSettings).setSecureSettings(secureSettings).build();
    Environment env = InternalSettingsPreparer.prepareEnvironment(input, null);
    Setting<SecureString> fakeSetting = SecureSetting.secureString("foo", null, false);
    assertEquals("secret", fakeSetting.get(env.settings()).toString());
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:9,代码来源:InternalSettingsPreparerTests.java

示例12: testDefaultPropertiesOverride

import org.elasticsearch.node.InternalSettingsPreparer; //导入依赖的package包/类
public void testDefaultPropertiesOverride() throws Exception {
    Path configDir = homeDir.resolve("config");
    Files.createDirectories(configDir);
    Files.write(configDir.resolve("elasticsearch.yml"), Collections.singletonList("setting: bar"), StandardCharsets.UTF_8);
    Map<String, String> props = Collections.singletonMap("default.setting", "foo");
    Environment env = InternalSettingsPreparer.prepareEnvironment(baseEnvSettings, null, props);
    assertEquals("bar", env.settings().get("setting"));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:9,代码来源:InternalSettingsPreparerTests.java

示例13: createEnv

import org.elasticsearch.node.InternalSettingsPreparer; //导入依赖的package包/类
/** Create an {@link Environment} for the command to use. Overrideable for tests. */
protected Environment createEnv(Terminal terminal, Map<String, String> settings) {
    return InternalSettingsPreparer.prepareEnvironment(Settings.EMPTY, terminal, settings);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:5,代码来源:EnvironmentAwareCommand.java

示例14: testDefaultClusterName

import org.elasticsearch.node.InternalSettingsPreparer; //导入依赖的package包/类
public void testDefaultClusterName() {
    Settings settings = InternalSettingsPreparer.prepareSettings(Settings.EMPTY);
    assertEquals("elasticsearch", settings.get("cluster.name"));
    settings = InternalSettingsPreparer.prepareSettings(Settings.builder().put("cluster.name", "foobar").build());
    assertEquals("foobar", settings.get("cluster.name"));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:7,代码来源:InternalSettingsPreparerTests.java

示例15: testDefaultProperties

import org.elasticsearch.node.InternalSettingsPreparer; //导入依赖的package包/类
public void testDefaultProperties() throws Exception {
    Map<String, String> props = Collections.singletonMap("default.setting", "foo");
    Environment env = InternalSettingsPreparer.prepareEnvironment(baseEnvSettings, null, props);
    assertEquals("foo", env.settings().get("setting"));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:6,代码来源:InternalSettingsPreparerTests.java


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