Enum Class MessageType
- All Implemented Interfaces:
VeniceEnumValue
,Serializable
,Comparable<MessageType>
,Constable
A simple enum to map the values of
KafkaMessageEnvelope.messageType
N.B.: We maintain this enum manually because Avro's auto-generated enums do
not support evolution (i.e.: adding values) properly.-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
-
Method Summary
Modifier and TypeMethodDescriptionbyte
Simple utility function to generate the right type of payload, based on message type.int
getValue()
static MessageType
valueOf
(int value) Returns the enum constant of this class with the specified name.static MessageType
valueOf
(KafkaMessageEnvelope kafkaMessageEnvelope) Returns the enum constant of this class with the specified name.static MessageType
Returns the enum constant of this class with the specified name.static MessageType[]
values()
Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
PUT
-
DELETE
-
CONTROL_MESSAGE
-
UPDATE
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum class has no constant with the specified nameNullPointerException
- if the argument is null
-
getValue
public int getValue()- Specified by:
getValue
in interfaceVeniceEnumValue
- Returns:
- This is the value used in
KafkaMessageEnvelope.messageType
to distinguish message types.
-
getKeyHeaderByte
public byte getKeyHeaderByte()- Returns:
- This is the value used at the beginning of our Kafka keys, in order to ensure that Kafka's Log Compaction has the correct overwriting semantics. For example, DELETE must overwrite PUT and vice versa, so they share the same .
-
getNewInstance
Simple utility function to generate the right type of payload, based on message type.- Returns:
- an empty instance of either:
-
Put
-Delete
-ControlMessage
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
value
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum class has no constant with the specified nameNullPointerException
- if the argument is null
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
kafkaMessageEnvelope
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum class has no constant with the specified nameNullPointerException
- if the argument is null
-