Class AdminOperationSerializer

java.lang.Object
com.linkedin.venice.controller.kafka.protocol.serializer.AdminOperationSerializer

public class AdminOperationSerializer extends Object
  • Field Details

    • LATEST_SCHEMA_ID_FOR_ADMIN_OPERATION

      public static final int LATEST_SCHEMA_ID_FOR_ADMIN_OPERATION
    • LATEST_SCHEMA

      public static final org.apache.avro.Schema LATEST_SCHEMA
  • Constructor Details

    • AdminOperationSerializer

      public AdminOperationSerializer()
  • Method Details

    • serialize

      public byte[] serialize(AdminOperation object, int targetSchemaId)
      Serialize AdminOperation object to bytes[] with the writer schema
      Parameters:
      object - AdminOperation object
      targetSchemaId - writer schema id that we will refer to for serialization and deserialization

      If targetSchemaId equals LATEST_SCHEMA_ID_FOR_ADMIN_OPERATION, return the bytes[] from the first serialization. Otherwise, serialize the object to the writer schema (lower version).

      This involves:

      1. Serializing the object to a GenericRecord with the latest schema.
      2. Deserializing it to a GenericRecord with the writer schema.
      3. Serializing it to bytes.

      This process ensures the object is serialized to the lower schema version. The normal serialization process may fail (ClassCastException) due to:

      • Differences in field types
      • New fields added in the middle of the schema instead of at the end

    • deserialize

      public AdminOperation deserialize(ByteBuffer byteBuffer, int writerSchemaId)
    • validate

      public void validate(AdminOperation message, int targetSchemaId)
      Validate the AdminOperation message against the target schema for serialization compatibility.
      Throws:
      VeniceProtocolException - if the message does not conform to the target schema.
    • initProtocolMap

      public static Map<Integer,org.apache.avro.Schema> initProtocolMap()
    • getSchema

      public org.apache.avro.Schema getSchema(int schemaId)
      Get schema by schema id from either built-in protocol map or system store schema repository cache.
    • fetchAndStoreSchemaIfAbsent

      public void fetchAndStoreSchemaIfAbsent(VeniceHelixAdmin admin, int schemaId)
      Download schema from system store schema repository and add it to the protocol map if not already present.
      Throws:
      VeniceProtocolException - if the schema could not be found in the system store schema repository.
    • addSchema

      public void addSchema(int schemaId, org.apache.avro.Schema schema)
    • removeSchema

      public void removeSchema(int schemaId)