Reputation: 67
Initializer myInitializer = ... // your implementation
Cluster cluster = Cluster.buildFrom(myInitializer);
Im trying to connect to Cassandracluster with several node details mentioning in addcontactpoints("192.1.1.1","192.2.2.2").build()
.
Now I want to connect to Cassandra cluster with out mentioning the in that method. I want to mention my node details in separate properties file and want to connect to my cluster using that properties file. I have got one method in Java driver called getcontactpoint()
.
I'm not getting how to use that and implement it. Please help me to improve my code
Upvotes: 0
Views: 814
Reputation: 384
put all nodes ip like below nodes=192.1.1.1,192.2.2.2
In java Resource interface is there by using that you can get your properties file
Like ResourceBundle resource=ResourceBundle.getBundle("cassandra")
then by getProperty method you can get nodes and split it by comma(,) so it will gives you Array of String mean all IP . Like nodes=resource.getString("nodes")
then in method addContactPoints() just give nodes variable .
Like addContactPoints(nodes)
Upvotes: 0