0
votes

I'm trying to use kafka-connect-hdfs but it doesn't seem to work..

I tried to mess around with the settings but nothing seem to work..

This is the Protobuf message schema:

syntax = "proto3";
package com.company;
option java_package = "com.company";
option java_outer_classname = "MyObjectData";
import public "wrappers.proto";
message MyObject {
int64 site_id = 1;
string time_zone = 2;
uint64 dev_id = 3;
uint64 rep_id = 4;
uint64 dev_sn = 5;
UInt64Value timestamp = 6;
UInt32Value secs = 7;
UInt64Value man_id = 8;
FloatValue panv = 9;
FloatValue outputv = 10;
FloatValue panelc = 11;
FloatValue ereset = 12;
FloatValue temp = 13;
FloatValue tempin = 14;
FloatValue tempout = 15;
UInt32Value sectelem = 16;
FloatValue energytelem = 17;
UInt32Value ecode = 18;

}

The connect-standalone.properties is as follows:

bootstrap.servers=k1:9092,k2:9092,k3:9092


key.converter=org.apache.kafka.connect.storage.StringConverter

value.converter=com.blueapron.connect.protobuf.ProtobufConverter
value.converter.protoClassName=com.company.MyObjectData$MyObject
key.converter.schemas.enable=false
value.converter.schemas.enable=true

offset.storage.file.filename=/tmp/connect.offsets
offset.flush.interval.ms=10000

plugin.path=/usr/share/java

And the quickstart-hdfs.properties is:

name=hdfs-sink
connector.class=io.confluent.connect.hdfs.HdfsSinkConnector
tasks.max=1
topics=ObjectTopic
hadoop.conf.dir=/etc/hadoop
hdfs.url=hdfs://hdp-01:8020/user/hdfs/telems
hadoop.home=/etc/hadoop/client
flush.size=3
key.converter=org.apache.kafka.connect.storage.StringConverter

value.converter=com.blueapron.connect.protobuf.ProtobufConverter
value.converter.protoClassName=com.company.MyObjectData$MyObject

format.class=io.confluent.connect.hdfs.parquet.ParquetFormat

transforms=SetSchemaName
transforms.SetSchemaName.type=org.apache.kafka.connect.transforms.SetSchemaMetadata$Value
transforms.SetSchemaName.schema.name=com.acme.avro.MyObject

Currently I'm receiving the following error:

org.apache.kafka.connect.errors.ConnectException: Exiting WorkerSinkTask due to unrecoverable exception. at org.apache.kafka.connect.runtime.WorkerSinkTask.deliverMessages(WorkerSinkTask.java:586) at org.apache.kafka.connect.runtime.WorkerSinkTask.poll(WorkerSinkTask.java:322) at org.apache.kafka.connect.runtime.WorkerSinkTask.iteration(WorkerSinkTask.java:225) at org.apache.kafka.connect.runtime.WorkerSinkTask.execute(WorkerSinkTask.java:193) at org.apache.kafka.connect.runtime.WorkerTask.doRun(WorkerTask.java:175) at org.apache.kafka.connect.runtime.WorkerTask.run(WorkerTask.java:219) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748) Caused by: org.apache.avro.SchemaParseException: Can't redefine: io.confluent.connect.avro.ConnectDefault at org.apache.avro.Schema$Names.put(Schema.java:1128) at org.apache.avro.Schema$NamedSchema.writeNameRef(Schema.java:562) at org.apache.avro.Schema$RecordSchema.toJson(Schema.java:690) at org.apache.avro.Schema$UnionSchema.toJson(Schema.java:882) at org.apache.avro.Schema$RecordSchema.fieldsToJson(Schema.java:716) at org.apache.avro.Schema$RecordSchema.toJson(Schema.java:701) at org.apache.avro.Schema.toString(Schema.java:324) at org.apache.avro.Schema.toString(Schema.java:314) at org.apache.parquet.avro.AvroWriteSupport.init(AvroWriteSupport.java:133) at org.apache.parquet.hadoop.ParquetWriter.(ParquetWriter.java:270) at org.apache.parquet.hadoop.ParquetWriter.(ParquetWriter.java:222) at org.apache.parquet.hadoop.ParquetWriter.(ParquetWriter.java:188) at org.apache.parquet.avro.AvroParquetWriter.(AvroParquetWriter.java:131) at org.apache.parquet.avro.AvroParquetWriter.(AvroParquetWriter.java:106) at io.confluent.connect.hdfs.parquet.ParquetRecordWriterProvider$1.write(ParquetRecordWriterProvider.java:75) at io.confluent.connect.hdfs.TopicPartitionWriter.writeRecord(TopicPartitionWriter.java:643) at io.confluent.connect.hdfs.TopicPartitionWriter.write(TopicPartitionWriter.java:379) at io.confluent.connect.hdfs.DataWriter.write(DataWriter.java:375) at io.confluent.connect.hdfs.HdfsSinkTask.put(HdfsSinkTask.java:109) at org.apache.kafka.connect.runtime.WorkerSinkTask.deliverMessages(WorkerSinkTask.java:564)

Also, If it matters, I do it using user hdfs

Is it a schema problem? It seems that nothing that I do even changes the error message...

1

1 Answers

0
votes

It might be that, Can't redefine: io.confluent.connect.avro.ConnectDefault is because your transform is setting a schema property.

You could try using AvroFormat, too, which would take internal Schema & Struct object of Connect and write to Avro files in HDFS.

Note, ParquetFormat uses the parquet-avro project, so the data probably should be Avro to begin with.

Notice the Stacktrace.

org.apache.avro.SchemaParseException ...

...

org.apache.avro.Schema$Names.put(Schema.java:1128) at org.apache.avro.Schema$NamedSchema.writeNameRef(Schema.java:562) at org.apache.avro.Schema$RecordSchema.toJson(Schema.java:690) at org.apache.avro.Schema$UnionSchema.toJson(Schema.java:882) at org.apache.avro.Schema$RecordSchema.fieldsToJson(Schema.java:716) at org.apache.avro.Schema$RecordSchema.toJson(Schema.java:701) at org.apache.avro.Schema.toString(Schema.java:324) at org.apache.avro.Schema.toString(Schema.java:314) at org.apache.parquet.avro.AvroWriteSupport.init(AvroWriteSupport.java:133) at org.apache.parquet.hadoop.ParquetWriter.(ParquetWriter.java:270) at org.apache.parquet.hadoop.ParquetWriter.(ParquetWriter.java:222) at org.apache.parquet.hadoop.ParquetWriter.(ParquetWriter.java:188) at org.apache.parquet.avro.AvroParquetWriter.(AvroParquetWriter.java:131) at org.apache.parquet.avro.AvroParquetWriter.(AvroParquetWriter.java:106)

Therefore you would need to write a protofuf-avro converter somewhere. Maybe using skeuomorph

  1. Kafka Streams, or similar process, between your producer and Connect (the easiest of these options)
  2. Modify the kafka-connect-hdfs project so that Protobuf could be handled
  3. Modify the ProtobufConverter code so that it generates a ConnectRecord of Avro data

If all else fails, you could file an issue about it and see what you get.