flume内置的ChannelSelector有两种,分别是Replicating和Multiplexing。

Replicating类型的ChannelSelector会针对每一个Event,拷贝到所有的Channel中,这是默认的ChannelSelector。

replicating类型的ChannelSelector例子如下

 a1.sources = r1
a1.channels = c1 c2 # 如果有100个Event,那么c1和c2中都会有这100个事件 a1.channels.c1.type = memory
a1.channels.c1.capacity =
a1.channels.c1.transactionCapacity = a1.channels.c2.type = memory
a1.channels.c2.capacity =
a1.channels.c2.transactionCapacity =

Multiplexing类型的ChannelSelector会根据Event中Header中的某个属性决定分发到哪个Channel。

multiplexing类型的ChannelSelector例子如下:

 a1.sources = r1

 a1.sources.source1.selector.type = multiplexing
a1.sources.source1.selector.header = validation # 以header中的validation对应的值作为条件
a1.sources.source1.selector.mapping.SUCCESS = c2 # 如果header中validation的值为SUCCESS,使用c2这个channel
a1.sources.source1.selector.mapping.FAIL = c1 # 如果header中validation的值为FAIL,使用c1这个channel
a1.sources.source1.selector.default = c1 # 默认使用c1这个channel
a1.sources.source1.selector.header = validation # 以header中的validation对应的值作为条件

同理,如下conf文件:
 a1.sources = r1
a1.sinks = k1 k2
a1.channels = c1 c2 # Describe/configure the source
a1.sources.r1.type = exec
a1.sources.r1.command = tail -F /usr/lib/flume-ng/test.log
a1.sources.r1.interceptors = i1
a1.sources.r1.interceptors.i1.type = regex_extractor
a1.sources.r1.interceptors.i1.regex = (\\w+):(\\w+):(\\w+)
a1.sources.r1.interceptors.i1.serializers = s1 s2 s3
a1.sources.r1.interceptors.i1.serializers.s1.name = ip
a1.sources.r1.interceptors.i1.serializers.s2.name = domain
a1.sources.r1.interceptors.i1.serializers.s3.name = course a1.sources.r1.selector.type = multiplexing
a1.sources.r1.selector.header = course
a1.sources.r1.selector.mapping.hadoop = c1
a1.sources.r1.selector.default = c2 # Describe the sink
a1.sinks.k1.type = file_roll
a1.sinks.k1.channel = c1
a1.sinks.k1.sink.directory = /tmp/multiplexing/flume_sink1 a1.sinks.k2.type = file_roll
a1.sinks.k2.channel = c2
a1.sinks.k2.sink.directory = /tmp/multiplexing/flume_sink2 # Use a channel which buffers events in memory
a1.channels.c1.type = memory
a1.channels.c1.capacity =
a1.channels.c1.transactionCapacity = a1.channels.c2.type = memory
a1.channels.c2.capacity =
a1.channels.c2.transactionCapacity = # Bind the source and sink to the channel
a1.sources.r1.channels = c1 c2
a1.sinks.k1.channel = c1
a1.sinks.k2.channel = c2

interceptor只对头部进行改变。

source r1中的头部有IP、Domain和cource三种信息,而r1的selector.header = course,表示selector只对IP,Domain和Cource中的Cource进行判断选择,然后再划分channel。

关于Flume中Chanel.Selector.header解释的更多相关文章

  1. flume中Source

    Spooling Directory Source: 以下2组参数解释: fileHeader及fileHeaderKey:fileHeader是个布尔值,可配置为true或者false,表示在flu ...

  2. flume中的拦截器

    Flume中的拦截器(interceptor),用户Source读取events发送到Sink的时候,在events header中加入一些有用的信息,或者对events的内容进行过滤,完成初步的数据 ...

  3. epoll浅析以及nio中的Selector

    出处: https://my.oschina.net/hosee/blog/730598 首先介绍下epoll的基本原理,网上有很多版本,这里选择一个个人觉得相对清晰的讲解(详情见reference) ...

  4. epoll 浅析以及 nio 中的 Selector

    首先介绍下epoll的基本原理,网上有很多版本,这里选择一个个人觉得相对清晰的讲解(详情见reference): 首先我们来定义流的概念,一个流可以是文件,socket,pipe等等可以进行I/O操作 ...

  5. 关于flume中涉及到时间戳的错误解决,Expected timestamp in the Flume even

    在搭建flume集群收集日志写入hdfs时发生了下面的错误: java.lang.NullPointerException: Expected timestamp in the Flume event ...

  6. Java I/O(4):AIO和NIO中的Selector

    您好,我是湘王,这是我的博客园,欢迎您来,欢迎您再来- 在Java NIO的三大核心中,除了Channel和Buffer,剩下的就是Selector了.有的地方叫它选择器,也有叫多路复用器的(比如Ne ...

  7. flume中的agent配置和启动

    首先创建一个文件example.conf(touch example.conf) 然后在文件中,进行agent文件的如下的配置(vi  example.conf)   agent文件的配置:(配置ag ...

  8. 关于flume中的几个疑惑

    文章发自http://www.cnblogs.com/hark0623/p/4205756.html  转载请注明 flume越用越有一些疑惑,这个月中按计划是要阅读flume源码的,我希望能解决我的 ...

  9. VC中Source Files, Header Files, Resource Files,External Dependencies的区别

    VC中Source Files, Header Files, Resource Files,External Dependencies的区别 区别: Source Files 放源文件(.c..cpp ...

随机推荐

  1. 简单的redis缓存操作(get、put)

    简单的redis缓存操作(get.put) 本文介绍简单的redis缓存操作,包括引入jedisjar包.配置redis.RedisDao需要的一些工具.向redis中放数据(put).从redis中 ...

  2. spring-bean实例化三种方式

    在spring中,bean的示例化有三种方式. 1.使用类的无参构造函数创建 2.使用静态工厂方式创建 3.使用实例化工厂方式创建. 具体代码如下 静态工厂方式: Bean2.java package ...

  3. python学习之老男孩python全栈第九期_day012知识点总结

    # def wrapper(f):# def inner(*args,**kwargs):# print('在被装饰的函数执行之前做的事')# res = f(*args,**kwargs)# pri ...

  4. influxdb-1.7.2.x86_64安装 install influxdb-1.7.2.x86_64 on RedHat & CentOS

    1.下载安装 wget http://dl.influxdata.com/influxdb/releases/influxdb-1.7.2.x86_64.rpm https://portal.infl ...

  5. windows下安装composer方法

    composer是一个新崛起的PHP的依赖管理工具.官方安装方法见: 此处假定: (1)php安装目录为C:/php5.4 (2)php 安装目录已经加入PATH环境变量(这样就可以在命令行直接输入“ ...

  6. JS--我发现,原来你是这样的JS(一)(初识,历史)

    一.前言: 前段时间看红宝书(JavaScript高级程序设计),但没有计划的去看,也没有做详细的笔记,读了之后有点空虚,感觉不对劲啊,学的东西很难记住,印象不深啊,有种挫败感. 作前端的js都学不好 ...

  7. 简单三招,设计复杂ERP报表

    报表无疑是ERP系统中用到的最频繁的单据之一.比如每天采购要打印采购明细帐:仓库每天要导出收货或者出货明细:销售每天要打印订单明细等.故报表的设计在ERP系统开发中占据大半江山. 不过笔者在实际工作中 ...

  8. Linux 配置iso系统盘为本地yum源

    Linux配置iso系统盘为本地yum源 by:授客 QQ:1033553122   1.目的 安装软件时,经常会遇到包或类库的依赖性问题,为此,我们可以通过yum命令安装软件,尽量避免出现繁琐的软件 ...

  9. Oracle EBS OPM convert dtl reservation

    --convert_dtl_reservation --created by jenrry DECLARE l_reservation_rec mtl_reservations%ROWTYPE; l_ ...

  10. Sql Server中的游标最好只用于有主键或唯一键的表

    游标cursor,我想大多数人都在sql server里面用过.当一个表数据量不太大的时候,游标还是可以用的,毕竟游标是循环一个表中每一行数据的最简便办法.但是如果你用一个游标去循环一个没有主键或唯一 ...