Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
public class QuorumInfo {
    private final Integer leaderId;
    private final List<ReplicaState> voters;
    private final List<ReplicaState> observers;

    QuorumInfo(Integer leaderId, List<ReplicaState> voters, List<ReplicaState> observers) {
        this.leaderId = leaderId;
        this.voters = voters;
        this.observers = observers;
    }

    public Integer leaderId() {
        return leaderId;
    }

    public List<ReplicaState> voters() {
        return voters;
    }

    public List<ReplicaState> observers() {
        return observers;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        QuorumInfo that = (QuorumInfo) o;
        return leaderId.equals(that.leaderId)
            && voters.equals(that.voters)
            && observers.equals(that.observers);
    }

    @Override
    public int hashCode() {
        return Objects.hash(leaderId, voters, observers);
    }

    @Override
    public String toString() {
        return "QuorumInfo(" +
            "leaderId=" + leaderId +
            ", voters=" + voters +
            ", observers=" + observers +
            ')';
    }

    public static class ReplicaState {
        private final int replicaId;
        private final long logEndOffset;
        private final OptionalLong lastFetchTimeMslastFetchTimestamp;
        private final OptionalLong lastCaughtUpTimeMslastCaughtUpTimestamp;

        ReplicaState() {
            this(0, 0, OptionalLong.empty(), OptionalLong.empty());
        }

        ReplicaState(
            int replicaId,
            long logEndOffset,
            OptionalLong lastFetchTimeMslastFetchTimestamp,
            OptionalLong lastCaughtUpTimeMslastCaughtUpTimestamp
        ) {
            this.replicaId = replicaId;
            this.logEndOffset = logEndOffset;
            this.lastFetchTimeMslastFetchTimestamp = lastFetchTimeMslastFetchTimestamp;
            this.lastCaughtUpTimeMslastCaughtUpTimestamp = lastCaughtUpTimeMslastCaughtUpTimestamp;
        }

        /**
         * Return the ID for this replica.
         * @return The ID for this replica
         */
        public int replicaId() {
            return replicaId;
        }

        /**
         * Return the logEndOffset known by the leader for this replica.
         * @return The logEndOffset for this replica
         */
        public long logEndOffset() {
            return logEndOffset;
        }

        /**
         * Return the lastFetchTime in milliseconds for this replica.
         * @return The value of the lastFetchTime if known, empty otherwise
         */
        public OptionalLong lastFetchTimeMslastFetchTimestamp() {
            return lastFetchTimeMslastFetchTimestamp;
        }

        /**
         * Return the lastCaughtUpTime in milliseconds for this replica.
         * @return The value of the lastCaughtUpTime if known, empty otherwise
         */
        public OptionalLong lastCaughtUpTimeMslastCaughtUpTimestamp() {
            return lastCaughtUpTimeMslastCaughtUpTimestamp;
        }

        @Override
        public boolean equals(Object o) {
            if (this == o) return true;
            if (o == null || getClass() != o.getClass()) return false;
            ReplicaState that = (ReplicaState) o;
            return replicaId == that.replicaId
                && logEndOffset == that.logEndOffset
                && lastFetchTimeMslastFetchTimestamp.equals(that.lastFetchTimeMslastFetchTimestamp)
                && lastCaughtUpTimeMslastCaughtUpTimestamp.equals(that.lastCaughtUpTimeMslastCaughtUpTimestamp);
        }

        @Override
        public int hashCode() {
            return Objects.hash(replicaId, logEndOffset, lastFetchTimeMslastFetchTimestamp, lastCaughtUpTimeMslastCaughtUpTimestamp);
        }

        @Override
        public String toString() {
            return "ReplicaState(" +
                "replicaId=" + replicaId +
                ", logEndOffset=" + logEndOffset +
                ", lastFetchTimeMslastFetchTimestamp=" + lastFetchTimeMslastFetchTimestamp +
                ", lastCaughtUpTimeMslastCaughtUpTimestamp=" + lastCaughtUpTimeMslastCaughtUpTimestamp +
                ')';
        }
    }
}


Code Block
public class DescribeMetadataQuorumOptions extends AbstractOptions<DescribeMetadataQuorumOptions> {

}

...

Code Block
> bin/kafka-metadata-quorum.sh --describe replication
ReplicaId   LogEndOffset    Lag		LastFetchTimeMsLastFetchTimestamp     LastCaughtUpTimeMsLastCaughtUpTimestamp    Status
0           234134          0       	tnow				    tnow 	          Leader
1           234130          4       	t2					t6		          Follower
2           234100          34      	t3					t7			      Follower
3           234124          10      	t4					t8	              Observer
4           234130          4       	t5					t9		          Observer

...