@Test public void doRPC() throws java.lang.Exception { successfulLeaderElection(); String[] methods = {"fooMethod", "barMethod"}; ArrayList<Object> args = new ArrayList<Object>(); for (String method : methods) { raftServer[0].applyToStateMachine(new ConsensusRSMPolicy.RPC(method, args)); } }
public Object applyToStateMachine(Object operation) throws java.lang.Exception { logger.fine(String.format("%s: applyToStateMachine(%s)", pState.myServerID, operation)); if (vState.getState() == State.LEADER) { return leader.applyToStateMachine(operation); } else { throw new LeaderException( String.format("Current Leader is %s", vState.getCurrentLeader()), getCurrentLeader()); } }
Server implements RemoteRaftServer { public Object applyToStateMachine(Object operation) throws java.lang.Exception { logger.fine(String.format("%s: applyToStateMachine(%s)", pState.myServerID, operation)); if (vState.getState() == State.LEADER) { return leader.applyToStateMachine(operation); } else { throw new LeaderException( String.format("Current Leader is %s", vState.getCurrentLeader()), getCurrentLeader()); } } }
Server implements RemoteRaftServer { public Object applyToStateMachine(Object operation) throws java.lang.Exception { logger.fine(String.format("%s: applyToStateMachine(%s)", pState.myServerID, operation)); if (vState.getState() == State.LEADER) { return leader.applyToStateMachine(operation); } else { throw new LeaderException( String.format("Current Leader is %s", vState.getCurrentLeader()), getCurrentLeader()); } } Server(StateMachineApplier applier); }
Server implements RemoteRaftServer { public Object applyToStateMachine(Object operation) throws java.lang.Exception { logger.fine(String.format("%s: applyToStateMachine(%s)", pState.myServerID, operation)); if (vState.getState() == State.LEADER) { return leader.applyToStateMachine(operation); } else { throw new LeaderException( String.format("Current Leader is %s", vState.getCurrentLeader()), getCurrentLeader()); } } 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 { public Object applyToStateMachine(Object operation) throws java.lang.Exception { logger.fine(String.format("%s: applyToStateMachine(%s)", pState.myServerID, operation)); if (vState.getState() == State.LEADER) { return leader.applyToStateMachine(operation); } else { throw new LeaderException( String.format("Current Leader is %s", vState.getCurrentLeader()), getCurrentLeader()); } } 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; }