Search in sources :

Example 6 with RecordWriter

use of io.confluent.connect.storage.format.RecordWriter in project kafka-connect-storage-cloud by confluentinc.

the class TopicPartitionWriter method writeRecord.

private void writeRecord(SinkRecord record) {
    currentOffset = record.kafkaOffset();
    if (!startOffsets.containsKey(currentEncodedPartition)) {
        log.trace("Setting writer's start offset for '{}' to {}", currentEncodedPartition, currentOffset);
        startOffsets.put(currentEncodedPartition, currentOffset);
    }
    RecordWriter writer = getWriter(record, currentEncodedPartition);
    writer.write(record);
    ++recordCount;
}
Also used : RecordWriter(io.confluent.connect.storage.format.RecordWriter)

Example 7 with RecordWriter

use of io.confluent.connect.storage.format.RecordWriter in project kafka-connect-storage-cloud by confluentinc.

the class TopicPartitionWriter method commitFile.

private void commitFile(String encodedPartition) {
    if (!startOffsets.containsKey(encodedPartition)) {
        log.warn("Tried to commit file with missing starting offset partition: {}. Ignoring.");
        return;
    }
    if (writers.containsKey(encodedPartition)) {
        RecordWriter writer = writers.get(encodedPartition);
        // Commits the file and closes the underlying output stream.
        writer.commit();
        writers.remove(encodedPartition);
        log.debug("Removed writer for '{}'", encodedPartition);
    }
    startOffsets.remove(encodedPartition);
}
Also used : RecordWriter(io.confluent.connect.storage.format.RecordWriter)

Aggregations

RecordWriter (io.confluent.connect.storage.format.RecordWriter)7 S3OutputStream (io.confluent.connect.s3.storage.S3OutputStream)3 IOException (java.io.IOException)3 ConnectException (org.apache.kafka.connect.errors.ConnectException)3 SinkRecord (org.apache.kafka.connect.sink.SinkRecord)3 OutputStream (java.io.OutputStream)2 JsonGenerator (com.fasterxml.jackson.core.JsonGenerator)1 NonRecordContainer (io.confluent.kafka.serializers.NonRecordContainer)1 DataFileWriter (org.apache.avro.file.DataFileWriter)1 GenericDatumWriter (org.apache.avro.generic.GenericDatumWriter)1 Schema (org.apache.kafka.connect.data.Schema)1 Struct (org.apache.kafka.connect.data.Struct)1 DataException (org.apache.kafka.connect.errors.DataException)1