简体   繁体   English

Cassandra群集连接中的多个端点

[英]Multiple Endpoints in Cassandra cluster Connection

I want to give multiple Cassandra endpoints from the config file to my Java application. 我想将多个Cassandra端点从配置文件提供给我的Java应用程序。

Ex: cassandra host: "host1, host2" 例如:cassandra主机:“ host1,host2”

I tried addContactPoints(host) , but it did not work. 我尝试了addContactPoints(host) ,但是没有用。 If one of the Cassandra node goes down, I don't want my application to go down. 如果Cassandra节点之一发生故障,我不希望我的应用程序发生故障。

cluster = Cluster.builder()
  .withClusterName(cassandraConfig.getClusterName())
  .addContactPoints(cassandraConfig.getHostName())
  .withSocketOptions(new SocketOptions().setConnectTimeoutMillis(30000).setReadTimeoutMillis(30000))
  .withPoolingOptions(poolingOptions).build();

The java driver is resilient to one of the contact points provided not being available. Java驱动程序可以抵抗所提供的不可用的联系点之一。 Contact points are used for establishing an initial connection [*]. 接触点用于建立初始连接[*]。 As long as the driver is able to communicate with one contact point, it should be able to query the system.peers and system.local table to discover the rest of the nodes in the cluster. 只要驱动程序能够与一个联系点进行通信,它就应该能够查询system.peerssystem.local表以发现集群中的其余节点。

* They are also added to a list of initial hosts in the cluster, but typically the contact points provided map to a node in the system.peers table. *它们也被添加到集群中的初始主机列表中,但是通常提供的联系点映射到system.peers表中的节点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM