flume源码分析笔记

flume1.8.0的启动类是org.apache.flume.node.Application;
(Application依赖org.apache.flume.lifecycle的LifecycleAware、LifecycleState和LifecycleSupervisor、org.apache.flume.annotations的InterfaceStability和InterfaceAudience、MaterializedConfiguration、PollingZooKeeperConfigurationProvider、StaticZooKeeperConfigurationProvider、AbstractZooKeeperConfigurationProvider、AbstractConfigurationProvider、
org.apache.flume.instrumentation的MonitorService、org.apache.flume.conf的FlumeConfiguration、guava-11.0.2的EventBus、Lists、Preconditions等;)
(Application的main方法执行start、stop,其他方法有handleConfigurationEvent、startAllComponents、stopAllComponents,继而调用loadMonitoring等;)

flume-ng-core包:
LifecycleSupervisor依赖LifecycleAware、LifecycleState、ScheduledThreadPoolExecutor、ScheduledExecutorService等;
(方法有start、stop、fail、supervise、unsupervise、getLifecycleState等;)

MonitorService用于监控服务;它继承org.apache.flume.conf的Configurable;
SourceCounter继承MonitoredCounterGroup实现SourceCounterMBean,为各种source服务;
SinkCounter继承MonitoredCounterGroup实现SinkCounterMBean,为各种sink服务;
ChannelCounter继承MonitoredCounterGroup实现ChannelCounterMBean,为各种channel服务;
HTTPMetricsServer依赖jetty-6.1.26.jar的Server和SelectChannelConnector,以及gson-2.2.2.jar的Gson实现;
org.apache.flume.instrumentation.kafka是专为kafka提供的source、sink和channel实现;
(包括KafkaSinkCounter、KafkaChannelCounter、KafkaSourceCounter;)
org.apache.flume.interceptor提供拦截器,包括HostInterceptor、RegexExtractorInterceptor、StaticInterceptor、InterceptorChain拦截器链等;
org.apache.flume.serialization提供序列化和反序列化;
(EventDeserializer、EventSerializer、AvroEventDeserializer、LineDeserializer、EventDeserializerFactory、EventSerializerFactory等;)
org.apache.flume.annotations提供注解Recyclable和Disposable;

Channel接口方法有put、take、getTransaction; ChannelFactory用于创建Channel;
ChannelSelector是channel选择器,方法有getAllChannels、getOptionalChannels、getRequiredChannels、setChannels;
Source接口方法有setChannelProcessor、getChannelProcessor; SourceFactory用于创建Source; PollableSource是Source子类;
Sink接口方法有setChannel、getChannel、process; SinkFactory用于创建Sink; SinkProcessor接口方法有process、setSinks,被SinkRunner使用;
Transaction接口方法有begin、commit、rollback、close;

org.apache.flume.source目录定义了多种source,如AvroSource、ExecSource、MultiportSyslogTCPSource、NetcatSource、NetcatUdpSource、SequenceGeneratorSource、SpoolDirectorySource、StressSource、SyslogUDPSource、ThriftSource,以及http目录的HTTPSource:

org.apache.flume.channel目录定义了多种选择器和channel,如AbstractChannelSelector、MemoryChannel、ReplicatingChannelSelector、MultiplexingChannelSelector等;

org.apache.flume.sink目录定义了多种sink,如AbstractRpcSink、AvroSink、LoggerSink、NullSink、RollingFileSink、ThriftSink等;

flume-ng-sources包:
JMSSource依赖JMSMessageConverter、JMSMessageConsumer、JMSDestinationType、JMSDestinationLocator、JMSSourceConfiguration、InitialContextFactory等;
(方法有doStart、doStop、doConfigure、doProcess、createConsumer等;)

KafkaSource依赖KafkaConsumer(kafka-clients-0.9.0.1.jar)、KafkaSourceCounter、KafkaSourceConstants等;
(方法有doStart、doStop、doConfigure、doProcess等;)

ScribeSource依赖LogEntry、TServer(libthrift-0.9.3.jar)、Scribe、ResultCode等;
(方法有start、stop、configure;)

TwitterSource依赖TwitterStream和TwitterStreamFactory(twitter4j-stream-3.0.3.jar)、Schema(avro-1.7.4.jar)等;
(方法有start、stop、configure、onStatus等;)

TaildirSource依赖Table、ThreadFactoryBuilder(guava-11.0.2.jar)、ReliableTaildirEventReader、TaildirMatcher、TailFile、TaildirSourceConfigurationConstants、
JsonReader(gson-2.2.2.jar)、ExecutorService、ScheduledExecutorService、以及大量java.io和java.nio的类;
(方法有start、stop、configure、process等;)

flume-ng-channels包有flume-file-channel、flume-jdbc-channel、flume-kafka-channel、flume-spillable-memory-channel四种channel;
以flume-file-channel为例,主要类为FileChannel,利用Semaphore和ThreadLocal实现;方法有configure、start、stop等;

flume-ng-sinks包有flume-hdfs-sink、flume-hive-sink、flume-http-sink、flume-ng-elasticsearch-sink、flume-ng-hbase-sink、flume-ng-kafka-sink、flume-ng-morphline-solr-sink等多种sink;
以flume-hdfs-sink为例,主要文件是HDFSEventSink、BucketWriter;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值