예제 #1
0
파일: Storage.py 프로젝트: yarcat/manent
 def is_requested(self, digest, code):
   logging.debug("Seeing block code=%s, digest=%s" %
       (Container.code_name(code), base64.b64encode(digest)))
   if self.block_handler.is_requested(
       self.sequence_id, self.container_idx, digest, code):
     return True
   logging.debug("Seeing block of code %s" % Container.code_name(code))
   return code == Container.CODE_HEADER
예제 #2
0
  def add_aside_block(self, digest, code, data):
    logging.debug("BlockSequencer adding aside block %s:%s:%d" %
        (base64.b64encode(digest), Container.code_name(code), len(data)))
    key = str(self.aside_block_last + 1)
    self.aside_block_last += 1
    self.aside_block_db[key] = digest

    self.aside_block_num += 1
    self.aside_block_size += len(data)
예제 #3
0
    def add_block(self, digest, code, data):
        self.block_manager.add_block(digest, code, data)

        if self.block_container_db.has_key(digest):
            return False

        logging.debug(
            "Storage manager adding new block %s:%s:%d"
            % (base64.b64encode(digest), Container.code_name(code), len(data))
        )
        self.block_sequencer.add_block(digest, code, data)
        return True
예제 #4
0
 def load_block(self, digest):
   """
   Actually perform loading of the block.
   """
   logging.debug("BM Loading block " + base64.b64encode(digest) +
       " " + Container.code_name(self.get_block_code(digest)))
   if self.block_epoch.has_key(digest):
     # Block exists in the temporary cache.
     self._update_block_epoch(digest)
     return self.tmp_blocks[digest]
   if self.cached_blocks.has_key(digest):
     #
     # Blocks that sit in self.cached_blocks are never unloaded
     #
     return self.cached_blocks[digest]
   raise Exception("Block is unknown.")