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为:

 void close()
 void configure(Context context)
          The Context of the associated Source is passed.
 ChannelSelector getSelector()
 void initialize()
 void processEvent(Event event)
          Attempts to put the given event into each configured channel.
 void processEventBatch(List<Event> events)
          Attempts to put the given events into each configured channel.

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

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.

Flume学习——Flume的架构的更多相关文章

  1. Flume学习——Flume中事务的定义

    首先要搞清楚的问题是:Flume中的事务用来干嘛? Flume中的事务用来保证消息的可靠传递. 当使用继承自BasicChannelSemantics的Channel时,Flume强制在操作Chann ...

  2. Flume应用场景及架构原理

    Flume概念 Flume是一个分布式.可靠.和高可用的海量日志聚合的系统,支持在系统中定制各类数据发送方,用于收集数据:同时,Flume提供对数据进行简单处理,并写到各种数据接受方(可定制)的能力. ...

  3. flume学习以及ganglia(若是要监控hive日志,hive存放在/tmp/hadoop/hive.log里,只要运行过hive就会有)

    python3.6hdfs的使用 https://blog.csdn.net/qq_29863961/article/details/80291654 https://pypi.org/  官网直接搜 ...

  4. Flume系列一之架构介绍和安装

    Flume架构介绍和安装 写在前面 在学习一门新的技术之前,我们得知道了解这个东西有什么用?我们可以使用它来做些什么呢?简单来说,flume是大数据日志分析中不能缺少的一个组件,既可以使用在流处理中, ...

  5. flume学习笔记——安装和使用

    Flume是一个分布式.可靠.和高可用的海量日志聚合的系统,支持在系统中定制各类数据发送方,用于收集数据:同时,Flume提供对数据进行简单处理,并写到各种数据接受方(可定制)的能力. Flume是一 ...

  6. flume 学习总结

    flume 总结 flume 总结 下载配置安装 1 下载 2 配置安装 flume 架构 agent 配置 1 source 配置 11 监听网络端口 12 监控文件 2 channel 配置 3 ...

  7. Flume学习之路 (一)Flume的基础介绍

    一.背景 Hadoop业务的整体开发流程: 从Hadoop的业务开发流程图中可以看出,在大数据的业务处理过程中,对于数据的采集是十分重要的一步,也是不可避免的一步. 许多公司的平台每天会产生大量的日志 ...

  8. Flume学习总结

    Flume学习总结 flume是一个用来采集数据的软件,它可以从数据源采集数据到一个集中存放的地方. 最常用flume的数据采集场景是对日志的采集,不过,lume也可以用来采集其他的各种各样的数据,因 ...

  9. Flume日志收集系统架构详解--转

     2017-09-06 朱洁 大数据和云计算技术 任何一个生产系统在运行过程中都会产生大量的日志,日志往往隐藏了很多有价值的信息.在没有分析方法之前,这些日志存储一段时间后就会被清理.随着技术的发展和 ...

随机推荐

  1. 免费主机kilu使用

    我也是看了这篇文章:http://www.cnblogs.com/tenny/archive/2011/03/30/1999957.html 采取申请注册. 主机申请地址:http://www.kil ...

  2. Cocos2d-x优化中图片优化

    在2D游戏中图片无疑是最为重要的资源文件,它会被加载到内存中转换为纹理,由GPU贴在精灵之上渲染出来.它能够优化的方面很多,包括:图片格式.拼图和纹理格式等,下面我们从这几个方面介绍一下图片和纹理的优 ...

  3. HTML+CSS学习笔记(4) - 认识标签(3)

    HTML+CSS学习笔记(4) - 认识标签(3) 1.使用<a>标签,链接到另一个页面 使用<a>标签可实现超链接,它在网页制作中可以说是无处不在,只要有链接的地方,就会有这 ...

  4. 项目中的那些事---PHP函数

    总结工作中遇到的php函数: 1.查找:strpos("str", "substr"): 查找substr字符串在str字符串中出现的位置 第一个参数是:被查找 ...

  5. lex&yacc5--YYSTYPE

    yacc里的YYSTYPE默认是int型的,当然也可以勇%union来定义联合但是由于程序需要,我要将YYSTYPE定义为我自己定义的一个struct的指针然后作为一个全局变量,让lex在扫描的时候, ...

  6. java将多个连续的空格转化成一个空格

    java将多个连续的空格转化成一个空格: System.out.println("a a".replaceAll(" + ", " ")); ...

  7. php学习日志(3)-echo&print

    在php中,结果输出一共有两种方式:echo和print,下面将对两种方式做一个比较. echo与print的区别:   echo print 连续输出字符串 能连续输出多个字符串 只能输出一个字符串 ...

  8. delphi xe memory leak produced in WSDLLookup.pas

    constructor TWSDLLookup.Create; begin FLookup := TDictionary<string, Variant>.Create; end; des ...

  9. CentOS 下 Codeblocks 的 安装 + 汉化 以及 基本使用介绍

    Codeblocks 安装 注:在root用户下运行下列命令 1.安装gcc,需要c和c++两部分,默认安装下,CentOS不安装编译器的,在终端输入以下命令即可 yum install gcc yu ...

  10. 分享自lordinloft 《[转载]COMPILE_OPT 的用法介绍》

    来源:http://blog.sina.com.cn/s/blog_63180b75010117oj.html#bsh-73-372143085