|NO.Z.00048|——————————|BigDataEnd|——|Hadoop&Flume.V11|——|Flume.v11|高级特性|拦截器|高可用|选择器.v03|

一、选择器
### --- 选择器

~~~     source可以向多个channel同时写数据,所以也就产生了以何种方式向多个channel写的问题:
~~~     replication(复制,缺省)。数据完整地发送到每一个channel;
~~~     multiplexing(多路复用)。通过配置来按照一定的规则进行分发;
### --- 复制选择器:默认的选择器。
~~~     上面这个例子中,c3配置成了可选的。向c3发送数据如果失败了会被忽略。
~~~     c1c2没有配置成可选的,向c1c2写数据失败会导致事务失败回滚。

a1.sources = r1
a1.channels = c1 c2 c3
a1.sources.r1.selector.type = replicating
a1.sources.r1.channels = c1 c2 c3
a1.sources.r1.selector.optional = c3

### --- 多路复用选择器

a1.sources = r1
a1.channels = c1 c2 c3 c4
a1.sources.r1.selector.type = multiplexing
a1.sources.r1.selector.header = state                   #以每个Event的header中的state这个属性的值作为选择channel的依据
a1.sources.r1.selector.mapping.CZ = c1                  #如果state=CZ,则选择c1这个channel
a1.sources.r1.selector.mapping.US = c2 c3               #如果state=US,则选择c2 和 c3 这两个channel
a1.sources.r1.selector.default = c4                     #默认使用c4这个channel
### --- 自定义选择器
~~~     自定义选择器就是开发一个 org.apache.flume.ChannelSelector 接口的实现类。
~~~     实现类以及依赖的jar包在启动时候都必须放入Flume的classpath。
        
a1.sources = r1
a1.channels = c1
a1.sources.r1.selector.type =
org.liyifeng.flume.channel.MyChannelSelector

 
 
 
 
 
 
 
 
 

Walter Savage Landor:strove with none,for none was worth my strife.Nature I loved and, next to Nature, Art:I warm'd both hands before the fire of life.It sinks, and I am ready to depart
                                                                                                                                                   ——W.S.Landor

 

 

posted on   yanqi_vip  阅读(17)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· DeepSeek 开源周回顾「GitHub 热点速览」
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

导航

统计

点击右上角即可分享
微信分享提示