Ejemplo n.º 1
0
func (t *tribe) processAddAgreementIntents() bool {
	for idx, v := range t.intentBuffer {
		if v.GetType() == addAgreementMsgType {
			intent := v.(*agreementMsg)
			if _, ok := t.agreements[intent.AgreementName]; !ok {
				t.agreements[intent.AgreementName] = agreement.New(intent.AgreementName)
				t.intentBuffer = append(t.intentBuffer[:idx], t.intentBuffer[idx+1:]...)
				return false
			}
		}
	}
	return true
}
Ejemplo n.º 2
0
func init() {
	mockTribeAgreement = agreement.New("Agree1")
	mockTribeAgreement.PluginAgreement.Add(
		agreement.Plugin{Name_: "mockVersion", Version_: 1, Type_: core.CollectorPluginType})
	mockTribeAgreement.TaskAgreement.Add(
		agreement.Task{ID: "mockTask", StartOnCreate: true})
	mockTribeAgreement.Members["member1"] = agreement.NewMember(&memberlist.Node{
		Name: "mockName",
		Addr: net.ParseIP("193.34.23.11"),
		Port: uint16(0),
		Meta: []byte("meta"), // Metadata from the delegate for this node.
		PMin: uint8(0),       // Minimum protocol version this understands
		PMax: uint8(0),       // Maximum protocol version this understands
		PCur: uint8(0),       // Current version node is speaking
		DMin: uint8(0),       // Min protocol version for the delegate to understand
		DMax: uint8(0),       // Max protocol version for the delegate to understand
		DCur: uint8(0),       // Current version delegate is speaking
	})
}
Ejemplo n.º 3
0
func (t *tribe) handleAddAgreement(msg *agreementMsg) bool {
	t.mutex.Lock()
	defer t.mutex.Unlock()

	// update clock if newer
	t.clock.Update(msg.LTime)

	if t.isDuplicate(msg) {
		return false
	}

	// add msg to seen buffer
	t.msgBuffer[msg.LTime%LTime(len(t.msgBuffer))] = msg

	// add agreement
	if _, ok := t.agreements[msg.AgreementName]; !ok {
		t.agreements[msg.AgreementName] = agreement.New(msg.AgreementName)
		t.processIntents()
		return true
	}
	t.addAgreementIntent(msg)
	return true
}