|Constructor and Description|
|Modifier and Type||Method and Description|
Allows the policy to return remote hosts when building query plans for queries having consistency level
Builds the policy configured by this builder.
Sets the name of the datacenter that will be considered "local" by the policy.
Sets the number of hosts per remote datacenter that the policy should consider.
public DCAwareRoundRobinPolicy.Builder withLocalDc(String localDc)
This must be the name as known by Cassandra (in other words, the name in that appears in
system.peers, or in the output of admin tools like nodetool).
If this method isn't called, the policy will default to the datacenter of the first node
connected to. This will always be ok if all the contact points use at
creation are in the local data-center. Otherwise, you should provide the name yourself with
localDc- the name of the datacenter. It should not be
public DCAwareRoundRobinPolicy.Builder withUsedHostsPerRemoteDc(int usedHostsPerRemoteDc)
distance() method will return a
usedHostsPerRemoteDc hosts per remote datacenter. Other hosts of the remote
datacenters will be ignored (and thus no connections to them will be maintained).
usedHostsPerRemoteDc > 0, then if for a query no host in the local datacenter
can be reached and if the consistency level of the query is not
LOCAL_QUORUM, then up to
usedHostsPerRemoteDc hosts per remote datacenter will be
tried by the policy as a fallback. By default, no remote host will be used for
LOCAL_QUORUM, since this would change the meaning of the consistency
level, somewhat breaking the consistency contract (this can be overridden with
If this method isn't called, the policy will default to 0.
usedHostsPerRemoteDc- the number.
public DCAwareRoundRobinPolicy.Builder allowRemoteDCsForLocalConsistencyLevel()
When used in conjunction with
> 0, this overrides the policy of never using remote datacenter nodes for
LOCAL_QUORUM queries. It is however inadvisable to do so in almost all cases, as
this would potentially break consistency guarantees and if you are fine with that, it's
probably better to use a weaker consistency like
As such, this method should generally be avoided; use it only if you know and understand what
public DCAwareRoundRobinPolicy build()
Copyright © 2012–2018. All rights reserved.