示例#1
0
        def __put_next(srv, hashdic, hashdic_left, allset, key, lock):
            dbg.job("submitted to: %s" % srv)
            while True:
                lock.acquire()
                if (len(hashdic[key]) == 0 or len(allset) == 0):
                    lock.release()
                    break

                next = hashdic[key].pop()
                if (next in allset):
                    allset.remove(next)
                else:
                    hashdic_left[key].append(next)
                    next = None
                lock.release()
                if next is not None:
                    with open(self.get_local_obj_path(next), "rb") as f:
                        blob = f.read()
                        for tr in self.translators:
                            blob = tr.put(blob)
                        # XXX HACK
                        backoff = 0.5
                        remote_path = self.get_remote_obj_path(next)
                        while not srv.put(remote_path, blob):
                            dbg.dbg("backoff %s" % srv)
                            time.sleep(backoff)
                            backoff *= 2
示例#2
0
        def __put_next(srv, hashdic, hashdic_left, allset, key, lock):
            dbg.job("submitted to: %s" % srv)
            while True:
                lock.acquire()
                if(len(hashdic[key]) == 0 or len(allset) == 0):
                    lock.release()
                    break

                next = hashdic[key].pop()
                if(next in allset):
                    allset.remove(next)
                else:
                    hashdic_left[key].append(next)
                    next = None
                lock.release()
                if next is not None:
                    with open(self.get_local_obj_path(next), "rb") as f:
                        blob = f.read()
                        for tr in self.translators:
                            blob = tr.put(blob)
                        # XXX HACK
                        backoff = 0.5
                        remote_path = self.get_remote_obj_path(next)
                        while not srv.put(remote_path, blob):
                            dbg.dbg("backoff %s" % srv)
                            time.sleep(backoff)
                            backoff *= 2
示例#3
0
 def __get(srv, path, remote_path):
     dbg.job("submitted to: %s (%s)" % (srv, path))
     with open(path, "wb") as f:
         blob = srv.get(remote_path)
         if (blob is None):
             time.sleep(1)
             blob = srv.get(remote_path)
         for tr in reversed(self.translators):
             blob = tr.get(blob)
         f.write(blob)
示例#4
0
 def __get(srv, path, remote_path):
     dbg.job("submitted to: %s (%s)" % (srv, path))
     with open(path,  "wb") as f:
         blob = srv.get(remote_path)
         if(blob is None):
             time.sleep(1)
             blob = srv.get(remote_path)
         for tr in reversed(self.translators):
             blob = tr.get(blob)
         f.write(blob)
示例#5
0
 def __rm_next(srv, lst, lock):
     dbg.job("submitted to: %s" % srv)
     while True:
         lock.acquire()
         if (len(lst) == 0):
             lock.release()
             break
         next = lst.pop()
         lock.release()
         if next is not None:
             remote_path = self.get_remote_obj_path(next)
             srv.rm(remote_path)
示例#6
0
 def __rm_next(srv, lst, lock):
     dbg.job("submitted to: %s" % srv)
     while True:
         lock.acquire()
         if(len(lst) == 0):
             lock.release()
             break
         next = lst.pop()
         lock.release()
         if next is not None:
             remote_path = self.get_remote_obj_path(next)
             srv.rm(remote_path)
示例#7
0
 def __put_next(srv, lst, lock):
     dbg.job("submitted to: %s" % srv)
     while True:
         lock.acquire()
         if (len(lst) == 0):
             lock.release()
             break
         next = lst.pop()
         lock.release()
         if next is not None:
             with open(self.get_local_obj_path(next), "rb") as f:
                 blob = f.read()
                 for tr in self.translators:
                     blob = tr.put(blob)
                 # XXX HACK
                 backoff = 0.5
                 remote_path = self.get_remote_obj_path(next)
                 while not srv.put(remote_path, blob):
                     time.sleep(backoff)
                     backoff *= 2
示例#8
0
 def __put_next(srv, lst, lock):
     dbg.job("submitted to: %s" % srv)
     while True:
         lock.acquire()
         if(len(lst) == 0):
             lock.release()
             break
         next = lst.pop()
         lock.release()
         if next is not None:
             with open(self.get_local_obj_path(next), "rb") as f:
                 blob = f.read()
                 for tr in self.translators:
                     blob = tr.put(blob)
                 # XXX HACK
                 backoff = 0.5
                 remote_path = self.get_remote_obj_path(next)
                 while not srv.put(remote_path, blob):
                     time.sleep(backoff)
                     backoff *= 2
示例#9
0
 def __rm(srv, remote_path):
     dbg.job("submitted to: %s (%s)" % (srv, remote_path))
     srv.rm(remote_path)
示例#10
0
 def __rm(srv, remote_path):
     dbg.job("submitted to: %s (%s)" % (srv, remote_path))
     srv.rm(remote_path)