Search in sources :

Example 1 with KinesisClientRecord

use of software.amazon.kinesis.retrieval.KinesisClientRecord in project pulsar by apache.

the class KinesisRecordProcessor method processRecords.

@Override
public void processRecords(ProcessRecordsInput processRecordsInput) {
    log.info("Processing " + processRecordsInput.records().size() + " records from " + kinesisShardId);
    for (KinesisClientRecord record : processRecordsInput.records()) {
        try {
            queue.put(new KinesisRecord(record));
        } catch (InterruptedException e) {
            log.warn("unable to create KinesisRecord ", e);
        }
    }
    // Checkpoint once every checkpoint interval.
    if (System.nanoTime() > nextCheckpointTimeInNanos) {
        checkpoint(processRecordsInput.checkpointer());
        nextCheckpointTimeInNanos = System.nanoTime() + checkpointInterval;
    }
}
Also used : KinesisClientRecord(software.amazon.kinesis.retrieval.KinesisClientRecord)

Example 2 with KinesisClientRecord

use of software.amazon.kinesis.retrieval.KinesisClientRecord in project aws-glue-schema-registry by awslabs.

the class GlueSchemaRegistryRecordProcessor method processRecords.

public void processRecords(ProcessRecordsInput processRecordsInput) {
    this.recordProcessor.consumptionSuccess = true;
    try {
        LOGGER.info("Processing {} record(s)", processRecordsInput.records().size());
        for (KinesisClientRecord r : processRecordsInput.records()) {
            ByteBuffer bb = r.data();
            byte[] bytes = new byte[bb.remaining()];
            bb.get(bytes);
            Schema gsrSchema = glueSchemaRegistryDeserializer.getSchema(bytes);
            LOGGER.info("Consumed Schema from GSR : {}", gsrSchema.getSchemaDefinition());
            Object decodedRecord = glueSchemaRegistryDeserializerFactory.getInstance(DataFormat.valueOf(gsrSchema.getDataFormat()), gsrConfig).deserialize(ByteBuffer.wrap(bytes), gsrSchema);
            this.recordProcessor.consumedRecords.add(decodedRecord);
            LOGGER.info("Processed record: {}", decodedRecord);
        }
    } catch (Exception e) {
        LOGGER.error("Failed while processing records. Aborting", e);
        Runtime.getRuntime().halt(1);
    }
}
Also used : KinesisClientRecord(software.amazon.kinesis.retrieval.KinesisClientRecord) Schema(com.amazonaws.services.schemaregistry.common.Schema) ByteBuffer(java.nio.ByteBuffer) InvalidStateException(software.amazon.kinesis.exceptions.InvalidStateException) ShutdownException(software.amazon.kinesis.exceptions.ShutdownException)

Aggregations

KinesisClientRecord (software.amazon.kinesis.retrieval.KinesisClientRecord)2 Schema (com.amazonaws.services.schemaregistry.common.Schema)1 ByteBuffer (java.nio.ByteBuffer)1 InvalidStateException (software.amazon.kinesis.exceptions.InvalidStateException)1 ShutdownException (software.amazon.kinesis.exceptions.ShutdownException)1