Beispiel #1
0
func Clean(s *store.Store, p paxos.Proposer) {
	timer := timer.New("/session/**", timer.OneSecond, s)
	for tick := range timer.C {
		_, cas := s.Get(tick.Path)
		paxos.Del(p, tick.Path, cas)
	}
}
Beispiel #2
0
func removeMember(p paxos.Proposer, g store.Getter, name string) {
	k := "/doozer/members/" + name
	_, cas := g.Get(k)
	if cas != store.Missing {
		paxos.Del(p, k, cas)
	}
}
Beispiel #3
0
func del(c *conn, _ uint, data interface{}) interface{} {
	r := data.(*proto.ReqDel)
	err := paxos.Del(c.s.Mg, r.Path, r.Cas)
	if err != nil {
		return err
	}

	return Ok
}
Beispiel #4
0
func removeInfo(p paxos.Proposer, g store.Getter, name string) {
	ch, err := store.Walk(g, "/doozer/info/"+name+"/**")
	if err != nil {
		panic(err)
	}

	for ev := range ch {
		paxos.Del(p, ev.Path, ev.Cas)
	}
}
Beispiel #5
0
func Clean(st *store.Store, pp paxos.Proposer) {
	logger := util.NewLogger("lock")
	for ev := range st.Watch("/session/*") {
		if !ev.IsDel() {
			continue
		}

		parts := strings.Split(ev.Path, "/", 3)
		name := parts[2]
		logger.Printf("lost session %s", name)

		ch, err := store.Walk(ev, "/lock/**")
		if err != nil {
			continue
		}

		for ev := range ch {
			if ev.Body == name {
				paxos.Del(pp, ev.Path, ev.Cas)
			}
		}
	}
}