コード例 #1
0
ファイル: navel.py プロジェクト: Cloudxtreme/Trieste
 def processKeyedData (self, data, function, backupFunction=None):
   keys= data.keys ()
   keysQty= len (keys)
   accepted= {}
   i= 0
   added= 0
   m= self.key ()
   n= self.getSucc ().key ()
   wrongKey= None
   while i<keysQty:
     key= keys[i]
     args= data[key]
     if coBetween (m, key, n):
       self.debug (2, '[%d,%d] processing %d; data %s' % (i, keysQty, key, args))
       function (key, args)
       if backupFunction:
         accepted[key]= args
       added+= 1
     else:
       self.debug (2, '[%d,%d] dropping %d' % (i, keysQty, key))
       if not wrongKey:
         wrongKey= key
     i+= 1
   if backupFunction and len (accepted.keys())>0:
     backupFunction (accepted)
   if added<keysQty:
     # some values don't belong to us
     server= self.findAuth (wrongKey)
     return server
   else:
     return None
コード例 #2
0
ファイル: navel.py プロジェクト: Cloudxtreme/Trieste
 def amAuth (self, key):
   # ! someone should have the lock on succ
   m= self._key
   n= self.getSucc ().key ()
   if coBetween (m, key, n):
     return True
   else:
     return False
コード例 #3
0
ファイル: master.py プロジェクト: Cloudxtreme/Trieste
  def giveData (self, m, n, what=Set):
    """
      returns: a hash
    """
    self.debug (1, "giveData called", 2)

    keys= self._data.keys ()
    keys.sort ()
    self.debug (1, 'my know keys are: %s' % keys)
    h= {}

    nextKey= next (keys)
    while not nextKey==None:
      self.debug (2, "m: %d, k: %d, n: %d" % (m, nextKey, n))
      if (what==self.Set and coBetween (m, nextKey, n)) or (what==self.Complement and coBetween (n, nextKey, m)):
        h[nextKey]= self._data.getValues (nextKey)

      nextKey= next (keys)

    if what==self.Set:
      self.debug (1, 'giving Set %d:%d %s' % (m, n, h.keys ()))
    else:
      self.debug (1, 'giving Complement %d:%d %s' % (n, m, h.keys ()))
    return h