Kafka Connector特性

    Kafka Connector特性可以对源数据库到目标数据库的拷贝处理,可以借助此特性实现自己的ETL工具用于数据抽取、清洗等功能。

其数据流程图:

180827_AX3T_1263326.png

  •     Connector相关接口

    通过继承SourceConnector和SinkConnector实现自己的Connector,分别表示对源数据的读取和对目标库的写入。

   Connector的主要接口:

  initialize(ConnectorContext ctx) Initialize this connector, using the provided ConnectorContext to notify the runtime of input configuration changes.

  initialize(ConnectorContext ctx, List<Map<String,String>> taskConfigs) Initialize this connector, using the provided ConnectorContext to notify the runtime of input configuration changes and using the provided set of Task configurations.

    start(Map<String,String> props) Start this Connector.

   stop() Stop this connector.

  taskClass() Returns the Task implementation for this Connector.

   taskConfigs(int maxTasks) Returns a set of configurations for Tasks based on the current configuration, producing at most count configurations.


    通过继承SourceTask和SinkTask实现对应的Connector的业务逻辑任务。

    其对应的接口可查看task接口api


   对实现的Connector可通过一下配置文件进行配置

    connect-file-source.properties配置源系统的connector:

#connector唯一的名称
name=local-console-source
#connector的实现
connector.class=org.apache.kafka.connect.file.FileStreamSourceConnector
#connector需要创建的最大任务数
tasks.max=1
#需要处理的topic类别
topic=connect-test

    connect-file-sink.properties配置目标系统的connector(和以上配置类似):   

name=local-file-sink
connector.class=org.apache.kafka.connect.file.FileStreamSinkConnector
tasks.max=1
file=test.sink.txt
#接收topic类别列表
topics=connect-test


  •     REST API

     Kafka Connect提供rest api接口,用于管理所有的connectors信息可通过rest api查看对应接口信息

        

    对于此特性0.9版本的客户端中未找对对应的connect包(不知包不对还是怎么回事),因此也未能写出测试的demo,待以后再来补上demo。


        


转载于:https://my.oschina.net/u/1263326/blog/608011

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值