示例#1
0
    def link(self):
        content_chunks = list()

        kwargs = MetachunkLinker.filter_kwargs(self.extra_kwargs)
        for meta_chunk in self.chunk_prep():
            try:
                handler = MetachunkLinker(
                    meta_chunk,
                    self.fullpath,
                    self.blob_client,
                    storage_method=self.storage_method,
                    reqid=self.headers.get(REQID_HEADER),
                    connection_timeout=self.connection_timeout,
                    write_timeout=self.write_timeout,
                    **kwargs)
                chunks = handler.link()
            except Exception as ex:
                if isinstance(ex, exc.UnfinishedUploadException):
                    # pylint: disable=no-member
                    content_chunks = content_chunks + \
                            ex.chunks_already_uploaded
                    ex = ex.exception
                raise exc.UnfinishedUploadException(ex, content_chunks)

            for chunk in chunks:
                if not chunk.get('error'):
                    content_chunks.append(chunk)

        return content_chunks
示例#2
0
文件: io.py 项目: lhllacp/oio-sds
 def link(self):
     """
     Create new hard links for all the chunks of a metachunk.
     """
     new_meta_chunks = list()
     failed_chunks = list()
     # pylint: disable=unbalanced-tuple-unpacking
     acct, ct, path, vers, _ = decode_fullpath(self.fullpath)
     cid = cid_from_name(acct, ct)
     for chunk_target in self.meta_chunk_target:
         try:
             chunk_id = compute_chunk_id(cid, path, vers,
                                         chunk_target['pos'], self.policy)
             resp, new_chunk_url = self.blob_client.chunk_link(
                 chunk_target['url'],
                 chunk_id,
                 self.fullpath,
                 connection_timeout=self.connection_timeout,
                 write_timeout=self.write_timeout,
                 reqid=self.reqid,
                 perfdata=self.perfdata,
                 logger=self.logger)
             new_chunk = chunk_target.copy()
             new_chunk['url'] = new_chunk_url
             new_meta_chunks.append(new_chunk)
         except Exception:
             failed_chunks.append(chunk_target)
     try:
         self.quorum_or_fail(new_meta_chunks, failed_chunks)
     except Exception as ex:
         raise exc.UnfinishedUploadException(ex, new_meta_chunks)
     return new_meta_chunks
示例#3
0
 def link(self):
     new_meta_chunks = list()
     failed_chunks = list()
     for chunk_target in self.meta_chunk_target:
         try:
             resp, new_chunk_url = self.blob_client.chunk_link(
                 chunk_target['url'], None, self.fullpath,
                 connection_timeout=self.connection_timeout,
                 write_timeout=self.write_timeout)
             new_chunk = chunk_target.copy()
             new_chunk['url'] = new_chunk_url
             new_meta_chunks.append(new_chunk)
         except Exception:
             failed_chunks.append(chunk_target)
     try:
         self.quorum_or_fail(new_meta_chunks, failed_chunks)
     except Exception as ex:
         raise exc.UnfinishedUploadException(ex, new_meta_chunks)
     return new_meta_chunks