Flume Intercept Selector配置详解

Flume Intercept Selector配置详解

Flume配置遇到了一个问题是关于Inteceptor和Selector的问题,这篇文章主要讲解关于Inteceptor和Selector配置。
在Flume中,Source,Channel,都可以多对多,也就是,一个Source可以对应多个Channel,一个Channel可以对应多个Sink,但是一个Sink只能对应一个Channel。我给自己描绘了一个比较通俗易懂的图,来讲解一下整个Flume组件的配置。如下图所示:

多个SourceSink配置

在这里有2个source,2个Intercept,1个Selector,2个Channel,3个Sink,它们之间的对应关系如上图。

Source1需要经过2个Intercept,这两个Intercept是需要自定义的,在下篇文章会讲到。第一个Intercept的作用是过滤不需要的数据,第二个Intercept根据不同的Event body类型来添加Header的topic属性,用于Selector根据topic来选择发往不同的Channel。

Selector接收Intercept的Hearder有两种topic,分别是topic_start、topic_end,其中topic_start发往c1,topic_end发往c2,以下为整个图的详细配置

a1.sources = r1 r2
a1.channels = c1 c2
a1.sinks = k1 k2 k3

#r1 Source,Intercept,Selector配置
a1.sources.r1.type = com.master.source1 
a1.sources.r1.channels = c1 c2

#Intercept配置
a1.sources.r1.interceptors = i1 i2
a1.sources.r1.interceptors.i1.type = com.master.myIntercept1 #自定义拦截器
a1.sources.r1.interceptors.i2.type = com.master.myIntercept2

#Selector配置
a1.sources.s1.selector.type = mutiplexing #选择Flume自带的Selector
a1.sources.s1.selector.type.header = topic
a1.sources.s1.selector.type.mapping.topic_start = c1
a1.sources.s1.selector.type.mapping.topic_end = c2

#s2配置
a1.sources.r2.type = com.master.source2

#c1 c2配置
a1.channels.c1.type = memory
a1.channels.c2.type = memory

#s1配置
a1.sinks.k1.type = com.master.mySink1
a1.sinks.k1.channel = c1

#s2配置
a1.sinks.k2.type = com.master.mySink2
a1.sinks.k1.channel = c1

#s3配置
a1.sinks.k3.type=com.master.mySink3
a1.sinks.k1.channel = c2
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值