Package org.apache.cassandra.locator
Class Replica
java.lang.Object
org.apache.cassandra.locator.Replica
- All Implemented Interfaces:
Comparable<Replica>
A Replica represents an owning node for a copy of a portion of the token ring.
It consists of:
- the logical token range that is being replicated (i.e. for the first logical replica only, this will be equal
to one of its owned portions of the token ring; all other replicas will have this token range also)
- an endpoint (IP and port)
- whether the range is replicated in full, or transiently (CASSANDRA-14404)
In general, it is preferred to use a Replica to a Range<Token>, particularly when users of the concept depend on
knowledge of the full/transient status of the copy.
That means you should avoid unwrapping and rewrapping these things and think hard about subtraction
and such and what the result is WRT to transientness. Definitely avoid creating fake Replicas with misinformation
about endpoints, ranges, or transientness.
-
Constructor Summary
ConstructorsConstructorDescriptionReplica(InetAddressAndPort endpoint, Range<Token> range, boolean full) Replica(InetAddressAndPort endpoint, Token start, Token end, boolean full) -
Method Summary
Modifier and TypeMethodDescriptionintbooleandecorateSubrange(Range<Token> subrange) final InetAddressAndPortendpoint()booleanstatic ReplicafullReplica(InetAddressAndPort endpoint, Range<Token> range) static ReplicafullReplica(InetAddressAndPort endpoint, Token start, Token end) inthashCode()booleanintersectsOnRange(Replica replica) final booleanisFull()booleanisSelf()final booleanrange()subtractIgnoreTransientStatus(Range<Token> subtract) Don't use this method and ignore transient status unless you are explicitly handling it outside this method.subtractSameReplication(RangesAtEndpoint toSubtract) This is used exclusively in TokenMetadata to check if a portion of a range is already replicated by an endpoint so that we only mark as pending the portion that is either not replicated sufficiently (transient when we need full) or at all.toString()static ReplicatransientReplica(InetAddressAndPort endpoint, Range<Token> range) static ReplicatransientReplica(InetAddressAndPort endpoint, Token start, Token end)
-
Constructor Details
-
Replica
-
Replica
-
-
Method Details
-
equals
-
compareTo
- Specified by:
compareToin interfaceComparable<Replica>
-
hashCode
public int hashCode() -
toString
-
endpoint
-
isSelf
public boolean isSelf() -
range
-
isFull
public final boolean isFull() -
isTransient
public final boolean isTransient() -
subtractSameReplication
This is used exclusively in TokenMetadata to check if a portion of a range is already replicated by an endpoint so that we only mark as pending the portion that is either not replicated sufficiently (transient when we need full) or at all. If it's not replicated at all it needs to be pending because there is no data. If it's replicated but only transiently and we need to replicate it fully it must be marked as pending until it is available fully otherwise a read might treat this replica as full and not read from a full replica that has the data. -
subtractIgnoreTransientStatus
Don't use this method and ignore transient status unless you are explicitly handling it outside this method. This helper method is used by StorageService.calculateStreamAndFetchRanges to perform subtraction. It ignores transient status because it's already being handled in calculateStreamAndFetchRanges. -
contains
-
intersectsOnRange
-
decorateSubrange
-
fullReplica
-
fullReplica
-
transientReplica
-
transientReplica
-