第 5 章 自定义 source

Source 是负责接收数据到 Flume Agent 的组件。

Source 组件可以处理各种类型、各种格式的日志数据,包括 avro、thrift、exec、jms、spooling directory、netcat、sequence generator、syslog、http、legacy。

官方提供的source类型已经很多,但是有时候并不能满足实际开发当中的需求,此时我们就需要根据实际需求自定义某些 source。

官方也提供了自定义source的接口: https://flume.apache.org/FlumeDeveloperGuide.html#source

根据官方说明自定义 MySource 需要继承 AbstractSource 类并实现 ConfigurablePollableSource 接口。

实现相应方法:

getBackOffSleepIncrement()//暂不用
getMaxBackOffSleepInterval()//暂不用
configure(Context context)//初始化context(读取配置文件内容)
process()//获取数据封装成event并写入channel,这个方法将被循环调用。

//使用场景:读取MySQL数据或者其他文件系统。
Copyright © 尚硅谷大数据 2019 all right reserved,powered by Gitbook
该文件最后修订时间: 2018-12-17 14:44:53

results matching ""

    No results matching ""