Ticket #68: enable_client_with_multi_introducer.dpatch

File enable_client_with_multi_introducer.dpatch, 10.0 KB (added by writefaruq, at 2010-07-09T18:06:45Z)

Revised patch for client.py web/root.py web/welcome.xhtml

Line 
1Fri Jul  9 18:33:59 BST 2010  writefaruq@gmail.com
2  * enable_client_with_multi_introducer.dpatch
3  Using this patch client can read a config file basedir/intoducers that contains the furls of introducers one per line. Client uses these furls along with the furl from tahoe.cfg to connect to the introducers. Statuses of these connections are listed in client's welcome page.
4
5New patches:
6
7[enable_client_with_multi_introducer.dpatch
8writefaruq@gmail.com**20100709173359
9 Ignore-this: 2b4c9553b2c150ee8ba3c5d86cf148fd
10 Using this patch client can read a config file basedir/intoducers that contains the furls of introducers one per line. Client uses these furls along with the furl from tahoe.cfg to connect to the introducers. Statuses of these connections are listed in client's welcome page.
11] {
12hunk ./src/allmydata/client.py 34
13 TiB=1024*GiB
14 PiB=1024*TiB
15 
16+MULTI_INTRODUCERS_CFG = "introducers"
17+
18 class StubClient(Referenceable):
19     implements(RIStubClient)
20 
21hunk ./src/allmydata/client.py 128
22         self.started_timestamp = time.time()
23         self.logSource="Client"
24         self.DEFAULT_ENCODING_PARAMETERS = self.DEFAULT_ENCODING_PARAMETERS.copy()
25-        self.init_introducer_client()
26+        self.init_introducer_clients()
27         self.init_stats_provider()
28         self.init_secrets()
29         self.init_storage()
30hunk ./src/allmydata/client.py 175
31         if os.path.exists(os.path.join(self.basedir, "run_helper")):
32             self.set_config("helper", "enabled", "true")
33 
34-    def init_introducer_client(self):
35-        self.introducer_furl = self.get_config("client", "introducer.furl")
36-        ic = IntroducerClient(self.tub, self.introducer_furl,
37+    def init_introducer_clients(self):
38+        # read first furl from tahoe.cfg       
39+        introducer_furl1 = self.get_config("client", "introducer.furl", None)     
40+        self.introducer_furls = []
41+        if introducer_furl1:
42+            self.introducer_furls.append(introducer_furl1)
43+        # read from ""BASEDIR/introducers" cfg file
44+        cfg = os.path.join(self.basedir, MULTI_INTRODUCERS_CFG)
45+        if os.path.exists(cfg):
46+           f = open(cfg, 'r')
47+           for introducer_furl in  f.read().split('\n'):
48+                if not introducer_furl.strip():
49+                    continue
50+                self.introducer_furls.append(introducer_furl)
51+           f.close()
52+        # create a pool of introducer_clients
53+        self.introducer_clients = []
54+        for introducer_furl in self.introducer_furls:
55+            ic = IntroducerClient(self.tub, introducer_furl,
56                               self.nickname,
57                               str(allmydata.__full_version__),
58                               str(self.OLDEST_SUPPORTED_VERSION))
59hunk ./src/allmydata/client.py 197
60-        self.introducer_client = ic
61+            self.introducer_clients.append(ic)
62+        # init introducer_clients as usual     
63+        for ic in self.introducer_clients:                   
64+            self.init_introducer_client(ic)
65+   
66+    def init_introducer_client(self, ic):
67         # hold off on starting the IntroducerClient until our tub has been
68         # started, so we'll have a useful address on our RemoteReference, so
69         # that the introducer's status page will show us.
70hunk ./src/allmydata/client.py 290
71             furl_file = os.path.join(self.basedir, "private", "storage.furl")
72             furl = self.tub.registerReference(ss, furlFile=furl_file)
73             ri_name = RIStorageServer.__remote_name__
74-            self.introducer_client.publish(furl, "storage", ri_name)
75+            # Now, publish our multi-introducers
76+            for ic in self.introducer_clients:
77+                ic.publish(furl, "storage", ri_name)           
78         d.addCallback(_publish)
79         d.addErrback(log.err, facility="tahoe.init",
80                      level=log.BAD, umid="aLGBKw")
81hunk ./src/allmydata/client.py 346
82         # check to see if we're supposed to use the introducer too
83         if self.get_config("client-server-selection", "use_introducer",
84                            default=True, boolean=True):
85-            sb.use_introducer(self.introducer_client)
86+           
87+            # Now, use our multi-introducers
88+            for ic in self.introducer_clients:
89+                sb.use_introducer(ic)   
90 
91     def get_storage_broker(self):
92         return self.storage_broker
93hunk ./src/allmydata/client.py 362
94             sc = StubClient()
95             furl = self.tub.registerReference(sc)
96             ri_name = RIStubClient.__remote_name__
97-            self.introducer_client.publish(furl, "stub_client", ri_name)
98+            # Now publish our multiple introducers
99+            for ic in self.introducer_clients:
100+                ic.publish(furl, "stub_client", ri_name)
101         d = self.when_tub_ready()
102         d.addCallback(_publish)
103         d.addErrback(log.err, facility="tahoe.init",
104hunk ./src/allmydata/client.py 476
105 
106     def get_encoding_parameters(self):
107         return self.DEFAULT_ENCODING_PARAMETERS
108-
109+   
110+    # In case we configure multiple introducers
111     def connected_to_introducer(self):
112hunk ./src/allmydata/client.py 479
113-        if self.introducer_client:
114-            return self.introducer_client.connected_to_introducer()
115-        return False
116-
117+        status = []
118+        if self.introducer_clients:
119+            s = False
120+            for ic in self.introducer_clients:
121+                s = ic.connected_to_introducer()
122+                status.append(s)
123+        return status
124+   
125     def get_renewal_secret(self): # this will go away
126         return self._secret_holder.get_renewal_secret()
127 
128hunk ./src/allmydata/web/root.py 220
129 
130         return ctx.tag[ul]
131 
132-    def data_introducer_furl(self, ctx, data):
133-        return self.client.introducer_furl
134-    def data_connected_to_introducer(self, ctx, data):
135-        if self.client.connected_to_introducer():
136-            return "yes"
137-        return "no"
138+    # In case we configure multiple introducers
139+    def data_introducers(self, ctx, data):
140+        connection_status = self.client.connected_to_introducer()         
141+        s = []
142+        furls = self.client.introducer_furls       
143+        for furl in furls:
144+            i = furls.index(furl)
145+            if connection_status[i]:           
146+                s.append( (furl, "Yes") )
147+            else:
148+                s.append( (furl, "No") )
149+        s.sort()
150+        return s
151+
152+    def render_introducers_row(self, ctx, s):
153+        (furl, connected) = s
154+        #connected =
155+        ctx.fillSlots("introducer_furl", "%s" % (furl))
156+        ctx.fillSlots("connected", "%s" % (connected))
157+        return ctx.tag
158 
159     def data_helper_furl(self, ctx, data):
160         try:
161hunk ./src/allmydata/web/welcome.xhtml 25
162     <tr><th>Tahoe-LAFS code imported from:</th> <td n:render="string" n:data="import_path" /></tr>
163     <tr><th>Services running:</th> <td n:render="services" /></tr>
164   </table>
165
166+
167 
168 </div>
169 
170hunk ./src/allmydata/web/welcome.xhtml 40
171   <div n:render="download_form" />
172 </div>
173 
174+<h2>Connected Introducer(s)</h2>
175+
176+<div>
177+<table n:render="sequence" n:data="introducers">
178+  <tr n:pattern="header">
179+    <td>Introducer FURL</td>
180+    <td>Connected?</td>
181+  </tr>
182+  <tr n:pattern="item" n:render="introducers_row">
183+    <td><tt><n:slot name="introducer_furl"/></tt></td>
184+    <td><tt><n:slot name="connected"/></tt></td>
185+  </tr>
186+  <tr n:pattern="empty"><td>no introducers!</td></tr>
187+</table>
188+</div>
189+
190+
191+
192 <div class="section" id="grid">
193   <h2>Status of the Storage Grid</h2>
194 
195hunk ./src/allmydata/web/welcome.xhtml 61
196-  <div>
197-    <n:attr name="class">connected-<n:invisible n:render="string" n:data="connected_to_introducer" /></n:attr>
198-    <div>Introducer: <span class="data-chars" n:render="string" n:data="introducer_furl" /></div>
199-    <div>Connected to introducer?: <span n:render="string" n:data="connected_to_introducer" /></div>
200-  </div>
201-
202   <div>
203     <n:attr name="class">connected-<n:invisible n:render="string" n:data="connected_to_helper" /></n:attr>
204     <div>Helper: <span n:render="string" n:data="helper_furl" /></div>
205hunk ./src/allmydata/web/welcome.xhtml 103
206 <div class="section" id="other-resources">
207   <h2>Other Resources</h2>
208 
209-  <div>Please visit the <a target="_blank" href="http://tahoe-lafs.org">Tahoe-LAFS home page</a> for
210+  <div>Please visit the <a href="http://allmydata.org">Tahoe-LAFS home page</a> for
211   code updates and bug reporting.</div>
212 
213   <div>The <a href="provisioning">provisioning tool</a> and <a
214}
215
216Context:
217
218[quickstart.html: python 2.5 -> 2.6 as recommended version
219david-sarah@jacaranda.org**20100705175858
220 Ignore-this: bc3a14645ea1d5435002966ae903199f
221] 
222[SFTP: don't call .stopProducing on the producer registered with OverwriteableFileConsumer (which breaks with warner's new downloader).
223david-sarah@jacaranda.org**20100628231926
224 Ignore-this: 131b7a5787bc85a9a356b5740d9d996f
225] 
226[docs/how_to_make_a_tahoe-lafs_release.txt: trivial correction, install.html should now be quickstart.html.
227david-sarah@jacaranda.org**20100625223929
228 Ignore-this: 99a5459cac51bd867cc11ad06927ff30
229] 
230[setup: in the Makefile, refuse to upload tarballs unless someone has passed the environment variable "BB_BRANCH" with value "trunk"
231zooko@zooko.com**20100619034928
232 Ignore-this: 276ddf9b6ad7ec79e27474862e0f7d6
233] 
234[trivial: tiny update to in-line comment
235zooko@zooko.com**20100614045715
236 Ignore-this: 10851b0ed2abfed542c97749e5d280bc
237 (I'm actually committing this patch as a test of the new eager-annotation-computation of trac-darcs.)
238] 
239[docs: about.html link to home page early on, and be decentralized storage instead of cloud storage this time around
240zooko@zooko.com**20100619065318
241 Ignore-this: dc6db03f696e5b6d2848699e754d8053
242] 
243[docs: update about.html, especially to have a non-broken link to quickstart.html, and also to comment out the broken links to "for Paranoids" and "for Corporates"
244zooko@zooko.com**20100619065124
245 Ignore-this: e292c7f51c337a84ebfeb366fbd24d6c
246] 
247[TAG allmydata-tahoe-1.7.0
248zooko@zooko.com**20100619052631
249 Ignore-this: d21e27afe6d85e2e3ba6a3292ba2be1
250] 
251Patch bundle hash:
2528c4c745fc13326220dfc53bb0112c89fce76a34d