in ratatool-sampling/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/PatchedBigQueryServicesImpl.java [269:296]
Job pollJob(
JobReference jobRef,
Sleeper sleeper,
BackOff backoff) throws InterruptedException {
Instant nextLog = Instant.now().plus(POLLING_LOG_GAP);
do {
try {
Job job = client.jobs().get(jobRef.getProjectId(), jobRef.getJobId()).execute();
JobStatus status = job.getStatus();
if (status != null && status.getState() != null && status.getState().equals("DONE")) {
return job;
}
// The job is not DONE, wait longer and retry.
if (Instant.now().isAfter(nextLog)) {
LOG.info("Still waiting for BigQuery job {}\n{}",
jobRef.getJobId(),
formatBqStatusCommand(
jobRef.getProjectId(), jobRef.getJobId()));
nextLog = Instant.now().plus(POLLING_LOG_GAP);
}
} catch (IOException e) {
// ignore and retry
LOG.info("Ignore the error and retry polling job status.", e);
}
} while (nextBackOff(sleeper, backoff));
LOG.warn("Unable to poll job status: {}, aborting after reached max .", jobRef.getJobId());
return null;
}