小编典典

尝试启动嵌入式Elasticsearch节点时不受支持的http.type [netty3]

elasticsearch

我知道不建议使用嵌入式Elasticsearch。我只是为了测试而尝试。

我正在尝试启动嵌入式Elasticsearch节点,并从以下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

我使用的是es 5.1.1,我的代码启动嵌入式节点如下。

    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;
    }

我得到以下跟踪。

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

我也尝试过,http.type: netty4但到目前为止还没有运气。它在http.enabled:false设置时有效,但我想使用http
rest api进行测试。

PS:在实现嵌入式es时,我一直在使用这个
elasticsearch hadoop类作为参考,很遗憾,我在上找不到任何文档http.type

我现在不能在ES 5.x中使用http启动嵌入式节点吗? 我在这里做错了什么?

非常感谢您的帮助。


阅读 703

收藏
2020-06-22

共1个答案

小编典典

如@Bastian所述,问题是传输模块不在类路径中。该解决方案已经存在于es-
hadoop嵌入式es实现中。

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

我们可以给netty3作为插件,如下所示。然后一切正常。

Collection<Class<? extends Plugin>> plugins = Arrays.asList(Netty3Plugin.class);
Node node = new PluginConfigurableNode(elasticsearchSetting, plugins).start();
2020-06-22