Hadoop 之 注解

来源:互联网 发布:网络英语哪家好 编辑:程序博客网 时间:2024/05/21 09:38

InterfaceAudience 类主要包括三类注解用来强调使用范围:


@InterfaceAudience.Public : 任何工程均可使用

@InterfaceAudience.LimitedPrivate :只有在特定的工程中可以使用,如 Common HDFS MapReduce ZooKeeper HBase

@InterfaceAudience.Private: 只有在Hadoop中可以使用


具体代码如下:

@InterfaceAudience.Public@InterfaceStability.Evolvingpublic class InterfaceAudience {  /**   * Intended for use by any project or application.   */  @Documented  @Retention(RetentionPolicy.RUNTIME)  public @interface Public {};    /**   * Intended only for the project(s) specified in the annotation.   * For example, "Common", "HDFS", "MapReduce", "ZooKeeper", "HBase".   */  @Documented  @Retention(RetentionPolicy.RUNTIME)  public @interface LimitedPrivate {    String[] value();  };    /**   * Intended for use only within Hadoop itself.   */  @Documented  @Retention(RetentionPolicy.RUNTIME)  public @interface Private {};  private InterfaceAudience() {} // Audience can't exist on its own}

InterfaceStability类中定义了三种注解,主要用来说明代码的稳定性(即其内容是否会随版本的变化而变化):

@InterfaceStability.Stable : 代码具有较强的稳定性,但随着工程主版本号的变化可能会发生改变

@InterfaceStability.Evolving:随着工程次版本号的变化可能会发生改变

@InterfaceStability.Unstable :代码在任何发布版本中均有可能会发生变化

@InterfaceAudience.Public@InterfaceStability.Evolvingpublic class InterfaceStability {  /**   * Can evolve while retaining compatibility for minor release boundaries.;    * can break compatibility only at major release (ie. at m.0).   */  @Documented  @Retention(RetentionPolicy.RUNTIME)  public @interface Stable {};    /**   * Evolving, but can break compatibility at minor release (i.e. m.x)   */  @Documented  @Retention(RetentionPolicy.RUNTIME)  public @interface Evolving {};    /**   * No guarantee is provided as to reliability or stability across any   * level of release granularity.   */  @Documented  @Retention(RetentionPolicy.RUNTIME)  public @interface Unstable {};}


0 0
原创粉丝点击