Flume源码学习知识储备

  • source类图关系举例 (eg:ExecSource)

    ExecSource

  • 关系图中的Stable Public 分别为InterfaceAudience InterfaceStability的注解类型。

    1. InterfaceAudience 类包含有三个注解类型,用来说明被他们注解的类型的潜在使用范围,即audience 源码如下:
        import java.lang.annotation.Documented;
      
        /**
      	* Annotation to inform users of a package, class or method's intended audience.
      	* Currently the audience can be {@link Public}, {@link LimitedPrivate} or
      	* {@link Private}. <br>
      	* All public classes must have InterfaceAudience annotation. <br>
      	* <ul>
      	* <li>Public classes that are not marked with this annotation must be
      	* considered by default as {@link Private}.</li>
      	*
      	* <li>External applications must only use classes that are marked
      	* {@link Public}. Avoid using non public classes as these classes
      	* could be removed or change in incompatible ways.</li>
      	*
      	* <li>Flume projects must only use classes that are marked
      	* {@link LimitedPrivate} or {@link Public}</li>
      	*
      	* <li> Methods may have a different annotation that it is more restrictive
      	* compared to the audience classification of the class. Example: A class
      	* might be {@link Public}, but a method may be {@link LimitedPrivate}
      	* </li></ul>
      	*/
      	@InterfaceAudience.Public
      	@InterfaceStability.Evolving
      	public class InterfaceAudience {
      		/**
      		* Intended for use by any project or application.
              * 被注解的类型对多有工程和应用可用。
      		*/
      		@Documented public @interface Public {};
      
      		/**
      		* Intended only for the project(s) specified in the annotation.
      		* For example, "Common", "HDFS", "MapReduce", "ZooKeeper", "HBase".
              * 被注解的类型只能用于某些特定的工程或应用,如Common,HDFS,MapReduce,ZooKeeper,HBase等
      		*/
      		@Documented public @interface LimitedPrivate {
      			String[] value();
      		};
      
      		/**
      		* Intended for use only within Flume
              * 被注解的类型只能用于Flume。
      		*/
      		@Documented public @interface Private {};
      
      		private InterfaceAudience() {} // Audience can't exist on its own
      	}
      
    2. `InterfaceStability` 类包含三个注解,用于说明被他们注解的类型的稳定性 源码如下:
    
import java.lang.annotation.Documented;

			/**
 			* Annotation to inform users of how much to rely on a particular package,
 			* class or method not changing over time. Currently the stability can be
 			* {@link Stable}, {@link Evolving} or {@link Unstable}. <br>
 			*
 			* <ul><li>All classes that are annotated with {@link Public} or
 			* {@link LimitedPrivate} must have InterfaceStability annotation. </li>
 			* <li>Classes that are {@link Private} are to be considered unstable unless
 			* a different InterfaceStability annotation states otherwise.</li>
 			* <li>Incompatible changes must not be made to classes marked as stable.</li>
 			* </ul>
 			*/
			@InterfaceAudience.Public
			@InterfaceStability.Evolving
			public class InterfaceStability {
  				/**
   				* Can evolve while retaining compatibility for minor release boundaries.;
   				* can break compatibility only at major release (ie. at m.0).
                   * 主版本是稳定的,不同主版本之间可能不兼容。
   				*/
  				@Documented
  				public @interface Stable {};

  				/**
   				* Evolving, but can break compatibility at minor release (i.e. m.x)
                   * 不停在变化的,不同小版本之间也可能不兼容。
   				*/
  				@Documented
  				public @interface Evolving {};

  				/**
   				* No guarantee is provided as to reliability or stability across any
   				* level of release granularity.
                   * 稳定性没有任何保证。
   				*/
  				@Documented
  				public @interface Unstable {};
			}
  • 类图中LifecycleState表示组件source的生命周期枚举值,源码:
 package org.apache.flume.lifecycle;

  public enum LifecycleState {
      IDLE, START, STOP, ERROR;//空闲、开始、结束、错误

      public static final LifecycleState[] START_OR_ERROR = new LifecycleState[]{
START, ERROR };
      public static final LifecycleState[] STOP_OR_ERROR = new LifecycleState[] {
STOP, ERROR };
  }

转载于:https://my.oschina.net/danier/blog/891920

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值