Class RackAwareRoundRobinPolicy.Builder

    • Constructor Detail

      • Builder

        public Builder()
    • Method Detail

      • withLocalDc

        public RackAwareRoundRobinPolicy.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 Cluster creation 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 be null.
        Returns:
        this builder.
      • withLocalRack

        public RackAwareRoundRobinPolicy.Builder withLocalRack​(String localRack)
        Sets the name of the rack 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 rack of the first node connected to. This will always be ok if all the contact points use at Cluster creation are in the local rack. Otherwise, you should provide the name yourself with this method.

        Parameters:
        localRack - the name of the rack. It should not be null.
        Returns:
        this builder.
      • withUsedHostsPerRemoteDc

        @Deprecated
        public RackAwareRoundRobinPolicy.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 a HostDistance.REMOTE distance for only usedHostsPerRemoteDc hosts 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_ONE or 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_ONE and 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.

        Parameters:
        usedHostsPerRemoteDc - the number.
        Returns:
        this builder.
      • allowRemoteDCsForLocalConsistencyLevel

        @Deprecated
        public RackAwareRoundRobinPolicy.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 level LOCAL_ONE or LOCAL_QUORUM.

        When used in conjunction with usedHostsPerRemoteDc > 0, this overrides the policy of never using remote datacenter nodes for LOCAL_ONE and 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 ONE, TWO or THREE. As such, this method should generally be avoided; use it only if you know and understand what you do.

        Returns:
        this builder.