예제 #1
0
파일: txn.go 프로젝트: CrazyJvm/doozerd
func (t *txn) del() {
	if !t.c.waccess {
		t.respondOsError(syscall.EACCES)
		return
	}

	if !t.c.canWrite {
		t.respondErrCode(response_READONLY)
		return
	}

	if t.req.Path == nil || t.req.Rev == nil {
		t.respondErrCode(response_MISSING_ARG)
		return
	}

	go func() {
		ev := consensus.Del(t.c.p, *t.req.Path, *t.req.Rev)
		if ev.Err != nil {
			t.respondOsError(ev.Err)
			return
		}
		t.respond()
	}()
}
예제 #2
0
파일: member.go 프로젝트: CrazyJvm/doozerd
func removeInfo(p consensus.Proposer, g store.Getter, name string) {
	glob, err := store.CompileGlob("/ctl/node/" + name + "/**")
	if err != nil {
		log.Println(err)
		return
	}
	store.Walk(g, glob, func(path, _ string, rev int64) bool {
		consensus.Del(p, path, rev)
		return false
	})
}
예제 #3
0
파일: server.go 프로젝트: srid/doozerd
func serve(nc net.Conn, st *store.Store, p consensus.Proposer, w bool, rwsk, rosk string, self string) {
	client_addr := strings.Replace(nc.RemoteAddr().String(), ":", "-", 1)
	eph_node := "/ctl/node/" + self + "/client/" + client_addr

	c := &conn{
		c:        nc,
		addr:     nc.RemoteAddr().String(),
		eph_node: eph_node,
		st:       st,
		p:        p,
		canWrite: w,
		rwsk:     rwsk,
		rosk:     rosk,
		self:     self,
	}

	// create the ephemeral node on client connect under this
	// node's tree. the list of all clients connected can be
	// determined by globbing /ctl/node/*/client/*. to set
	// arbitrary value in the ephemeral node for that client,
	// simply call SET('/eph', value), where /eph is a symlink to
	// that client's ephemeral node.
	log.Println("** setting ephemeral node", eph_node)
	ev := consensus.Set(p, eph_node, []byte(""), store.Missing)
	if ev.Err != nil {
		log.Println("** failed to set ephemeral node:", ev.Err)
		nc.Close()
		return
	}

	c.grant("") // start as if the client supplied a blank password
	c.serve()

	// delete the ephemeral node on disconnect
	log.Println("** deleting ephemeral node", eph_node)
	ev = consensus.Del(p, eph_node, store.Clobber)
	if ev.Err != nil {
		log.Println("** failed to delete ephemeral node:", ev.Err)
	}

	nc.Close()

}