in genie-client/src/main/java/com/netflix/genie/client/JobClient.java [812:846]
public JobStatus waitForCompletion(final String jobId, final long blockTimeout, final long pollTime)
throws GenieClientException, InterruptedException, IOException, GenieTimeoutException {
if (StringUtils.isEmpty(jobId)) {
throw new IllegalArgumentException("Missing required parameter: jobId.");
}
final long startTime = System.currentTimeMillis();
int errorCount = 0;
// wait for job to finish
while (true) {
try {
final JobStatus status = this.getJobStatus(jobId);
if (status.isFinished()) {
return status;
}
// reset the error count
errorCount = 0;
} catch (final IOException ioe) {
errorCount++;
// Ignore for 5 times in a row
if (errorCount >= this.maxStatusRetries) {
throw ioe;
}
}
if (System.currentTimeMillis() - startTime < blockTimeout) {
Thread.sleep(pollTime);
} else {
throw new GenieTimeoutException("Timed out waiting for job to finish: " + jobId);
}
}
}