Class DCAwareRoundRobinPolicy.Builder
- java.lang.Object
-
- com.datastax.driver.core.policies.DCAwareRoundRobinPolicy.Builder
-
- Enclosing class:
- DCAwareRoundRobinPolicy
public static class DCAwareRoundRobinPolicy.Builder extends Object
Helper class to build the policy.
-
-
Constructor Summary
Constructors Constructor Description Builder()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description DCAwareRoundRobinPolicy.BuilderallowRemoteDCsForLocalConsistencyLevel()Deprecated.This functionality will be removed in the next major release of the driver.DCAwareRoundRobinPolicybuild()Builds the policy configured by this builder.DCAwareRoundRobinPolicy.BuilderwithLocalDc(String localDc)Sets the name of the datacenter that will be considered "local" by the policy.DCAwareRoundRobinPolicy.BuilderwithUsedHostsPerRemoteDc(int usedHostsPerRemoteDc)Deprecated.This functionality will be removed in the next major release of the driver.
-
-
-
Method Detail
-
withLocalDc
public DCAwareRoundRobinPolicy.Builder withLocalDc(String localDc)
Sets the name of the datacenter that will be considered "local" by the policy.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
Clustercreation are in the local data-center. Otherwise, you should provide the name yourself with this method.- Parameters:
localDc- the name of the datacenter. It should not benull.- Returns:
- this builder.
-
withUsedHostsPerRemoteDc
@Deprecated public DCAwareRoundRobinPolicy.Builder withUsedHostsPerRemoteDc(int usedHostsPerRemoteDc)
Deprecated.This functionality will be removed in the next major release of the driver. DC failover shouldn't be done in the driver, which does not have the necessary context to know what makes sense considering application semantics.Sets the number of hosts per remote datacenter that the policy should consider.The policy's
distance()method will return aHostDistance.REMOTEdistance for onlyusedHostsPerRemoteDchosts 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 notLOCAL_ONEorLOCAL_QUORUM, then up tousedHostsPerRemoteDchosts per remote datacenter will be tried by the policy as a fallback. By default, no remote host will be used forLOCAL_ONEandLOCAL_QUORUM, since this would change the meaning of the consistency level, somewhat breaking the consistency contract (this can be overridden withallowRemoteDCsForLocalConsistencyLevel()).If this method isn't called, the policy will default to 0.
- Parameters:
usedHostsPerRemoteDc- the number.- Returns:
- this builder.
-
allowRemoteDCsForLocalConsistencyLevel
@Deprecated public DCAwareRoundRobinPolicy.Builder allowRemoteDCsForLocalConsistencyLevel()
Deprecated.This functionality will be removed in the next major release of the driver. DC failover shouldn't be done in the driver, which does not have the necessary context to know what makes sense considering application semantics.Allows the policy to return remote hosts when building query plans for queries having consistency levelLOCAL_ONEorLOCAL_QUORUM.When used in conjunction with
usedHostsPerRemoteDc> 0, this overrides the policy of never using remote datacenter nodes forLOCAL_ONEandLOCAL_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 likeONE,TWOorTHREE. As such, this method should generally be avoided; use it only if you know and understand what you do.- Returns:
- this builder.
-
build
public DCAwareRoundRobinPolicy build()
Builds the policy configured by this builder.- Returns:
- the policy.
-
-