@Test public void applyCommitted() throws Exception { raftServer[0].applyCommitted(); }
void applyCommitted() { int lastApplied; while (vState.getCommitIndex() > (lastApplied = vState.getLastApplied())) { LogEntry entry; synchronized (pState) { entry = pState.log().get(vState.incrementLastApplied(lastApplied)); } logger.fine(pState.myServerID + ": Applying " + entry); try { applier.apply(entry.operation); } catch (java.lang.Exception e) { logger.warning( String.format( "Operation %s generated exception %s on replica. " + "This should generally not be a problem, as the same exception should be " + "generated on the master and all other replicas, and returned to the client " + "for appropriate action (e.g. retry)", entry, e)); } } }
Server implements RemoteRaftServer { void applyCommitted() { int lastApplied; while (vState.getCommitIndex() > (lastApplied = vState.getLastApplied())) { LogEntry entry; synchronized (pState) { entry = pState.log().get(vState.incrementLastApplied(lastApplied)); } logger.fine(pState.myServerID + ": Applying " + entry); try { applier.apply(entry.operation); } catch (java.lang.Exception e) { logger.warning( String.format( "Operation %s generated exception %s on replica. " + "This should generally not be a problem, as the same exception should be " + "generated on the master and all other replicas, and returned to the client " + "for appropriate action (e.g. retry)", entry, e)); } } } }
Server implements RemoteRaftServer { void applyCommitted() { int lastApplied; while (vState.getCommitIndex() > (lastApplied = vState.getLastApplied())) { LogEntry entry; synchronized (pState) { entry = pState.log().get(vState.incrementLastApplied(lastApplied)); } logger.fine(pState.myServerID + ": Applying " + entry); try { applier.apply(entry.operation); } catch (java.lang.Exception e) { logger.warning( String.format( "Operation %s generated exception %s on replica. " + "This should generally not be a problem, as the same exception should be " + "generated on the master and all other replicas, and returned to the client " + "for appropriate action (e.g. retry)", entry, e)); } } } Server(StateMachineApplier applier); }
Server implements RemoteRaftServer { void applyCommitted() { int lastApplied; while (vState.getCommitIndex() > (lastApplied = vState.getLastApplied())) { LogEntry entry; synchronized (pState) { entry = pState.log().get(vState.incrementLastApplied(lastApplied)); } logger.fine(pState.myServerID + ": Applying " + entry); try { applier.apply(entry.operation); } catch (java.lang.Exception e) { logger.warning( String.format( "Operation %s generated exception %s on replica. " + "This should generally not be a problem, as the same exception should be " + "generated on the master and all other replicas, and returned to the client " + "for appropriate action (e.g. retry)", entry, e)); } } } Server(StateMachineApplier applier); UUID getMyServerID(); void start(); void stop(); int appendEntries(
            int term,
            UUID leader,
            int prevLogIndex,
            int prevLogTerm,
            List<LogEntry> entries,
            int leaderCommit); int requestVote(int term, UUID candidate, int lastLogIndex, int lastLogTerm); Object applyToStateMachine(Object operation); void addServer(UUID id, RemoteRaftServer server); }
Server implements RemoteRaftServer { void applyCommitted() { int lastApplied; while (vState.getCommitIndex() > (lastApplied = vState.getLastApplied())) { LogEntry entry; synchronized (pState) { entry = pState.log().get(vState.incrementLastApplied(lastApplied)); } logger.fine(pState.myServerID + ": Applying " + entry); try { applier.apply(entry.operation); } catch (java.lang.Exception e) { logger.warning( String.format( "Operation %s generated exception %s on replica. " + "This should generally not be a problem, as the same exception should be " + "generated on the master and all other replicas, and returned to the client " + "for appropriate action (e.g. retry)", entry, e)); } } } Server(StateMachineApplier applier); UUID getMyServerID(); void start(); void stop(); int appendEntries(
            int term,
            UUID leader,
            int prevLogIndex,
            int prevLogTerm,
            List<LogEntry> entries,
            int leaderCommit); int requestVote(int term, UUID candidate, int lastLogIndex, int lastLogTerm); Object applyToStateMachine(Object operation); void addServer(UUID id, RemoteRaftServer server); static final int LEADER_HEARTBEAT_TIMEOUT; }