Show a server is available by periodically sending a message to all the other servers : https://martinfowler.com/articles/patterns-of-distributed-systems/heartbeat.html
On the sending server side, the scheduler executes a method to send heartbeat messages : class SendingServer…
private void sendHeartbeat() throws IOException { socketChannel.blockingSend(newHeartbeatRequest(serverId)); }
On the receiving server, the failure detection mechanism has a similar scheduler started. At regular intervals, it checks if the heartbeat was received or not : class AbstractFailureDetector…
private HeartBeatScheduler heartbeatScheduler = new HeartBeatScheduler(this::heartBeatCheck, 100l); abstract void heartBeatCheck(); abstract void heartBeatReceived(T serverId);
A method to periodically check the heartbeat status and detect possible failures.