Changeset 0fab511 in trunk


Ignore:
Timestamp:
2008-11-22T03:28:12Z (17 years ago)
Author:
Brian Warner <warner@…>
Branches:
master
Children:
3e25efc
Parents:
bf06492
Message:

upload: don't use servers which can't support the share size we need. This ought to avoid #439 problems. Some day we'll have a storage server which advertises support for a larger share size. No tests yet.

Location:
src/allmydata
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified src/allmydata/immutable/upload.py

    rbf06492 r0fab511  
    165165            raise NotEnoughSharesError("client gave us zero peers")
    166166
    167         # figure out how much space to ask for
    168 
    169167        # this needed_hashes computation should mirror
    170168        # Encoder.send_all_share_hash_trees. We use an IncompleteHashTree
     
    173171        ht = hashtree.IncompleteHashTree(total_shares)
    174172        num_share_hashes = len(ht.needed_hashes(0, include_leaf=True))
     173
     174        # figure out how much space to ask for
     175        allocated_size = layout.allocated_size(share_size,
     176                                               num_segments,
     177                                               num_share_hashes,
     178                                               EXTENSION_SIZE)
     179        # filter the list of peers according to which ones can accomodate
     180        # this request. This excludes older peers (which used a 4-byte size
     181        # field) from getting large shares (for files larger than about
     182        # 12GiB). See #439 for details.
     183        def _get_maxsize(peer):
     184            (peerid, conn) = peer
     185            v1 = conn.version["http://allmydata.org/tahoe/protocols/storage/v1"]
     186            return v1["maximum-immutable-share-size"]
     187        peers = [peer for peer in peers
     188                 if _get_maxsize(peer) >= allocated_size]
     189        if not peers:
     190            raise NotEnoughSharesError("no peers could accept an allocated_size of %d" % allocated_size)
    175191
    176192        # decide upon the renewal/cancel secrets, to include them in the
  • TabularUnified src/allmydata/test/test_upload.py

    rbf06492 r0fab511  
    88from foolscap import eventual
    99
     10import allmydata
    1011from allmydata import uri, monitor
    1112from allmydata.immutable import upload
     
    8283        self.allocated = []
    8384        self.queries = 0
     85        self.version = { "http://allmydata.org/tahoe/protocols/storage/v1" :
     86                         { "maximum-immutable-share-size": 2**32 },
     87                         "application-version": str(allmydata.__version__),
     88                         }
     89
    8490    def callRemote(self, methname, *args, **kwargs):
    8591        def _call():
Note: See TracChangeset for help on using the changeset viewer.