Class Endpoints<E extends Endpoints<E>>

java.lang.Object
org.apache.cassandra.locator.AbstractReplicaCollection<E>
org.apache.cassandra.locator.Endpoints<E>
Type Parameters:
E - The concrete type of Endpoints, that will be returned by the modifying methods
All Implemented Interfaces:
Iterable<Replica>, ReplicaCollection<E>
Direct Known Subclasses:
EndpointsForRange, EndpointsForToken

public abstract class Endpoints<E extends Endpoints<E>> extends AbstractReplicaCollection<E>
A collection of Endpoints for a given ring position. This will typically reside in a ReplicaLayout, representing some subset of the endpoints for the Token or Range
  • Method Details

    • 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.
    • endpoint

      public InetAddressAndPort endpoint(int i)
    • endpointList

      public List<InetAddressAndPort> endpointList()
    • byEndpoint

      public Map<InetAddressAndPort,Replica> byEndpoint()
    • 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.
    • contains

      public boolean contains(InetAddressAndPort endpoint)
    • withoutSelf

      public E withoutSelf()
    • selfIfPresent

      public Replica selfIfPresent()
    • without

      public E without(Set<InetAddressAndPort> remove)
      Returns:
      a collection without the provided endpoints, otherwise in the same order as this collection
    • keep

      public E keep(Set<InetAddressAndPort> keep)
      Returns:
      a collection with only the provided endpoints (ignoring any not present), otherwise in the same order as this collection
    • select

      public E select(Iterable<InetAddressAndPort> endpoints, boolean ignoreMissing)
      Returns:
      a collection containing the Replica from this collection for the provided endpoints, in the order of the provided endpoints
    • concat

      public static <E extends Endpoints<E>> E concat(E natural, E pending)
      Care must be taken to ensure no conflicting ranges occur in pending and natural. Conflicts can occur for two reasons: 1) due to lack of isolation when reading pending/natural 2) because a movement that changes the type of replication from transient to full must be handled differently for reads and writes (with the reader treating it as transient, and writer as full) The method ReplicaLayout.haveWriteConflicts(E, E) can be used to detect and resolve any issues
    • append

      public static <E extends Endpoints<E>> E append(E replicas, Replica extraReplica)