this.stateMachine.exit(0); return;
this.stateMachine.exit(0); return;
this.stateMachine.exit(-1); return null; this.stateMachine.exit(-1); return null; if(sizeRead < data.length){ this.logger.error("only %d bytes could be read from snapshot while %d bytes are expected, should be something wrong" , sizeRead, data.length); this.stateMachine.exit(-1); return null; this.stateMachine.exit(-1); return null;
this.stateMachine.exit(-1); return null; this.stateMachine.exit(-1); return null; if(sizeRead < data.length){ this.logger.error("only %d bytes could be read from snapshot while %d bytes are expected, should be something wrong" , sizeRead, data.length); this.stateMachine.exit(-1); return null; this.stateMachine.exit(-1); return null;
this.stateMachine.exit(-1); 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.stateMachine.exit(-1); return false;
this.stateMachine.exit(-1); 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.stateMachine.exit(-1); return false;
if(lastSnapshot == null){ this.logger.error("No snapshot could be found while no configuration cannot be found in current committed logs, this is a system error, exiting"); this.stateMachine.exit(-1); return; }else if(config.getLogIndex() > indexCommitted && config.getLastLogIndex() == 0){ this.logger.error("BUG!!! stop the system, there must be a configuration at index one"); this.stateMachine.exit(-1);
if(lastSnapshot == null){ this.logger.error("No snapshot could be found while no configuration cannot be found in current committed logs, this is a system error, exiting"); this.stateMachine.exit(-1); return; }else if(config.getLogIndex() > indexCommitted && config.getLastLogIndex() == 0){ this.logger.error("BUG!!! stop the system, there must be a configuration at index one"); this.stateMachine.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; }
}else{ this.logger.error("Received an unexpected message %s for response, system exits.", response.getMessageType().toString()); this.stateMachine.exit(-1);
}catch(Throwable error){ 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);
}else{ this.logger.error("Received an unexpected message %s for response, system exits.", response.getMessageType().toString()); this.stateMachine.exit(-1);
}catch(Throwable error){ 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.stateMachine.exit(-1);
this.stateMachine.exit(-1);
}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.restartElectionTimer();
}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.restartElectionTimer();