Class RecordSchemaValidator

java.lang.Object
io.confluent.kafka.schemaregistry.validator.RecordSchemaValidator
All Implemented Interfaces:
Closeable, AutoCloseable, org.apache.kafka.common.Configurable, org.apache.kafka.server.interceptor.RecordInterceptor

public class RecordSchemaValidator extends Object implements org.apache.kafka.server.interceptor.RecordInterceptor
A RecordInterceptor that performs schema validation. This interceptor checks that

1) The record payload has a magic byte, then followed by a schema id integer encoded in the next 4 bytes.

2) The encoded schema id exists in the Schema Registry, and is registered under the subject matching the topic.

If both 1) and 2) are true, then the interceptor will return ACCEPT, otherwise return REJECT.

  • Nested Class Summary

    Nested classes/interfaces inherited from interface org.apache.kafka.server.interceptor.RecordInterceptor

    org.apache.kafka.server.interceptor.RecordInterceptor.RecordInterceptorResponse
  • Constructor Summary

    Constructors
    Constructor
    Description
     
    RecordSchemaValidator(io.confluent.kafka.schemaregistry.client.SchemaRegistryClient schemaRegistry, org.slf4j.Logger log)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
     
    void
    configure(Map<String,?> configs)
     
    org.apache.kafka.server.interceptor.RecordInterceptor.RecordInterceptorResponse
    onAppend(org.apache.kafka.common.TopicPartition tp, org.apache.kafka.common.record.Record record)
     

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.apache.kafka.server.interceptor.RecordInterceptor

    setMetrics
  • Constructor Details

    • RecordSchemaValidator

      public RecordSchemaValidator()
    • RecordSchemaValidator

      public RecordSchemaValidator(io.confluent.kafka.schemaregistry.client.SchemaRegistryClient schemaRegistry, org.slf4j.Logger log)
  • Method Details

    • configure

      public void configure(Map<String,?> configs)
      Specified by:
      configure in interface org.apache.kafka.common.Configurable
      Specified by:
      configure in interface org.apache.kafka.server.interceptor.RecordInterceptor
    • onAppend

      public org.apache.kafka.server.interceptor.RecordInterceptor.RecordInterceptorResponse onAppend(org.apache.kafka.common.TopicPartition tp, org.apache.kafka.common.record.Record record)
      Specified by:
      onAppend in interface org.apache.kafka.server.interceptor.RecordInterceptor
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Specified by:
      close in interface org.apache.kafka.server.interceptor.RecordInterceptor