1 | --- home/omar/pc2/gs/tahoe-lafs/src/allmydata/client.py 2010-05-22 20:32:00.000000000 +0100 |
---|
2 | +++ media/disk3/gs/tahoe-lafs/src/allmydata/client.py 2010-06-12 18:27:44.000000000 +0100 |
---|
3 | @@ -31,6 +31,8 @@ GiB=1024*MiB |
---|
4 | TiB=1024*GiB |
---|
5 | PiB=1024*TiB |
---|
6 | |
---|
7 | +MULTI_INTRODUCERS_CFG = "introducers" |
---|
8 | + |
---|
9 | class StubClient(Referenceable): |
---|
10 | implements(RIStubClient) |
---|
11 | |
---|
12 | @@ -123,7 +125,7 @@ class Client(node.Node, pollmixin.PollMi |
---|
13 | self.started_timestamp = time.time() |
---|
14 | self.logSource="Client" |
---|
15 | self.DEFAULT_ENCODING_PARAMETERS = self.DEFAULT_ENCODING_PARAMETERS.copy() |
---|
16 | - self.init_introducer_client() |
---|
17 | + self.init_introducer_clients() |
---|
18 | self.init_stats_provider() |
---|
19 | self.init_secrets() |
---|
20 | self.init_storage() |
---|
21 | @@ -170,13 +172,37 @@ class Client(node.Node, pollmixin.PollMi |
---|
22 | if os.path.exists(os.path.join(self.basedir, "run_helper")): |
---|
23 | self.set_config("helper", "enabled", "true") |
---|
24 | |
---|
25 | - def init_introducer_client(self): |
---|
26 | + def init_introducer_clients(self): |
---|
27 | + # keep self.introducer_furl intact to break any reference to it |
---|
28 | self.introducer_furl = self.get_config("client", "introducer.furl") |
---|
29 | - ic = IntroducerClient(self.tub, self.introducer_furl, |
---|
30 | + # build a list of introducers from MULTI_INTRODUCERS_CFG |
---|
31 | + # "BASEDIR/introducers" |
---|
32 | + self.introducer_furls = [] |
---|
33 | + self.introducer_furls.append(self.introducer_furl) |
---|
34 | + cfg = os.path.join(self.basedir, MULTI_INTRODUCERS_CFG) |
---|
35 | + if os.path.exists(cfg): |
---|
36 | + f = open(cfg, 'r') |
---|
37 | + for introducer_furl in f.read().split('\n'): |
---|
38 | + if (introducer_furl == '') or (introducer_furl == '\n'): |
---|
39 | + continue |
---|
40 | + self.introducer_furls.append(introducer_furl) |
---|
41 | + f.close() |
---|
42 | + #print "@Init_ICs: furls =", len(self.introducer_furls) |
---|
43 | + # create a list a introducers client |
---|
44 | + self.introducer_clients = [] |
---|
45 | + for introducer_furl in self.introducer_furls: |
---|
46 | + ic = IntroducerClient(self.tub, introducer_furl, |
---|
47 | self.nickname, |
---|
48 | str(allmydata.__full_version__), |
---|
49 | str(self.OLDEST_SUPPORTED_VERSION)) |
---|
50 | - self.introducer_client = ic |
---|
51 | + self.introducer_clients.append(ic) |
---|
52 | + # retain a link to self.introducer_client |
---|
53 | + self.introducer_client = self.introducer_clients[0] |
---|
54 | + for ic in self.introducer_clients: |
---|
55 | + self.init_introducer_client(ic) |
---|
56 | + |
---|
57 | + def init_introducer_client(self, ic): |
---|
58 | + #print "entering init_introducer_client:", ic |
---|
59 | # hold off on starting the IntroducerClient until our tub has been |
---|
60 | # started, so we'll have a useful address on our RemoteReference, so |
---|
61 | # that the introducer's status page will show us. |
---|
62 | @@ -185,7 +211,8 @@ class Client(node.Node, pollmixin.PollMi |
---|
63 | ic.setServiceParent(self) |
---|
64 | d.addCallback(_start_introducer_client) |
---|
65 | d.addErrback(log.err, facility="tahoe.init", |
---|
66 | - level=log.BAD, umid="URyI5w") |
---|
67 | + level=log.BAD, umid="URyI5x") |
---|
68 | + #print "exiting init_introducer_clinet()" |
---|
69 | |
---|
70 | def init_stats_provider(self): |
---|
71 | gatherer_furl = self.get_config("client", "stats_gatherer.furl", None) |
---|
72 | @@ -264,6 +291,11 @@ class Client(node.Node, pollmixin.PollMi |
---|
73 | furl_file = os.path.join(self.basedir, "private", "storage.furl") |
---|
74 | furl = self.tub.registerReference(ss, furlFile=furl_file) |
---|
75 | ri_name = RIStorageServer.__remote_name__ |
---|
76 | + # in case, we have multi-introducers configured |
---|
77 | + if self.introducer_clients: |
---|
78 | + for ic in self.introducer_clients: |
---|
79 | + ic.publish(furl, "storage", ri_name) |
---|
80 | + else: |
---|
81 | self.introducer_client.publish(furl, "storage", ri_name) |
---|
82 | d.addCallback(_publish) |
---|
83 | d.addErrback(log.err, facility="tahoe.init", |
---|
84 | @@ -318,6 +350,11 @@ class Client(node.Node, pollmixin.PollMi |
---|
85 | # check to see if we're supposed to use the introducer too |
---|
86 | if self.get_config("client-server-selection", "use_introducer", |
---|
87 | default=True, boolean=True): |
---|
88 | + # in case, we have multi-introducers configured |
---|
89 | + if self.introducer_clients: |
---|
90 | + for ic in self.introducer_clients: |
---|
91 | + sb.use_introducer(ic) |
---|
92 | + else: |
---|
93 | sb.use_introducer(self.introducer_client) |
---|
94 | |
---|
95 | def get_storage_broker(self): |
---|
96 | @@ -331,6 +368,11 @@ class Client(node.Node, pollmixin.PollMi |
---|
97 | sc = StubClient() |
---|
98 | furl = self.tub.registerReference(sc) |
---|
99 | ri_name = RIStubClient.__remote_name__ |
---|
100 | + # in case, we have multi-introducers configured |
---|
101 | + if self.introducer_clients: |
---|
102 | + for ic in self.introducer_clients: |
---|
103 | + ic.publish(furl, "stub_client", ri_name) |
---|
104 | + else: |
---|
105 | self.introducer_client.publish(furl, "stub_client", ri_name) |
---|
106 | d = self.when_tub_ready() |
---|
107 | d.addCallback(_publish) |
---|