属性文件中的Apache Beam选项

Pie*_*BEL 2 options google-cloud-dataflow apache-beam

我有一个Apache Beam管道成功运行作为数据流模板.但是,我有一个选项类(扩展DataflowPipelineOptions).生成模板时,此类从pom或命令行界面获取参数.我想知道是否存在某个类,以便我可以直接从属性文件中加载这些参数.这样,从环境切换到环境会更容易,而且更干净

Sco*_*ner 5

我不确定我理解你的问题.我想你是否有办法将默认模板参数绑定到资源文件而不是命令行或pom.xml文件提供的值.

指定为的参数PipelineOptions可以使用注释@Default.InstanceFactory来指定用户提供的工厂方法以生成参数的默认值.有了这个,您可以从实现中的资源文件中读取默认值DefaultValueFactory.

有关示例,请参阅如何WindowedWordCount定义DefaultToCurrentSystemTime注释minTimestampMillis参数:

/** A {@link DefaultValueFactory} that returns the current system time. */
public static class DefaultToCurrentSystemTime implements DefaultValueFactory<Long> {
  @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);
Run Code Online (Sandbox Code Playgroud)