Esempio n. 1
0
func TestMakeInitialBallot(t *testing.T) {
	param := &Param{
		ReplicaId:    3,
		Size:         5,
		StateMachine: new(test.DummySM),
		Transporter:  transporter.NewDummyTR(3, 5),
	}
	r, _ := New(param)
	r.Epoch = 3
	b := r.makeInitialBallot()
	assert.Equal(t, b, message.NewBallot(3, 0, 3))
}
Esempio n. 2
0
func NewInstance(replica *Replica, rowId uint8, instanceId uint64) (i *Instance) {
	i = &Instance{
		replica:      replica,
		id:           instanceId,
		rowId:        rowId,
		deps:         replica.makeInitialDeps(),
		info:         NewInstanceInfo(),
		recoveryInfo: NewRecoveryInfo(),
		ballot:       message.NewBallot(0, 0, 0),
		status:       nilStatus,

		CommittedNotify: make(chan struct{}),
		ExecutedNotify:  make(chan struct{}),
	}
	return i
}
Esempio n. 3
0
func NewRecoveryInfo() *RecoveryInfo {
	return &RecoveryInfo{
		ballot: message.NewBallot(0, 0, 0),
	}
}
Esempio n. 4
0
func (r *Replica) makeInitialBallot() *message.Ballot {
	return message.NewBallot(r.Epoch, 0, r.Id)
}