Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HDDS-4024. Avoid while loop too soon when exception happen #1253

Merged
merged 3 commits into from
Jul 29, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -224,19 +224,26 @@ private void start() throws IOException {
nextHB.set(Time.monotonicNow() + heartbeatFrequency);
context.execute(executorService, heartbeatFrequency,
TimeUnit.MILLISECONDS);
now = Time.monotonicNow();
if (now < nextHB.get()) {
if(!Thread.interrupted()) {
Thread.sleep(nextHB.get() - now);
}
}
} catch (InterruptedException e) {
// Some one has sent interrupt signal, this could be because
// 1. Trigger heartbeat immediately
// 2. Shutdown has be initiated.
LOG.warn("Interrupt the execution.", e);
runzhiwang marked this conversation as resolved.
Show resolved Hide resolved
Thread.currentThread().interrupt();
} catch (Exception e) {
LOG.error("Unable to finish the execution.", e);
}

now = Time.monotonicNow();
if (now < nextHB.get()) {
if(!Thread.interrupted()) {
try {
Thread.sleep(nextHB.get() - now);
} catch (InterruptedException e) {
LOG.warn("Interrupt the execution.", e);
}
}
}
}

// If we have got some exception in stateMachine we set the state to
Expand Down