Example #1
0
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
}
Example #2
0
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
}
Example #3
0
File: paxos.go Project: 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
}
Example #4
0
File: paxos.go Project: 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
}