if(response.isAccepted()){ synchronized(peer){ peer.setNextLogIndex(response.getNextIndex()); peer.setMatchedIndex(response.getNextIndex() - 1); peer.setNextLogIndex(response.getNextIndex()); }else{ peer.setNextLogIndex(peer.getNextLogIndex() - 1);
if(response.isAccepted()){ synchronized(peer){ peer.setNextLogIndex(response.getNextIndex()); peer.setMatchedIndex(response.getNextIndex() - 1); peer.setNextLogIndex(response.getNextIndex()); }else{ peer.setNextLogIndex(peer.getNextLogIndex() - 1);
if(response.isAccepted()){ synchronized(peer){ peer.setNextLogIndex(response.getNextIndex()); peer.setMatchedIndex(response.getNextIndex() - 1); peer.setNextLogIndex(response.getNextIndex()); }else{ peer.setNextLogIndex(peer.getNextLogIndex() - 1);
if(server.getId() != this.id){ PeerServer peer = new PeerServer(server, context, peerServer -> this.handleHeartbeatTimeout(peerServer)); peer.setNextLogIndex(this.logStore.getFirstAvailableIndex()); this.peers.put(server.getId(), peer); this.logger.info("server %d is added to cluster", peer.getId()); this.enableHeartbeatForPeer(peer); if(this.serverToJoin != null && this.serverToJoin.getId() == peer.getId()){ peer.setNextLogIndex(this.serverToJoin.getNextLogIndex()); this.serverToJoin = null;
if(server.getId() != this.id){ PeerServer peer = new PeerServer(server, context, peerServer -> this.handleHeartbeatTimeout(peerServer)); peer.setNextLogIndex(this.logStore.getFirstAvailableIndex()); this.peers.put(server.getId(), peer); this.logger.info("server %d is added to cluster", peer.getId()); this.enableHeartbeatForPeer(peer); if(this.serverToJoin != null && this.serverToJoin.getId() == peer.getId()){ peer.setNextLogIndex(this.serverToJoin.getNextLogIndex()); this.serverToJoin = null;
if(server.getId() != this.id){ PeerServer peer = new PeerServer(server, context, peerServer -> this.handleHeartbeatTimeout(peerServer)); peer.setNextLogIndex(this.logStore.getFirstAvailableIndex()); this.peers.put(server.getId(), peer); this.logger.info("server %d is added to cluster", peer.getId()); this.enableHeartbeatForPeer(peer); if(this.serverToJoin != null && this.serverToJoin.getId() == peer.getId()){ peer.setNextLogIndex(this.serverToJoin.getNextLogIndex()); this.serverToJoin = null;
private void becomeLeader(){ this.stopElectionTimer(); this.role = ServerRole.Leader; this.leader = this.id; this.serverToJoin = null; for(PeerServer server : this.peers.values()){ server.setNextLogIndex(this.logStore.getFirstAvailableIndex()); server.setSnapshotInSync(null); server.setFree(); this.enableHeartbeatForPeer(server); } // if current config is not committed, try to commit it if(this.config.getLogIndex() == 0){ this.config.setLogIndex(this.logStore.getFirstAvailableIndex()); this.logStore.append(new LogEntry(this.state.getTerm(), this.config.toBytes(), LogValueType.Configuration)); this.logger.info("add initial configuration to log store"); this.configChanging = true; } this.requestAppendEntries(); }
private void becomeLeader(){ this.stopElectionTimer(); this.role = ServerRole.Leader; this.leader = this.id; this.serverToJoin = null; for(PeerServer server : this.peers.values()){ server.setNextLogIndex(this.logStore.getFirstAvailableIndex()); server.setSnapshotInSync(null); server.setFree(); this.enableHeartbeatForPeer(server); } // if current config is not committed, try to commit it if(this.config.getLogIndex() == 0){ this.config.setLogIndex(this.logStore.getFirstAvailableIndex()); this.logStore.append(new LogEntry(this.state.getTerm(), this.config.toBytes(), LogValueType.Configuration)); this.logger.info("add initial configuration to log store"); this.configChanging = true; } this.requestAppendEntries(); }
private void becomeLeader(){ this.stopElectionTimer(); this.role = ServerRole.Leader; this.leader = this.id; this.serverToJoin = null; for(PeerServer server : this.peers.values()){ server.setNextLogIndex(this.logStore.getFirstAvailableIndex()); server.setSnapshotInSync(null); server.setFree(); this.enableHeartbeatForPeer(server); } // if current config is not committed, try to commit it if(this.config.getLogIndex() == 0){ this.config.setLogIndex(this.logStore.getFirstAvailableIndex()); this.logStore.append(new LogEntry(this.state.getTerm(), this.config.toBytes(), LogValueType.Configuration)); this.logger.info("add initial configuration to log store"); this.configChanging = true; } this.requestAppendEntries(); }
peer.setNextLogIndex(currentNextIndex);
if(response.getNextIndex() >= context.getSnapshot().getSize()){ this.logger.debug("snapshot sync is done"); peer.setNextLogIndex(context.getSnapshot().getLastLogIndex() + 1); peer.setMatchedIndex(context.getSnapshot().getLastLogIndex()); peer.setSnapshotInSync(null);
if(response.getNextIndex() >= context.getSnapshot().getSize()){ this.logger.debug("snapshot sync is done"); peer.setNextLogIndex(context.getSnapshot().getLastLogIndex() + 1); peer.setMatchedIndex(context.getSnapshot().getLastLogIndex()); peer.setSnapshotInSync(null);
peer.setNextLogIndex(currentNextIndex);
if(response.getNextIndex() >= context.getSnapshot().getSize()){ this.logger.debug("snapshot sync is done"); peer.setNextLogIndex(context.getSnapshot().getLastLogIndex() + 1); peer.setMatchedIndex(context.getSnapshot().getLastLogIndex()); peer.setSnapshotInSync(null);
peer.setNextLogIndex(currentNextIndex);
this.serverToJoin.setNextLogIndex(response.getNextIndex()); this.serverToJoin.setMatchedIndex(response.getNextIndex() - 1); this.syncLogsToNewComingServer(response.getNextIndex()); this.serverToJoin.setNextLogIndex(context.getSnapshot().getLastLogIndex() + 1); this.serverToJoin.setMatchedIndex(context.getSnapshot().getLastLogIndex()); }else{
this.serverToJoin.setNextLogIndex(response.getNextIndex()); this.serverToJoin.setMatchedIndex(response.getNextIndex() - 1); this.syncLogsToNewComingServer(response.getNextIndex()); this.serverToJoin.setNextLogIndex(context.getSnapshot().getLastLogIndex() + 1); this.serverToJoin.setMatchedIndex(context.getSnapshot().getLastLogIndex()); }else{
this.serverToJoin.setNextLogIndex(response.getNextIndex()); this.serverToJoin.setMatchedIndex(response.getNextIndex() - 1); this.syncLogsToNewComingServer(response.getNextIndex()); this.serverToJoin.setNextLogIndex(context.getSnapshot().getLastLogIndex() + 1); this.serverToJoin.setMatchedIndex(context.getSnapshot().getLastLogIndex()); }else{