示例#1
0
func registerNode(persist p.Controller) {
	node = disco.NewNode()
	nj, err := node.Marshal()
	if err != nil {
		log.Fatalf(err.Error())
	}
	_, err = persist.Create(PREFIX+"/nodes/"+node.Id, string(nj), false)
	_, err = persist.CreatePath(PREFIX + "/containers/nodes/" + node.Id)
	if err != nil {
		log.Fatalf(err.Error())
	}
}
示例#2
0
func createTree(persist p.Controller) {
	for _, p := range []string{"nodes", "containers/nodes", "containers/master", "links"} {
		exists, err := persist.Exists(PREFIX + "/" + p)
		if err != nil {
			log.Fatalf(err.Error())
		}
		if !exists {
			_, err := persist.CreatePath(PREFIX + "/" + p)
			if err != nil {
				log.Fatalf(err.Error())
			}
		}
	}
}