/** * init slot allocation from zk. */ func GetSlotAllocationsFromZk(zkHelper *utils.ZkHelper) *SlotAllocation { allocationsPath := "/yundis/allocations" if b := zkHelper.PathExist(allocationsPath); b { bytes, _, err := zkHelper.GetZkConn().Get(allocationsPath) if err != nil { log.Errorf("Read the data of '/yundis/allocations' error. err : %s", err) } allocations, err := InitSlotAlloctionWithJson(string(bytes)) if err != nil { log.Errorf("Parse the json data error. err:%s", err) } else { return allocations } } return nil }