add RemoteInterfaces (foolscap schemas). some tests break.
This commit is contained in:
parent
18d8911c51
commit
e9d67ecc49
|
@ -4,6 +4,8 @@ from foolscap import Referenceable
|
||||||
from twisted.application import service
|
from twisted.application import service
|
||||||
from twisted.python.failure import Failure
|
from twisted.python.failure import Failure
|
||||||
from allmydata.util import idlib
|
from allmydata.util import idlib
|
||||||
|
from zope.interface import implements
|
||||||
|
from allmydata.interfaces import RIBucketWriter
|
||||||
|
|
||||||
from amdlib.util.assertutil import precondition
|
from amdlib.util.assertutil import precondition
|
||||||
|
|
||||||
|
@ -44,6 +46,8 @@ class BucketStore(service.MultiService, Referenceable):
|
||||||
return NoSuchBucketError()
|
return NoSuchBucketError()
|
||||||
|
|
||||||
class Lease(Referenceable):
|
class Lease(Referenceable):
|
||||||
|
implements(RIBucketWriter)
|
||||||
|
|
||||||
def __init__(self, verifierid, leaser, bucket):
|
def __init__(self, verifierid, leaser, bucket):
|
||||||
self._leaser = leaser
|
self._leaser = leaser
|
||||||
self._verifierid = verifierid
|
self._verifierid = verifierid
|
||||||
|
|
|
@ -5,6 +5,8 @@ from foolscap import Tub, Referenceable
|
||||||
from twisted.application import service
|
from twisted.application import service
|
||||||
from twisted.python import log
|
from twisted.python import log
|
||||||
from allmydata.util.iputil import get_local_ip_for
|
from allmydata.util.iputil import get_local_ip_for
|
||||||
|
from zope.interface import implements
|
||||||
|
from allmydata.interfaces import RIClient
|
||||||
|
|
||||||
from twisted.internet import defer, reactor
|
from twisted.internet import defer, reactor
|
||||||
# this BlockingResolver is because otherwise unit tests must sometimes deal
|
# this BlockingResolver is because otherwise unit tests must sometimes deal
|
||||||
|
@ -16,6 +18,7 @@ reactor.installResolver(BlockingResolver())
|
||||||
from allmydata.storageserver import StorageServer
|
from allmydata.storageserver import StorageServer
|
||||||
|
|
||||||
class Client(service.MultiService, Referenceable):
|
class Client(service.MultiService, Referenceable):
|
||||||
|
implements(RIClient)
|
||||||
CERTFILE = "client.pem"
|
CERTFILE = "client.pem"
|
||||||
STOREDIR = 'storage'
|
STOREDIR = 'storage'
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,41 @@
|
||||||
|
|
||||||
|
from foolscap.schema import StringConstraint, ListOf, TupleOf, Any, Nothing
|
||||||
|
from foolscap import RemoteInterface
|
||||||
|
|
||||||
|
Nodeid = StringConstraint(20)
|
||||||
|
PBURL = StringConstraint()
|
||||||
|
# these three are here because Foolscap does not yet support the kind of
|
||||||
|
# restriction I really want to apply to these.
|
||||||
|
RIClient_ = Any
|
||||||
|
Referenceable_ = Any
|
||||||
|
RIBucketWriter_ = Any
|
||||||
|
|
||||||
|
class RIQueenRoster(RemoteInterface):
|
||||||
|
def hello(nodeid=Nodeid, node=RIClient_, pburl=PBURL):
|
||||||
|
return Nothing
|
||||||
|
|
||||||
|
class RIClient(RemoteInterface):
|
||||||
|
def get_service(name=str):
|
||||||
|
return Referenceable_
|
||||||
|
def add_peers(new_peers=ListOf(TupleOf(Nodeid, PBURL), maxLength=100)):
|
||||||
|
return Nothing
|
||||||
|
def lost_peers(lost_peers=ListOf(Nodeid)):
|
||||||
|
return Nothing
|
||||||
|
|
||||||
|
class RIStorageServer(RemoteInterface):
|
||||||
|
def allocate_bucket(verifierid=Nodeid, bucket_num=int, size=int,
|
||||||
|
leaser=Nodeid):
|
||||||
|
return RIBucketWriter_
|
||||||
|
|
||||||
|
|
||||||
|
class RIBucketWriter(RemoteInterface):
|
||||||
|
def write(data=str):
|
||||||
|
return Nothing
|
||||||
|
|
||||||
|
def set_size(size=int):
|
||||||
|
return Nothing
|
||||||
|
|
||||||
|
def close():
|
||||||
|
return Nothing
|
||||||
|
|
||||||
|
|
|
@ -5,8 +5,12 @@ from twisted.application import service
|
||||||
from twisted.python import log
|
from twisted.python import log
|
||||||
import os.path
|
import os.path
|
||||||
from allmydata.util.iputil import get_local_ip_for
|
from allmydata.util.iputil import get_local_ip_for
|
||||||
|
from zope.interface import implements
|
||||||
|
from allmydata.interfaces import RIQueenRoster
|
||||||
|
|
||||||
class Roster(service.MultiService, Referenceable):
|
class Roster(service.MultiService, Referenceable):
|
||||||
|
implements(RIQueenRoster)
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
service.MultiService.__init__(self)
|
service.MultiService.__init__(self)
|
||||||
self.phonebook = {}
|
self.phonebook = {}
|
||||||
|
|
|
@ -7,11 +7,14 @@ from twisted.python.failure import Failure
|
||||||
from amdlib.util.assertutil import precondition
|
from amdlib.util.assertutil import precondition
|
||||||
|
|
||||||
from allmydata.bucketstore import BucketStore
|
from allmydata.bucketstore import BucketStore
|
||||||
|
from zope.interface import implements
|
||||||
|
from allmydata.interfaces import RIStorageServer
|
||||||
|
|
||||||
class BucketAlreadyExistsError(Exception):
|
class BucketAlreadyExistsError(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
class StorageServer(service.MultiService, Referenceable):
|
class StorageServer(service.MultiService, Referenceable):
|
||||||
|
implements(RIStorageServer)
|
||||||
name = 'storageserver'
|
name = 'storageserver'
|
||||||
|
|
||||||
def __init__(self, store_dir):
|
def __init__(self, store_dir):
|
||||||
|
|
|
@ -33,5 +33,10 @@ back pocket ideas:
|
||||||
looks for differences between their self-reported availability and the
|
looks for differences between their self-reported availability and the
|
||||||
experiences of others
|
experiences of others
|
||||||
|
|
||||||
|
store filetable URI in the first 10 peers that appear after your own nodeid
|
||||||
|
each entry has a sequence number, maybe a timestamp
|
||||||
|
on recovery, find the newest
|
||||||
|
|
||||||
big questions:
|
big questions:
|
||||||
convergence?
|
convergence?
|
||||||
|
peer list maintenance: lots of entries
|
||||||
|
|
Loading…
Reference in New Issue