Package org.apache.cassandra.locator
Class RangesAtEndpoint
- java.lang.Object
-
- org.apache.cassandra.locator.AbstractReplicaCollection<RangesAtEndpoint>
-
- org.apache.cassandra.locator.RangesAtEndpoint
-
- All Implemented Interfaces:
java.lang.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)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classRangesAtEndpoint.Builder-
Nested classes/interfaces inherited from class org.apache.cassandra.locator.AbstractReplicaCollection
AbstractReplicaCollection.ReplicaList, AbstractReplicaCollection.ReplicaMap<K>
-
-
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 RangesAtEndpoint.Builderbuilder(InetAddressAndPort endpoint)static RangesAtEndpoint.Builderbuilder(InetAddressAndPort endpoint, int capacity)java.util.Map<Range<Token>,Replica>byRange()static java.util.stream.Collector<Replica,RangesAtEndpoint.Builder,RangesAtEndpoint>collector(InetAddressAndPort endpoint)static RangesAtEndpointconcat(RangesAtEndpoint replicas, RangesAtEndpoint extraReplicas)booleancontains(Range<Token> range, boolean isFull)booleancontains(Replica replica)static RangesAtEndpointcopyOf(java.util.List<Replica> replicas)static RangesAtEndpointempty(InetAddressAndPort endpoint)InetAddressAndPortendpoint()java.util.Set<InetAddressAndPort>endpoints()static booleanisDummyList(RangesAtEndpoint ranges)ReplicaCollection.Builder<RangesAtEndpoint>newBuilder(int initialCapacity)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;static RangesAtEndpointof(Replica replica)static RangesAtEndpointof(Replica... replicas)RangesAtEndpointonlyFull()RangesAtEndpointonlyTransient()java.util.Set<Range<Token>>ranges()RangesAtEndpointsnapshot()protected RangesAtEndpointsnapshot(AbstractReplicaCollection.ReplicaList newList)static RangesAtEndpointtoDummyList(java.util.Collection<Range<Token>> ranges)Use of this method to synthesize Replicas is almost always wrong.RangesAtEndpointunwrap()-
Methods inherited from class org.apache.cassandra.locator.AbstractReplicaCollection
anyMatch, asList, collector, count, equals, filter, filter, filterLazily, filterLazily, forEach, get, hashCode, isEmpty, iterator, size, sorted, stream, subList, toString
-
-
-
-
Method Detail
-
endpoint
public InetAddressAndPort endpoint()
-
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.
-
ranges
public java.util.Set<Range<Token>> ranges()
- Returns:
- a set of all unique Ranges This method is threadsafe, though it is not synchronised
-
byRange
public java.util.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
protected RangesAtEndpoint snapshot(AbstractReplicaCollection.ReplicaList newList)
-
snapshot
public RangesAtEndpoint snapshot()
- Specified by:
snapshotin classAbstractReplicaCollection<RangesAtEndpoint>
-
newBuilder
public ReplicaCollection.Builder<RangesAtEndpoint> newBuilder(int initialCapacity)
Description copied from class:AbstractReplicaCollectionconstruct 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:
newBuilderin classAbstractReplicaCollection<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()
-
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
public static java.util.stream.Collector<Replica,RangesAtEndpoint.Builder,RangesAtEndpoint> collector(InetAddressAndPort endpoint)
-
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(java.util.List<Replica> replicas)
-
toDummyList
public static RangesAtEndpoint toDummyList(java.util.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
-
-