From: Brian Warner Date: Mon, 1 Aug 2011 22:43:17 +0000 (-0700) Subject: remove nodeid from WriteBucketProxy classes and customers X-Git-Url: https://git.rkrishnan.org/vdrive/%22news.html//%22doc.html/%22?a=commitdiff_plain;h=3668cb3d068b7f3a56cc88e7c45d4f81c0b4f499;p=tahoe-lafs%2Ftahoe-lafs.git remove nodeid from WriteBucketProxy classes and customers refs #1363 --- diff --git a/src/allmydata/immutable/downloader/share.py b/src/allmydata/immutable/downloader/share.py index 1f828ace..d5127021 100644 --- a/src/allmydata/immutable/downloader/share.py +++ b/src/allmydata/immutable/downloader/share.py @@ -123,9 +123,8 @@ class Share: # use the upload-side code to get this as accurate as possible ht = IncompleteHashTree(N) num_share_hashes = len(ht.needed_hashes(0, include_leaf=True)) - wbp = make_write_bucket_proxy(None, share_size, r["block_size"], - r["num_segments"], num_share_hashes, 0, - None) + wbp = make_write_bucket_proxy(None, None, share_size, r["block_size"], + r["num_segments"], num_share_hashes, 0) self._fieldsize = wbp.fieldsize self._fieldstruct = wbp.fieldstruct self.guessed_offsets = wbp._offsets diff --git a/src/allmydata/immutable/layout.py b/src/allmydata/immutable/layout.py index 30956780..8d9a8f03 100644 --- a/src/allmydata/immutable/layout.py +++ b/src/allmydata/immutable/layout.py @@ -76,19 +76,22 @@ limitations described in #346. FORCE_V2 = False # set briefly by unit tests to make small-sized V2 shares -def make_write_bucket_proxy(rref, data_size, block_size, num_segments, - num_share_hashes, uri_extension_size_max, nodeid): +def make_write_bucket_proxy(rref, server, + data_size, block_size, num_segments, + num_share_hashes, uri_extension_size_max): # Use layout v1 for small files, so they'll be readable by older versions # (" % nodeid_s + return "" % self._server.get_name() def put_header(self): return self._write(0, self._offset_data) @@ -247,10 +245,10 @@ class WriteBucketProxy: return self._rref.callRemoteOnly("abort") + def get_servername(self): + return self._server.get_name() def get_peerid(self): - if self._nodeid: - return self._nodeid - return None + return self._server.get_serverid() class WriteBucketProxy_v2(WriteBucketProxy): fieldsize = 8 diff --git a/src/allmydata/immutable/upload.py b/src/allmydata/immutable/upload.py index 24ea51dd..d152c44d 100644 --- a/src/allmydata/immutable/upload.py +++ b/src/allmydata/immutable/upload.py @@ -77,10 +77,10 @@ class ServerTracker: self.buckets = {} # k: shareid, v: IRemoteBucketWriter self.sharesize = sharesize - wbp = layout.make_write_bucket_proxy(None, sharesize, + wbp = layout.make_write_bucket_proxy(None, None, sharesize, blocksize, num_segments, num_share_hashes, - EXTENSION_SIZE, server.get_serverid()) + EXTENSION_SIZE) self.wbp_class = wbp.__class__ # to create more of them self.allocated_size = wbp.get_allocated_size() self.blocksize = blocksize @@ -120,12 +120,11 @@ class ServerTracker: #log.msg("%s._got_reply(%s)" % (self, (alreadygot, buckets))) b = {} for sharenum, rref in buckets.iteritems(): - bp = self.wbp_class(rref, self.sharesize, + bp = self.wbp_class(rref, self._server, self.sharesize, self.blocksize, self.num_segments, self.num_share_hashes, - EXTENSION_SIZE, - self._server.get_serverid()) + EXTENSION_SIZE) b[sharenum] = bp self.buckets.update(b) return (alreadygot, set(b.keys())) @@ -149,7 +148,7 @@ class ServerTracker: def str_shareloc(shnum, bucketwriter): - return "%s: %s" % (shnum, idlib.shortnodeid_b2a(bucketwriter._nodeid),) + return "%s: %s" % (shnum, bucketwriter.get_servername(),) class Tahoe2ServerSelector(log.PrefixingLogMixin): @@ -205,9 +204,9 @@ class Tahoe2ServerSelector(log.PrefixingLogMixin): num_share_hashes = len(ht.needed_hashes(0, include_leaf=True)) # figure out how much space to ask for - wbp = layout.make_write_bucket_proxy(None, share_size, 0, num_segments, - num_share_hashes, EXTENSION_SIZE, - None) + wbp = layout.make_write_bucket_proxy(None, None, + share_size, 0, num_segments, + num_share_hashes, EXTENSION_SIZE) allocated_size = wbp.get_allocated_size() all_servers = storage_broker.get_servers_for_psi(storage_index) if not all_servers: diff --git a/src/allmydata/test/test_storage.py b/src/allmydata/test/test_storage.py index 91c2fdc1..5952eeca 100644 --- a/src/allmydata/test/test_storage.py +++ b/src/allmydata/test/test_storage.py @@ -136,12 +136,12 @@ class BucketProxy(unittest.TestCase): def test_create(self): bw, rb, sharefname = self.make_bucket("test_create", 500) - bp = WriteBucketProxy(rb, + bp = WriteBucketProxy(rb, None, data_size=300, block_size=10, num_segments=5, num_share_hashes=3, - uri_extension_size_max=500, nodeid=None) + uri_extension_size_max=500) self.failUnless(interfaces.IStorageBucketWriter.providedBy(bp), bp) def _do_test_readwrite(self, name, header_size, wbp_class, rbp_class): @@ -167,13 +167,12 @@ class BucketProxy(unittest.TestCase): uri_extension = "s" + "E"*498 + "e" bw, rb, sharefname = self.make_bucket(name, sharesize) - bp = wbp_class(rb, + bp = wbp_class(rb, None, data_size=95, block_size=25, num_segments=4, num_share_hashes=3, - uri_extension_size_max=len(uri_extension), - nodeid=None) + uri_extension_size_max=len(uri_extension)) d = bp.put_header() d.addCallback(lambda res: bp.put_block(0, "a"*25))