Search in sources :

Example 1 with Terminal

use of org.elasticsearch.common.cli.Terminal in project crate by crate.

the class NodeSettingsTest method doSetup.

private void doSetup() throws IOException {
    // mute log4j warning by configuring a dummy logger
    if (!loggingConfigured) {
        Logger root = Logger.getRootLogger();
        root.removeAllAppenders();
        root.setLevel(Level.OFF);
        root.addAppender(new NullAppender());
        loggingConfigured = true;
    }
    tmp.create();
    Settings.Builder builder = Settings.settingsBuilder().put("node.name", "node-test").put("node.data", true).put("index.store.type", "default").put("index.store.fs.memory.enabled", "true").put("gateway.type", "default").put("path.home", createConfigPath()).put("index.number_of_shards", "1").put("index.number_of_replicas", "0").put("cluster.routing.schedule", "50ms").put("node.local", true);
    Terminal terminal = Terminal.DEFAULT;
    Environment environment = CrateSettingsPreparer.prepareEnvironment(builder.build(), terminal);
    node = new CrateNode(environment);
    node.start();
    client = node.client();
    client.admin().indices().prepareCreate("test").execute().actionGet();
}
Also used : NullAppender(org.apache.log4j.varia.NullAppender) Environment(org.elasticsearch.env.Environment) Logger(org.apache.log4j.Logger) Terminal(org.elasticsearch.common.cli.Terminal) Settings(org.elasticsearch.common.settings.Settings)

Example 2 with Terminal

use of org.elasticsearch.common.cli.Terminal in project crate by crate.

the class NodeSettingsTest method testInvalidUnicastHost.

@Test
public void testInvalidUnicastHost() throws Exception {
    Settings.Builder builder = Settings.settingsBuilder().put("discovery.zen.ping.multicast.enabled", false).put("discovery.zen.ping.unicast.hosts", "nonexistinghost:4300").put("path.home", createConfigPath());
    Terminal terminal = Terminal.DEFAULT;
    Environment environment = CrateSettingsPreparer.prepareEnvironment(builder.build(), terminal);
    try {
        node = new CrateNode(environment);
        fail("Exception expected (failed to resolve address)");
    } catch (Throwable t) {
        assertThat(t, instanceOf(CreationException.class));
        Throwable rootCause = ((CreationException) t).getErrorMessages().iterator().next().getCause();
        assertThat(rootCause, instanceOf(IllegalArgumentException.class));
        assertThat(rootCause.getMessage(), is("Failed to resolve address for [nonexistinghost:4300]"));
    }
}
Also used : Environment(org.elasticsearch.env.Environment) CreationException(org.elasticsearch.common.inject.CreationException) Terminal(org.elasticsearch.common.cli.Terminal) Settings(org.elasticsearch.common.settings.Settings) Test(org.junit.Test)

Aggregations

Terminal (org.elasticsearch.common.cli.Terminal)2 Settings (org.elasticsearch.common.settings.Settings)2 Environment (org.elasticsearch.env.Environment)2 Logger (org.apache.log4j.Logger)1 NullAppender (org.apache.log4j.varia.NullAppender)1 CreationException (org.elasticsearch.common.inject.CreationException)1 Test (org.junit.Test)1