Package org.apache.cassandra.locator
Interface ReplicaCollection<C extends ReplicaCollection<C>>
-
- All Superinterfaces:
java.lang.Iterable<Replica>
- All Known Subinterfaces:
ReplicaCollection.Builder<C>
- All Known Implementing Classes:
AbstractReplicaCollection
,Endpoints
,EndpointsForRange
,EndpointsForRange.Builder
,EndpointsForToken
,EndpointsForToken.Builder
,RangesAtEndpoint
,RangesAtEndpoint.Builder
public interface ReplicaCollection<C extends ReplicaCollection<C>> extends java.lang.Iterable<Replica>
A collection like class for Replica objects. Represents both a well defined order on the contained Replica objects, and efficient methods for accessing the contained Replicas, directly and as a projection onto their endpoints and ranges.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
ReplicaCollection.Builder<C extends ReplicaCollection<C>>
A mutable (append-only) extension of a ReplicaCollection.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description boolean
contains(Replica replica)
int
count(java.util.function.Predicate<? super Replica> predicate)
java.util.Set<InetAddressAndPort>
endpoints()
boolean
equals(java.lang.Object o)
C
filter(java.util.function.Predicate<? super Replica> predicate)
C
filter(java.util.function.Predicate<? super Replica> predicate, int maxSize)
java.lang.Iterable<Replica>
filterLazily(java.util.function.Predicate<? super Replica> predicate)
java.lang.Iterable<Replica>
filterLazily(java.util.function.Predicate<? super Replica> predicate, int maxSize)
Replica
get(int i)
int
hashCode()
boolean
isEmpty()
java.util.Iterator<Replica>
iterator()
int
size()
C
sorted(java.util.Comparator<? super Replica> comparator)
java.util.stream.Stream<Replica>
stream()
C
subList(int start, int end)
java.lang.String
toString()
-
-
-
Method Detail
-
endpoints
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.
-
get
Replica get(int i)
- Parameters:
i
- a value in the range [0..size())- Returns:
- the i'th Replica, in our iteration order
-
size
int size()
- Returns:
- the number of Replica contained
-
isEmpty
boolean isEmpty()
- Returns:
- true iff size() == 0
-
contains
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.
-
count
int count(java.util.function.Predicate<? super Replica> predicate)
- Returns:
- the number of replicas that match the predicate
-
filter
C filter(java.util.function.Predicate<? super Replica> predicate)
- Returns:
- a *eagerly constructed* copy of this collection containing the Replica that match the provided predicate. An effort will be made to either return ourself, or a subList, where possible. It is guaranteed that no changes to any upstream Builder will affect the state of the result.
-
filter
C filter(java.util.function.Predicate<? super Replica> predicate, int maxSize)
- Returns:
- a *eagerly constructed* copy of this collection containing the Replica that match the provided predicate. An effort will be made to either return ourself, or a subList, where possible. It is guaranteed that no changes to any upstream Builder will affect the state of the result. Only the first maxSize items will be returned.
-
filterLazily
java.lang.Iterable<Replica> filterLazily(java.util.function.Predicate<? super Replica> predicate)
- Returns:
- a *lazily constructed* Iterable over this collection, containing the Replica that match the provided predicate.
-
filterLazily
java.lang.Iterable<Replica> filterLazily(java.util.function.Predicate<? super Replica> predicate, int maxSize)
- Returns:
- a *lazily constructed* Iterable over this collection, containing the Replica that match the provided predicate. Only the first maxSize matching items will be returned.
-
subList
C subList(int start, int end)
- Returns:
- an *eagerly constructed* copy of this collection containing the Replica at positions [start..end); An effort will be made to either return ourself, or a subList, where possible. It is guaranteed that no changes to any upstream Builder will affect the state of the result.
-
sorted
C sorted(java.util.Comparator<? super Replica> comparator)
- Returns:
- an *eagerly constructed* copy of this collection containing the Replica re-ordered according to this comparator It is guaranteed that no changes to any upstream Builder will affect the state of the result.
-
iterator
java.util.Iterator<Replica> iterator()
- Specified by:
iterator
in interfacejava.lang.Iterable<C extends ReplicaCollection<C>>
-
stream
java.util.stream.Stream<Replica> stream()
-
equals
boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-