2

我们正在考虑按自动计划使用 Dataprep,以便将 GCS .gz 文件的文件夹加载到 Big Query 中。

挑战是:源 .gz 文件在处理后如何移动到冷存储?

我找不到由 Dataprep 生成的事件,我们可以连接到该事件以执行归档任务。如果 Dataprep 可以自行归档源文件,那将是最理想的。

有什么建议么 ?

4

1 回答 1

2

我不相信有一种方法可以在直接从 Dataprep 完成工作时获得通知。您可以做的是轮询底层数据流作业。您可以安排脚本在您计划的数据准备作业运行时运行。这是一个简单的例子:

#!/bin/bash

# list running dataflow jobs, filter so that only the one with the "dataprep" string in its name is actually listed and keep its id
id=$(gcloud dataflow jobs list --status=active --filter="name:dataprep" | sed -n 2p | cut -f 1 -d " ")
# loop until the state of the job changes to done
until [ $(gcloud dataflow jobs describe $id | grep currentState | head -1 | awk '{print $2}') == "JOB_STATE_DONE" ]
do
# sleep so that you reduce API calls
sleep 5m
done
# send to cold storage, e.g. gsutil mv ...
echo "done"

这里的问题是上面假设您只运行一个数据准备作业。如果您安排许多并发数据准备作业,则脚本会更复杂。

于 2018-03-14T17:29:16.003 回答