Source:
<code>public LogReplicationRuntimeState processEvent(LogReplicationRuntimeEvent event) throws IllegalTransitionException { switch (event.getType()) { case ON_CONNECTION_DOWN: String endpointDown = event.getEndpoint(); fsm.updateDisconnectedEndpoints(endpointDown); if (fsm.getRemoteLeader().isPresent() && fsm.getRemoteLeader().get().equals(endpointDown)) { log.warn("Connection to remote leader endpoint={} is down. Attempt to reconnect.", endpointDown); fsm.resetRemoteLeaderEndpoint(); return fsm.getConnectedEndpoints().size() == 0 ? fsm.getStates().get(LogReplicationRuntimeStateType.WAITING_FOR_CONNECTIVITY) : fsm.getStates().get(LogReplicationRuntimeStateType.VERIFYING_REMOTE_LEADER); } log.debug("Connection lost to non-leader node {}", endpointDown); return null; case REMOTE_LEADER_LOSS: <START> if (fsm.getRemoteLeader().isPresent() && fsm.getRemoteLeader().get().equals(event.getEndpoint())) { <END> fsm.resetRemoteLeaderEndpoint(); return fsm.getStates().get(LogReplicationRuntimeStateType.VERIFYING_REMOTE_LEADER); } return null; case ON_CONNECTION_UP: fsm.updateConnectedEndpoints(event.getEndpoint()); return null; case NEGOTIATION_COMPLETE: return fsm.getStates().get(LogReplicationRuntimeStateType.REPLICATING); case LOCAL_LEADER_LOSS: return fsm.getStates().get(LogReplicationRuntimeStateType.STOPPED); default: { log.warn("Unexpected communication event when in init state.", event.getType()); throw new IllegalTransitionException(event.getType(), getType()); } } }</code><technical_language>want check if fsm.getConnectedEndpoints? if connected remote endpoint jump WaitForConnections is query for leadership</technical_language>

Target:
public LogReplicationRuntimeState processEvent(LogReplicationRuntimeEvent event) throws IllegalTransitionException { switch (event.getType()) { case ON_CONNECTION_DOWN: String endpointDown = event.getEndpoint(); fsm.updateDisconnectedEndpoints(endpointDown); if (fsm.getRemoteLeader().isPresent() && fsm.getRemoteLeader().get().equals(endpointDown)) { log.warn("Connection to remote leader endpoint={} is down. Attempt to reconnect.", endpointDown); fsm.resetRemoteLeaderEndpoint(); return fsm.getConnectedEndpoints().isEmpty() ? fsm.getStates().get(LogReplicationRuntimeStateType.WAITING_FOR_CONNECTIVITY) : fsm.getStates().get(LogReplicationRuntimeStateType.VERIFYING_REMOTE_LEADER); } log.debug("Connection lost to non-leader node {}", endpointDown); return null; case REMOTE_LEADER_LOSS: if (fsm.getRemoteLeader().isPresent() && fsm.getRemoteLeader().get().equals(event.getEndpoint())) { fsm.resetRemoteLeaderEndpoint(); return fsm.getConnectedEndpoints().isEmpty() ? fsm.getStates().get(LogReplicationRuntimeStateType.WAITING_FOR_CONNECTIVITY) : fsm.getStates().get(LogReplicationRuntimeStateType.VERIFYING_REMOTE_LEADER); } return null; case ON_CONNECTION_UP: fsm.updateConnectedEndpoints(event.getEndpoint()); return null; case NEGOTIATION_COMPLETE: return fsm.getStates().get(LogReplicationRuntimeStateType.REPLICATING); case LOCAL_LEADER_LOSS: return fsm.getStates().get(LogReplicationRuntimeStateType.STOPPED); default: { log.warn("Unexpected communication event when in init state.", event.getType()); throw new IllegalTransitionException(event.getType(), getType()); } } }