Package com.linkedin.venice.offsets
Class OffsetRecord
- java.lang.Object
-
- com.linkedin.venice.offsets.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 Summary
Fields Modifier and Type Field Description static long
DEFAULT_OFFSET_LAG
static long
LOWEST_OFFSET
static long
LOWEST_OFFSET_LAG
static java.lang.String
NON_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 void
cloneUpstreamOffsetMap(java.util.Map<java.lang.String,java.lang.Long> checkpointUpstreamOffsetMapReceiver)
Clone the checkpoint upstream offset map to another map provided as the input.void
endOfPushReceived(long endOfPushOffset)
boolean
equals(java.lang.Object o)
long
getCheckpointUpstreamVersionTopicOffset()
java.util.Map<java.lang.String,java.lang.String>
getDatabaseInfo()
long
getLatestProducerProcessingTimeInMs()
GUID
getLeaderGUID()
java.lang.String
getLeaderHostId()
java.lang.String
getLeaderTopic()
PubSubTopic
getLeaderTopic(PubSubTopicRepository pubSubTopicRepository)
long
getLocalVersionTopicOffset()
long
getMaxMessageTimeInMs()
long
getOffsetLag()
java.util.List<java.lang.String>
getPendingReportIncPushVersionList()
ProducerPartitionState
getProducerPartitionState(GUID producerGuid)
java.util.Map<java.lang.CharSequence,ProducerPartitionState>
getProducerPartitionStateMap()
ProducerPartitionState
getRealTimeProducerState(java.lang.String kafkaUrl, GUID producerGuid)
long
getUpstreamOffset(java.lang.String kafkaURL)
The caller of this API should be interested in the largest known upstream offset.java.lang.Long
getUpstreamOffsetWithNoDefault(java.lang.String kafkaURL)
int
hashCode()
boolean
isEndOfPushReceived()
void
removeProducerPartitionState(GUID producerGuid)
void
removeRealTimeTopicProducerState(java.lang.String kafkaUrl, GUID producerGuid)
void
resetUpstreamOffsetMap(java.util.Map<java.lang.String,java.lang.Long> checkpointUpstreamOffsetMap)
Reset the checkpoint upstream offset map to another map provided as the input.void
setCheckpointLocalVersionTopicOffset(long offset)
void
setCheckpointUpstreamVersionTopicOffset(long upstreamVersionTopicOffset)
void
setDatabaseInfo(java.util.Map<java.lang.String,java.lang.String> databaseInfo)
void
setLatestProducerProcessingTimeInMs(long updateTimeInMs)
void
setLeaderGUID(GUID guid)
void
setLeaderHostId(java.lang.String leaderHostId)
void
setLeaderTopic(PubSubTopic leaderTopic)
void
setLeaderUpstreamOffset(java.lang.String upstreamKafkaURL, long leaderOffset)
void
setOffsetLag(long offsetLag)
void
setPendingReportIncPushVersionList(java.util.List<java.lang.String> incPushVersionList)
void
setProducerPartitionState(GUID producerGuid, ProducerPartitionState state)
void
setRealtimeTopicProducerState(java.lang.String kafkaUrl, GUID producerGuid, ProducerPartitionState state)
byte[]
toBytes()
serialize to bytesjava.lang.String
toJsonString()
PartitionState will be encoded with an in-house JsonEncoder which would transfer all data with "bytes" schema to hexadecimal strings.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.java.lang.String
toString()
-
-
-
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:
toString
in 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:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toBytes
public byte[] toBytes()
serialize to bytes- Returns:
- byte[]
-
-