弹性搜索NodeBuilder与TranportClient [英] elasticsearch NodeBuilder vs TranportClient

查看:793
本文介绍了弹性搜索NodeBuilder与TranportClient的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能是其他弹性搜索开发人员的一个非常简单(愚蠢的)问题,这两者之间有什么区别?

Probably a very easy (and dumb) question to other elasticsearch devs, what's the difference between these two?

我正在连接到一个远程弹性搜索服务器Java webapp,到目前为止我一直在使用TransportClient,但是我想知道NodeBuilder是否可以被使用,或者NodeBuilder应该只用于嵌入式客户端?

I'm connecting to a remote elasticsearch server from a Java webapp, so far I have been using TransportClient but I was wondering if NodeBuilder can be used to, or NodeBuilder should be used just for embedded clients?

两个可以用于连接到远程ES服务器,哪个应该在内存和性能方面更好?

If any of the two can be used to connect to remote ES servers, which one should be better in terms of memory and performance?

如果有人可以指出我连接到一个NodeBuilder远程ES服务器示例将会很棒,因为我没有找到任何幸运的发现。

If anyone can point me out to a NodeBuilder connecting to a remote ES server example would be great because I haven't had any lucky finding one.

谢谢。

推荐答案

NodeBuilder也可以用于连接到集群。

NodeBuilder can also be used to connect to a cluster.

Node node = nodeBuilder().clusterName("yourcluster").client(true).node();
Client client = node.client();

它将作为另一个节点加入群集,并且将了解整个拓扑。使用节点,您可以使用多播来发现其他正在运行的节点。

It will join the cluster as another node and will be aware of the whole topology. Using nodes, you can use multicast to discover other running nodes.

我的意见是我更喜欢使用 TransportClient NodeClient 因为其他集群节点在TransportClient停止时不会收到无用的信息。当NodeClient停止时,每个节点必须知道,即使它们不需要管理它,因为它不包含任何数据。
另外,我在调试模式下看到,NodeClient比TransportCLient启动更多的线程。所以我认为TransportClient的内存空间较小。

My opinion is that I prefer to use TransportClient than NodeClient because other cluster nodes won't receive useless information when the TransportClient stops. When a NodeClient stops, each node has to know that even if they don't have to manage it as it does not hold any data. Also, I have seen in debug mode that NodeClient starts more Threads than TransportCLient. So I think TransportClient has a lesser memory footprint.

顺便说一句,如果你使用Spring,你可以使用 spring-elasticsearch 工厂。如果没有,您可以随时查看源代码,看看我如何管理NodeClient和TransportClient。

By the way, if you are using Spring, you can use the spring-elasticsearch factories for that. If not, you can always have a look at source code to see how I manage NodeClient vs TransportClient.

希望这有帮助。

编辑XXX3-09 NodeClient 不应该使用。如果有需要,人们应该创建一个客户端节点(启动一个带有 node.data的弹性搜索节点:false node.master:false ),并使用 TransportClient 在本地连接。

EDIT 2016-03-09: NodeClient should not be used. If there is a need for that, people should create a client node (launch an elasticsearch node with node.data: false and node.master: false) and use a TransportClient to connect to it locally.

这篇关于弹性搜索NodeBuilder与TranportClient的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆