Beispiel #1
0
func NewSimpleTxnSubmitter(rmId common.RMId, bootCount uint32, topology *server.Topology, cm paxos.ConnectionManager) *SimpleTxnSubmitter {
	rng := rand.New(rand.NewSource(time.Now().UnixNano()))
	resolver := ch.NewResolver(rng, topology.AllRMs)
	disabled := make(map[common.RMId]server.EmptyStruct, len(topology.AllRMs))
	for _, rmId := range topology.AllRMs {
		disabled[rmId] = server.EmptyStructVal
	}

	cache := ch.NewCache(resolver, topology.AllRMs.NonEmptyLen(), rng)
	if topology.RootVarUUId != nil {
		cache.AddPosition(topology.RootVarUUId, topology.RootPositions)
	}

	sts := &SimpleTxnSubmitter{
		rmId:              rmId,
		bootCount:         bootCount,
		disabledHashCodes: disabled,
		connections:       nil,
		connectionManager: cm,
		outcomeConsumers:  make(map[common.TxnId]txnOutcomeConsumer),
		onShutdown:        make(map[*func(bool)]server.EmptyStruct),
		resolver:          resolver,
		hashCache:         cache,
		topology:          topology,
		rng:               rng,
	}
	return sts
}
Beispiel #2
0
func (sts *SimpleTxnSubmitter) TopologyChange(topology *server.Topology, servers map[common.RMId]paxos.Connection) {
	if topology != nil {
		server.Log("TM setting topology to", topology)
		sts.topology = topology
		sts.resolver = ch.NewResolver(sts.rng, topology.AllRMs)
		sts.hashCache.SetResolverDesiredLen(sts.resolver, topology.AllRMs.NonEmptyLen())
		if topology.RootVarUUId != nil {
			sts.hashCache.AddPosition(topology.RootVarUUId, topology.RootPositions)
		}

		if !topology.Equal(server.BlankTopology) && sts.bufferedSubmissions != nil {
			funcs := sts.bufferedSubmissions
			sts.bufferedSubmissions = nil
			for _, fun := range funcs {
				fun()
			}
		}
	}
	if servers != nil {
		sts.disabledHashCodes = make(map[common.RMId]server.EmptyStruct, len(sts.topology.AllRMs))
		for _, rmId := range sts.topology.AllRMs {
			if _, found := servers[rmId]; !found {
				sts.disabledHashCodes[rmId] = server.EmptyStructVal
			}
		}
		sts.connections = servers
		server.Log("TM disabled hash codes", sts.disabledHashCodes)
	}
}
Beispiel #3
0
func newLocationChecker(stores stores) *locationChecker {
	resolver := ch.NewResolver(stores[0].topology.RMs(), stores[0].topology.TwoFInc)
	m := make(map[common.RMId]*store, len(stores))
	for _, s := range stores {
		m[s.rmId] = s
	}
	return &locationChecker{
		resolver: resolver,
		stores:   m,
	}
}
Beispiel #4
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()
}
Beispiel #5
0
func (g *Generator) SatisfiedBy(topology *Topology, positions *common.Positions) (bool, error) {
	rms := topology.RMs()
	twoFInc := topology.TwoFInc
	if g.UseNext {
		next := topology.Next()
		rms = next.RMs()
		twoFInc = (uint16(next.F) * 2) + 1
	}
	server.Log("Generator:SatisfiedBy:NewResolver:", rms, twoFInc)
	resolver := ch.NewResolver(rms, twoFInc)
	perm, err := resolver.ResolveHashCodes((*capn.UInt8List)(positions).ToArray())
	if err != nil {
		return false, err
	}
	for _, rmId := range perm {
		if rmId == g.RMId {
			return g.Includes, nil
		}
	}
	return !g.Includes, nil

}