Ticket #1382: interface.dpatch

File interface.dpatch, 13.5 KB (added by kevan, at 2011-03-29T04:06:09Z)

initial implementation of IPeerSelector interface

Line 
1Mon Mar 28 20:00:59 PDT 2011  Kevan Carstensen <kevan@isnotajoke.com>
2  * interfaces: Create "IPeerSelector", an interface for an abstract peer selection class.
3
4New patches:
5
6[interfaces: Create "IPeerSelector", an interface for an abstract peer selection class.
7Kevan Carstensen <kevan@isnotajoke.com>**20110329030059
8 Ignore-this: 6bd8ad4056a7d75c7349876c59de8848
9] hunk ./src/allmydata/interfaces.py 602
10     """I am a node which represents a file: a sequence of bytes. I am not a
11     container, like IDirectoryNode."""
12 
13+class IPeerSelector(Interface):
14+    """
15+    I select peers for an upload, maximizing some measure of health.
16+
17+    I keep track of the state of a grid relative to a file. This means
18+    that I know about all of the peers that parts of that file could be
19+    placed on, and about shares that have been placed on those peers.
20+    Given this, I assign shares to peers in a way that maximizes the
21+    file's health according to whichever definition of health I am
22+    programmed with. I tell the uploader whether or not my assignment is
23+    healthy. I keep track of failures during the process and update my
24+    conclusions appropriately.
25+    """
26+    def add_peer_with_share(peerid, shnum, existing=False):
27+        """
28+        Update my internal state to reflect the fact that peer peerid
29+        holds share shnum. Called for shares that are detected before
30+        peer selection begins, and for shares that are successfully
31+        allocated after peer selection ends.
32+
33+        I take an optional parameter called existing. This is a hint
34+        that the peer => share relationship I'm being told about already
35+        exists. I may use this hint in heuristics designed to minimize
36+        the amount of share data uploaded to the grid.
37+        """
38+
39+    def add_peers(peerids=set):
40+        """
41+        Update my internal state to include the peers in peerids as
42+        potential candidates for storing a file.
43+        """
44+
45+    def mark_full_peer(peerid):
46+        """
47+        Mark the peer peerid as full. This means that any
48+        peer-with-share relationships I know about for peerid remain
49+        valid, but that peerid will not be assigned any new shares.
50+        """
51+
52+    def mark_bad_peer(peerid):
53+        """
54+        Mark the peer peerid as bad. This is typically called when an
55+        error is encountered when communicating with a peer. I will
56+        disregard any existing peer => share relationships associated
57+        with peerid, and will not attempt to assign it any more shares.
58+        """
59+
60+    def get_share_assignments(shallow=False):
61+        """
62+        Given what I know about the state of the grid, I'll attempt to
63+        assign shares to peers in a way that maximizes my definition of
64+        file health. I'll return a list of (share, peerid) tuples with
65+        my decision.
66+
67+        I have an optional shallow parameter. If True, I will not
68+        attempt to assign any new shares before checking happiness;
69+        instead, I will rely only on the shares that I know are already
70+        placed.
71+        """
72+
73+    def is_healthy():
74+        """
75+        I return whether the share assignments I'm currently using
76+        reflect a healthy file, based on my internal definitions.
77+        """
78+
79+    def needs_recomputation():
80+        """
81+        I return True if the share assignments I last returned may have
82+        become stale. This is a hint to the caller that they should call
83+        get_share_assignments again.
84+        """
85+
86 class IImmutableFileNode(IFileNode):
87     def read(consumer, offset=0, size=None):
88         """Download a portion (possibly all) of the file's contents, making
89
90Context:
91
92[NEWS: 'top' for node processes, WUI formatting, removal of GUI apps, documentation updates, foolscap dependency. refs #174, #1219, #1225
93david-sarah@jacaranda.org**20110106005727
94 Ignore-this: f61ac58b4d10e635feb6f7391b1b48fe
95] 
96[Makefile: update 'clean' target for files in bin/
97david-sarah@jacaranda.org**20110103052738
98 Ignore-this: 2bdbc4a50e13e508b66d0f65718c79b2
99] 
100[docs: update performance.rst to describe the difference between already-uploaded and not-already-uploaded, to parameterize segment size, and to use "~A" to mean "approximately A"
101zooko@zooko.com**20110104065455
102 Ignore-this: 8df0d79a062ee19854c0211bd202f606
103] 
104[bin/tahoe-script.template: On non-Windows, invoke support/bin/tahoe directly as a script (rather than via python), so that 'top' for example will show it as 'tahoe'. On Windows, simplify some code that set argv[0], which is never used. fixes #174
105david-sarah@jacaranda.org**20101127232650
106 Ignore-this: 42a86f3eecfdc1ea7b76a7cc68626898
107] 
108[test_runner: avoid unnecessary use of non-ASCII.
109david-sarah@jacaranda.org**20110101100101
110 Ignore-this: e2ff40dce6bb3b021306f2913d4e75df
111] 
112[docs/quickstart.html: fix redundant, badly nested tag. refs #1284
113david-sarah@jacaranda.org**20110102175159
114 Ignore-this: 2ae9cc0b47d2e87b9eb64a0f517c4eef
115] 
116[docs/quickstart.html: information about 'troublesome dependencies' and 'verified systems' de-emphasized by smaller italic font. Re-wrap so that the HTML source is readable (just about) as text. Minor wording tweaks. Improve organization by adding 'Windows Caveats' subsection. fixes #1284
117david-sarah@jacaranda.org**20110102174212
118 Ignore-this: e9dc57983974478200856651c5318fee
119] 
120[NEWS: update entry for removal of Mac and Windows apps. refs #1282
121david-sarah@jacaranda.org**20101226042245
122 Ignore-this: c8099bc6e8235718d042c9a13c1e2425
123] 
124[Move dependency imports from windows/depends.py (which has gone away) into src/allmydata/windows/tahoesvc.py. Also fix a pyflakes warning, and change the service display name from 'Allmydata Tahoe Node' to 'Tahoe-LAFS node'. refs #1282
125david-sarah@jacaranda.org**20101226042100
126 Ignore-this: ee45f324934e1251380206dbee6346d0
127] 
128[Remove unmaintained Windows GUI app, except for windows/tahoesvc.py which is moved to src/allmydata/windows. refs #1282
129david-sarah@jacaranda.org**20101226040237
130 Ignore-this: cae37b6622a7dd5940acc7d3e6a98b90
131] 
132[Remove the Makefile targets relating to the Mac GUI app. refs #1282
133david-sarah@jacaranda.org**20101226025859
134 Ignore-this: 75303be783974b41138744ec62b07965
135] 
136[NEWS: remove unmaintained Mac GUI app. refs #1282
137david-sarah@jacaranda.org**20101226020858
138 Ignore-this: 40474a07f4a550b48563d35350be7ab5
139] 
140[Remove unmaintained Mac GUI app. fixes #1282
141david-sarah@jacaranda.org**20101226020508
142 Ignore-this: b3613bf1abfd284d542bf7c753ec557a
143] 
144[Remove src/allmydata/util/find_exe.py which is no longer used. fixes #1150
145david-sarah@jacaranda.org**20101226023206
146 Ignore-this: 7436c9b53bf210aed34a1a973cd9cace
147] 
148[status_web_pages_review.darcs.patch
149freestorm77@gmail.com**20110102034214
150 Ignore-this: 29f1ecb36177f10f3f846b3d56b313b2
151 
152 I make some changes on status web pages
153 
154 status.xhtml:
155 - Delete unused webform_css link
156 - Align tables on the left
157 
158 tahoe-css:
159 - Do some minor changes on code synthax
160 - changes table.status-download-events style to look like other tables
161 
162 status.py:
163 - Align table on the left
164 - Changes table header
165 - Add heading tags
166 - Modify google api graph: add image border, calculate height to feet data
167 
168 signed-off-by: zooko@zooko.com
169 fixes #1219
170] 
171[test_storage.py: fix a pyflakes unused import warning.
172david-sarah@jacaranda.org**20101231220756
173 Ignore-this: df08231540cb7dff9d2b038e47ab30ee
174] 
175[test_storage.py: leave at least 512 MiB free when running test_large_share. refs #1195
176david-sarah@jacaranda.org**20101231203215
177 Ignore-this: b2144c0341c3452b5d4ba219e284ea0e
178] 
179[storage: use fileutil's version of get_disk_stats() and get_available_space(), use mockery/fakery in tests, enable large share test on platforms with sparse files and if > 4 GiB of disk space is currently available
180zooko@zooko.com**20100910173629
181 Ignore-this: 1304f1164c661de6d5304f993eb9b27b
182] 
183[fileutil: copy in the get_disk_stats() and get_available_space() functions from storage/server.py
184zooko@zooko.com**20100910173520
185 Ignore-this: 8b15569715f710f4fc5092f7ca109253
186] 
187[Update foolscap version requirement to 0.6.0, to address http://foolscap.lothar.com/trac/ticket/167
188david-sarah@jacaranda.org**20101231060039
189 Ignore-this: 98d2b8086a1a500b9f4565bca5a3810
190] 
191[docs/webapi.rst: typos.
192david-sarah@jacaranda.org**20101230034422
193 Ignore-this: d1f5166d72cc711f7e0d9981eac9105e
194] 
195[docs/webapi.rst: capitalization, formatting of section on URL character encoding, and a correction about Internet Explorer.
196david-sarah@jacaranda.org**20101230034049
197 Ignore-this: b3b9819d2fb264b4cdc5c8afd4e8c48d
198] 
199[docs: corrections and clarifications.
200david-sarah@jacaranda.org**20101227051056
201 Ignore-this: e33202858c7644c58f3f924b164294b6
202] 
203[docs: more formatting cleanups and corrections. Spell webapi and wapi as web-API.
204david-sarah@jacaranda.org**20101227050533
205 Ignore-this: 18b23cbfb780df585d8a722a1ec63e94
206] 
207[docs/debian.rst: bring description of building dependencies from source up-to-date, and change hostname from allmydata.com to tahoe-lafs.org.
208david-sarah@jacaranda.org**20101212222912
209 Ignore-this: f38462afc88b4475195610385a28391c
210] 
211[docs/architecture.rst: correct rst syntax.
212david-sarah@jacaranda.org**20101212202003
213 Ignore-this: 3fbe12feb28bec6f1c63aedbc79aad21
214] 
215[docs/architecture.rst: formatting.
216david-sarah@jacaranda.org**20101212201719
217 Ignore-this: 305fa5dfc2939355eaf6d0d2161eb1ff
218] 
219[docs: linkification, wording improvements.
220david-sarah@jacaranda.org**20101212201234
221 Ignore-this: 4e67287f527a8bc728cfbd93255d2aae
222] 
223[docs: formatting.
224david-sarah@jacaranda.org**20101212201115
225 Ignore-this: 2e0ed394ac7726651d3a4f2c4b0d3798
226] 
227[docs/configuration.rst: more formatting tweaks; which -> that.
228david-sarah@jacaranda.org**20101212195522
229 Ignore-this: a7becb7021854ca5a90edd892b36fdd7
230] 
231[docs/configuration.rst: more changes to formatting.
232david-sarah@jacaranda.org**20101212194511
233 Ignore-this: 491aac33e5f5268d224359f1447d10be
234] 
235[docs/configuration.rst: changes to formatting (mainly putting commands and filenames in monospace).
236david-sarah@jacaranda.org**20101212181828
237 Ignore-this: 8a1480e2d5f43bee678476424615b50f
238] 
239[scripts/backupdb.py: more accurate comment about path field.
240david-sarah@jacaranda.org**20101212170320
241 Ignore-this: 50e47a2228a85207bbcd188a78a0d4e6
242] 
243[scripts/cli.py: fix missing 'put' in usage example for 'tahoe put'.
244david-sarah@jacaranda.org**20101212170207
245 Ignore-this: 2cbadf066fff611fc03d3c0ff97ce6ec
246] 
247[docs/frontends/CLI.rst: changes to formatting (mainly putting commands and filenames in monospace), and to command syntax to reflect that DIRCAP/... is accepted. Clarify the syntax of 'tahoe put' and other minor corrections. Tahoe -> Tahoe-LAFS.
248david-sarah@jacaranda.org**20101212165800
249 Ignore-this: a123ef6b564aa8624d1e79c97068ea12
250] 
251[docs/frontends/CLI.rst: Unicode arguments to 'tahoe' work on Windows as of v1.7.1.
252david-sarah@jacaranda.org**20101212063740
253 Ignore-this: 3977a99dfa86ac33a44171deaf43aaab
254] 
255[docs/known_issues.rst: fix title and linkify another URL. refs #1225
256david-sarah@jacaranda.org**20101212062817
257 Ignore-this: cc91287f7fb51c23440b3d2fe79c449c
258] 
259[docs/known_issues.rst: fix an external link. refs #1225
260david-sarah@jacaranda.org**20101212062435
261 Ignore-this: b8cbf12f353131756c358965c48060ec
262] 
263[Fix a link from uri.rst to dirnodes.rst. refs #1225
264david-sarah@jacaranda.org**20101212054502
265 Ignore-this: af6205299f5c9a33229cab259c00f9d5
266] 
267[Fix a link from webapi.rst to FTP-and-SFTP.rst. refs #1225
268david-sarah@jacaranda.org**20101212053435
269 Ignore-this: 2b9f88678c3447ea860d6b61e8799858
270] 
271[More specific hyperlink to architecture.rst from helper.rst. refs #1225
272david-sarah@jacaranda.org**20101212052607
273 Ignore-this: 50424c768fca481252fabf58424852dc
274] 
275[Update hyperlinks between docs, and linkify some external references. refs #1225
276david-sarah@jacaranda.org**20101212051459
277 Ignore-this: cd43a4c3d3de1f832abfa88d5fc4ace1
278] 
279[docs/specifications/dirnodes.rst: fix references to mutable.rst. refs #1225
280david-sarah@jacaranda.org**20101212012720
281 Ignore-this: 6819b4b4e06e947ee48b365e840db37d
282] 
283[docs/specifications/mutable.rst: correct the magic string for v1 mutable containers. refs #1225
284david-sarah@jacaranda.org**20101212011400
285 Ignore-this: 99a5fcdd40cef83dbb08f323f6cdaaca
286] 
287[Move .txt files in docs/frontends and docs/specifications to .rst. refs #1225
288david-sarah@jacaranda.org**20101212010251
289 Ignore-this: 8796d35d928370f7dc6ad2dafdc1c0fe
290] 
291[Convert docs/frontends and docs/specifications to reStructuredText format (not including file moves).
292david-sarah@jacaranda.org**20101212004632
293 Ignore-this: e3ceb2d832d73875abe48624ddbb5622
294] 
295[scripts/cli.py: remove the disclaimer in the help for 'tahoe cp' that it does not handle non-ASCII filenames well. (At least, we intend to handle them.)
296david-sarah@jacaranda.org**20101130002145
297 Ignore-this: 94c003efaa20b9eb4a83503d79844ca
298] 
299[relnotes.txt: fifth -> sixth labor-of-love release
300zooko@zooko.com**20101129045647
301 Ignore-this: 21c245015268b38916e3a138d256c09d
302] 
303[Makefile: BB_BRANCH is set to the empty string for trunk, not the string 'trunk'.
304david-sarah@jacaranda.org**20101128233512
305 Ignore-this: 5a7ef8eb10475636d21b91e25b56c369
306] 
307[relnotes.txt: eleventh -> twelfth release.
308david-sarah@jacaranda.org**20101128223321
309 Ignore-this: 1e26410156a665271c1170803dea2c0d
310] 
311[relnotes.tst: point to known_issues.rst, not known_issues.txt.
312david-sarah@jacaranda.org**20101128222918
313 Ignore-this: 60194eb4544cac446fe4f60b3e34b887
314] 
315[quickstart.html: fix link to point to allmydata-tahoe-1.8.1.zip.
316david-sarah@jacaranda.org**20101128221728
317 Ignore-this: 7b3ee86f8256aa12f5d862f689f3ee29
318] 
319[TAG allmydata-tahoe-1.8.1
320david-sarah@jacaranda.org**20101128212336
321 Ignore-this: 9c18bdeaef4822f590d2a0d879e00621
322] 
323Patch bundle hash:
3249a0a487d93c7ef13e5e40e21603f9feeb68466ca