Class MultiClusterReplicaAwareFailureHandler<I extends org.apache.cassandra.spark.common.model.CassandraInstance>

  • Type Parameters:
    I - CassandraInstance type

    public class MultiClusterReplicaAwareFailureHandler<I extends org.apache.cassandra.spark.common.model.CassandraInstance>
    extends ReplicaAwareFailureHandler<I>
    A ReplicaAwareFailureHandler that can handle multiple clusters, including the case of single cluster.
    • Constructor Detail

      • MultiClusterReplicaAwareFailureHandler

        public MultiClusterReplicaAwareFailureHandler​(org.apache.cassandra.spark.data.partitioner.Partitioner partitioner)
    • Method Detail

      • addFailure

        public void addFailure​(com.google.common.collect.Range<java.math.BigInteger> tokenRange,
                               I instance,
                               java.lang.String errMessage)
        Description copied from class: ReplicaAwareFailureHandler
        Adds a new token range as a failed token range, with errors on given instance.

        It's guaranteed that failedRangesMap has overlapping ranges for the range we are trying to insert (Check constructor, we are adding complete ring first).

        So the scheme is to get list of overlapping ranges first. For each overlapping range get the failure map. Make a copy of the map and add new failure to this map. It's important we make the copy and not use the one returned from failedRangesMap map. As our range could be overlapping partially and the map could be used by other range.

        Specified by:
        addFailure in class ReplicaAwareFailureHandler<I extends org.apache.cassandra.spark.common.model.CassandraInstance>
        Parameters:
        tokenRange - the range which failed
        instance - the instance on which the range failed
        errMessage - the error that occurred for this particular range/instance pair
      • getFailedInstances

        public java.util.Set<I> getFailedInstances()
        Specified by:
        getFailedInstances in class ReplicaAwareFailureHandler<I extends org.apache.cassandra.spark.common.model.CassandraInstance>
        Returns:
        the set of all failed instances
      • getFailedRangesInternal

        protected java.util.List<ReplicaAwareFailureHandler.ConsistencyFailurePerRange> getFailedRangesInternal​(TokenRangeMapping<I> tokenRangeMapping,
                                                                                                                ConsistencyLevel cl,
                                                                                                                @Nullable
                                                                                                                java.lang.String localDC,
                                                                                                                org.apache.cassandra.spark.data.ReplicationFactor replicationFactor)
        Description copied from class: ReplicaAwareFailureHandler
        Given the number of failed instances for each token range, validates if the consistency guarantees are maintained for the size of the ring and the consistency level.
        Specified by:
        getFailedRangesInternal in class ReplicaAwareFailureHandler<I extends org.apache.cassandra.spark.common.model.CassandraInstance>
        Parameters:
        tokenRangeMapping - the mapping of token ranges to a Cassandra instance
        cl - the desired consistency level
        localDC - the local datacenter
        replicationFactor - replication of the enclosing keyspace
        Returns:
        list of failed token ranges that break consistency. This should ideally be empty for a successful operation.