Пример #1
0
func initReplica() *Replica {
	peers := make([]string, 3)
	r := &Replica{genericsmr.NewReplica(0, peers, false, false, false),
		make(chan *Propose, CHAN_BUFFER_SIZE),
		make(chan *epaxosproto.Prepare, CHAN_BUFFER_SIZE),
		make(chan *epaxosproto.PreAccept, CHAN_BUFFER_SIZE),
		make(chan *epaxosproto.PreAccept, CHAN_BUFFER_SIZE),
		make(chan *epaxosproto.Accept, CHAN_BUFFER_SIZE),
		make(chan *epaxosproto.Commit, CHAN_BUFFER_SIZE),
		make(chan *epaxosproto.PrepareReply, CHAN_BUFFER_SIZE),
		make(chan *epaxosproto.PreAcceptReply, CHAN_BUFFER_SIZE),
		make(chan *epaxosproto.PreAcceptOK, CHAN_BUFFER_SIZE),
		make(chan *epaxosproto.AcceptReply, CHAN_BUFFER_SIZE),
		make([][]*Instance, 3),
		make([]int32, 3),
		false,
		0,
		make([]int32, 3),
		nil}

	for i := 0; i < r.N; i++ {
		r.InstanceSpace[i] = make([]*Instance, 1024*1024)
		r.crtInstance[i] = 0
		r.ExecedUpTo[i] = -1
	}

	r.exec = &Exec{r}

	return r
}
Пример #2
0
func NewReplica(id int, peerAddrList []string, thrifty bool, exec bool, dreply bool, durable bool) *Replica {
	r := &Replica{genericsmr.NewReplica(id, peerAddrList, thrifty, exec, dreply),
		make(chan fastrpc.Serializable, genericsmr.CHAN_BUFFER_SIZE),
		make(chan fastrpc.Serializable, genericsmr.CHAN_BUFFER_SIZE),
		make(chan fastrpc.Serializable, genericsmr.CHAN_BUFFER_SIZE),
		make(chan fastrpc.Serializable, genericsmr.CHAN_BUFFER_SIZE),
		make(chan fastrpc.Serializable, genericsmr.CHAN_BUFFER_SIZE),
		make(chan fastrpc.Serializable, 3*genericsmr.CHAN_BUFFER_SIZE),
		0, 0, 0, 0, 0, 0,
		false,
		make([]*Instance, 15*1024*1024),
		0,
		-1,
		false,
		0,
		true,
		-1}

	r.Durable = durable

	r.prepareRPC = r.RegisterRPC(new(paxosproto.Prepare), r.prepareChan)
	r.acceptRPC = r.RegisterRPC(new(paxosproto.Accept), r.acceptChan)
	r.commitRPC = r.RegisterRPC(new(paxosproto.Commit), r.commitChan)
	r.commitShortRPC = r.RegisterRPC(new(paxosproto.CommitShort), r.commitShortChan)
	r.prepareReplyRPC = r.RegisterRPC(new(paxosproto.PrepareReply), r.prepareReplyChan)
	r.acceptReplyRPC = r.RegisterRPC(new(paxosproto.AcceptReply), r.acceptReplyChan)

	go r.run()

	return r
}
Пример #3
0
func NewReplica(id int, peerAddrList []string, thrifty bool, exec bool, dreply bool) *Replica {
	r := &Replica{genericsmr.NewReplica(id, peerAddrList, thrifty, exec, dreply),
		make(chan *gpaxosproto.Prepare, CHAN_BUFFER_SIZE),
		make(chan *gpaxosproto.M_1a, CHAN_BUFFER_SIZE),
		make(chan *gpaxosproto.M_1b, CHAN_BUFFER_SIZE),
		make(chan *gpaxosproto.M_2a, CHAN_BUFFER_SIZE),
		make(chan *gpaxosproto.M_2b, CHAN_BUFFER_SIZE),
		make(chan *gpaxosproto.Commit, CHAN_BUFFER_SIZE),
		false,
		0,
		3,
		make([]*Ballot, 2*1024*1024),
		make(map[int32]*state.Command, 100000),
		new(sync.Mutex),
		make(map[int32]bool, 100000),
		make(map[int32]*genericsmr.Propose, 200),
		-1,
		false,
		false,
		0,
		false}

	r.fastQSize = 3 * r.N / 4
	if r.fastQSize*4 < 3*r.N {
		r.fastQSize++
	}

	go r.run()

	return r
}
Пример #4
0
func NewReplica(id int, peerAddrList []string, thrifty bool, exec bool, dreply bool, durable bool, beacon bool, leaseRep *lpaxos.Replica, directAcks bool) *Replica {
	r := &Replica{genericsmr.NewReplica(id, peerAddrList, thrifty, exec, dreply),
		make(chan fastrpc.Serializable, genericsmr.CHAN_BUFFER_SIZE),
		make(chan fastrpc.Serializable, genericsmr.CHAN_BUFFER_SIZE),
		make(chan fastrpc.Serializable, genericsmr.CHAN_BUFFER_SIZE),
		make(chan fastrpc.Serializable, genericsmr.CHAN_BUFFER_SIZE),
		make(chan fastrpc.Serializable, genericsmr.CHAN_BUFFER_SIZE),
		make(chan fastrpc.Serializable, 3*genericsmr.CHAN_BUFFER_SIZE),
		make(chan fastrpc.Serializable, genericsmr.CHAN_BUFFER_SIZE),
		make(chan fastrpc.Serializable, genericsmr.CHAN_BUFFER_SIZE),
		0, 0, 0, 0, 0, 0, 0, 0,
		false,
		0,
		make([]*Instance, 15*1024*1024),
		0,
		-1,
		false,
		0,
		true,
		leaseRep,
		make(map[state.Key][]int32, HT_INIT_SIZE),
		make(map[state.Key]bool, HT_INIT_SIZE),
		-1,
		make(chan int32, genericsmr.CHAN_BUFFER_SIZE),
		make(map[state.Key]int, 15000),
		new(sync.Mutex),
		-1,
		-1,
		make(chan *genericsmr.Propose, READ_CHAN_SIZE),
		make(chan *paxosproto.Forward, READ_CHAN_SIZE),
		make(map[int32]*genericsmr.Propose, 200000),
		0,
		nil,
		true,
		directAcks,
		make([]bool, len(peerAddrList)),
		true}

	r.Durable = durable
	r.Beacon = beacon

	r.prepareRPC = r.RegisterRPC(new(paxosproto.Prepare), r.prepareChan)
	r.acceptRPC = r.RegisterRPC(new(paxosproto.Accept), r.acceptChan)
	r.commitRPC = r.RegisterRPC(new(paxosproto.Commit), r.commitChan)
	r.commitShortRPC = r.RegisterRPC(new(paxosproto.CommitShort), r.commitShortChan)
	r.prepareReplyRPC = r.RegisterRPC(new(paxosproto.PrepareReply), r.prepareReplyChan)
	r.acceptReplyRPC = r.RegisterRPC(new(paxosproto.AcceptReply), r.acceptReplyChan)
	r.forwardRPC = r.RegisterRPC(new(paxosproto.Forward), r.forwardChan)
	r.forwardReplyRPC = r.RegisterRPC(new(paxosproto.ForwardReply), r.forwardReplyChan)

	go r.run()

	return r
}
Пример #5
0
func NewReplica(id int, peerAddrList []string, thrifty bool, exec bool, dreply bool, durable bool) *Replica {
	skippedTo := make([]int32, len(peerAddrList))
	for i := 0; i < len(skippedTo); i++ {
		skippedTo[i] = -1
	}
	r := &Replica{genericsmr.NewReplica(id, peerAddrList, thrifty, exec, dreply),
		make(chan fastrpc.Serializable, genericsmr.CHAN_BUFFER_SIZE*4),
		make(chan fastrpc.Serializable, genericsmr.CHAN_BUFFER_SIZE),
		make(chan fastrpc.Serializable, genericsmr.CHAN_BUFFER_SIZE),
		make(chan fastrpc.Serializable, genericsmr.CHAN_BUFFER_SIZE),
		make(chan fastrpc.Serializable, genericsmr.CHAN_BUFFER_SIZE),
		make(chan fastrpc.Serializable, genericsmr.CHAN_BUFFER_SIZE*4),
		make(chan *DelayedSkip, genericsmr.CHAN_BUFFER_SIZE),
		0, 0, 0, 0, 0, 0,
		make(chan bool, 10),
		make([]*Instance, 10*1024*1024),
		int32(id),
		int32(-1),
		int32(0),
		int32(0),
		0,
		false,
		false,
		0,
		0,
		skippedTo}

	r.Durable = durable

	r.skipRPC = r.RegisterRPC(new(menciusproto.Skip), r.skipChan)
	r.prepareRPC = r.RegisterRPC(new(menciusproto.Prepare), r.prepareChan)
	r.acceptRPC = r.RegisterRPC(new(menciusproto.Accept), r.acceptChan)
	r.commitRPC = r.RegisterRPC(new(menciusproto.Commit), r.commitChan)
	r.prepareReplyRPC = r.RegisterRPC(new(menciusproto.PrepareReply), r.prepareReplyChan)
	r.acceptReplyRPC = r.RegisterRPC(new(menciusproto.AcceptReply), r.acceptReplyChan)

	go r.run()

	return r
}
Пример #6
0
func NewReplica(id int, peerAddrList []string, thrifty bool, exec bool, dreply bool, beacon bool, durable bool) *Replica {
	r := &Replica{
		genericsmr.NewReplica(id, peerAddrList, thrifty, exec, dreply),
		make(chan fastrpc.Serializable, genericsmr.CHAN_BUFFER_SIZE),
		make(chan fastrpc.Serializable, genericsmr.CHAN_BUFFER_SIZE),
		make(chan fastrpc.Serializable, genericsmr.CHAN_BUFFER_SIZE),
		make(chan fastrpc.Serializable, genericsmr.CHAN_BUFFER_SIZE),
		make(chan fastrpc.Serializable, genericsmr.CHAN_BUFFER_SIZE),
		make(chan fastrpc.Serializable, genericsmr.CHAN_BUFFER_SIZE),
		make(chan fastrpc.Serializable, genericsmr.CHAN_BUFFER_SIZE*3),
		make(chan fastrpc.Serializable, genericsmr.CHAN_BUFFER_SIZE*3),
		make(chan fastrpc.Serializable, genericsmr.CHAN_BUFFER_SIZE*2),
		make(chan fastrpc.Serializable, genericsmr.CHAN_BUFFER_SIZE),
		make(chan fastrpc.Serializable, genericsmr.CHAN_BUFFER_SIZE),
		0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
		make([][]*Instance, len(peerAddrList)),
		make([]int32, len(peerAddrList)),
		[DS]int32{-1, -1, -1, -1, -1},
		make([]int32, len(peerAddrList)),
		nil,
		make([]map[state.Key]int32, len(peerAddrList)),
		make(map[state.Key]int32),
		0,
		0,
		-1,
		new(sync.Mutex),
		make(chan *instanceId, genericsmr.CHAN_BUFFER_SIZE)}

	r.Beacon = beacon
	r.Durable = durable

	for i := 0; i < r.N; i++ {
		r.InstanceSpace[i] = make([]*Instance, 2*1024*1024)
		r.crtInstance[i] = 0
		r.ExecedUpTo[i] = -1
		r.conflicts[i] = make(map[state.Key]int32, HT_INIT_SIZE)
	}

	for bf_PT = 1; math.Pow(2, float64(bf_PT))/float64(MAX_BATCH) < BF_M_N; {
		bf_PT++
	}

	r.exec = &Exec{r}

	cpMarker = make([]state.Command, 0)

	//register RPCs
	r.prepareRPC = r.RegisterRPC(new(epaxosproto.Prepare), r.prepareChan)
	r.prepareReplyRPC = r.RegisterRPC(new(epaxosproto.PrepareReply), r.prepareReplyChan)
	r.preAcceptRPC = r.RegisterRPC(new(epaxosproto.PreAccept), r.preAcceptChan)
	r.preAcceptReplyRPC = r.RegisterRPC(new(epaxosproto.PreAcceptReply), r.preAcceptReplyChan)
	r.preAcceptOKRPC = r.RegisterRPC(new(epaxosproto.PreAcceptOK), r.preAcceptOKChan)
	r.acceptRPC = r.RegisterRPC(new(epaxosproto.Accept), r.acceptChan)
	r.acceptReplyRPC = r.RegisterRPC(new(epaxosproto.AcceptReply), r.acceptReplyChan)
	r.commitRPC = r.RegisterRPC(new(epaxosproto.Commit), r.commitChan)
	r.commitShortRPC = r.RegisterRPC(new(epaxosproto.CommitShort), r.commitShortChan)
	r.tryPreAcceptRPC = r.RegisterRPC(new(epaxosproto.TryPreAccept), r.tryPreAcceptChan)
	r.tryPreAcceptReplyRPC = r.RegisterRPC(new(epaxosproto.TryPreAcceptReply), r.tryPreAcceptReplyChan)

	go r.run()

	return r
}