Example #1
0
func (p *Proposer) TopologyChange(topology *configuration.Topology) {
	if topology == p.topology {
		return
	}
	p.topology = topology
	rmsRemoved := topology.RMsRemoved()
	server.Log("proposer", p.txnId, "in", p.currentState, "sees loss of", rmsRemoved)
	if _, found := rmsRemoved[p.proposerManager.RMId]; found {
		return
	}
	// create new acceptors slice because the initial slice can be
	// shared with proposals.
	acceptors := make([]common.RMId, 0, len(p.acceptors))
	for _, rmId := range p.acceptors {
		if _, found := rmsRemoved[rmId]; !found {
			acceptors = append(acceptors, rmId)
		}
	}
	p.acceptors = acceptors

	switch p.currentState {
	case &p.proposerAwaitBallots, &p.proposerReceiveOutcomes, &p.proposerAwaitLocallyComplete:
		if p.outcomeAccumulator.TopologyChange(topology) {
			p.allAcceptorsAgree()
		}
	case &p.proposerReceiveGloballyComplete:
		for rmId := range rmsRemoved {
			p.TxnGloballyCompleteReceived(rmId)
		}
	case &p.proposerAwaitFinished:
		// do nothing
	}
}
Example #2
0
func (cach *connectionAwaitClientHandshake) verifyPeerCerts(topology *configuration.Topology, peerCerts []*x509.Certificate) (authenticated bool, hashsum [sha256.Size]byte) {
	fingerprints := topology.Fingerprints()
	for _, cert := range peerCerts {
		hashsum = sha256.Sum256(cert.Raw)
		if _, found := fingerprints[hashsum]; found {
			return true, hashsum
		}
	}
	return false, hashsum
}
Example #3
0
func (sts *SimpleTxnSubmitter) TopologyChanged(topology *configuration.Topology) {
	if topology == nil || topology.RMs().NonEmptyLen() < int(topology.TwoFInc) {
		// topology is needed for client txns. As we're booting up, we
		// just don't care.
		return
	}
	sts.topology = topology
	sts.resolver = ch.NewResolver(topology.RMs(), topology.TwoFInc)
	sts.hashCache.SetResolver(sts.resolver)
	if topology.Root.VarUUId != nil {
		sts.hashCache.AddPosition(topology.Root.VarUUId, topology.Root.Positions)
	}
	sts.calculateDisabledHashcodes()
}
Example #4
0
func (oa *OutcomeAccumulator) TopologyChange(topology *configuration.Topology) bool {
	result := false
	for rmId := range topology.RMsRemoved() {
		if _, found := oa.pendingTGC[rmId]; found {
			delete(oa.pendingTGC, rmId)
			if outcome, found := oa.acceptorIdToTxnOutcome[rmId]; found {
				delete(oa.acceptorIdToTxnOutcome, rmId)
				outcome.outcomeReceivedCount--
			}
			oa.acceptorCount--
			if oa.acceptorCount > oa.fInc {
				oa.fInc = oa.acceptorCount
			}
			if oa.decidingOutcome != nil {
				result = result || oa.decidingOutcome.outcomeReceivedCount == oa.acceptorCount
			}
		}
	}
	return result
}
Example #5
0
func (vm *VarManager) TopologyChanged(topology *configuration.Topology, done func(bool)) {
	resultChan := make(chan struct{})
	enqueued := vm.exe.Enqueue(func() {
		if od := vm.onDisk; od != nil {
			vm.onDisk = nil
			od(false)
		}
		vm.Topology = topology
		oldRollAllowed := vm.RollAllowed
		if !vm.RollAllowed {
			vm.RollAllowed = topology == nil || !topology.NextBarrierReached1(vm.RMId)
		}
		server.Log("VarManager", fmt.Sprintf("%p", vm), "rollAllowed:", oldRollAllowed, "->", vm.RollAllowed, fmt.Sprintf("%p", topology))

		goingToDisk := topology != nil && topology.NextBarrierReached1(vm.RMId) && !topology.NextBarrierReached2(vm.RMId)

		doneWrapped := func(result bool) {
			close(resultChan)
			done(result)
		}
		if goingToDisk {
			vm.onDisk = doneWrapped
			vm.checkAllDisk()
		} else {
			server.Log("VarManager", fmt.Sprintf("%p", vm), "calling done", fmt.Sprintf("%p", topology))
			doneWrapped(true)
		}
	})
	if enqueued {
		go vm.exe.WithTerminatedChan(func(terminated chan struct{}) {
			select {
			case <-resultChan:
			case <-terminated:
				select {
				case <-resultChan:
				default:
					done(false)
				}
			}
		})
	} else {
		done(false)
	}
}