若发现文章有误,敬请指教,感谢
参考资料
一、运行环境
- CentOS7
- JDK8
- Flume1.9
二、自定义Source
2.1 程序具体实现
导入依赖:pom.xml
<dependency>
<groupId>org.apache.flume</groupId>
<artifactId>flume-ng-core</artifactId>
<version>1.9.0</version>
</dependency>
编写自定义的source:UniSource.java
注:必须继承AbstractSource,并实现Configurable和PollableSource接口
package com.uni.flume.source;
import org.apache.flume.Context;
import org.apache.flume.Event;
import org.apache.flume.EventDeliveryException;
import org.apache.flume.PollableSource;
import org.apache.flume.conf.Configurable;
import org.apache.flume.event.SimpleEvent;
import org.apache.flume.source.AbstractSource;
import java.util.HashMap;
/**
* Author: Unirithe
* Date: 2022/3/20
**/
public class UniSource extends AbstractSource implements Configurable, PollableSource {
// 声明数据源source的前后缀
private String prefix;
private String subfix;
private Long delay