【发布时间】:2021-08-03 09:02:30
【问题描述】:
我尝试将文件从 Azure 容器传输到 GCS 存储桶,但最终出现以下问题
- 源文件中的记录顺序与目标文件的记录顺序不同,因为管道将进行并行处理
- 必须编写大量自定义代码来为 GCS 目标文件提供自定义名称,因为管道为其提供默认名称。
无论如何,Apache 管道可以在不处理文件内容的情况下传输文件本身(这样就不会发生上述问题)?因为我需要将多个文件从 Azure 容器传输到 GCS 存储桶
下面是我目前用来传输文件的代码
String format = LocalDateTime.now().format(DateTimeFormatter.ofPattern("YYYY_MM_DD_HH_MM_SS3")).toString();
String connectionString = "<<AZURE_STORAGE_CONNECTION_STRING>>";
PipelineOptions options = PipelineOptionsFactory.create();
options.as(BlobstoreOptions.class).setAzureConnectionString(connectionString);
Pipeline p = Pipeline.create(options);
p.apply(TextIO.read().from("azfs://storageaccountname/containername/CSVSample.csv"))
.apply("",FileIO.<String>write().to("azfs://storageaccountname/containername/"+format+"/").withNumShards(1).withSuffix(".csv")
.via(TextIO.sink()));
p.run().waitUntilFinish();
【问题讨论】:
标签: java azure-blob-storage google-cloud-dataflow apache-beam