예제 #1
0
func set(c *conn, _ uint, data interface{}) interface{} {
	r := data.(*proto.ReqSet)
	_, cas, err := paxos.Set(c.s.Mg, r.Path, r.Body, r.Cas)
	if err != nil {
		return err
	}
	return cas
}
예제 #2
0
func checkin(c *conn, _ uint, data interface{}) interface{} {
	r := data.(*proto.ReqCheckin)
	t := time.Nanoseconds() + lease
	_, cas, err := paxos.Set(c.s.Mg, "/session/"+r.Sid, strconv.Itoa64(t), r.Cas)
	if err != nil {
		return err
	}
	return proto.ResCheckin{t, cas}
}
예제 #3
0
func sett(c *conn, _ uint, data interface{}) interface{} {
	r := data.(*proto.ReqSett)
	t := time.Nanoseconds() + r.Interval
	_, cas, err := paxos.Set(c.s.Mg, r.Path, strconv.Itoa64(t), r.Cas)
	if err != nil {
		return err
	}
	return proto.ResSett{t, cas}
}
예제 #4
0
func clearSlot(p paxos.Proposer, g store.Getter, name string) {
	ch, err := store.Walk(g, "/doozer/slot/*")
	if err != nil {
		panic(err)
	}

	for ev := range ch {
		if ev.Body == name {
			paxos.Set(p, ev.Path, "", ev.Cas)
		}
	}
}
예제 #5
0
func join(c *conn, _ uint, data interface{}) interface{} {
	r := data.(*proto.ReqJoin)
	key := "/doozer/members/" + r.Who
	seqn, _, err := paxos.Set(c.s.Mg, key, r.Addr, store.Missing)
	if err != nil {
		return err
	}

	done := make(chan int)
	go c.s.AdvanceUntil(done)
	c.s.St.Sync(seqn + uint64(c.s.Mg.Alpha()))
	close(done)
	seqn, snap := c.s.St.Snapshot()
	return proto.ResJoin{seqn, snap}
}