Source:
private void consume() { try { if (state.getType() == LogReplicationStateType.STOPPED) { log.info("Log Replication State Machine has been stopped. No more events will be processed."); return; } LogReplicationEvent event = eventQueue.take(); if (event.getType() == LogReplicationEventType.REPLICATION_START) { baseSnapshot = event.getMetadata().getLastBaseSnapshot(); ackedTimestamp = event.getMetadata().getLastLogEntrySyncedTimestamp(); log.info("Log Replication FSM consume event {}", event); } if (event.getType() == LogReplicationEventType.LOG_ENTRY_SYNC_REPLICATED) { if (state.getType() == LogReplicationStateType.IN_LOG_ENTRY_SYNC && state.getTransitionEventId().equals(event.getMetadata().getRequestId())) { log.debug("Log Entry Sync ACK, update last ack timestamp to {}", event.getMetadata().getLastLogEntrySyncedTimestamp()); ackedTimestamp = event.getMetadata().getLastLogEntrySyncedTimestamp(); log.debug("Replicated Event ackTs ", ackedTimestamp); } } else { if (event.getType() == LogReplicationEventType.SNAPSHOT_SYNC_COMPLETE) { if (state.getType() == LogReplicationStateType.IN_SNAPSHOT_SYNC && state.getTransitionEventId().equals(event.getMetadata().getRequestId())) { log.info("Snapshot Sync ACK, update last ack timestamp to {}", event.getMetadata().getLastLogEntrySyncedTimestamp()); baseSnapshot = event.getMetadata().getLastLogEntrySyncedTimestamp(); ackedTimestamp = baseSnapshot; } } try { LogReplicationState newState = state.processEvent(event); log.trace("Transition from to {}", state, newState); transition(state, newState); state = newState; numTransitions.setValue(numTransitions.getValue() + 1); } catch (IllegalTransitionException illegalState) { log.error("Illegal log replication event when in state {}", event.getType(), state.getType()); } } if (event.getType() == LogReplicationEventType.REPLICATION_STOP) { synchronized (event) { event.notifyAll(); } } logReplicationFSMConsumer.submit(this::consume); } catch (Throwable t) { log.error("Error on event consumer: ", t); } }

Target:
private void consume() { try { if (state.getType() == LogReplicationStateType.STOPPED) { log.info("Log Replication State Machine has been stopped. No more events will be processed."); return; } LogReplicationEvent event = eventQueue.take(); if (event.getType() == LogReplicationEventType.REPLICATION_START) { baseSnapshot = event.getMetadata().getLastBaseSnapshot(); ackedTimestamp = event.getMetadata().getLastLogEntrySyncedTimestamp(); log.info("Log Replication FSM consume event {}", event); } if (event.getType() == LogReplicationEventType.LOG_ENTRY_SYNC_REPLICATED) { if (state.getType() == LogReplicationStateType.IN_LOG_ENTRY_SYNC && state.getTransitionEventId().equals(event.getMetadata().getRequestId())) { log.debug("Log Entry Sync ACK, update last ack timestamp to {}", event.getMetadata().getLastLogEntrySyncedTimestamp()); ackedTimestamp = event.getMetadata().getLastLogEntrySyncedTimestamp(); log.debug("Replicated Event ackTs ", ackedTimestamp); } } else { if (event.getType() == LogReplicationEventType.SNAPSHOT_SYNC_COMPLETE) { if (state.getType() == LogReplicationStateType.IN_SNAPSHOT_SYNC && state.getTransitionEventId().equals(event.getMetadata().getRequestId())) { log.info("Snapshot Sync ACK, update last ack timestamp to {}", event.getMetadata().getLastLogEntrySyncedTimestamp()); baseSnapshot = event.getMetadata().getLastBaseSnapshot(); ackedTimestamp = event.getMetadata().getLastLogEntrySyncedTimestamp(); } } try { LogReplicationState newState = state.processEvent(event); log.trace("Transition from to {}", state, newState); transition(state, newState); state = newState; numTransitions.setValue(numTransitions.getValue() + 1); } catch (IllegalTransitionException illegalState) { log.error("Illegal log replication event when in state {}", event.getType(), state.getType()); } } if (event.getType() == LogReplicationEventType.REPLICATION_STOP) { synchronized (event) { event.notifyAll(); } } logReplicationFSMConsumer.submit(this::consume); } catch (Throwable t) { log.error("Error on event consumer: ", t); } }