processor示例

来源:互联网 发布:快递软件系统软件 编辑:程序博客网 时间:2024/06/03 14:56
sink group允许组织多个sink到一个实体上,sink processors能够提供在组内所有sink之间实现负载均衡的能力,而且在失败的情况下能够进行故障转移从一个sink到另外一个sink
1、default sink processor 
接收单一的sink,不强制用户为sink创建processor
2、failover sink processor
其维护了一个优先级列表,保证没一个有效的事件都会被处理。
故障转移的工作原理是将连续失败的sink分配到一个池中,在那里被分配一个冷冻期。一旦sink成功发送一个event,sink将会被还原到live池中。
在这配置中,要设置sink group processor为failover,需要为所有的sink分配优先级,所有的优先级数字必须是唯一的。此外failover time的上限可以通过maxpenalty属性进行设置
3、load balancing sink processor
负载均衡片处理器提供在多个sink之间负载均衡流量的能力。实现支持通过round_robin或者random参数来实现负载分发,默认情况下使用round_robin,但可以通过设置覆盖这个默认值。还可以通过集成AbstractSinkProcessor类来实现用户自己的选择机制。
当被调用的时候,这个选择器通过配置的选择规则选择下一个sink来调用。

13、case14_failover_sink.conf
#配置内容
#name the component on this agent
a1.sources = r1
a1.channels= c1 c2
a1.sinks = k1 k2

a1.sinkgroups = g1
a1.sinkgroups.g1.sinks = k1 k2
a1.sinkgroups.g1.processor.type = failover
a1.sinkgroups.g1.processor.priority.k1 = 5
a1.sinkgroups.g1.processor.priority.k2 = 10
a1.sinkgroups.g1.processor.maxpenalty = 10000

#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

case14_failover_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


case14_failover_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

14、case15_load_sink.conf
#配置内容
#name the component on this agent
a1.sources = r1
a1.channels= c1
a1.sinks = k1 k2

a1.sinkgroups = g1
a1.sinkgroups.g1.sinks = k1 k2
a1.sinkgroups.g1.processor.type = load_balance
a1.sinkgroups.g1.processor.backoff = true
a1.sinkgroups.g1.processor.selector= round_robin

#describe/configure the source
a1.sources.r1.type = syslogtcp
a1.sources.r1.host= localhost
a1.sources.r1.port  = 5140
a1.sources.r1.channels = 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

case15_load_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


case14_load_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

0 0