作者:ekuuu | 来源:互联网 | 2023-01-07 12:29
我有一个Apache Beam管道成功运行作为数据流模板.但是,我有一个选项类(扩展DataflowPipelineOptions).生成模板时,此类从pom或命令行界面获取参数.我想知道是否存在某个类,以便我可以直接从属性文件中加载这些参数.这样,从环境切换到环境会更容易,而且更干净
1> Scott Wegner..:
我不确定我理解你的问题.我想你是否有办法将默认模板参数绑定到资源文件而不是命令行或pom.xml
文件提供的值.
指定为的参数PipelineOptions
可以使用注释@Default.InstanceFactory
来指定用户提供的工厂方法以生成参数的默认值.有了这个,您可以从实现中的资源文件中读取默认值DefaultValueFactory
.
有关示例,请参阅如何WindowedWordCount
定义DefaultToCurrentSystemTime
注释minTimestampMillis参数:
/** A {@link DefaultValueFactory} that returns the current system time. */
public static class DefaultToCurrentSystemTime implements DefaultValueFactory {
@Override
public Long create(PipelineOptions options) {
return System.currentTimeMillis();
}
}
@Description("Minimum randomly assigned timestamp, in milliseconds-since-epoch")
@Default.InstanceFactory(DefaultToCurrentSystemTime.class)
Long getMinTimestampMillis();
void setMinTimestampMillis(Long value);