Class OffsetRecord


  • public class OffsetRecord
    extends java.lang.Object
    If OffsetRecord is initialized with a serializer that contains SchemaReader, old version of server codes will be able to deserialize OffsetRecord that is serialized with a newer protocol version, which can happen after rolling back a server release with new protocol version to an old server release with old protocol version.
    • Field Detail

      • NON_AA_REPLICATION_UPSTREAM_OFFSET_MAP_KEY

        public static final java.lang.String NON_AA_REPLICATION_UPSTREAM_OFFSET_MAP_KEY
        See Also:
        Constant Field Values
    • Method Detail

      • getLocalVersionTopicOffset

        public long getLocalVersionTopicOffset()
      • setCheckpointLocalVersionTopicOffset

        public void setCheckpointLocalVersionTopicOffset​(long offset)
      • getCheckpointUpstreamVersionTopicOffset

        public long getCheckpointUpstreamVersionTopicOffset()
      • setCheckpointUpstreamVersionTopicOffset

        public void setCheckpointUpstreamVersionTopicOffset​(long upstreamVersionTopicOffset)
      • getOffsetLag

        public long getOffsetLag()
      • setOffsetLag

        public void setOffsetLag​(long offsetLag)
      • getMaxMessageTimeInMs

        public long getMaxMessageTimeInMs()
        Returns:
        the last messageTimeStamp across all producers tracked by this OffsetRecord
      • getLatestProducerProcessingTimeInMs

        public long getLatestProducerProcessingTimeInMs()
      • setLatestProducerProcessingTimeInMs

        public void setLatestProducerProcessingTimeInMs​(long updateTimeInMs)
      • endOfPushReceived

        public void endOfPushReceived​(long endOfPushOffset)
      • isEndOfPushReceived

        public boolean isEndOfPushReceived()
      • removeProducerPartitionState

        public void removeProducerPartitionState​(GUID producerGuid)
      • getProducerPartitionStateMap

        public java.util.Map<java.lang.CharSequence,​ProducerPartitionState> getProducerPartitionStateMap()
      • setRealtimeTopicProducerState

        public void setRealtimeTopicProducerState​(java.lang.String kafkaUrl,
                                                  GUID producerGuid,
                                                  ProducerPartitionState state)
      • removeRealTimeTopicProducerState

        public void removeRealTimeTopicProducerState​(java.lang.String kafkaUrl,
                                                     GUID producerGuid)
      • getRealTimeProducerState

        public ProducerPartitionState getRealTimeProducerState​(java.lang.String kafkaUrl,
                                                               GUID producerGuid)
      • setDatabaseInfo

        public void setDatabaseInfo​(java.util.Map<java.lang.String,​java.lang.String> databaseInfo)
      • getDatabaseInfo

        public java.util.Map<java.lang.String,​java.lang.String> getDatabaseInfo()
      • setLeaderTopic

        public void setLeaderTopic​(PubSubTopic leaderTopic)
      • setLeaderUpstreamOffset

        public void setLeaderUpstreamOffset​(java.lang.String upstreamKafkaURL,
                                            long leaderOffset)
      • setLeaderGUID

        public void setLeaderGUID​(GUID guid)
      • setLeaderHostId

        public void setLeaderHostId​(java.lang.String leaderHostId)
      • getLeaderTopic

        public java.lang.String getLeaderTopic()
      • getUpstreamOffset

        public long getUpstreamOffset​(java.lang.String kafkaURL)
        The caller of this API should be interested in the largest known upstream offset. For example, during re-balance, a new leader is elected to consume a partition from scratch; the partition in VT looks like this: SOP, data messages from batch..., EOP, TS, some data messages from RT... Leader shouldn't act on the TS message the moment it consumes TS, but instead, it should consume all the messages in the VT including all the existing real-time messages in VT, in order to resume consumption from RT at the largest known upstream offset to avoid duplicate work. In this case, leader is still consuming VT, so it would return VT offset; users should call this API to get the latest upstream offset.
      • getUpstreamOffsetWithNoDefault

        public java.lang.Long getUpstreamOffsetWithNoDefault​(java.lang.String kafkaURL)
      • cloneUpstreamOffsetMap

        public void cloneUpstreamOffsetMap​(@Nonnull
                                           java.util.Map<java.lang.String,​java.lang.Long> checkpointUpstreamOffsetMapReceiver)
        Clone the checkpoint upstream offset map to another map provided as the input.
      • resetUpstreamOffsetMap

        public void resetUpstreamOffsetMap​(@Nonnull
                                           java.util.Map<java.lang.String,​java.lang.Long> checkpointUpstreamOffsetMap)
        Reset the checkpoint upstream offset map to another map provided as the input.
        Parameters:
        checkpointUpstreamOffsetMap -
      • getLeaderGUID

        public GUID getLeaderGUID()
      • getLeaderHostId

        public java.lang.String getLeaderHostId()
      • getPendingReportIncPushVersionList

        public java.util.List<java.lang.String> getPendingReportIncPushVersionList()
      • setPendingReportIncPushVersionList

        public void setPendingReportIncPushVersionList​(java.util.List<java.lang.String> incPushVersionList)
      • toString

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

        public java.lang.String toSimplifiedString()
        This function will print only the critical info inside OffsetRecord, like offset, EOP received; producer DIV info will not be printed.
      • toJsonString

        public java.lang.String toJsonString()
        PartitionState will be encoded with an in-house JsonEncoder which would transfer all data with "bytes" schema to hexadecimal strings.
      • equals

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

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

        public byte[] toBytes()
        serialize to bytes
        Returns:
        byte[]