Exemple #1
0
 def get_tmaster(self, topologyName, callback=None):
     if callback:
         self.tmaster_watchers[topologyName].append(callback)
     else:
         tmaster_path = self.get_tmaster_path(topologyName)
         with open(tmaster_path) as f:
             data = f.read()
             tmaster = TMasterLocation()
             tmaster.ParseFromString(data)
             return tmaster
Exemple #2
0
    def watch_tmaster(data, stats):
      if data:
        tmaster = TMasterLocation()
        tmaster.ParseFromString(data)
        callback(tmaster)
      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