【问题标题】:Syncing Kafka with aws s3 with different directory structure将 Kafka 与具有不同目录结构的 aws s3 同步
【发布时间】:2019-03-16 04:21:49
【问题描述】:

我们有事件来到 Kafka,我们使用 kafka connect 将这些事件与 aws s3 同步。 数据在 s3 的以下 dir 结构中可见:

bucket_name/sub_folder/
                       Partition=0/events.json
                       Partition=1/events.json
                       Partition=2/events.json

有没有办法存储在下面的目录结构中:

Bucket_name/sub_folder/date=today_date/ events.json or Partition=0..2/date=today/events.json
Bucket_name/sub_folder/date=today_date/ events.json or 

动机是将那一天的事件存储在那一天的目录中,我搜索了网页但找不到任何其他方式。 提前致谢。

【问题讨论】:

    标签: amazon-s3 apache-kafka apache-kafka-connect


    【解决方案1】:

    您可以使用TimeBasedPartitioner

    根据摄取时间对数据进行分区。

    例如每小时分区:

    […]
    "partitioner.class": "io.confluent.connect.storage.partitioner.TimeBasedPartitioner",
    "path.format": "'year'=YYYY/'month'=MM/'day'=dd/'hour'=HH",
    "locale": "US",
    "timezone": "UTC",
    "partition.duration.ms": "3600000",
    "timestamp.extractor": "RecordField",
    "timestamp.field": "my_record_field_with_timestamp_in",
    […]
    

    【讨论】:

    • 如果提到的“RecordField”包含不正确的值会怎样?
    • kafka-connect 消费者端是否会抛出异常,如果是,那将是什么,以便我们可以将它们放入死信队列以供以后处理。我尝试使用 null 值,但它没有与 s3 同步,但我也没有看到任何异常。
    • 在测试环境中,我尝试向 RecordField 发送一个值为空的事件,然后它没有开始。@Robin
    • @Raghav 那么不要发送错误的值?这只能在 Producer 端解决,而不是在 Connect 端。一旦它在分区中看到错误记录,它将停止读取它,直到您手动重新启动任务并且错误消息超过主题保留期
    猜你喜欢
    • 2017-04-15
    • 2014-08-21
    • 2016-12-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-01-26
    • 2014-06-01
    相关资源
    最近更新 更多