func make_config(t *testing.T, tag string, n int, unreliable bool, maxraftstate int) *config { runtime.GOMAXPROCS(4) cfg := &config{} cfg.t = t cfg.tag = tag cfg.net = labrpc.MakeNetwork() cfg.n = n cfg.kvservers = make([]*RaftKV, cfg.n) cfg.saved = make([]*raft.Persister, cfg.n) cfg.endnames = make([][]string, cfg.n) cfg.clerks = make(map[*Clerk][]string) cfg.nextClientId = cfg.n + 1000 // client ids start 1000 above the highest serverid cfg.maxraftstate = maxraftstate // create a full set of KV servers. for i := 0; i < cfg.n; i++ { cfg.StartServer(i) } cfg.ConnectAll() cfg.net.Reliable(!unreliable) return cfg }
func make_config(t *testing.T, n int, unreliable bool) *config { runtime.GOMAXPROCS(4) cfg := &config{} cfg.t = t cfg.net = labrpc.MakeNetwork() cfg.n = n cfg.applyErr = make([]string, cfg.n) cfg.rafts = make([]*Raft, cfg.n) cfg.connected = make([]bool, cfg.n) cfg.saved = make([]*Persister, cfg.n) cfg.endnames = make([][]string, cfg.n) cfg.logs = make([]map[int]int, cfg.n) cfg.setunreliable(unreliable) cfg.net.LongDelays(true) // create a full set of Rafts. for i := 0; i < cfg.n; i++ { cfg.logs[i] = map[int]int{} cfg.start1(i) } // connect everyone for i := 0; i < cfg.n; i++ { cfg.connect(i) } return cfg }
func make_config(t *testing.T, n int, unreliable bool, maxraftstate int) *config { runtime.GOMAXPROCS(4) cfg := &config{} cfg.t = t cfg.maxraftstate = maxraftstate cfg.net = labrpc.MakeNetwork() // master cfg.nmasters = 3 cfg.masterservers = make([]*shardmaster.ShardMaster, cfg.nmasters) for i := 0; i < cfg.nmasters; i++ { cfg.StartMasterServer(i) } cfg.mck = cfg.shardclerk() cfg.ngroups = 3 cfg.groups = make([]*group, cfg.ngroups) cfg.n = n for gi := 0; gi < cfg.ngroups; gi++ { gg := &group{} cfg.groups[gi] = gg gg.gid = 100 + gi gg.servers = make([]*ShardKV, cfg.n) gg.saved = make([]*raft.Persister, cfg.n) gg.endnames = make([][]string, cfg.n) gg.mendnames = make([][]string, cfg.nmasters) for i := 0; i < cfg.n; i++ { cfg.StartServer(gi, i) } } cfg.clerks = make(map[*Clerk][]string) cfg.nextClientId = cfg.n + 1000 // client ids start 1000 above the highest serverid cfg.net.Reliable(!unreliable) return cfg }