|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)
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
Clustercreation are in the local data-center. Otherwise, you should provide the name yourself with this method.
localDc- the name of the datacenter. It should not be
public DCAwareRoundRobinPolicy.Builder withUsedHostsPerRemoteDc(int usedHostsPerRemoteDc)
distance()method will return a
HostDistance.REMOTEdistance for only
usedHostsPerRemoteDchosts per remote datacenter. Other hosts of the remote datacenters will be ignored (and thus no connections to them will be maintained). If
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
usedHostsPerRemoteDchosts 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
allowRemoteDCsForLocalConsistencyLevel()). If this method isn't called, the policy will default to 0.
usedHostsPerRemoteDc- the number.
public DCAwareRoundRobinPolicy.Builder allowRemoteDCsForLocalConsistencyLevel()
LOCAL_QUORUM. When used in conjunction with
usedHostsPerRemoteDc> 0, this overrides the policy of never using remote datacenter nodes for
LOCAL_QUORUMqueries. 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
THREE. As such, this method should generally be avoided; use it only if you know and understand what you do.
public DCAwareRoundRobinPolicy build()