Flume源码学习知识储备

原创
2017/05/03 22:31
阅读数 35
  • 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 };
  }
展开阅读全文
打赏
0
1 收藏
分享
加载中
更多评论
打赏
0 评论
1 收藏
0
分享
返回顶部
顶部