I'm new to Cassandra I want to connect to Cassandra through Java client as Cassandra api.I can connect to Cassandra with my java code by using datastax as weel as jdbc drivers by giving the node details in my java code. Now I want to connect to Cassandra cluster where I have 4 nodes in cluster,I want to connect to the Cassandra cluster nodes with out giving the node details in code and need to get connection when 1 node is down in cluster it should get connect to the next node in the cluster,so where to mention my node details in my code when Im using datastax drivers. Can any one help me to do this..It will helps me alot Thanks in advance
问问题
1352 次
2 回答
0
查看此负载平衡页面。
Cassandra 使用 gossip 来保持所有其他节点的最新状态。您可以连接到一个,它会知道所有其他人并按照指示进行负载平衡。基本上,如果您之前测试的节点是这个新集群的一部分,那么您的旧代码应该可以正常工作。
于 2016-05-25T17:07:05.340 回答
0
当我的一个节点从集群中关闭时,我能够连接到 cassandra 集群可以连接到集群中的其他节点并且也可以实现负载平衡,下面是我使用并连接的连接。
cluster = Cluster
.builder()
.addContactPoints("192.1.1.1","192.1.1.2")
.withRetryPolicy(DefaultRetryPolicy.INSTANCE)
.withLoadBalancingPolicy(
new TokenAwarePolicy(new DCAwareRoundRobinPolicy.Builder().build()))
.build();
于 2016-05-31T11:34:30.060 回答