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

  • All Implemented Interfaces:
    java.io.Serializable

    public class TokenRangeMapping<I extends org.apache.cassandra.spark.common.model.CassandraInstance>
    extends java.lang.Object
    implements java.io.Serializable
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      TokenRangeMapping​(org.apache.cassandra.spark.data.partitioner.Partitioner partitioner, com.google.common.collect.Multimap<I,​com.google.common.collect.Range<java.math.BigInteger>> tokenRanges, java.util.Set<I> allInstances)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.Set<I> allInstances()  
      static <I extends org.apache.cassandra.spark.common.model.CassandraInstance>
      TokenRangeMapping<I>
      consolidate​(java.util.List<TokenRangeMapping<I>> all)
      Consolidate all TokenRangeMapping and produce a new TokenRangeMapping instance
      static <I extends org.apache.cassandra.spark.common.model.CassandraInstance>
      TokenRangeMapping<I>
      create​(java.util.function.Supplier<o.a.c.sidecar.client.shaded.common.response.TokenRangeReplicasResponse> topologySupplier, java.util.function.Supplier<org.apache.cassandra.spark.data.partitioner.Partitioner> partitionerSupplier, java.util.function.Function<o.a.c.sidecar.client.shaded.common.response.TokenRangeReplicasResponse.ReplicaMetadata,​I> instanceCreator)  
      boolean equals​(java.lang.Object other)  
      com.google.common.collect.RangeMap<java.math.BigInteger,​java.util.List<I>> getRangeMap()  
      com.google.common.collect.RangeMap<java.math.BigInteger,​java.util.List<I>> getSubRanges​(com.google.common.collect.Range<java.math.BigInteger> tokenRange)  
      com.google.common.collect.Multimap<I,​com.google.common.collect.Range<java.math.BigInteger>> getTokenRanges()  
      java.util.Map<com.google.common.collect.Range<java.math.BigInteger>,​java.util.Set<I>> getWriteReplicasOfRange​(com.google.common.collect.Range<java.math.BigInteger> range, java.lang.String localDc)
      Get write replica-sets of sub-ranges that overlap with the input range.
      java.util.Map<com.google.common.collect.Range<java.math.BigInteger>,​java.util.Set<I>> getWriteReplicasOfRange​(com.google.common.collect.Range<java.math.BigInteger> range, java.util.function.Predicate<I> instanceFilter)
      Get write replica-sets of sub-ranges that overlap with the input range.
      int hashCode()  
      org.apache.cassandra.spark.data.partitioner.Partitioner partitioner()  
      java.util.Set<I> pendingInstances()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • TokenRangeMapping

        public TokenRangeMapping​(org.apache.cassandra.spark.data.partitioner.Partitioner partitioner,
                                 com.google.common.collect.Multimap<I,​com.google.common.collect.Range<java.math.BigInteger>> tokenRanges,
                                 java.util.Set<I> allInstances)
    • Method Detail

      • create

        public static <I extends org.apache.cassandra.spark.common.model.CassandraInstance> TokenRangeMapping<I> create​(java.util.function.Supplier<o.a.c.sidecar.client.shaded.common.response.TokenRangeReplicasResponse> topologySupplier,
                                                                                                                        java.util.function.Supplier<org.apache.cassandra.spark.data.partitioner.Partitioner> partitionerSupplier,
                                                                                                                        java.util.function.Function<o.a.c.sidecar.client.shaded.common.response.TokenRangeReplicasResponse.ReplicaMetadata,​I> instanceCreator)
      • consolidate

        public static <I extends org.apache.cassandra.spark.common.model.CassandraInstance> TokenRangeMapping<I> consolidate​(@NotNull
                                                                                                                             java.util.List<TokenRangeMapping<I>> all)
        Consolidate all TokenRangeMapping and produce a new TokenRangeMapping instance
        Type Parameters:
        I - CassandraInstance type
        Parameters:
        all - list of TokenRangeMapping
        Returns:
        a consolidated TokenRangeMapping
      • partitioner

        public org.apache.cassandra.spark.data.partitioner.Partitioner partitioner()
      • allInstances

        public java.util.Set<I> allInstances()
      • pendingInstances

        public java.util.Set<I> pendingInstances()
      • getWriteReplicasOfRange

        public java.util.Map<com.google.common.collect.Range<java.math.BigInteger>,​java.util.Set<I>> getWriteReplicasOfRange​(com.google.common.collect.Range<java.math.BigInteger> range,
                                                                                                                                   @Nullable
                                                                                                                                   java.lang.String localDc)
        Get write replica-sets of sub-ranges that overlap with the input range.
        Parameters:
        range - range to check. The range can potentially overlap with multiple ranges. For example, a down node adds one failure of a token range that covers multiple primary token ranges that replicate to it.
        localDc - local DC name to filter out non-local-DC instances. The parameter is optional. When not present, i.e. null, no filtering is applied
        Returns:
        the write replicas of sub-ranges
      • getWriteReplicasOfRange

        public java.util.Map<com.google.common.collect.Range<java.math.BigInteger>,​java.util.Set<I>> getWriteReplicasOfRange​(com.google.common.collect.Range<java.math.BigInteger> range,
                                                                                                                                   @Nullable
                                                                                                                                   java.util.function.Predicate<I> instanceFilter)
        Get write replica-sets of sub-ranges that overlap with the input range.
        Parameters:
        range - range to check. The range can potentially overlap with multiple ranges. For example, a down node adds one failure of a token range that covers multiple primary token ranges that replicate to it.
        instanceFilter - predicate to filter the instances
        Returns:
        the write replicas of sub-ranges
      • getRangeMap

        public com.google.common.collect.RangeMap<java.math.BigInteger,​java.util.List<I>> getRangeMap()
      • getSubRanges

        public com.google.common.collect.RangeMap<java.math.BigInteger,​java.util.List<I>> getSubRanges​(com.google.common.collect.Range<java.math.BigInteger> tokenRange)
      • getTokenRanges

        public com.google.common.collect.Multimap<I,​com.google.common.collect.Range<java.math.BigInteger>> getTokenRanges()
      • equals

        public boolean equals​(java.lang.Object other)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object