栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

Flink1.15源码阅读——flink-annotations

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Flink1.15源码阅读——flink-annotations

文章目录
  • flink-annotations源码分析
    • Flink-annotation类图关系
    • FlinkVersion
    • docs注解
      • @ConfigGroup
      • @ConfigGroups
      • @Documentation
        • @Documentation.OverrideDefault
        • @Documentation.Section
        • @Documentation.TableOption
        • @Documentation.SuffixOption
        • @Documentation.ExcludeFromDocumentation
    • @Experimental
    • @Internal
    • @Public
    • @PublicEvolving
    • @VisibleForTesting

flink-annotations源码分析 Flink-annotation类图关系

本文将详细介绍下flink中的自定义注解模块,了解flink注解的作用与使用。主要围绕flink源码中的 flink-annotations模块,与docs 相关的注解有@ConfigGroup和@ConfigGroups , 通常作用于配置类上;@Documentation.OverrideDefault、@Documentation.Section、@Documentation.TableOption、@Documentation.SuffixOption,@Documentation.ExcludeFromDocumentation 作用于配置类的 ConfigOption 字段上,对配置项做一些修改。另外,还有其他5种标记注解,@Experimental、@Internal、@Public、@PublicEvolving、@VisibleForTesting。


FlinkVersion

flink 版本枚举类,在SQL/Table API升级期间,它用于API版本控制和迁移测试。

docs注解 @ConfigGroup

指定一组配置选项的类。组的名称将作为基础生成的html文件的文件名,定义在{@link ConfigOptionsDocGenerator}中。
如 @ConfigGroup(name = ExponentialDelayRestartStrategy",keyPrefix = “restart-strategy.exponential-delay”),生成的 HTML 文件名为 ExponentialDelayRestartStrategy ,其中的配置项名称都是以 restart-strategy.exponential-delay 开头的。

@Target({})
@Internal
public @interface ConfigGroup {
    String name();
    String keyPrefix();
}
@ConfigGroups

在包含配置选项的类上使用的注释,允许根据键前缀将选项分离到不同的表中。如果选项键匹配组前缀,则配置选项被分配给{@link ConfigGroup}。当一个键匹配多个前缀时,匹配时间最长的前缀优先。选项永远不会分配给多个组。不匹配任何组的选项将隐式添加到默认组。

允许一个配置类中的配置项可以按照配置项名称前缀分成不同的组,生成多个 HTML 文件。
如:

@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Internal
public @interface ConfigGroups {
    ConfigGroup[] groups() default {};
}
@Documentation

用于修改文档生成器行为的注释集合。

@Documentation.OverrideDefault
    @Target(ElementType.FIELD)
    @Retention(RetentionPolicy.RUNTIME)
    @Internal
    public @interface OverrideDefault {
        String value();
    }
@Documentation.Section
    @Target(ElementType.FIELD)
    @Retention(RetentionPolicy.RUNTIME)
    @Internal
    public @interface Section {
        
        String[] value() default {};

        
        int position() default Integer.MAX_VALUE;
    }
@Documentation.TableOption
    @Target(ElementType.FIELD)
    @Retention(RetentionPolicy.RUNTIME)
    @Internal
    public @interface TableOption {
        ExecMode execMode();
    }

    
    public enum ExecMode {
        BATCH("Batch"),
        STREAMING("Streaming"),
        BATCH_STREAMING("Batch and Streaming");

        private final String name;

        ExecMode(String name) {
            this.name = name;
        }

        @Override
        public String toString() {
            return name;
        }
    }

@Documentation.SuffixOption
    
    @Target({ElementType.FIELD, ElementType.TYPE})
    @Retention(RetentionPolicy.RUNTIME)
    @Internal
    public @interface SuffixOption {
        String value();
    }

@Documentation.ExcludeFromDocumentation
    
    @Target({ElementType.FIELD, ElementType.TYPE})
    @Retention(RetentionPolicy.RUNTIME)
    @Internal
    public @interface ExcludeFromDocumentation {
        
        String value() default "";
    }

@Experimental
@Documented
@Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD, ElementType.CONSTRUCTOR})
@Public
public @interface Experimental {
}

@Internal
@Documented
@Target({ElementType.TYPE, ElementType.METHOD, ElementType.CONSTRUCTOR, ElementType.FIELD})
@Public
public @interface Internal {
}
@Public
@Documented
@Target(ElementType.TYPE)
@Public
public @interface Public {
}
@PublicEvolving
@Documented
@Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD, ElementType.CONSTRUCTOR})
@Public
public @interface PublicEvolving {
}

@VisibleForTesting
@Documented
@Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD, ElementType.CONSTRUCTOR})
@Internal
public @interface VisibleForTesting {
}
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/1020753.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号