예제 #1
0
파일: election.go 프로젝트: bvk/ascent
func (this *Election) doUpdateConfig(change *thispb.Configuration) error {
	walRecord := thispb.WALRecord{}
	walRecord.ConfigChange = change
	_, errSync := wal.SyncChangeProto(this.wal, this.uid, &walRecord)
	if errSync != nil {
		this.Errorf("could not append config change wal record: %v", errSync)
		return errSync
	}

	this.doRestoreConfig(change)
	return nil
}
예제 #2
0
파일: election.go 프로젝트: bvk/ascent
func (this *Election) doUpdateCommittee(change *thispb.CommitteeChange) error {
	if !this.wal.IsRecovering() {
		walRecord := thispb.WALRecord{}
		walRecord.CommitteeChange = change
		_, errSync := wal.SyncChangeProto(this.wal, this.uid, &walRecord)
		if errSync != nil {
			this.Errorf("could not write committee change wal record: %v", errSync)
			return errSync
		}
	}

	round := change.GetNewElectionRound()
	winner := change.GetNewElectionWinner()
	this.electionHistoryMap[round] = winner
	return nil
}
예제 #3
0
파일: paxos.go 프로젝트: bvk/ascent
func (this *Paxos) doUpdateProposer(change *thispb.ProposerChange) error {
	if !this.wal.IsRecovering() {
		walRecord := thispb.WALRecord{}
		walRecord.ProposerChange = change
		_, errSync := wal.SyncChangeProto(this.wal, this.uid, &walRecord)
		if errSync != nil {
			this.Errorf("could not write proposer change record: %v", errSync)
			return errSync
		}
	}

	if change.ProposalBallot != nil {
		ballot := change.GetProposalBallot()
		if this.proposalBallot < ballot {
			this.proposalBallot = ballot
		}
	}
	return nil
}
예제 #4
0
파일: paxos.go 프로젝트: bvk/ascent
func (this *Paxos) doUpdateAcceptor(change *thispb.AcceptorChange) error {
	if !this.wal.IsRecovering() {
		walRecord := thispb.WALRecord{}
		walRecord.AcceptorChange = change
		_, errSync := wal.SyncChangeProto(this.wal, this.uid, &walRecord)
		if errSync != nil {
			this.Errorf("could not write acceptor change record: %v", errSync)
			return errSync
		}
	}

	if change.PromisedBallot != nil {
		this.promisedBallot = change.GetPromisedBallot()
	}

	if change.VotedBallot != nil {
		ballot := change.GetVotedBallot()
		value := change.GetVotedValue()
		this.votedBallot = ballot
		this.votedValue = value
		this.votedValueMap[ballot] = value
	}

	if change.AckedLearner != nil {
		learner := change.GetAckedLearner()
		if change.GetAckedChosenValue() {
			this.doneLearnerSet[learner] = struct{}{}
		} else {
			for _, ballot := range change.GetAckedBallotList() {
				learnerSet, found := this.learnerAckMap[ballot]
				if !found {
					learnerSet = make(map[string]struct{})
					this.learnerAckMap[ballot] = learnerSet
				}
				learnerSet[learner] = struct{}{}
			}
		}
	}
	return nil
}