Class Replica

  • All Implemented Interfaces:
    java.lang.Comparable<Replica>

    public final class Replica
    extends java.lang.Object
    implements java.lang.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.
    • Method Detail

      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • compareTo

        public int compareTo​(Replica o)
        Specified by:
        compareTo in interface java.lang.Comparable<Replica>
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • isSelf

        public boolean isSelf()
      • isFull

        public final boolean isFull()
      • isTransient

        public final boolean isTransient()
      • subtractSameReplication

        public RangesAtEndpoint 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. 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

        public RangesAtEndpoint subtractIgnoreTransientStatus​(Range<Token> subtract)
        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

        public boolean contains​(Range<Token> that)
      • intersectsOnRange

        public boolean intersectsOnRange​(Replica replica)