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.
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();
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With