Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unsupported http.type [netty3] when trying to start embedded elasticsearch node

I know that embedded Elasticsearch is not recommended. I'm just trying it for testing purposes.

I'm trying to start an embedded Elasticsearch node giving the configuration from the following elasticsearch.yml

# Name for the cluster
cluster.name: elasticsearch
# Name for the embedded node
node.name: EmbeddedESNode
# Path to log files:
path.logs: logs
discovery.zen.ping.unicast.hosts: []
# Disable dynamic scripting
script.inline: false
script.stored: false
script.file: false
transport.type: local
http.type: netty3

I'm using es 5.1.1 and my code to start embedded node is as follows.

    try {
        Settings elasticsearchSetting = Settings.builder()
                // Value for path.home is required for es but will not be used as long as other properties
                // path.logs, path.data and path.conf is set.
                .put(ES_PROPERTY_PATH_HOME, "nullpath")
                .put(ES_PROPERTY_PATH_CONF, confDir)
                .build();
        Node node = new Node(elasticsearchSetting).start();
        logger.info("Embedded Elasticsearch server successfully started ...");

    } catch (Exception e) {
        throw e;
    }

I get the following trace.

java.lang.IllegalStateException: Unsupported http.type [netty3]
    at org.elasticsearch.common.network.NetworkModule.getHttpServerTransportSupplier(NetworkModule.java:194) ~[elasticsearch-5.1.1.jar:5.1.1]
    at org.elasticsearch.node.Node.<init>(Node.java:396) ~[elasticsearch-5.1.1.jar:5.1.1]
    at org.elasticsearch.node.Node.<init>(Node.java:229) ~[elasticsearch-5.1.1.jar:5.1.1]
    at org.elasticsearch.node.Node.<init>(Node.java:225) ~[elasticsearch-5.1.1.jar:5.1.1]
    ... 18 more

I've tried with http.type: netty4 as well but no luck so far. It works when http.enabled:false is set but I want to use http rest api for testing.

P.S: I've been using this elasticsearch hadoop class for reference in implementing embedded es and unfortunately I couldn't find any docs on http.type.

Can't I start an embedded node with http now in ES 5.x ? What am i doing wrong here ?

Any help is highly appreciated.

like image 312
Rajind Ruparathna Avatar asked Dec 21 '16 12:12

Rajind Ruparathna


2 Answers

As mentioned by @Bastian the issue was that transport module not being in the classpath. The solution was already there in es-hadoop embedded es implementation.

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

We can give netty3 as a plugin as follows. Then everything works well.

Collection<Class<? extends Plugin>> plugins = Arrays.asList(Netty3Plugin.class);
Node node = new PluginConfigurableNode(elasticsearchSetting, plugins).start();
like image 148
Rajind Ruparathna Avatar answered Nov 12 '22 15:11

Rajind Ruparathna


You need to add the module transport-netty4 to your classpath:

 <dependency>
        <groupId>org.elasticsearch.plugin</groupId>
        <artifactId>transport-netty4-client</artifactId>
        <version>5.1.1</version>
        <scope>test</scope>
 </dependency>

See also my answer here

like image 34
Bastian Voigt Avatar answered Nov 12 '22 14:11

Bastian Voigt