Class RangesAtEndpoint

All Implemented Interfaces:
Iterable<Replica>, ReplicaCollection<RangesAtEndpoint>
Direct Known Subclasses:
RangesAtEndpoint.Builder

public class RangesAtEndpoint extends AbstractReplicaCollection<RangesAtEndpoint>
A ReplicaCollection for Ranges occurring at an endpoint. All Replica will be for the same endpoint, and must be unique Ranges (though overlapping ranges are presently permitted, these should probably not be permitted to occur)
  • Method Details

    • endpoint

      public InetAddressAndPort endpoint()
    • endpoints

      public Set<InetAddressAndPort> endpoints()
      Returns:
      a Set of the endpoints of the contained Replicas. Iteration order is maintained where there is a 1:1 relationship between endpoint and Replica Typically this collection offers O(1) access methods, and this is true for all but ReplicaList.
    • ranges

      public Set<Range<Token>> ranges()
      Returns:
      a set of all unique Ranges This method is threadsafe, though it is not synchronised
    • byRange

      public Map<Range<Token>,Replica> byRange()
      Returns:
      a map of all Ranges, to their owning Replica instance This method is threadsafe, though it is not synchronised
    • snapshot

    • snapshot

      public RangesAtEndpoint snapshot()
      Specified by:
      snapshot in class AbstractReplicaCollection<RangesAtEndpoint>
    • newBuilder

      public ReplicaCollection.Builder<RangesAtEndpoint> newBuilder(int initialCapacity)
      Description copied from class: AbstractReplicaCollection
      construct a new Builder of our own type, so that we can concatenate TODO: this isn't terribly pretty, but we need sometimes to select / merge two Endpoints of unknown type;
      Specified by:
      newBuilder in class AbstractReplicaCollection<RangesAtEndpoint>
    • contains

      public boolean contains(Replica replica)
      Returns:
      true iff a Replica in this collection is equal to the provided Replica. Typically this method is expected to take O(1) time, and this is true for all but ReplicaList.
    • onlyFull

      public RangesAtEndpoint onlyFull()
    • onlyTransient

      public RangesAtEndpoint onlyTransient()
    • contains

      public boolean contains(Range<Token> range, boolean isFull)
    • unwrap

      public RangesAtEndpoint unwrap()
      Returns:
      if there are no wrap around ranges contained in this RangesAtEndpoint, return self; otherwise, return a RangesAtEndpoint covering the same logical portions of the ring, but with those ranges unwrapped
    • collector

    • builder

      public static RangesAtEndpoint.Builder builder(InetAddressAndPort endpoint)
    • builder

      public static RangesAtEndpoint.Builder builder(InetAddressAndPort endpoint, int capacity)
    • empty

      public static RangesAtEndpoint empty(InetAddressAndPort endpoint)
    • of

      public static RangesAtEndpoint of(Replica replica)
    • of

      public static RangesAtEndpoint of(Replica... replicas)
    • copyOf

      public static RangesAtEndpoint copyOf(List<Replica> replicas)
    • toDummyList

      public static RangesAtEndpoint toDummyList(Collection<Range<Token>> ranges)
      Use of this method to synthesize Replicas is almost always wrong. In repair it turns out the concerns of transient vs non-transient are handled at a higher level, but eventually repair needs to ask streaming to actually move the data and at that point it doesn't have a great handle on what the replicas are and it doesn't really matter. Streaming expects to be given Replicas with each replica indicating what type of data (transient or not transient) should be sent. So in this one instance we can lie to streaming and pretend all the replicas are full and use a dummy address and it doesn't matter because streaming doesn't rely on the address for anything other than debugging and full is a valid value for transientness because streaming is selecting candidate tables from the repair/unrepaired set already.
      Parameters:
      ranges -
      Returns:
    • isDummyList

      public static boolean isDummyList(RangesAtEndpoint ranges)
    • concat

      public static RangesAtEndpoint concat(RangesAtEndpoint replicas, RangesAtEndpoint extraReplicas)
      Returns:
      concatenate two DISJOINT collections together