设为首页 收藏本站
查看: 1662|回复: 0

[经验分享] Flume学习——Flume的架构

[复制链接]

尚未签到

发表于 2015-9-17 07:02:45 | 显示全部楼层 |阅读模式
DSC0000.png
  Flume有三个组件:Source、Channel 和 Sink。在源码中对应同名的三个接口。

  When a Flume source receives an event, it stores it into one or more channels. The channel is a passive store that keeps the event until it’s consumed by a Flume sink.




public interface Source extends LifecycleAware, NamedComponent {
/**
* Specifies which channel processor will handle this source's events.
*
* @param channelProcessor
*/
public void setChannelProcessor(ChannelProcessor channelProcessor);
/**
* Returns the channel processor that will handle this source's events.
*/
public ChannelProcessor getChannelProcessor();
}
  Source并没有与定义与Event有关的接口,它的接口只是对ChannelProcessor的get和set方法。Source通过获取对应的ChannelProcessor来完成消息的投递。



public interface Sink extends LifecycleAware, NamedComponent {
public void setChannel(Channel channel);
public Channel getChannel();
public Status process() throws EventDeliveryException;
public static enum Status {
READY, BACKOFF
}
}
  Sink也有与Channel有关的set和get方法,不过它是对应于Channel,而是ChannelProcessor。ChannelProcessor是位于Source和Channel之间的一个消息分发器一样的角色。因此,一个Source的消息可以通过ChannelProcessor发给多个Channel(简单的分发到所有,或者有选择的发送给特定channel),但是Sink直接对应于Channel,所以每个Sink只从唯一一个Channel中获得消息。
  ChannelProcessor的API为:


voidclose()
voidconfigure(Context context)
          The Context of the associated Source is passed.
ChannelSelectorgetSelector()
voidinitialize()
voidprocessEvent(Event event)
          Attempts to put the given event into each configured channel.
voidprocessEventBatch(List<Event> events)
          Attempts to put the given events into each configured channel.

  通过ChannelProcessor, Flume可以实现下面的消息流
DSC0001.png



public interface Channel extends LifecycleAware, NamedComponent {
public void put(Event event) throws ChannelException;
public Event take() throws ChannelException;
public Transaction getTransaction();
}
  A channel connects a Source to a Sink. The source acts as producer while the sink acts as a consumer of events. The channel itself is the buffer between the two.
  A channel exposes a Transaction interface that can be used by its clients to ensure atomic put and take semantics. This is necessary to guarantee single hop reliability between agents. For instance, a source will successfully produce an event if and only if that event can be committed to the source's associated channel. Similarly, a sink will consume an event if and only if its respective endpoint can accept the event. The extent of transaction support varies for different channel implementations ranging from strong to best-effort semantics.
  Channels are associated with unique names that can be used for separating configuration and working namespaces.

  Channel连接起了Source和Sink。Source相当于消息的生产者,Sink相当于消息的消费者。Channel相当于二者之间的缓冲层。
  更重要的是,Channel提供了Transaction的机制,来确保了消息的可靠传递。



  Flume uses a transactional approach to guarantee the reliable delivery of the events. The sources and sinks encapsulate in a transaction the storage/retrieval, respectively, of the events placed in or provided by a transaction provided by the channel. This ensures that the set of events are reliably passed from point to point in the flow. In the case of a multi-hop flow, the sink from the previous hop and the source from the next hop both have their transactions running to ensure that the data is safely stored in the channel of the next hop.

  Flume使用了事务来保证消息的可靠传递。Source和Sink对于消息的存储和获取都被包装在由Channel提供的事务中。一个消息只有被成功存入下一个agent的Channel(或者至最终的存储位置),才会被从当前的channel中删除。这就使用在消息流中,消息可以可靠地从一点传送到另一点。在一个包括agent间传递的消息流中,前一个agent的sink和下一个agent的source都有各自的事务,来保证消息被安全存入下一个agent的channel.

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-114556-1-1.html 上篇帖子: flume-agent实例 下篇帖子: Flume-NG 使用首记
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表