(executor) Implement process removal for long-absent heartbeats
Added functionality to remove processes from listing that have not checked in for over a day. A 'removeProcessHeartbeat' function was created to delete the respective entry from the PROCESS_HEARTBEAT table in case heartbeats are absent for more than one day.
This commit is contained in:
parent
7b40c0bbee
commit
0454447e41
@ -41,6 +41,14 @@ public class ProcessLivenessMonitorActor extends RecordActorPrototype {
|
||||
var processId = heartbeat.getProcessId();
|
||||
if (null == processId) continue;
|
||||
|
||||
if (heartbeat.lastSeenMillis() > TimeUnit.DAYS.toMillis(1)) {
|
||||
// This process has been MIA for a long time
|
||||
// ... so we delete it from the listing altogether
|
||||
|
||||
removeProcessHeartbeat(heartbeat);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (processService.isRunning(processId) && heartbeat.lastSeenMillis() < 10_000)
|
||||
continue;
|
||||
|
||||
@ -174,7 +182,20 @@ public class ProcessLivenessMonitorActor extends RecordActorPrototype {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
}
|
||||
private void removeProcessHeartbeat(ProcessHeartbeat heartbeat) {
|
||||
try (var conn = dataSource.getConnection();
|
||||
var stmt = conn.prepareStatement("""
|
||||
DELETE FROM PROCESS_HEARTBEAT
|
||||
WHERE INSTANCE = ?
|
||||
""")) {
|
||||
|
||||
stmt.setString(1, heartbeat.uuidFull());
|
||||
stmt.executeUpdate();
|
||||
}
|
||||
catch (SQLException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
}
|
||||
private record ProcessHeartbeat(
|
||||
String processId,
|
||||
String processBase,
|
||||
|
Loading…
Reference in New Issue
Block a user