Changeset d575ccb in trunk


Ignore:
Timestamp:
2011-08-28T08:09:31Z (14 years ago)
Author:
Brian Warner <warner@…>
Branches:
master
Children:
9756146
Parents:
97b601f
Message:

Teach 'tahoe debug catalog-shares about MDMF. Closes #1507.

Location:
src/allmydata
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified src/allmydata/scripts/debug.py

    r97b601f rd575ccb  
    729729        share_type = "unknown"
    730730        f.seek(m.DATA_OFFSET)
    731         if f.read(1) == "\x00":
     731        version = f.read(1)
     732        if version == "\x00":
    732733            # this slot contains an SMDF share
    733734            share_type = "SDMF"
     735        elif version == "\x01":
     736            share_type = "MDMF"
    734737
    735738        if share_type == "SDMF":
     
    750753
    751754            print >>out, "SDMF %s %d/%d %d #%d:%s %d %s" % \
     755                  (si_s, k, N, datalen,
     756                   seqnum, base32.b2a(root_hash),
     757                   expiration, quote_output(abs_sharefile))
     758        elif share_type == "MDMF":
     759            from allmydata.mutable.layout import MDMFSlotReadProxy
     760            fake_shnum = 0
     761            # TODO: factor this out with dump_MDMF_share()
     762            class ShareDumper(MDMFSlotReadProxy):
     763                def _read(self, readvs, force_remote=False, queue=False):
     764                    data = []
     765                    for (where,length) in readvs:
     766                        f.seek(m.DATA_OFFSET+where)
     767                        data.append(f.read(length))
     768                    return defer.succeed({fake_shnum: data})
     769
     770            p = ShareDumper(None, "fake-si", fake_shnum)
     771            def extract(func):
     772                stash = []
     773                # these methods return Deferreds, but we happen to know that
     774                # they run synchronously when not actually talking to a
     775                # remote server
     776                d = func()
     777                d.addCallback(stash.append)
     778                return stash[0]
     779
     780            verinfo = extract(p.get_verinfo)
     781            (seqnum, root_hash, salt_to_use, segsize, datalen, k, N, prefix,
     782             offsets) = verinfo
     783            print >>out, "MDMF %s %d/%d %d #%d:%s %d %s" % \
    752784                  (si_s, k, N, datalen,
    753785                   seqnum, base32.b2a(root_hash),
  • TabularUnified src/allmydata/test/test_mutable.py

    r97b601f rd575ccb  
    29912991            vcap = n.get_verify_cap().to_string()
    29922992            self.failUnless("  verify-cap: %s" % vcap in lines, output)
     2993
     2994            cso = debug.CatalogSharesOptions()
     2995            cso.nodedirs = fso.nodedirs
     2996            cso.stdout = StringIO()
     2997            cso.stderr = StringIO()
     2998            debug.catalog_shares(cso)
     2999            shares = cso.stdout.getvalue().splitlines()
     3000            oneshare = shares[0] # all shares should be MDMF
     3001            self.failIf(oneshare.startswith("UNKNOWN"), oneshare)
     3002            self.failUnless(oneshare.startswith("MDMF"), oneshare)
     3003            fields = oneshare.split()
     3004            self.failUnlessEqual(fields[0], "MDMF")
     3005            self.failUnlessEqual(fields[1], storage_index)
     3006            self.failUnlessEqual(fields[2], "3/10")
     3007            self.failUnlessEqual(fields[3], "%d" % len(self.data))
     3008            self.failUnless(fields[4].startswith("#1:"), fields[3])
     3009            # the rest of fields[4] is the roothash, which depends upon
     3010            # encryption salts and is not constant. fields[5] is the
     3011            # remaining time on the longest lease, which is timing dependent.
     3012            # The rest of the line is the quoted pathname to the share.
    29933013        d.addCallback(_debug)
    29943014        return d
Note: See TracChangeset for help on using the changeset viewer.