private boolean requestAppendEntries(PeerServer peer){ if(peer.makeBusy()){ peer.SendRequest(this.createAppendEntriesRequest(peer)) .whenCompleteAsync((RaftResponseMessage response, Throwable error) -> { try{ handlePeerResponse(response, error); }catch(Throwable err){ this.logger.error("Uncaught exception %s", err.toString()); } }, this.context.getScheduledExecutor()); return true; } this.logger.debug("Server %d is busy, skip the request", peer.getId()); return false; }
private boolean requestAppendEntries(PeerServer peer){ if(peer.makeBusy()){ peer.SendRequest(this.createAppendEntriesRequest(peer)) .whenCompleteAsync((RaftResponseMessage response, Throwable error) -> { try{ handlePeerResponse(response, error); }catch(Throwable err){ this.logger.error("Uncaught exception %s", err.toString()); } }, this.context.getScheduledExecutor()); return true; } this.logger.debug("Server %d is busy, skip the request", peer.getId()); return false; }
private boolean requestAppendEntries(PeerServer peer){ if(peer.makeBusy()){ peer.SendRequest(this.createAppendEntriesRequest(peer)) .whenCompleteAsync((RaftResponseMessage response, Throwable error) -> { try{ handlePeerResponse(response, error); }catch(Throwable err){ this.logger.error("Uncaught exception %s", err.toString()); } }, this.context.getScheduledExecutor()); return true; } this.logger.debug("Server %d is busy, skip the request", peer.getId()); return false; }
this.logger.error("bad server role for applying a snapshot, exit for debugging"); System.exit(-1); this.logger.info("successfully compact the log store, will now ask the statemachine to apply the snapshot"); if(!this.stateMachine.applySnapshot(snapshotSyncRequest.getSnapshot())){ this.logger.error("failed to apply the snapshot after log compacted, to ensure the safety, will shutdown the system"); System.exit(-1); return false; //should never be reached this.logger.error("failed to compact the log store after a snapshot is received, will ask the leader to retry"); return false; this.logger.error("I/O error %s while saving the snapshot or applying the snapshot, no reason to continue", error.getMessage()); System.exit(-1); return false;
this.logger.error("bad server role for applying a snapshot, exit for debugging"); this.stateMachine.exit(-1); this.logger.info("successfully compact the log store, will now ask the statemachine to apply the snapshot"); if(!this.stateMachine.applySnapshot(snapshotSyncRequest.getSnapshot())){ this.logger.error("failed to apply the snapshot after log compacted, to ensure the safety, will shutdown the system"); this.stateMachine.exit(-1); return false; //should never be reached this.logger.error("failed to compact the log store after a snapshot is received, will ask the leader to retry"); return false; this.logger.error("I/O error %s while saving the snapshot or applying the snapshot, no reason to continue", error.getMessage()); this.stateMachine.exit(-1); return false;
this.logger.error("bad server role for applying a snapshot, exit for debugging"); this.stateMachine.exit(-1); this.logger.info("successfully compact the log store, will now ask the statemachine to apply the snapshot"); if(!this.stateMachine.applySnapshot(snapshotSyncRequest.getSnapshot())){ this.logger.error("failed to apply the snapshot after log compacted, to ensure the safety, will shutdown the system"); this.stateMachine.exit(-1); return false; //should never be reached this.logger.error("failed to compact the log store after a snapshot is received, will ask the leader to retry"); return false; this.logger.error("I/O error %s while saving the snapshot or applying the snapshot, no reason to continue", error.getMessage()); this.stateMachine.exit(-1); return false;
this.logger.error("A leader should never encounter election timeout, illegal application state, stop the application"); System.exit(-1); return;
private synchronized RaftResponseMessage handleExtendedMessages(RaftRequestMessage request){ if(request.getMessageType() == RaftMessageType.AddServerRequest){ return this.handleAddServerRequest(request); }else if(request.getMessageType() == RaftMessageType.RemoveServerRequest){ return this.handleRemoveServerRequest(request); }else if(request.getMessageType() == RaftMessageType.SyncLogRequest){ return this.handleLogSyncRequest(request); }else if(request.getMessageType() == RaftMessageType.JoinClusterRequest){ return this.handleJoinClusterRequest(request); }else if(request.getMessageType() == RaftMessageType.LeaveClusterRequest){ return this.handleLeaveClusterRequest(request); }else if(request.getMessageType() == RaftMessageType.InstallSnapshotRequest){ return this.handleInstallSnapshotRequest(request); }else{ this.logger.error("receive an unknown request %s, for safety, step down.", request.getMessageType().toString()); System.exit(-1); } return null; }
this.logger.error("A leader should never encounter election timeout, illegal application state, stop the application"); this.stateMachine.exit(-1); return;
server.logger.error("error %s encountered for committing thread, which should not happen, according to this, state machine may not have further progress, stop the system", error, error.getMessage()); System.exit(-1);
this.handleInstallSnapshotResponse(response); }else{ this.logger.error("Received an unexpected message %s for response, system exits.", response.getMessageType().toString()); System.exit(-1);
private synchronized RaftResponseMessage handleExtendedMessages(RaftRequestMessage request){ if(request.getMessageType() == RaftMessageType.AddServerRequest){ return this.handleAddServerRequest(request); }else if(request.getMessageType() == RaftMessageType.RemoveServerRequest){ return this.handleRemoveServerRequest(request); }else if(request.getMessageType() == RaftMessageType.SyncLogRequest){ return this.handleLogSyncRequest(request); }else if(request.getMessageType() == RaftMessageType.JoinClusterRequest){ return this.handleJoinClusterRequest(request); }else if(request.getMessageType() == RaftMessageType.LeaveClusterRequest){ return this.handleLeaveClusterRequest(request); }else if(request.getMessageType() == RaftMessageType.InstallSnapshotRequest){ return this.handleInstallSnapshotRequest(request); }else{ this.logger.error("receive an unknown request %s, for safety, step down.", request.getMessageType().toString()); this.stateMachine.exit(-1); } return null; }
private synchronized RaftResponseMessage handleExtendedMessages(RaftRequestMessage request){ if(request.getMessageType() == RaftMessageType.AddServerRequest){ return this.handleAddServerRequest(request); }else if(request.getMessageType() == RaftMessageType.RemoveServerRequest){ return this.handleRemoveServerRequest(request); }else if(request.getMessageType() == RaftMessageType.SyncLogRequest){ return this.handleLogSyncRequest(request); }else if(request.getMessageType() == RaftMessageType.JoinClusterRequest){ return this.handleJoinClusterRequest(request); }else if(request.getMessageType() == RaftMessageType.LeaveClusterRequest){ return this.handleLeaveClusterRequest(request); }else if(request.getMessageType() == RaftMessageType.InstallSnapshotRequest){ return this.handleInstallSnapshotRequest(request); }else{ this.logger.error("receive an unknown request %s, for safety, step down.", request.getMessageType().toString()); this.stateMachine.exit(-1); } return null; }
this.handleInstallSnapshotResponse(response); }else{ this.logger.error("Received an unexpected message %s for response, system exits.", response.getMessageType().toString()); this.stateMachine.exit(-1);
server.logger.error("error %s encountered for committing thread, which should not happen, according to this, state machine may not have further progress, stop the system", error, error.getMessage()); server.stateMachine.exit(-1);
this.handleInstallSnapshotResponse(response); }else{ this.logger.error("Received an unexpected message %s for response, system exits.", response.getMessageType().toString()); this.stateMachine.exit(-1);
this.logger.error("A leader should never encounter election timeout, illegal application state, stop the application"); this.stateMachine.exit(-1); return;
server.logger.error("error %s encountered for committing thread, which should not happen, according to this, state machine may not have further progress, stop the system", error, error.getMessage()); server.stateMachine.exit(-1);
this.logger.error("Peer's lastLogIndex is too large %d v.s. %d, server exits", lastLogIndex, currentNextIndex); this.stateMachine.exit(-1);
this.becomeFollower(); }else if(this.role == ServerRole.Leader){ this.logger.error("Receive InstallSnapshotRequest from another leader(%d) with same term, there must be a bug, server exits", request.getSource()); this.stateMachine.exit(-1); }else{ this.logger.error("Received a snapshot which is older than this server (%d)", this.id); response.setNextIndex(0); response.setAccepted(false);