Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -140,25 +140,26 @@ private Optional<JobState> submitJob(Attributes typeAttributes) {

private Optional<JobState> pollJobStatus(Attributes typeAttributes) {
long startTime = System.currentTimeMillis();
while (!jobFinished()) {
long elapsedTime = System.currentTimeMillis() - startTime;
if (elapsedTime > timeoutMs) {
Optional<JobState> job = jobsClient.getState(jobId);
// Do not cancel job if it is still in running state after 3 hours
if (job.isPresent() && !job.get().equals(JobState.RUNNING)) {
log.info(
"Cancelling job: {} due to timeout for {}: jobState: {}",
getType(),
metadata,
job.get());
if (!jobsClient.cancelJob(jobId)) {
log.error("Could not cancel job {} for {}", getType(), metadata);
return Optional.empty();
while (!Thread.currentThread().isInterrupted() && !jobFinished()) {
try {
long elapsedTime = System.currentTimeMillis() - startTime;
if (elapsedTime > timeoutMs) {
Optional<JobState> job = jobsClient.getState(jobId);
// Do not cancel job if it is still in running state after 3 hours
if (job.isPresent() && !job.get().equals(JobState.RUNNING)) {
log.info(
"Cancelling job: {} due to timeout for {}: jobState: {}",
getType(),
metadata,
job.get());
if (!jobsClient.cancelJob(jobId)) {
log.error("Could not cancel job {} for {}", getType(), metadata);
return Optional.empty();
}
break;
}
break;
}
}
try {
// Sleep for specified poll interval
Thread.sleep(pollIntervalMs);
} catch (InterruptedException e) {
log.warn(
Expand All @@ -170,6 +171,9 @@ private Optional<JobState> pollJobStatus(Attributes typeAttributes) {
log.error("Could not cancel job {} for {}", getType(), metadata);
return Optional.empty();
}
// Interrupt the current thread and exit the loop
Thread.currentThread().interrupt();
break;
}
}
Optional<JobResponseBody> ret = jobsClient.getJob(jobId);
Expand Down
Loading