selector示例

11、複製:同一份數據,發送給兩個sink
1個source、2個channel、2個sink
case12_replicate_sink.conf
#配置內容
#name the component on this agent
a1.sources = r1
a1.channels= c1 c2
a1.sinks = k1 k2

#describe/configure the source
a1.sources.r1.type = syslogtcp
a1.sources.r1.host= localhost
a1.sources.r1.port  = 5140
a1.sources.r1.selector.type = replicating
a1.sources.r1.channels = c1 c2

#decribe the sink
a1.sinks.k1.type = avro
a1.sinks.k1.hostname= 192.168.0.106
a1.sinks.k1.port = 4443
a1.sinks.k1.channel = c1

a1.sinks.k2.type = avro
a1.sinks.k2.hostname= 192.168.0.107
a1.sinks.k2.port = 4443
a1.sinks.k2.channel = c1

#use a channel which buffers events in memory
a1.channels.c1.type = memory
a1.channels.c1.capacity = 1000
a1.channels.c1.transactionCapacity = 100

a1.channels.c2.type = memory
a1.channels.c2.capacity = 1000
a1.channels.c2.transactionCapacity = 100

case12_replicate_s1.conf
#配置內容
#name the component on this agent
a1.sources = r1
a1.channels= c1
a1.sinks = k1

#describe/configure the source
a1.sources.r1.type = avro
a1.sources.r1.bind = 192.168.0.105
a1.sources.r1.port  = 4443
a1.sources.r1.channels = c1

#decribe the sink
a1.sinks.k1.type = logger
a1.sinks.k1.channel = c1

#use a channel which buffers events in memory
a1.channels.c1.type = memory
a1.channels.c1.capacity = 1000
a1.channels.c1.transactionCapacity = 100


case12_replicate_s2.conf
#配置內容
#name the component on this agent
a1.sources = r1
a1.channels= c1
a1.sinks = k1

#describe/configure the source
a1.sources.r1.type = avro
a1.sources.r1.bind = 192.168.0.105
a1.sources.r1.port  = 4443
a1.sources.r1.channels = c1

#decribe the sink
a1.sinks.k1.type = logger
a1.sinks.k1.channel = c1

#use a channel which buffers events in memory
a1.channels.c1.type = memory
a1.channels.c1.capacity = 1000
a1.channels.c1.transactionCapacity = 100

12、複用:
case13_multi_sink.conf、case13_multi_s1.conf、case13_multi_s2.conf
#配置內容
#name the component on this agent
a1.sources = r1
a1.channels= c1 c2
a1.sinks = k1 k2

#describe/configure the source
a1.sources.r1.type = org.apache.flume.source.http.HTTPSource
a1.sources.r1.host= localhost
a1.sources.r1.port  = 5140
a1.sources.r1.selector.type = multiplexing
a1.sources.r1.channels = c1 c2

a1.sources.r1.selector.header= state
a1.sources.r1.selector.mapping.CZ= c1
a1.sources.r1.selector.mapping.US= c2
a1.sources.r1.selector.default= c1

#decribe the sink
a1.sinks.k1.type = avro
a1.sinks.k1.hostname= 192.168.0.106
a1.sinks.k1.port = 4443
a1.sinks.k1.channel = c1

a1.sinks.k2.type = avro
a1.sinks.k2.hostname= 192.168.0.107
a1.sinks.k2.port = 4443
a1.sinks.k2.channel = c1

#use a channel which buffers events in memory
a1.channels.c1.type = memory
a1.channels.c1.capacity = 1000
a1.channels.c1.transactionCapacity = 100

a1.channels.c2.type = memory
a1.channels.c2.capacity = 1000
a1.channels.c2.transactionCapacity = 100

case13_multi_s1.conf
#配置內容
#name the component on this agent
a1.sources = r1
a1.channels= c1
a1.sinks = k1

#describe/configure the source
a1.sources.r1.type = avro
a1.sources.r1.bind = 192.168.0.105
a1.sources.r1.port  = 4443
a1.sources.r1.channels = c1

#decribe the sink
a1.sinks.k1.type = logger
a1.sinks.k1.channel = c1

#use a channel which buffers events in memory
a1.channels.c1.type = memory
a1.channels.c1.capacity = 1000
a1.channels.c1.transactionCapacity = 100


case13_multi_s2.conf
#配置內容
#name the component on this agent
a1.sources = r1
a1.channels= c1
a1.sinks = k1

#describe/configure the source
a1.sources.r1.type = avro
a1.sources.r1.bind = 192.168.0.105
a1.sources.r1.port  = 4443
a1.sources.r1.channels = c1

#decribe the sink
a1.sinks.k1.type = logger
a1.sinks.k1.channel = c1

#use a channel which buffers events in memory
a1.channels.c1.type = memory
a1.channels.c1.capacity = 1000
a1.channels.c1.transactionCapacity = 100


測試 在source端
curl -X POST -d '[{"headers": {"state":"CZ","datanode":"xx2"},"body":"really_random_body"}]' http://localhost:5140
curl -X POST -d '[{"headers": {"state":"US","datanode":"xx1"},"body":"really_random_body"}]' http://localhost:5140
curl -X POST -d '[{"headers": {"state":"SH","datanode":"xx3"},"body":"really_random_body"}]' http://localhost:5140









發佈了43 篇原創文章 · 獲贊 1 · 訪問量 4萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章