Class ReplicationStateMetadata

java.lang.Object
io.confluent.kafka.replication.push.ReplicationStateMetadata
All Implemented Interfaces:
ReplicationState

public class ReplicationStateMetadata extends Object implements ReplicationState
Manages replication mode transitions for push replication. A Follower partition can be in either PULL or PUSH mode.
  • Field Details

    • UNKNOWN_REPLICATION_SESSION_ID

      public static final long UNKNOWN_REPLICATION_SESSION_ID
      An invalid replication session ID. Used by followers in pull replication mode that do not support a transition to push replication mode. Also used to initialize the replication session ID on the leader before any fetches are received.
      See Also:
    • INITIAL_REPLICATION_SESSION_ID

      public static final long INITIAL_REPLICATION_SESSION_ID
      The initial replication session ID. Used when initializing replicas on the follower.
      See Also:
    • FINAL_REPLICATION_SESSION_ID

      public static final long FINAL_REPLICATION_SESSION_ID
      The final replication session ID. Used when push transition is disabled, in which case the replica fetch requests will be built with this replication session ID. This also means a partition with the final replication ID (which should never happen in practice) will not be able to transition to push.
      See Also:
    • INITIAL

      public static final ReplicationStateMetadata INITIAL
  • Constructor Details

    • ReplicationStateMetadata

      public ReplicationStateMetadata(ReplicationState.Mode replicationMode, long replicationSessionId)
  • Method Details

    • replicationSessionIdSupportsPushTransition

      public static boolean replicationSessionIdSupportsPushTransition(long replicationSessionId)
    • mode

      public ReplicationState.Mode mode()
      Description copied from interface: ReplicationState
      The replication mode of this partition replica.
      Specified by:
      mode in interface ReplicationState
    • replicationSessionId

      public long replicationSessionId()
      Description copied from interface: ReplicationState

      The current replication session ID for this partition replica. Used for coordinating transitions between pull and push replication mode by the leader and the follower.

      The replication session ID is included in both the Fetch (pull replication) protocol and the AppendRecords (push replication) protocol. It's incremented on the follower whenever the leader requests a transition back to ReplicationState.Mode.PULL.

      Specified by:
      replicationSessionId in interface ReplicationState
    • canTransitionTo

      public boolean canTransitionTo(ReplicationState.Mode next, long proposedSessionId)
      Follower replication mode transition proposal requires the proposed session ID to be incremented when the leader requests a transition back to PULL. Replication mode transitions also require the current replication mode to be a valid previous state.
      Parameters:
      next - proposed replication mode
      proposedSessionId - proposed session ID
      Returns:
      true if the follower state can be transitioned to the proposed replication mode with the proposed session ID, false otherwise
    • nextId

      public long nextId(ReplicationState.Mode nextMode)
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object