class name cleanups: s/FileNode/ImmutableFileNode/

also fix test/bench_dirnode.py for recent dirnode changes
This commit is contained in:
Brian Warner 2009-11-19 23:22:39 -08:00
parent 6e7fb1006d
commit d2badbea78
6 changed files with 33 additions and 26 deletions

View File

@ -72,9 +72,9 @@ class DownloadCache:
self.cachefile = None
self.download_in_progress = False
# five states:
# new FileNode, no downloads ever performed
# new FileNode, leftover file (partial)
# new FileNode, leftover file (whole)
# new ImmutableFileNode, no downloads ever performed
# new ImmutableFileNode, leftover file (partial)
# new ImmutableFileNode, leftover file (whole)
# download in progress, not yet complete
# download complete
@ -178,7 +178,7 @@ class DownloadCache:
pass
class FileNode(_ImmutableFileNodeBase, log.PrefixingLogMixin):
class ImmutableFileNode(_ImmutableFileNodeBase, log.PrefixingLogMixin):
def __init__(self, filecap, storage_broker, secret_holder,
downloader, history, cachedirectorymanager):
assert isinstance(filecap, CHKFileURI)

View File

@ -956,9 +956,9 @@ class IDirectoryNode(IMutableFilesystemNode):
def add_file(name, uploadable, metadata=None, overwrite=True):
"""I upload a file (using the given IUploadable), then attach the
resulting FileNode to the directory at the given name. I set metadata
the same way as set_uri and set_node. The child name must be a
unicode string.
resulting ImmutableFileNode to the directory at the given name. I set
metadata the same way as set_uri and set_node. The child name must be
a unicode string.
I return a Deferred that fires (with the IFileNode of the uploaded
file) when the operation completes."""
@ -2069,7 +2069,7 @@ class IClient(Interface):
@return: an instance that provides IFilesystemNode (or more usefully
one of its subclasses). File-specifying URIs will result in
IFileNode or IMutableFileNode -providing instances, like
FileNode, LiteralFileNode, or MutableFileNode.
ImmutableFileNode, LiteralFileNode, or MutableFileNode.
Directory-specifying URIs will result in
IDirectoryNode-providing instances, like DirectoryNode.
"""

View File

@ -2,7 +2,7 @@ import weakref
from zope.interface import implements
from allmydata.util.assertutil import precondition
from allmydata.interfaces import INodeMaker, NotDeepImmutableError
from allmydata.immutable.filenode import FileNode, LiteralFileNode
from allmydata.immutable.filenode import ImmutableFileNode, LiteralFileNode
from allmydata.immutable.upload import Data
from allmydata.mutable.filenode import MutableFileNode
from allmydata.dirnode import DirectoryNode, pack_children
@ -33,9 +33,9 @@ class NodeMaker:
def _create_lit(self, cap):
return LiteralFileNode(cap)
def _create_immutable(self, cap):
return FileNode(cap, self.storage_broker, self.secret_holder,
self.downloader, self.history,
self.download_cache_dirman)
return ImmutableFileNode(cap, self.storage_broker, self.secret_holder,
self.downloader, self.history,
self.download_cache_dirman)
def _create_mutable(self, cap):
n = MutableFileNode(self.storage_broker, self.secret_holder,
self.default_encoding_parameters,

View File

@ -2,14 +2,17 @@ import hotshot.stats, os, random, sys
from pyutil import benchutil, randutil # http://allmydata.org/trac/pyutil
from zope.interface import implements
from allmydata import dirnode, uri
from allmydata.mutable import filenode as mut_filenode
from allmydata.immutable import filenode as immut_filenode
from allmydata.interfaces import IFileNode
from allmydata.mutable.filenode import MutableFileNode
from allmydata.immutable.filenode import ImmutableFileNode
children = [] # tuples of (k, v) (suitable for passing to dict())
packstr = None
class ContainerNode:
implements(IFileNode)
# dirnodes sit on top of a "container" filenode, from which it extracts a
# writekey
def __init__(self):
@ -18,6 +21,8 @@ class ContainerNode:
self._cap = uri.WriteableSSKFileURI(self._writekey, self._fingerprint)
def get_writekey(self):
return self._writekey
def get_cap(self):
return self._cap
def get_uri(self):
return self._cap.to_string()
def is_readonly(self):
@ -45,17 +50,17 @@ def random_fsnode():
random.randrange(1, 5),
random.randrange(6, 15),
random.randrange(99, 1000000000000))
return immut_filenode.FileNode(cap, None, None, None, None, None)
return ImmutableFileNode(cap, None, None, None, None, None)
elif coin == 1:
cap = uri.WriteableSSKFileURI(randutil.insecurerandstr(16),
randutil.insecurerandstr(32))
n = mut_filenode.MutableFileNode(None, None, encoding_parameters, None)
n = MutableFileNode(None, None, encoding_parameters, None)
return n.init_from_cap(cap)
else:
assert coin == 2
cap = uri.WriteableSSKFileURI(randutil.insecurerandstr(16),
randutil.insecurerandstr(32))
n = mut_filenode.MutableFileNode(None, None, encoding_parameters, None)
n = MutableFileNode(None, None, encoding_parameters, None)
n.init_from_cap(cap)
return dirnode.DirectoryNode(n, nodemaker, uploader=None)

View File

@ -2,7 +2,8 @@
from twisted.trial import unittest
from allmydata import uri, client
from allmydata.monitor import Monitor
from allmydata.immutable import filenode, download
from allmydata.immutable import download
from allmydata.immutable.filenode import ImmutableFileNode, LiteralFileNode
from allmydata.mutable.filenode import MutableFileNode
from allmydata.util import hashutil, cachedir
from allmydata.test.common import download_to_data
@ -32,8 +33,8 @@ class Node(unittest.TestCase):
size=1000)
c = FakeClient()
cf = cachedir.CacheFile("none")
fn1 = filenode.FileNode(u, None, None, None, None, cf)
fn2 = filenode.FileNode(u, None, None, None, None, cf)
fn1 = ImmutableFileNode(u, None, None, None, None, cf)
fn2 = ImmutableFileNode(u, None, None, None, None, cf)
self.failUnlessEqual(fn1, fn2)
self.failIfEqual(fn1, "I am not a filenode")
self.failIfEqual(fn1, NotANode())
@ -56,8 +57,8 @@ class Node(unittest.TestCase):
DATA = "I am a short file."
u = uri.LiteralFileURI(data=DATA)
c = None
fn1 = filenode.LiteralFileNode(u)
fn2 = filenode.LiteralFileNode(u)
fn1 = LiteralFileNode(u)
fn2 = LiteralFileNode(u)
self.failUnlessEqual(fn1, fn2)
self.failIfEqual(fn1, "I am not a filenode")
self.failIfEqual(fn1, NotANode())
@ -151,7 +152,7 @@ class LiteralChecker(unittest.TestCase):
def test_literal_filenode(self):
DATA = "I am a short file."
u = uri.LiteralFileURI(data=DATA)
fn1 = filenode.LiteralFileNode(u)
fn1 = LiteralFileNode(u)
d = fn1.check(Monitor())
def _check_checker_results(cr):

View File

@ -11,7 +11,8 @@ import allmydata
from allmydata import uri
from allmydata.storage.mutable import MutableShareFile
from allmydata.storage.server import si_a2b
from allmydata.immutable import download, filenode, offloaded, upload
from allmydata.immutable import download, offloaded, upload
from allmydata.immutable.filenode import ImmutableFileNode, LiteralFileNode
from allmydata.util import idlib, mathutil
from allmydata.util import log, base32
from allmydata.scripts import runner
@ -1770,7 +1771,7 @@ class SystemTest(SystemTestMixin, unittest.TestCase):
d.addCallback(lambda res: self._personal_node.get(u"big file"))
def _got_chk_filenode(n):
self.failUnless(isinstance(n, filenode.FileNode))
self.failUnless(isinstance(n, ImmutableFileNode))
d = n.check(Monitor())
def _check_filenode_results(r):
self.failUnless(r.is_healthy())
@ -1782,7 +1783,7 @@ class SystemTest(SystemTestMixin, unittest.TestCase):
d.addCallback(lambda res: self._personal_node.get(u"sekrit data"))
def _got_lit_filenode(n):
self.failUnless(isinstance(n, filenode.LiteralFileNode))
self.failUnless(isinstance(n, LiteralFileNode))
d = n.check(Monitor())
def _check_lit_filenode_results(r):
self.failUnlessEqual(r, None)