Skip to content

Commit

Permalink
handle InterruptedException
Browse files Browse the repository at this point in the history
  • Loading branch information
HxpSerein committed Oct 29, 2024
1 parent 7cea308 commit 0ebcf91
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ private void startHeartbeat() {
log.info("Zookeeper session expired, attempting to reconnect...");
reconnectAndRegister();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
log.error("Failed to update heartbeat for node: {}", nodePath, e);
}
}, 0, HEARTBEAT_INTERVAL, TimeUnit.MILLISECONDS);
Expand All @@ -134,6 +135,7 @@ private void startHeartbeatChecker() {
log.info("Zookeeper session expired, attempting to reconnect...");
reconnectAndRegister();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
log.error("Failed to check heartbeat", e);
}
}, HEARTBEAT_TIMEOUT, HEARTBEAT_TIMEOUT, TimeUnit.MILLISECONDS);
Expand Down Expand Up @@ -164,6 +166,7 @@ private synchronized void handleNodeChanges() {
log.info("Zookeeper session expired, attempting to reconnect...");
reconnectAndRegister();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
log.error("Failed to handle node changes", e);
}
}
Expand All @@ -182,7 +185,7 @@ private void reconnectAndRegister() {
try {
Thread.sleep(3000);
} catch (InterruptedException ignored) {

Thread.currentThread().interrupt();
}
}
}
Expand All @@ -196,6 +199,7 @@ public void close() {
scheduler.shutdown();
log.info("ZooKeeper client closed: {}", nodePath);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
log.error("Failed to close ZooKeeper client", e);
}
}
Expand Down

0 comments on commit 0ebcf91

Please sign in to comment.