I have recently started using Datastax Java driver for our Cassandra use case... We will be using Datastax Java driver for reading/writing into Cassandra...
I am successfully able to create Cassandra connection using Datastax Java driver... But I am wondering, are there any other settings which I should be using in Production environment to get the better performance using Datastax Java driver while making the connection to Cassandra?
/**
* Creating Cassandra connection using Datastax driver
*
*/
private DatastaxConnection() {
try{
builder = Cluster.builder();
builder.addContactPoint("some-node");
// Can anybody explain me what does below piece of code do?
builder.poolingOptions().setCoreConnectionsPerHost(
HostDistance.LOCAL,
builder.poolingOptions().getMaxConnectionsPerHost(HostDistance.LOCAL));
// And also what does below piece of code is doing?
cluster = builder
.withRetryPolicy(DowngradingConsistencyRetryPolicy.INSTANCE)
.withReconnectionPolicy(new ConstantReconnectionPolicy(100L))
.build();
StringBuilder s = new StringBuilder();
Set<Host> allHosts = cluster.getMetadata().getAllHosts();
for (Host h : allHosts) {
s.append("[");
s.append(h.getDatacenter());
s.append("-");
s.append(h.getRack());
s.append("-");
s.append(h.getAddress());
s.append("]");
}
System.out.println("Cassandra Cluster: " + s.toString());
session = cluster.connect("testdatastaxks");
} catch (NoHostAvailableException e) {
} catch (Exception e) {
}
}
My top priorities are :-
- Filter out the Cassandra nodes basis on local datacenter.. So in the connection pool it will only have local datacenter Cassandra nodes.
- And get the best performance while using Datastax java driver with some certain settings.
I know it might be possible that certain settings will differ in different environment but there might be some settings that everybody has to follow to get the optimal performance while making the Cassandra connections using Datastax Java driver..
Like for an example in Astyanax when I was using earlier, it was that you need to use TOKEN_AWARE...
So there should be some best settings as well or recommended while using Datastax java driver?