Hadoop生态圈-Flume的组件之自定义拦截器(interceptor)

                Hadoop生态圈-Flume的组件之自定义拦截器(interceptor)

                                              作者:尹正杰

版权声明:原创作品,谢绝转载!否则将追究法律责任。

   本篇博客只是举例了一个自定义拦截器的方法,测试字节传输速度。

1>.自定义interceptor方法

2>.打包并将其发送到 /soft/flume/lib下

[[email protected] ~]$ cd /soft/flume/lib/
[yinzhengji[email protected] lib]$ 
[[email protected] lib]$ ll | grep MyFlume
-rw-r--r--  1 yinzhengjie yinzhengjie    5231 Jun 20 18:53 MyFlume-1.0-SNAPSHOT.jar
[[email protected] lib]$ 
[[email protected] lib]$ rm -rf MyFlume-1.0-SNAPSHOT.jar 
[[email protected] lib]$ 
[[email protected] lib]$ rz

[[email protected] lib]$ 
[[email protected] lib]$ ll | grep MyFlume
-rw-r--r--  1 yinzhengjie yinzhengjie    8667 Jun 20 21:02 MyFlume-1.0-SNAPSHOT.jar
[[email protected] lib]$ 
[[email protected] lib]$ 

3>.编写agent的配置文件

[[email protected] ~]$ more /soft/flume/conf/yinzhengjie_myInterceptor.conf 
# Name the components on this agent
a1.sources = r1
a1.sinks = k1
a1.channels = c1

# Describe/configure the source
a1.sources.r1.type = netcat
a1.sources.r1.bind = localhost
a1.sources.r1.port = 8888

# Describe the sink
a1.sinks.k1.type = cn.org.yinzhengjie.interceptor.MyInterceptor
a1.sinks.k1.speed = 1

# Use a channel which buffers events in memory
a1.channels.c1.type = memory
a1.channels.c1.capacity = 100000
a1.channels.c1.transactionCapacity = 10000

# Bind the source and sink to the channel
a1.sources.r1.channels = c1
a1.sinks.k1.channel = c1
[[email protected] ~]$ 
[[email protected] ~]$ 

4>.启动flume并测试

猜你喜欢

转载自www.cnblogs.com/yinzhengjie/p/9208268.html

相关文章