Datastax cassandra driver giving wrong metadata information about host states

感情迁移 提交于 2019-12-23 02:48:07

问题


I got a cluster with 2 DCs and each DC contain 2 nodes.

DC1:
192.168.60.81
192.168.60.82

DC2:
192.168.60.242
192.168.60.247

Application is connected to 192.168.60.81 and hence the local DC for the application is DC1.

Situation 1:

Initially when all the nodes are up and when I try to get cluster.metadata.allHosts, it gives me information about the state of the host as UP.

Situation 2:

When any of the nodes in local datacenter (DC1) goes up or down, the cluster.metadata.allHosts gives me the correct host state information.

Problem:

When any of the nodes in remote datacenter (DC2) goes down, the cluster.metadata.allHosts gives me the host state information as DOWN correctly. But the when the same node comes back up, still cluster.metadata.allHosts gives me the host state information as DOWN.

I registered with Host.StateListener to see if the events are fired for a node in remote DC. But unfortunately, when a node in remote DC comes back up it never notifies too.

Any help would be appreciated.

Cassandra version in all nodes: 2.1.4
Datastax java driver version: 2.1.9


回答1:


I got this answer from Andrew Tolbert from Datastax in the mail forum:

If the driver is not actively attempting to reconnect to DOWN nodes, it is very dependent on Cassandra to deliver host UP events to the driver. My guess is that you must be using the default load balancing policy or DCAwareRoundRobinPolicy with 0 usedRemoteHostsPerRemoteDC, so there is never an attempt to connect to nodes in DC2. Since you are running a fairly old version of C*, I suspect upgrading might help.

Explanation:

The above answer makes perfect sense as my load balancing policy was DCAwareRoundRobinPolicy with 0 usedRemoteHostsPerRemoteDC. Hence the driver was not trying to reconnect to nodes in remote DC. Hence the state of the remote nodes were not consistent from driver's view.

Thanks Andy.



来源:https://stackoverflow.com/questions/34743472/datastax-cassandra-driver-giving-wrong-metadata-information-about-host-states

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!