Sat Aug 7 11:03:51 BST 2010 writefaruq@gmail.com * multiple-introducer-client-side-001.dpatch client.py: Added support to read the multiple introducers config file "basedir/introducers" and to create necessary connections to all introducers. web/root.py: Fetches the connection status of all introducer_clients from client web/welcome.xhtml: shows the intriducer FURLs and their connection status on WUI's welcome page New patches: [multiple-introducer-client-side-001.dpatch writefaruq@gmail.com**20100807100351 Ignore-this: ad73102b8e1196536782382170314451 client.py: Added support to read the multiple introducers config file "basedir/introducers" and to create necessary connections to all introducers. web/root.py: Fetches the connection status of all introducer_clients from client web/welcome.xhtml: shows the intriducer FURLs and their connection status on WUI's welcome page ] { hunk ./src/allmydata/client.py 34 TiB=1024*GiB PiB=1024*TiB +MULTI_INTRODUCERS_CFG = "introducers" + class StubClient(Referenceable): implements(RIStubClient) hunk ./src/allmydata/client.py 128 self.started_timestamp = time.time() self.logSource="Client" self.DEFAULT_ENCODING_PARAMETERS = self.DEFAULT_ENCODING_PARAMETERS.copy() - self.init_introducer_client() + self.init_introducer_clients() self.init_stats_provider() self.init_secrets() self.init_storage() hunk ./src/allmydata/client.py 175 if os.path.exists(os.path.join(self.basedir, "run_helper")): self.set_config("helper", "enabled", "true") - def init_introducer_client(self): - self.introducer_furl = self.get_config("client", "introducer.furl") - ic = IntroducerClient(self.tub, self.introducer_furl, + def init_introducer_clients(self): + self.introducer_furls = [] + self.warn_flag = False + # Try to load ""BASEDIR/introducers" cfg file + cfg = os.path.join(self.basedir, MULTI_INTRODUCERS_CFG) + if os.path.exists(cfg): + f = open(cfg, 'r') + for introducer_furl in f.read().split('\n'): + if not introducer_furl.strip(): + continue + self.introducer_furls.append(introducer_furl) + f.close() + furl_count = len(self.introducer_furls) + #print "@icfg: furls: %d" %furl_count + + # read furl from tahoe.cfg + ifurl = self.get_config("client", "introducer.furl", None) + if ifurl not in self.introducer_furls: + self.introducer_furls.append(ifurl) + f = open(cfg, 'a') + f.writelines(ifurl) + f.write('\n') + f.close() + if furl_count > 1: + self.warn_flag = True + self.log("introducers config file modified.") + print "Warning! introducers config file modified." + + # create a pool of introducer_clients + self.introducer_clients = [] + for introducer_furl in self.introducer_furls: + ic = IntroducerClient(self.tub, introducer_furl, self.nickname, str(allmydata.__full_version__), str(self.OLDEST_SUPPORTED_VERSION)) hunk ./src/allmydata/client.py 210 - self.introducer_client = ic + self.introducer_clients.append(ic) + # init introducer_clients as usual + for ic in self.introducer_clients: + self.init_introducer_client(ic) + + def init_introducer_client(self, ic): # hold off on starting the IntroducerClient until our tub has been # started, so we'll have a useful address on our RemoteReference, so # that the introducer's status page will show us. hunk ./src/allmydata/client.py 303 furl_file = os.path.join(self.basedir, "private", "storage.furl") furl = self.tub.registerReference(ss, furlFile=furl_file) ri_name = RIStorageServer.__remote_name__ - self.introducer_client.publish(furl, "storage", ri_name) + # Now, publish multiple introducers + for ic in self.introducer_clients: + ic.publish(furl, "storage", ri_name) d.addCallback(_publish) d.addErrback(log.err, facility="tahoe.init", level=log.BAD, umid="aLGBKw") hunk ./src/allmydata/client.py 359 # check to see if we're supposed to use the introducer too if self.get_config("client-server-selection", "use_introducer", default=True, boolean=True): - sb.use_introducer(self.introducer_client) + + # Now, use our multiple introducers + for ic in self.introducer_clients: + sb.use_introducer(ic) def get_storage_broker(self): return self.storage_broker hunk ./src/allmydata/client.py 375 sc = StubClient() furl = self.tub.registerReference(sc) ri_name = RIStubClient.__remote_name__ - self.introducer_client.publish(furl, "stub_client", ri_name) + # Now publish our multiple introducers + for ic in self.introducer_clients: + ic.publish(furl, "stub_client", ri_name) d = self.when_tub_ready() d.addCallback(_publish) d.addErrback(log.err, facility="tahoe.init", hunk ./src/allmydata/client.py 489 def get_encoding_parameters(self): return self.DEFAULT_ENCODING_PARAMETERS - + + # In case we configure multiple introducers def connected_to_introducer(self): hunk ./src/allmydata/client.py 492 - if self.introducer_client: - return self.introducer_client.connected_to_introducer() - return False - + status = [] + if self.introducer_clients: + s = False + for ic in self.introducer_clients: + s = ic.connected_to_introducer() + status.append(s) + return status + def get_renewal_secret(self): # this will go away return self._secret_holder.get_renewal_secret() hunk ./src/allmydata/web/root.py 220 return ctx.tag[ul] - def data_introducer_furl(self, ctx, data): - return self.client.introducer_furl - def data_connected_to_introducer(self, ctx, data): - if self.client.connected_to_introducer(): - return "yes" - return "no" + # In case we configure multiple introducers + def data_introducers(self, ctx, data): + connection_status = self.client.connected_to_introducer() + s = [] + furls = self.client.introducer_furls + for furl in furls: + i = furls.index(furl) + if connection_status[i]: + s.append( (furl, "Yes") ) + else: + s.append( (furl, "No") ) + s.sort() + return s + + def render_introducers_row(self, ctx, s): + (furl, connected) = s + #connected = + ctx.fillSlots("introducer_furl", "%s" % (furl)) + ctx.fillSlots("connected", "%s" % (connected)) + return ctx.tag def data_helper_furl(self, ctx, data): try: hunk ./src/allmydata/web/welcome.xhtml 25
Introducer FURL | +Connected? | +
no introducers! |