reserved = 0
discard = self.get_config("storage", "debug_discard", False,
boolean=True)
- ss = StorageServer(storedir,
+ ss = StorageServer(storedir, self.nodeid,
reserved_space=reserved,
discard_storage=discard,
readonly_storage=readonly,
implements(RIStorageServer, IStatsProducer)
name = 'storage'
- def __init__(self, storedir, reserved_space=0,
+ def __init__(self, storedir, nodeid, reserved_space=0,
discard_storage=False, readonly_storage=False,
stats_provider=None):
service.MultiService.__init__(self)
+ assert isinstance(nodeid, str)
+ assert len(nodeid) == 20
+ self.my_nodeid = nodeid
self.storedir = storedir
sharedir = os.path.join(storedir, "shares")
fileutil.make_dirs(sharedir)
kwargs["facility"] = "tahoe.storage"
return log.msg(*args, **kwargs)
- def setNodeID(self, nodeid):
- # somebody must set this before any slots can be created or leases
- # added
- self.my_nodeid = nodeid
-
- def startService(self):
- service.MultiService.startService(self)
- if self.parent:
- nodeid = self.parent.nodeid # 20 bytes, binary
- assert len(nodeid) == 20
- self.setNodeID(nodeid)
-
def _clean_incomplete(self):
fileutil.rm_dir(self.incomingdir)
serverdir = os.path.join(basedir, "servers",
idlib.shortnodeid_b2a(serverid))
fileutil.make_dirs(serverdir)
- ss = StorageServer(serverdir)
+ ss = StorageServer(serverdir, serverid)
self.add_server(i, serverid, ss)
for i in range(num_clients):
self.clients.append(c)
def add_server(self, i, serverid, ss):
- # TODO: ss.setServiceParent(self), but first remove the goofy
- # self.parent.nodeid from Storage.startService . At the moment,
- # Storage doesn't really need to be startService'd, but it will in
- # the future.
- ss.setNodeID(serverid)
+ # TODO: ss.setServiceParent(self), but first deal with the fact that
+ # all StorageServers are named 'storage'. At the moment, Storage
+ # doesn't really need to be startService'd, but it will in the
+ # future.
+ #ss.setServiceParent(self)
self.servers_by_number[i] = ss
self.servers_by_id[serverid] = wrap(ss, "storage")
self.all_servers = frozenset(self.servers_by_id.items())
for peerid in self._peerids:
peerdir = os.path.join(basedir, idlib.shortnodeid_b2a(peerid))
make_dirs(peerdir)
- ss = StorageServer(peerdir)
- ss.setNodeID(peerid)
+ ss = StorageServer(peerdir, peerid)
lw = LocalWrapper(ss)
self._connections[peerid] = lw
self.nodeid = "fakenodeid"
def create(self, name, reserved_space=0, klass=StorageServer):
workdir = self.workdir(name)
- ss = klass(workdir, reserved_space=reserved_space,
+ ss = klass(workdir, "\x00" * 20, reserved_space=reserved_space,
stats_provider=FakeStatsProvider())
- ss.setNodeID("\x00" * 20)
ss.setServiceParent(self.sparent)
return ss
def test_readonly(self):
workdir = self.workdir("test_readonly")
- ss = StorageServer(workdir, readonly_storage=True)
- ss.setNodeID("\x00" * 20)
+ ss = StorageServer(workdir, "\x00" * 20, readonly_storage=True)
ss.setServiceParent(self.sparent)
already,writers = self.allocate(ss, "vid", [0,1,2], 75)
def test_discard(self):
# discard is really only used for other tests, but we test it anyways
workdir = self.workdir("test_discard")
- ss = StorageServer(workdir, discard_storage=True)
- ss.setNodeID("\x00" * 20)
+ ss = StorageServer(workdir, "\x00" * 20, discard_storage=True)
ss.setServiceParent(self.sparent)
canary = FakeCanary()
def test_advise_corruption(self):
workdir = self.workdir("test_advise_corruption")
- ss = StorageServer(workdir, discard_storage=True)
- ss.setNodeID("\x00" * 20)
+ ss = StorageServer(workdir, "\x00" * 20, discard_storage=True)
ss.setServiceParent(self.sparent)
si0_s = base32.b2a("si0")
def create(self, name):
workdir = self.workdir(name)
- ss = StorageServer(workdir)
+ ss = StorageServer(workdir, "\x00" * 20)
ss.setServiceParent(self.sparent)
- ss.setNodeID("\x00" * 20)
return ss
def test_create(self):
def create(self, name):
workdir = self.workdir(name)
- ss = StorageServer(workdir)
- ss.setNodeID("\x00" * 20)
+ ss = StorageServer(workdir, "\x00" * 20)
ss.setServiceParent(self.sparent)
return ss