Esempio n. 1
0
func ListAllInstances() (instances []string, err error) {
	instances, _, err = Zk.VisibleChildren(helper.GetBaseInstanceDataPath())
	if err != nil {
		log.Printf("Error getting list of all instances. Error: %s.", err.Error())
	}
	if instances == nil {
		log.Println("No instances found. Returning empty list.")
		instances = []string{}
	}
	return
}
Esempio n. 2
0
func GetInstance(id string) (zi *ZkInstance, err error) {
	zi = &ZkInstance{}
	err = getJson(helper.GetBaseInstanceDataPath(id), zi)
	if err != nil {
		/* NOTE(edanaher): The default error message here is typically from zookeeper, which is not very user
		 * friendly.  And at Ooyala, we've had a number of users run into this because they're looking at the wrong
		 * region.  So as long as that is the dominant source of this error, it makes sense to suggest this as the
		 * cause, much like compilers will attempt to guess at missing semicolons. */
		err = errors.New(err.Error() + "\nContainer " + id + " not found; is this the right region?")
	}
	return
}
Esempio n. 3
0
func CreateInstancePaths() {
	Zk.Touch(helper.GetBaseInstancePath())
	Zk.Touch(helper.GetBaseInstanceDataPath())
}
Esempio n. 4
0
func InstanceExists(id string) bool {
	if stat, err := Zk.Exists(helper.GetBaseInstanceDataPath(id)); err == nil && stat != nil {
		return true
	}
	return false
}
Esempio n. 5
0
func (zi *ZkInstance) dataPath() string {
	return helper.GetBaseInstanceDataPath(zi.ID)
}