Package com.linkedin.venice.offsets
Class OffsetRecord
- java.lang.Object
-
- com.linkedin.venice.offsets.OffsetRecord
-
public class OffsetRecord extends java.lang.ObjectIf 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 Summary
Fields Modifier and Type Field Description static longDEFAULT_OFFSET_LAGstatic longLOWEST_OFFSETstatic longLOWEST_OFFSET_LAGstatic java.lang.StringNON_AA_REPLICATION_UPSTREAM_OFFSET_MAP_KEY
-
Constructor Summary
Constructors Constructor Description OffsetRecord(byte[] bytes, InternalAvroSpecificSerializer<PartitionState> serializer)OffsetRecord(PartitionState partitionState, InternalAvroSpecificSerializer<PartitionState> serializer)OffsetRecord(InternalAvroSpecificSerializer<PartitionState> serializer)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcloneUpstreamOffsetMap(java.util.Map<java.lang.String,java.lang.Long> checkpointUpstreamOffsetMapReceiver)Clone the checkpoint upstream offset map to another map provided as the input.voidendOfPushReceived(long endOfPushOffset)booleanequals(java.lang.Object o)longgetCheckpointUpstreamVersionTopicOffset()java.util.Map<java.lang.String,java.lang.String>getDatabaseInfo()longgetLatestProducerProcessingTimeInMs()GUIDgetLeaderGUID()java.lang.StringgetLeaderHostId()java.lang.StringgetLeaderTopic()PubSubTopicgetLeaderTopic(PubSubTopicRepository pubSubTopicRepository)longgetLocalVersionTopicOffset()longgetMaxMessageTimeInMs()longgetOffsetLag()java.util.List<java.lang.String>getPendingReportIncPushVersionList()ProducerPartitionStategetProducerPartitionState(GUID producerGuid)java.util.Map<java.lang.CharSequence,ProducerPartitionState>getProducerPartitionStateMap()ProducerPartitionStategetRealTimeProducerState(java.lang.String kafkaUrl, GUID producerGuid)longgetUpstreamOffset(java.lang.String kafkaURL)The caller of this API should be interested in the largest known upstream offset.java.lang.LonggetUpstreamOffsetWithNoDefault(java.lang.String kafkaURL)inthashCode()booleanisEndOfPushReceived()voidremoveProducerPartitionState(GUID producerGuid)voidremoveRealTimeTopicProducerState(java.lang.String kafkaUrl, GUID producerGuid)voidresetUpstreamOffsetMap(java.util.Map<java.lang.String,java.lang.Long> checkpointUpstreamOffsetMap)Reset the checkpoint upstream offset map to another map provided as the input.voidsetCheckpointLocalVersionTopicOffset(long offset)voidsetCheckpointUpstreamVersionTopicOffset(long upstreamVersionTopicOffset)voidsetDatabaseInfo(java.util.Map<java.lang.String,java.lang.String> databaseInfo)voidsetLatestProducerProcessingTimeInMs(long updateTimeInMs)voidsetLeaderGUID(GUID guid)voidsetLeaderHostId(java.lang.String leaderHostId)voidsetLeaderTopic(PubSubTopic leaderTopic)voidsetLeaderUpstreamOffset(java.lang.String upstreamKafkaURL, long leaderOffset)voidsetOffsetLag(long offsetLag)voidsetPendingReportIncPushVersionList(java.util.List<java.lang.String> incPushVersionList)voidsetProducerPartitionState(GUID producerGuid, ProducerPartitionState state)voidsetRealtimeTopicProducerState(java.lang.String kafkaUrl, GUID producerGuid, ProducerPartitionState state)byte[]toBytes()serialize to bytesjava.lang.StringtoJsonString()PartitionState will be encoded with an in-house JsonEncoder which would transfer all data with "bytes" schema to hexadecimal strings.java.lang.StringtoSimplifiedString()This function will print only the critical info inside OffsetRecord, like offset, EOP received; producer DIV info will not be printed.java.lang.StringtoString()
-
-
-
Field Detail
-
LOWEST_OFFSET
public static final long LOWEST_OFFSET
- See Also:
- Constant Field Values
-
LOWEST_OFFSET_LAG
public static final long LOWEST_OFFSET_LAG
- See Also:
- Constant Field Values
-
DEFAULT_OFFSET_LAG
public static final long DEFAULT_OFFSET_LAG
- See Also:
- Constant Field Values
-
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
-
-
Constructor Detail
-
OffsetRecord
public OffsetRecord(PartitionState partitionState, InternalAvroSpecificSerializer<PartitionState> serializer)
-
OffsetRecord
public OffsetRecord(InternalAvroSpecificSerializer<PartitionState> serializer)
-
OffsetRecord
public OffsetRecord(byte[] bytes, InternalAvroSpecificSerializer<PartitionState> serializer)- Parameters:
bytes- to deserialize from
-
-
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()
-
setProducerPartitionState
public void setProducerPartitionState(GUID producerGuid, ProducerPartitionState state)
-
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)
-
getProducerPartitionState
public ProducerPartitionState getProducerPartitionState(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()
-
getLeaderTopic
public PubSubTopic getLeaderTopic(PubSubTopicRepository pubSubTopicRepository)
-
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:
toStringin classjava.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:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toBytes
public byte[] toBytes()
serialize to bytes- Returns:
- byte[]
-
-