Package org.apache.cassandra.locator
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:
java.lang.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
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.cassandra.locator.AbstractReplicaCollection
AbstractReplicaCollection.ReplicaList, AbstractReplicaCollection.ReplicaMap<K>
-
Nested classes/interfaces inherited from interface org.apache.cassandra.locator.ReplicaCollection
ReplicaCollection.Builder<C extends ReplicaCollection<C>>
-
-
Field Summary
-
Fields inherited from class org.apache.cassandra.locator.AbstractReplicaCollection
EMPTY_LIST, list
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <E extends Endpoints<E>>
Eappend(E replicas, Replica extraReplica)
java.util.Map<InetAddressAndPort,Replica>
byEndpoint()
static <E extends Endpoints<E>>
Econcat(E natural, E pending)
Care must be taken to ensure no conflicting ranges occur in pending and natural.boolean
contains(InetAddressAndPort endpoint)
boolean
contains(Replica replica)
InetAddressAndPort
endpoint(int i)
java.util.List<InetAddressAndPort>
endpointList()
java.util.Set<InetAddressAndPort>
endpoints()
E
keep(java.util.Set<InetAddressAndPort> keep)
E
select(java.lang.Iterable<InetAddressAndPort> endpoints, boolean ignoreMissing)
Replica
selfIfPresent()
E
without(java.util.Set<InetAddressAndPort> remove)
E
withoutSelf()
-
Methods inherited from class org.apache.cassandra.locator.AbstractReplicaCollection
anyMatch, asList, collector, count, equals, filter, filter, filterLazily, filterLazily, forEach, get, hashCode, isEmpty, iterator, newBuilder, size, snapshot, sorted, stream, subList, toString
-
-
-
-
Method Detail
-
endpoints
public java.util.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 java.util.List<InetAddressAndPort> endpointList()
-
byEndpoint
public java.util.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(java.util.Set<InetAddressAndPort> remove)
- Returns:
- a collection without the provided endpoints, otherwise in the same order as this collection
-
keep
public E keep(java.util.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(java.lang.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 methodReplicaLayout.haveWriteConflicts(E, E)
can be used to detect and resolve any issues
-
-