Class VersionSwap
java.lang.Object
org.apache.avro.specific.SpecificRecordBase
com.linkedin.venice.kafka.protocol.VersionSwap
- All Implemented Interfaces:
Externalizable,Serializable,Comparable<org.apache.avro.specific.SpecificRecord>,org.apache.avro.generic.GenericContainer,org.apache.avro.generic.GenericRecord,org.apache.avro.generic.IndexedRecord,org.apache.avro.specific.SpecificRecord
public class VersionSwap
extends org.apache.avro.specific.SpecificRecordBase
implements org.apache.avro.specific.SpecificRecord
This controlMessage is written to the real-time topic by the controller or to the store-version topic by the current version's leader server. It can be used to let current version and future version synchronize on a specific point for all regions' real-time topics, to guarantee there is only one store version producing to change capture topic all the time. It can also be used by the consumer client to switch to another store-version topic and filter messages that have a lower watermark than the one dictated by the leader.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionThe real-time topic region that this version swap was written to.longA timestamp-based generation id to differentiate multiple version swaps within the same version topicbooleanFlag to indicate this version swap message in version topic is triggered by the last version swap in real time topic the leader server has received.booleanFlag to indicate this version swap is triggered by repush or not.The latest pubsub positions of all real-time topics consumed up until now.The latest offsets of all real-time topic has been consumed up until now.Name of the new source topic we are switching to.Name of the old source topic we are switching from.static final org.apache.avro.SchemaThe region that initiated this version swap. -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor.VersionSwap(CharSequence oldServingVersionTopic, CharSequence newServingVersionTopic, List<Long> localHighWatermarks, List<ByteBuffer> localHighWatermarkPubSubPositions, Boolean isRepush, Boolean isLastVersionSwapMessageFromRealTimeTopic, CharSequence sourceRegion, CharSequence destinationRegion, Long generationId) All-args constructor. -
Method Summary
Modifier and TypeMethodDescriptionget(int field$) static org.apache.avro.SchemaGets the value of the 'destinationRegion' field.longGets the value of the 'generationId' field.booleanGets the value of the 'isLastVersionSwapMessageFromRealTimeTopic' field.booleanGets the value of the 'isRepush' field.Gets the value of the 'localHighWatermarkPubSubPositions' field.Gets the value of the 'localHighWatermarks' field.Gets the value of the 'newServingVersionTopic' field.Gets the value of the 'oldServingVersionTopic' field.org.apache.avro.SchemaGets the value of the 'sourceRegion' field.org.apache.avro.specific.SpecificDatavoidvoidvoidsetDestinationRegion(CharSequence value) Sets the value of the 'destinationRegion' field.voidsetGenerationId(long value) Sets the value of the 'generationId' field.voidsetIsLastVersionSwapMessageFromRealTimeTopic(boolean value) Sets the value of the 'isLastVersionSwapMessageFromRealTimeTopic' field.voidsetIsRepush(boolean value) Sets the value of the 'isRepush' field.voidSets the value of the 'localHighWatermarkPubSubPositions' field.voidsetLocalHighWatermarks(List<Long> value) Sets the value of the 'localHighWatermarks' field.voidSets the value of the 'newServingVersionTopic' field.voidSets the value of the 'oldServingVersionTopic' field.voidsetSourceRegion(CharSequence value) Sets the value of the 'sourceRegion' field.voidMethods inherited from class org.apache.avro.specific.SpecificRecordBase
compareTo, customDecode, customEncode, equals, get, getConversion, getConversion, hasCustomCoders, hashCode, put, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.avro.generic.GenericRecord
hasField
-
Field Details
-
SCHEMA$
public static final org.apache.avro.Schema SCHEMA$ -
oldServingVersionTopic
Name of the old source topic we are switching from. -
newServingVersionTopic
Name of the new source topic we are switching to. -
localHighWatermarks
The latest offsets of all real-time topic has been consumed up until now. -
localHighWatermarkPubSubPositions
The latest pubsub positions of all real-time topics consumed up until now. -
isRepush
public boolean isRepushFlag to indicate this version swap is triggered by repush or not. -
isLastVersionSwapMessageFromRealTimeTopic
public boolean isLastVersionSwapMessageFromRealTimeTopicFlag to indicate this version swap message in version topic is triggered by the last version swap in real time topic the leader server has received. With this flag, new leader will be able to recover the full state during leadership handover, when we rely on real-time topics for all regions to achieve version swap synchronization. -
sourceRegion
The region that initiated this version swap. -
destinationRegion
The real-time topic region that this version swap was written to. -
generationId
public long generationIdA timestamp-based generation id to differentiate multiple version swaps within the same version topic
-
-
Constructor Details
-
VersionSwap
public VersionSwap()Default constructor. Note that this does not initialize fields to their default values from the schema. If that is desired then one should usenewBuilder(). -
VersionSwap
public VersionSwap(CharSequence oldServingVersionTopic, CharSequence newServingVersionTopic, List<Long> localHighWatermarks, List<ByteBuffer> localHighWatermarkPubSubPositions, Boolean isRepush, Boolean isLastVersionSwapMessageFromRealTimeTopic, CharSequence sourceRegion, CharSequence destinationRegion, Long generationId) All-args constructor.- Parameters:
oldServingVersionTopic- Name of the old source topic we are switching from.newServingVersionTopic- Name of the new source topic we are switching to.localHighWatermarks- The latest offsets of all real-time topic has been consumed up until now.localHighWatermarkPubSubPositions- The latest pubsub positions of all real-time topics consumed up until now.isRepush- Flag to indicate this version swap is triggered by repush or not.isLastVersionSwapMessageFromRealTimeTopic- Flag to indicate this version swap message in version topic is triggered by the last version swap in real time topic the leader server has received. With this flag, new leader will be able to recover the full state during leadership handover, when we rely on real-time topics for all regions to achieve version swap synchronization.sourceRegion- The region that initiated this version swap.destinationRegion- The real-time topic region that this version swap was written to.generationId- A timestamp-based generation id to differentiate multiple version swaps within the same version topic
-
-
Method Details
-
getClassSchema
public static org.apache.avro.Schema getClassSchema() -
getSpecificData
public org.apache.avro.specific.SpecificData getSpecificData()- Overrides:
getSpecificDatain classorg.apache.avro.specific.SpecificRecordBase
-
getSchema
public org.apache.avro.Schema getSchema()- Specified by:
getSchemain interfaceorg.apache.avro.generic.GenericContainer- Specified by:
getSchemain classorg.apache.avro.specific.SpecificRecordBase
-
get
- Specified by:
getin interfaceorg.apache.avro.generic.IndexedRecord- Specified by:
getin classorg.apache.avro.specific.SpecificRecordBase
-
put
- Specified by:
putin interfaceorg.apache.avro.generic.IndexedRecord- Specified by:
putin classorg.apache.avro.specific.SpecificRecordBase
-
getOldServingVersionTopic
Gets the value of the 'oldServingVersionTopic' field.- Returns:
- Name of the old source topic we are switching from.
-
setOldServingVersionTopic
Sets the value of the 'oldServingVersionTopic' field. Name of the old source topic we are switching from.- Parameters:
value- the value to set.
-
getNewServingVersionTopic
Gets the value of the 'newServingVersionTopic' field.- Returns:
- Name of the new source topic we are switching to.
-
setNewServingVersionTopic
Sets the value of the 'newServingVersionTopic' field. Name of the new source topic we are switching to.- Parameters:
value- the value to set.
-
getLocalHighWatermarks
Gets the value of the 'localHighWatermarks' field.- Returns:
- The latest offsets of all real-time topic has been consumed up until now.
-
setLocalHighWatermarks
Sets the value of the 'localHighWatermarks' field. The latest offsets of all real-time topic has been consumed up until now.- Parameters:
value- the value to set.
-
getLocalHighWatermarkPubSubPositions
Gets the value of the 'localHighWatermarkPubSubPositions' field.- Returns:
- The latest pubsub positions of all real-time topics consumed up until now.
-
setLocalHighWatermarkPubSubPositions
Sets the value of the 'localHighWatermarkPubSubPositions' field. The latest pubsub positions of all real-time topics consumed up until now.- Parameters:
value- the value to set.
-
getIsRepush
public boolean getIsRepush()Gets the value of the 'isRepush' field.- Returns:
- Flag to indicate this version swap is triggered by repush or not.
-
setIsRepush
public void setIsRepush(boolean value) Sets the value of the 'isRepush' field. Flag to indicate this version swap is triggered by repush or not.- Parameters:
value- the value to set.
-
getIsLastVersionSwapMessageFromRealTimeTopic
public boolean getIsLastVersionSwapMessageFromRealTimeTopic()Gets the value of the 'isLastVersionSwapMessageFromRealTimeTopic' field.- Returns:
- Flag to indicate this version swap message in version topic is triggered by the last version swap in real time topic the leader server has received. With this flag, new leader will be able to recover the full state during leadership handover, when we rely on real-time topics for all regions to achieve version swap synchronization.
-
setIsLastVersionSwapMessageFromRealTimeTopic
public void setIsLastVersionSwapMessageFromRealTimeTopic(boolean value) Sets the value of the 'isLastVersionSwapMessageFromRealTimeTopic' field. Flag to indicate this version swap message in version topic is triggered by the last version swap in real time topic the leader server has received. With this flag, new leader will be able to recover the full state during leadership handover, when we rely on real-time topics for all regions to achieve version swap synchronization.- Parameters:
value- the value to set.
-
getSourceRegion
Gets the value of the 'sourceRegion' field.- Returns:
- The region that initiated this version swap.
-
setSourceRegion
Sets the value of the 'sourceRegion' field. The region that initiated this version swap.- Parameters:
value- the value to set.
-
getDestinationRegion
Gets the value of the 'destinationRegion' field.- Returns:
- The real-time topic region that this version swap was written to.
-
setDestinationRegion
Sets the value of the 'destinationRegion' field. The real-time topic region that this version swap was written to.- Parameters:
value- the value to set.
-
getGenerationId
public long getGenerationId()Gets the value of the 'generationId' field.- Returns:
- A timestamp-based generation id to differentiate multiple version swaps within the same version topic
-
setGenerationId
public void setGenerationId(long value) Sets the value of the 'generationId' field. A timestamp-based generation id to differentiate multiple version swaps within the same version topic- Parameters:
value- the value to set.
-
writeExternal
- Specified by:
writeExternalin interfaceExternalizable- Overrides:
writeExternalin classorg.apache.avro.specific.SpecificRecordBase- Throws:
IOException
-
readExternal
- Specified by:
readExternalin interfaceExternalizable- Overrides:
readExternalin classorg.apache.avro.specific.SpecificRecordBase- Throws:
IOException
-