private RaftResponseMessage handleClientRequest(RaftRequestMessage request){ RaftResponseMessage response = new RaftResponseMessage(); response.setMessageType(RaftMessageType.AppendEntriesResponse); response.setSource(this.id); response.setDestination(this.leader); response.setTerm(this.state.getTerm()); long term; synchronized(this){ if(this.role != ServerRole.Leader){ response.setAccepted(false); return response; } term = this.state.getTerm(); } LogEntry[] logEntries = request.getLogEntries(); if(logEntries != null && logEntries.length > 0){ for(int i = 0; i < logEntries.length; ++i){ this.stateMachine.preCommit(this.logStore.append(new LogEntry(term, logEntries[i].getValue())), logEntries[i].getValue()); } } // Urgent commit, so that the commit will not depend on heartbeat this.requestAppendEntries(); response.setAccepted(true); response.setNextIndex(this.logStore.getFirstAvailableIndex()); return response; }
private RaftResponseMessage handleClientRequest(RaftRequestMessage request){ RaftResponseMessage response = new RaftResponseMessage(); response.setMessageType(RaftMessageType.AppendEntriesResponse); response.setSource(this.id); response.setDestination(this.leader); response.setTerm(this.state.getTerm()); long term; synchronized(this){ if(this.role != ServerRole.Leader){ response.setAccepted(false); return response; } term = this.state.getTerm(); } LogEntry[] logEntries = request.getLogEntries(); if(logEntries != null && logEntries.length > 0){ for(int i = 0; i < logEntries.length; ++i){ this.stateMachine.preCommit(this.logStore.append(new LogEntry(term, logEntries[i].getValue())), logEntries[i].getValue()); } } // Urgent commit, so that the commit will not depend on heartbeat this.requestAppendEntries(); response.setAccepted(true); response.setNextIndex(this.logStore.getFirstAvailableIndex()); return response; }
private RaftResponseMessage handleClientRequest(RaftRequestMessage request){ RaftResponseMessage response = new RaftResponseMessage(); response.setMessageType(RaftMessageType.AppendEntriesResponse); response.setSource(this.id); response.setDestination(this.leader); response.setTerm(this.state.getTerm()); long term; synchronized(this){ if(this.role != ServerRole.Leader){ response.setAccepted(false); return response; } term = this.state.getTerm(); } LogEntry[] logEntries = request.getLogEntries(); if(logEntries != null && logEntries.length > 0){ for(int i = 0; i < logEntries.length; ++i){ this.stateMachine.preCommit(this.logStore.append(new LogEntry(term, logEntries[i].getValue())), logEntries[i].getValue()); } } // Urgent commit, so that the commit will not depend on heartbeat this.requestAppendEntries(); response.setAccepted(true); response.setNextIndex(this.logStore.getFirstAvailableIndex()); return response; }
this.logStore.writeAt(index, logEntry); if (logEntry.getValueType() == LogValueType.Application) { this.stateMachine.preCommit(index, logEntry.getValue()); } else if (logEntry.getValueType() == LogValueType.Configuration) { this.logger.info("received a configuration change at index %d from leader", index); this.configChanging = true; } else if(logEntry.getValueType() == LogValueType.Application) { this.stateMachine.preCommit(indexForEntry, logEntry.getValue());
this.logStore.writeAt(index, logEntry); if (logEntry.getValueType() == LogValueType.Application) { this.stateMachine.preCommit(index, logEntry.getValue()); } else if (logEntry.getValueType() == LogValueType.Configuration) { this.logger.info("received a configuration change at index %d from leader", index); this.configChanging = true; } else if(logEntry.getValueType() == LogValueType.Application) { this.stateMachine.preCommit(indexForEntry, logEntry.getValue());
this.configChanging = true; }else{ this.stateMachine.preCommit(indexForEntry, logEntry.getValue());