Search in sources :

Example 16 with Decoder

use of org.apache.avro.io.Decoder in project cdap by caskdata.

the class StoreHandler method rollback.

@POST
@Path("/rollback")
public void rollback(HttpRequest request, HttpResponder responder, @PathParam("namespace") String namespace, @PathParam("topic") String topic) throws Exception {
    TopicId topicId = new NamespaceId(namespace).topic(topic);
    Decoder decoder = DecoderFactory.get().directBinaryDecoder(new ChannelBufferInputStream(request.getContent()), null);
    DatumReader<GenericRecord> datumReader = new GenericDatumReader<>(Schemas.V1.PublishResponse.SCHEMA);
    messagingService.rollback(topicId, new GenericRecordRollbackDetail(datumReader.read(null, decoder)));
    responder.sendStatus(HttpResponseStatus.OK);
}
Also used : GenericDatumReader(org.apache.avro.generic.GenericDatumReader) TopicId(co.cask.cdap.proto.id.TopicId) NamespaceId(co.cask.cdap.proto.id.NamespaceId) ChannelBufferInputStream(org.jboss.netty.buffer.ChannelBufferInputStream) Decoder(org.apache.avro.io.Decoder) GenericRecord(org.apache.avro.generic.GenericRecord) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST)

Aggregations

Decoder (org.apache.avro.io.Decoder)16 GenericDatumReader (org.apache.avro.generic.GenericDatumReader)8 GenericRecord (org.apache.avro.generic.GenericRecord)8 IOException (java.io.IOException)6 SerializationException (voldemort.serialization.SerializationException)4 Schema (org.apache.avro.Schema)3 ChannelBufferInputStream (org.jboss.netty.buffer.ChannelBufferInputStream)3 BadRequestException (co.cask.cdap.common.BadRequestException)2 NamespaceId (co.cask.cdap.proto.id.NamespaceId)2 TopicId (co.cask.cdap.proto.id.TopicId)2 AvroAdapter (com.linkedin.data.avro.AvroAdapter)2 InputStream (java.io.InputStream)2 ArrayList (java.util.ArrayList)2 POST (javax.ws.rs.POST)2 Path (javax.ws.rs.Path)2 RawMessage (co.cask.cdap.messaging.data.RawMessage)1 InputSupplier (com.google.common.io.InputSupplier)1 BufferedReader (java.io.BufferedReader)1 EOFException (java.io.EOFException)1 FileInputStream (java.io.FileInputStream)1