]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
#538: add remote_get_version() to four main Referenceable objects: Introducer Service...
authorBrian Warner <warner@allmydata.com>
Sat, 22 Nov 2008 00:43:52 +0000 (17:43 -0700)
committerBrian Warner <warner@allmydata.com>
Sat, 22 Nov 2008 00:43:52 +0000 (17:43 -0700)
src/allmydata/control.py
src/allmydata/interfaces.py
src/allmydata/introducer/interfaces.py
src/allmydata/introducer/server.py
src/allmydata/offloaded.py
src/allmydata/storage.py
src/allmydata/test/test_client.py

index 28e5c615f931d968522ac9b05a548281ddbce0f7..b566231f9b9a5ae5c7e792495eb09df89072b6b7 100644 (file)
@@ -81,7 +81,7 @@ class ControlServer(Referenceable, service.Service):
             return results
         peerid, connection = everyone_left.pop(0)
         start = time.time()
-        d = connection.callRemote("get_versions")
+        d = connection.callRemote("get_version")
         def _done(ignored):
             stop = time.time()
             elapsed = stop - start
index 798b4baf8d0a30671e0525d8095a7c2bf2a05d55..bcfbf626fcb83005356add671053b3ef89578171 100644 (file)
@@ -1,7 +1,7 @@
 
 from zope.interface import Interface
 from foolscap.schema import StringConstraint, ListOf, TupleOf, SetOf, DictOf, \
-     ChoiceOf, IntegerConstraint
+     ChoiceOf, IntegerConstraint, Any
 from foolscap import RemoteInterface, Referenceable
 
 HASH_SIZE=32
@@ -86,21 +86,11 @@ ReadData = ListOf(ShareData)
 class RIStorageServer(RemoteInterface):
     __remote_name__ = "RIStorageServer.tahoe.allmydata.com"
 
-    def get_versions():
+    def get_version():
         """
-        Return a tuple of (my_version, oldest_supported) strings.  Each string can be parsed by
-        a pyutil.version_class.Version instance or a distutils.version.LooseVersion instance,
-        and then compared. The first goal is to make sure that nodes are not confused by
-        speaking to an incompatible peer. The second goal is to enable the development of
-        backwards-compatibility code.
-
-        The meaning of the oldest_supported element is that if you treat this storage server as
-        though it were of that version, then you will not be disappointed.
-
-        The precise meaning of this method might change in incompatible ways until we get the
-        whole compatibility scheme nailed down.
+        Return a dictionary of version information.
         """
-        return TupleOf(str, str)
+        return DictOf(str, Any())
 
     def allocate_buckets(storage_index=StorageIndex,
                          renew_secret=LeaseRenewSecret,
@@ -351,8 +341,6 @@ class IStorageBucketReader(Interface):
 
 
 # hm, we need a solution for forward references in schemas
-from foolscap.schema import Any
-
 FileNode_ = Any() # TODO: foolscap needs constraints on copyables
 DirectoryNode_ = Any() # TODO: same
 AnyNode_ = ChoiceOf(FileNode_, DirectoryNode_)
@@ -2077,6 +2065,12 @@ class RIEncryptedUploadable(RemoteInterface):
 class RICHKUploadHelper(RemoteInterface):
     __remote_name__ = "RIUploadHelper.tahoe.allmydata.com"
 
+    def get_version():
+        """
+        Return a dictionary of version information.
+        """
+        return DictOf(str, Any())
+
     def upload(reader=RIEncryptedUploadable):
         return UploadResults
 
@@ -2084,6 +2078,12 @@ class RICHKUploadHelper(RemoteInterface):
 class RIHelper(RemoteInterface):
     __remote_name__ = "RIHelper.tahoe.allmydata.com"
 
+    def get_version():
+        """
+        Return a dictionary of version information.
+        """
+        return DictOf(str, Any())
+
     def upload_chk(si=StorageIndex):
         """See if a file with a given storage index needs uploading. The
         helper will ask the appropriate storage servers to see if the file
index d084f49896dcc3e330ace56c42dfd0cc15218ca2..56b87b16fe059dec0250b9cda1c5637430a93d97 100644 (file)
@@ -1,6 +1,6 @@
 
 from zope.interface import Interface
-from foolscap.schema import StringConstraint, TupleOf, SetOf
+from foolscap.schema import StringConstraint, TupleOf, SetOf, DictOf, Any
 from foolscap import RemoteInterface
 FURL = StringConstraint(1000)
 
@@ -68,6 +68,8 @@ class RIIntroducerSubscriberService(RemoteInterface):
 
 class RIIntroducerPublisherAndSubscriberService(RemoteInterface):
     __remote_name__ = "RIIntroducerPublisherAndSubscriberService.tahoe.allmydata.com"
+    def get_version():
+        return DictOf(str, Any())
     def publish(announcement=Announcement):
         return None
     def subscribe(subscriber=RIIntroducerSubscriberClient, service_name=str):
index c71237a46d3f962fa6b6c3deaa6247cbaa6a09ae..3005b54d00662985973c5f6b40da130c197302b7 100644 (file)
@@ -3,6 +3,7 @@ import time, os.path
 from zope.interface import implements
 from twisted.application import service
 from foolscap import Referenceable
+import allmydata
 from allmydata import node
 from allmydata.util import log
 from allmydata.introducer.interfaces import \
@@ -46,6 +47,10 @@ class IntroducerNode(node.Node):
 class IntroducerService(service.MultiService, Referenceable):
     implements(RIIntroducerPublisherAndSubscriberService)
     name = "introducer"
+    VERSION = { "http://allmydata.org/tahoe/protocols/introducer/v1":
+                 { },
+                "application-version": str(allmydata.__version__),
+                }
 
     def __init__(self, basedir="."):
         service.MultiService.__init__(self)
@@ -64,6 +69,9 @@ class IntroducerService(service.MultiService, Referenceable):
     def get_subscribers(self):
         return self._subscribers
 
+    def remote_get_version(self):
+        return self.VERSION
+
     def remote_publish(self, announcement):
         self.log("introducer: announcement published: %s" % (announcement,) )
         index = make_index(announcement)
index 52a9f4fec5cebca3ce8266c526502a2162b929ea..048203d7e94c23670f00767eb53e8772659c61d5 100644 (file)
@@ -5,6 +5,7 @@ from twisted.application import service
 from twisted.internet import defer
 from foolscap import Referenceable, DeadReferenceError
 from foolscap.eventual import eventually
+import allmydata
 from allmydata import interfaces, storage, uri
 from allmydata.immutable import upload
 from allmydata.immutable.layout import ReadBucketProxy
@@ -131,6 +132,10 @@ class CHKUploadHelper(Referenceable, upload.CHKUploader):
     remote AssistedUploader.
     """
     implements(interfaces.RICHKUploadHelper)
+    VERSION = { "http://allmydata.org/tahoe/protocols/helper/chk-upload/v1" :
+                 { },
+                "application-version": str(allmydata.__version__),
+                }
 
     def __init__(self, storage_index, helper,
                  incoming_file, encoding_file,
@@ -186,6 +191,9 @@ class CHKUploadHelper(Referenceable, upload.CHKUploader):
         self.log("no ciphertext yet", level=log.NOISY)
         return (self._results, self)
 
+    def remote_get_version(self):
+        return self.VERSION
+
     def remote_upload(self, reader):
         # reader is an RIEncryptedUploadable. I am specified to return an
         # UploadResults dictionary.
@@ -482,6 +490,10 @@ class Helper(Referenceable, service.MultiService):
     # helper at random.
 
     name = "helper"
+    VERSION = { "http://allmydata.org/tahoe/protocols/helper/v1" :
+                 { },
+                "application-version": str(allmydata.__version__),
+                }
     chk_upload_helper_class = CHKUploadHelper
     MAX_UPLOAD_STATUSES = 10
 
@@ -554,6 +566,9 @@ class Helper(Referenceable, service.MultiService):
         stats.update(self._counters)
         return stats
 
+    def remote_get_version(self):
+        return self.VERSION
+
     def remote_upload_chk(self, storage_index):
         self.count("chk_upload_helper.upload_requests")
         r = upload.UploadResults()
index 7387daefd8565208cdeebf82c13b92ae54b47222..526de307cdd3548c843b67f87a67db660e278c25 100644 (file)
@@ -1,5 +1,4 @@
 import os, re, weakref, stat, struct, time
-from distutils.version import LooseVersion
 
 from foolscap import Referenceable
 from twisted.application import service
@@ -764,10 +763,10 @@ def create_mutable_sharefile(filename, my_nodeid, write_enabler, parent):
 class StorageServer(service.MultiService, Referenceable):
     implements(RIStorageServer, IStatsProducer)
     name = 'storage'
-
-    # This means that if a client treats me as though I were a 1.0.0 storage server, they will
-    # not be disappointed.
-    OLDEST_SUPPORTED_VERSION = LooseVersion("1.0.0")
+    VERSION = { "http://allmydata.org/tahoe/protocols/storage/v1" :
+                 { "maximum-immutable-share-size": 2**32 },
+                "application-version": str(allmydata.__version__),
+                }
 
     def __init__(self, storedir, sizelimit=None,
                  discard_storage=False, readonly_storage=False,
@@ -899,8 +898,8 @@ class StorageServer(service.MultiService, Referenceable):
             space += bw.allocated_size()
         return space
 
-    def remote_get_versions(self):
-        return (str(allmydata.__version__), str(self.OLDEST_SUPPORTED_VERSION))
+    def remote_get_version(self):
+        return self.VERSION
 
     def remote_allocate_buckets(self, storage_index,
                                 renew_secret, cancel_secret,
index 836cd74fe43666f2b3a9c5a3839be9083caa94bc..f38cb32a55e0a6b3a2dbebbb143848f9ad666e88 100644 (file)
@@ -153,8 +153,9 @@ class Basic(unittest.TestCase):
         open(os.path.join(basedir, "vdrive.furl"), "w").write("")
         c = client.Client(basedir)
         ss = c.getServiceNamed("storage")
-        mine, oldest = ss.remote_get_versions()
-        self.failUnlessEqual(mine, str(allmydata.__version__))
+        verdict = ss.remote_get_version()
+        self.failUnlessEqual(verdict["application-version"],
+                             str(allmydata.__version__))
         self.failIfEqual(str(allmydata.__version__), "unknown")
         self.failUnless("." in str(allmydata.__version__),
                         "non-numeric version in '%s'" % allmydata.__version__)