本文整理汇总了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__"));
}
示例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"));
}
}
示例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);
}
}
示例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();
}
示例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);
}
示例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());
}
示例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));
}
示例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 + "]"));
}
}
示例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 + "]"));
}
}
示例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());
}
}
示例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());
}
示例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"));
}
示例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);
}
示例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"));
}
示例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"));
}