Class MultiClusterReplicaAwareFailureHandler<I extends org.apache.cassandra.spark.common.model.CassandraInstance>
- java.lang.Object
-
- org.apache.cassandra.spark.bulkwriter.token.ReplicaAwareFailureHandler<I>
-
- org.apache.cassandra.spark.bulkwriter.token.MultiClusterReplicaAwareFailureHandler<I>
-
- 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.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.cassandra.spark.bulkwriter.token.ReplicaAwareFailureHandler
ReplicaAwareFailureHandler.ConsistencyFailurePerRange, ReplicaAwareFailureHandler.FailuresPerInstance
-
-
Constructor Summary
Constructors Constructor Description MultiClusterReplicaAwareFailureHandler(org.apache.cassandra.spark.data.partitioner.Partitioner partitioner)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddFailure(com.google.common.collect.Range<java.math.BigInteger> tokenRange, I instance, java.lang.String errMessage)Adds a new token range as a failed token range, with errors on given instance.java.util.Set<I>getFailedInstances()java.util.List<ReplicaAwareFailureHandler.ConsistencyFailurePerRange>getFailedRanges(TokenRangeMapping<I> tokenRangeMapping, JobInfo job, ClusterInfo cluster)Given the number of failed instances for each token range, validates if the consistency guarantees are maintained for the jobprotected java.util.List<ReplicaAwareFailureHandler.ConsistencyFailurePerRange>getFailedRangesInternal(TokenRangeMapping<I> tokenRangeMapping, ConsistencyLevel cl, java.lang.String localDC, org.apache.cassandra.spark.data.ReplicationFactor replicationFactor)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.
-
-
-
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:ReplicaAwareFailureHandlerAdds 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:
addFailurein classReplicaAwareFailureHandler<I extends org.apache.cassandra.spark.common.model.CassandraInstance>- Parameters:
tokenRange- the range which failedinstance- the instance on which the range failederrMessage- the error that occurred for this particular range/instance pair
-
getFailedInstances
public java.util.Set<I> getFailedInstances()
- Specified by:
getFailedInstancesin classReplicaAwareFailureHandler<I extends org.apache.cassandra.spark.common.model.CassandraInstance>- Returns:
- the set of all failed instances
-
getFailedRanges
public java.util.List<ReplicaAwareFailureHandler.ConsistencyFailurePerRange> getFailedRanges(TokenRangeMapping<I> tokenRangeMapping, JobInfo job, ClusterInfo cluster)
Description copied from class:ReplicaAwareFailureHandlerGiven the number of failed instances for each token range, validates if the consistency guarantees are maintained for the job- Specified by:
getFailedRangesin classReplicaAwareFailureHandler<I extends org.apache.cassandra.spark.common.model.CassandraInstance>- Parameters:
tokenRangeMapping- the mapping of token ranges to a Cassandra instancejob- the job to verifycluster- cluster info- Returns:
- list of failed token ranges that break consistency. This should ideally be empty for a successful operation.
-
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:ReplicaAwareFailureHandlerGiven 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:
getFailedRangesInternalin classReplicaAwareFailureHandler<I extends org.apache.cassandra.spark.common.model.CassandraInstance>- Parameters:
tokenRangeMapping- the mapping of token ranges to a Cassandra instancecl- the desired consistency levellocalDC- the local datacenterreplicationFactor- replication of the enclosing keyspace- Returns:
- list of failed token ranges that break consistency. This should ideally be empty for a successful operation.
-
-