Search in sources :

Example 1 with SerDesProtocolHandler

use of com.hortonworks.registries.schemaregistry.serdes.SerDesProtocolHandler in project registry by hortonworks.

the class AbstractAvroSnapshotDeserializer method deserializePayloadForProtocol.

protected Object deserializePayloadForProtocol(byte protocolId, InputStream payloadInputStream, Schema writerSchema, Schema readerSchema) throws SerDesException {
    Map<String, Object> props = new HashMap<>();
    props.put(SPECIFIC_AVRO_READER, useSpecificAvroReader);
    props.put(WRITER_SCHEMA, writerSchema);
    props.put(READER_SCHEMA, readerSchema);
    SerDesProtocolHandler serDesProtocolHandler = SerDesProtocolHandlerRegistry.get().getSerDesProtocolHandler(protocolId);
    return serDesProtocolHandler.handlePayloadDeserialization(payloadInputStream, props);
}
Also used : HashMap(java.util.HashMap) SerDesProtocolHandler(com.hortonworks.registries.schemaregistry.serdes.SerDesProtocolHandler)

Example 2 with SerDesProtocolHandler

use of com.hortonworks.registries.schemaregistry.serdes.SerDesProtocolHandler in project registry by hortonworks.

the class AbstractAvroSnapshotSerializer method doInit.

@Override
public void doInit(Map<String, ?> config) {
    Number number = (Number) ((Map<String, Object>) config).getOrDefault(SERDES_PROTOCOL_VERSION, SerDesProtocolHandlerRegistry.CURRENT_PROTOCOL);
    validateSerdesProtocolVersion(number);
    Byte protocolVersion = number.byteValue();
    SerDesProtocolHandler serDesProtocolHandler = SerDesProtocolHandlerRegistry.get().getSerDesProtocolHandler(protocolVersion);
    if (serDesProtocolHandler == null) {
        throw new AvroException("SerDesProtocolHandler with protocol version " + protocolVersion + " does not exist");
    }
    this.serDesProtocolHandler = serDesProtocolHandler;
}
Also used : AvroException(com.hortonworks.registries.schemaregistry.serdes.avro.exceptions.AvroException) SerDesProtocolHandler(com.hortonworks.registries.schemaregistry.serdes.SerDesProtocolHandler)

Aggregations

SerDesProtocolHandler (com.hortonworks.registries.schemaregistry.serdes.SerDesProtocolHandler)2 AvroException (com.hortonworks.registries.schemaregistry.serdes.avro.exceptions.AvroException)1 HashMap (java.util.HashMap)1