Exemple #1
0
 def get_packing_plan(self, topologyName, callback=None):
     """ get packing plan """
     if callback:
         self.packing_plan_watchers[topologyName].append(callback)
     else:
         packing_plan_path = self.get_packing_plan_path(topologyName)
         with open(packing_plan_path) as f:
             data = f.read()
             packing_plan = PackingPlan()
             packing_plan.ParseFromString(data)
Exemple #2
0
        def watch_packing_plan(data, stats, event):
            """ watch the packing plan for updates """
            if data:
                packing_plan = PackingPlan()
                packing_plan.ParseFromString(data)
                callback(packing_plan)
            else:
                callback(None)

            # Returning False will result in no future watches
            # being triggered. If isWatching is True, then
            # the future watches will be triggered.
            return isWatching