Gentoo Archives: gentoo-soc

From: Kostyantyn Ovechko <fastinetserver2@×××××.com>
To: gentoo-soc <gentoo-soc@l.g.o>
Subject: [gentoo-soc] Draft: Project IDFetch - Weekly report #8-9 ("Once upon a time...")
Date: Thu, 05 Aug 2010 21:13:08
Message-Id: 1281006769.23200.75.camel@monapc
1 Hello,
2
3 Robin, please take a look at this report, before i post it.
4
5 -=====================================================================-
6 - Project IDFetch - Weekly report #8-9 ("Once upon a time...") -
7 -=====================================================================-
8
9 Once upon a time there were no computers, and nobody knew how a gnome[1]
10 and dEmons[2] look like. Today even kids know this, but i still bumped
11 into a problem that i can not see a dEmon. All it started when i was
12 trying to play "Roshambo game"[3] with segget dEmon.
13
14 Firstly, i was trying to fork[4] the curly[5] daemon twice and it kept
15 punching me in my nose, so i thought my TTL[6] would rapidly decrease.
16 I understood that it's not such an easy thing to win while fighting with
17 someone you can not see. And when daemon obtained Python[7-8] support
18 and started to spawn[9], i've got even more problems. Conscience was
19 telling me that i must play by the rules, but consciousness was sure that
20 daemon doesn't always abide the protocol[10]. I've tried to follow the
21 thread[11], but the dEmon was moving like a ghost[12], so i almost got
22 myself lost in the thicket of of logs[13] and trees[14] :-(
23
24 Anjuta[15] came to my rescue and helped me to improve my tools, so i could
25 see what the daemon does. Unfortunately, curses[16-17] don't always work
26 with dEmons, and i really needed a pure magic to win this game. So, i've
27 learned: "Mutex"[18], "Rainbow Colors"[19] and some other tricks.
28
29 In a meantime i was finding myself knowing more and more about the dEmon,
30 but this was not enough and i had to prepare good arguments if i were
31 going to talk to the dEmon. Here they are:
32
33 1. For segget daemon:
34 Command line arguments:
35 --no-daemon
36 --conf-dir=specify_conf_dir_here
37 Arguments are optional. If no arguments provided, segget will run in a daemon
38 mode and use /etc/seggetd dir to read configuration files.
39
40 2. For request tool:
41 --pkglist-file
42 E.i.:
43 $request --pkglist-file=/home/user/mypkg.list
44
45 3. For tuiclient:
46 --wait-distfile=distfile_name
47 tuiclient checks distfile status, and returns when distfile is downloaded or not in the queue.
48
49
50 Btw, here's features added to segget daemon and tuiclient during this
51 period of time:
52
53 1. DAEMON
54 =========
55 1.1. Options:
56 --------------
57 Add daemon mode to segget
58 Add /etc/init.d/seggetd script to start|stop|restart|status segget daemon
59 Check all set checksums, checksums are optional.
60 Consider distfile failed if one of its segments is failed.
61 Fixed: if only local mirrors are available and all of them failed to download
62 a distfile, distfile still had DWAITING status, because attempt_limit wasn't reached.
63
64 Add CoralCDN support as an option to network#.conf files (section [mode])
65
66 Add options FOLLOW_LOCATION and MAX_REDIRS to network#.conf files
67
68 SYNOPSIS: FOLLOW_LOCATION= 0 | 1
69 A parameter set to 1 tells segget to follow any Location: header that the server
70 sends as part of an HTTP header. This means that the segget will re-send the
71 same request on the new location and follow new Location: headers all the way
72 until no more such headers are returned. MAX_REDIRS can be used to limit the
73 number of redirects segget will follow.
74 Default:
75 follow_location=1
76
77 MAX_REDIRS
78 The set number will be the redirection limit. If that many redirections have
79 been followed, the next redirect will cause an error. This option only makes
80 sense if the FOLLOW_LOCATION is used at the same time.
81 Setting the limit to 0 will make segget refuse any redirect.
82 Minimum value: 0
83 Maximum value: 100
84 Default:
85 max_redirs=5
86
87 Add BIND_LOCAL_PORT and BIND_LOCAL_PORT_RANGE options to network#.conf files
88
89 BIND_LOCAL_PORT
90 This sets the local port number of the socket used for connection. This option
91 can be used in combination with BIND_INTERFACE and you are recommended to
92 use BIND_LOCAL_PORT_RANGE as well when this is set. Set to 0 - to disable
93 binding. Valid port numbers are 1 - 65535.
94 Minimum value: 0 (no binding)
95 Maximum value: 65535
96 Default:
97 bind_local_port=0
98
99 BIND_LOCAL_PORT_RANGE
100 If BIND_LOCAL_PORT=0 this option will be ignored.
101 This is the number of attempts segget should make to find a
102 working local port number. It starts with the given BIND_LOCAL_PORT and adds
103 one to the number for each retry. Setting this to 1 or below will make segget
104 do only one try for the exact port number. Port numbers by nature are scarce
105 resources that will be busy at times so setting this value to something too
106 low might cause unnecessary connection setup failures.
107 Minimum value: 1
108 Maximum value: 65535
109 Default:
110 bind_local_port_range=20
111
112 Add option proxy_type to network#.conf files
113
114 SYNOPSIS: PROXY_TYPE = 0 | 1 | 2 | 3 | 4 | 5
115 0 - HTTP
116 1 - HTTP_1_0
117 2 - SOCKS4
118 3 - SOCKS4a
119 4 - SOCKS5
120 5 - SOCKS5_HOSTNAME
121 Specify type of the proxy.
122 Default:
123 proxy_type=0
124
125 1.2. Proxy-fetcher
126 ------------------
127 Implement checks for both (proxy_fetcher and request_server) queues.
128
129 There're 2 queues: proxy_fetcher queue and request_server queue.
130
131 Note: Segget processes request_server queue first and if no segment was
132 chosen switches to proxy_fetcher queue.
133
134 Before adding a distifile to any of the queues it's necessary to
135 check both queues, since distfile may already be in one of them.
136
137 1.3. Python scripting
138 ---------------------
139 Add [scripting_and_scheduling] section to segget.conf file.
140 [scripting_and_scheduling]
141 Segget provides Python scripting functionalyty to support scheduling.
142 Each time segget tries to start a new connection certain network it calls
143 a python script (client.py) to accept or reject this connection and
144 if necessary adjusts its settings.
145
146 PYTHON_PATH
147 Define path to python
148 Default:
149 python_path=/usr/bin/python
150
151 SCRIPTS_DIR
152 Define a path to the dir with python scripts. Before establishing connection for
153 a particular segment via network# segget checks SCRIPTS_DIR.
154 If SCRIPTS_DIR contains net#.py file, segget will launch schedule() function
155 from this file to apply settings for connetion and accept or reject this
156 segment for the moment. net#.py file is a python script file
157 with a user-writen schedule() function.
158 It's necessary to import functions before using get("variable"),
159 set("variable",value), accept_segment() and reject_segment() in schedule().
160 get() function can obtain values for the following variables:
161 connection.num, connection.url, connection.max_speed_limit,
162 network.num, network.mode, network.active_connections_count,
163 distfile.name, distfile.size, distfile.dld_segments_count,
164 distfile.segments_count, distfile.active_connections_count,
165 segment.num, segment.try_num, segment.size, segment.range
166 set() function can change connection.max_speed_limit, see example:
167 -----------------EXAMPLE STARTS-----------------
168 from functions import *
169 import time;
170 def schedule():
171 localtime = time.localtime(time.time());
172 hour=localtime[3];
173 # disable downloading distfiles that have size more than 5 000 000 bytes
174 # from 8-00 to 22-00.
175 if hour>8 and hour<22 and (get("distfile.size"))>5000000:
176 print "reject because distfile is too big"
177 reject_segment()
178 # set speed limit 50 000 cps for distfiles larger than 1 000 000 bytes
179 if get("distfile.size")>1000000:
180 print "limit connection speed"
181 set(connection.max_speed_limit, 50000)
182 accept_segment()
183 -----------------EXAMPLE ENDS-----------------
184 From example above localtime returns following tuple:
185 Index Attributes Values
186 0 tm_year e.i.: 2008
187 1 tm_mon 1 to 12
188 2 tm_mday 1 to 31
189 3 tm_hour 0 to 23
190 4 tm_min 0 to 59
191 5 tm_sec 0 to 61 (60 or 61 are leap-seconds)
192 6 tm_wday 0 to 6 (0 is Monday)
193 7 tm_yday 1 to 366 (Julian day)
194 8 tm_isdst -1, 0, 1, -1 means library determines DST
195 Therefore localtime[3] provides hours.
196 Segment will be accecpted by default if it was neither accepted nor rejected
197 during the schedule() function.
198 sagget saves logs of resulting stdout and stderr in the log folder
199 separatly for each network. Hence, if there's an error in net3.py file python
200 error message would be saved to net3_script_stderr.log. Results of print would
201 be saved in net3_script_stdout.log.
202 Default:
203 scripts_dir=./scripts
204
205 SCRIPT_SOCKET_PATH
206 Segget uses AF_UNIX domain sockets for communication with python.
207 Specify path for the socket on your filesystem.
208 Default:
209 script_socket_path=/tmp/segget_script_socket
210
211 1.4 Logs
212 --------
213 Add "none" as an option for log files.
214
215 Add explanations for CURL error codes to logs.
216
217 Add options: GENERAL_LOG_TIME_FORMAT, ERROR_LOG_TIME_FORMAT and DEBUG_LOG_TIME_FORMAT to segget.conf file
218
219 GENERAL_LOG_TIME_FORMAT
220 Set time format for general log as a string containing any combination of
221 regular characters and special format specifiers. These format specifiers are
222 replaced by the function to the corresponding values to represent the time
223 specified in timeptr. They all begin with a percentage (%) sign, and are:
224 %a Abbreviated weekday name [For example: Thu]
225 %A Full weekday name [For example: Thursday]
226 %b Abbreviated month name [For example: Aug]
227 %B Full month name [For example: August]
228 %c Date and time representation [For example: Thu Aug 23 14:55:02 2001]
229 %d Day of the month (01-31) [For example: 23]
230 %H Hour in 24h format (00-23) [For example: 14]
231 %I Hour in 12h format (01-12) [For example: 02]
232 %j Day of the year (001-366) [For example: 235]
233 %m Month as a decimal number (01-12) [For example: 08]
234 %M Minute (00-59) [For example: 55]
235 %p AM or PM designation [For example: PM]
236 %S Second (00-61) [For example: 02]
237 %U Week number with the first Sunday
238 as the first day of week one (00-53) [For example: 33]
239 %w Weekday as a decimal number with
240 Sunday as 0 (0-6) [For example: 4]
241 %W Week number with the first Monday as
242 the first day of week one (00-53) [For example: 34]
243 %x Date representation [For example: 08/23/01]
244 %X Time representation [For example: 14:55:02]
245 %y Year, last two digits (00-99) [For example: 01]
246 %Y Year [For example: 2001]
247 %Z Timezone name or abbreviation [For example: CDT]
248 %% A % sign [For example: %]
249
250 For instace general_log_time_format=Time: %m/%d %X
251
252 Default:
253 general_log_time_format=%m/%d %X
254
255 ERROR_LOG_TIME_FORMAT
256 Set time format for error log as a string containing any combination of
257 regular characters and special format specifiers. See GENERAL_LOG_TIME_FORMAT
258 for details on format specifiers.
259 Default:
260 error_log_time_format=%m/%d %X
261
262 DEBUG_LOG_TIME_FORMAT
263 Set time format for debug log as a string containing any combination of
264 regular characters and special format specifiers. See GENERAL_LOG_TIME_FORMAT
265 for details on format specifiers.
266 Default:
267 debug_log_time_format=%m/%d %X
268
269 2. REQUEST TOOL
270 ===============
271 Add request tool.
272
273 Request tool reads list of distfiles from ./pkg.list file and requests
274 seggetd daemon to download distfiles from the list.
275
276 3. TUICLIENT
277 ============
278 Add network_type for each connection to tui.
279 Add ETA, AVG speed and active/total connections to tui.
280 Add segments counters to stats and tui.
281 Add connetion num to totals.
282 Add log and error_log windows to tuiclient
283 Add distfiles window to tuiclient that shows progress on distfile downloads,
284 including its status: added/waiting/downloading/downloaded/failed/rejected by script etc.
285
286 [1] Gnome http://www.gnome.org/
287 [2] dEmon http://www.clker.com/cliparts/5/1/b/d/11954315391526924611beastie_freebsd_daemon_r_02.svg.med.png
288 [3] Roshambo game http://www.erikandanna.com/Humor/FlashStuff/SouthPark/roshamboN.swf
289 [4] fork http://en.wikipedia.org/wiki/Fork_%28software_development%29
290 [5] curl http://curl.haxx.se/
291 [6] TTL http://en.wikipedia.org/wiki/Time_to_live
292 [7] Python http://loyalkng.com/wp-content/uploads/2010/03/adam-apple-bizarro-cartoon-comic-tampon-chandelier-pc-mac-snake-eve.jpg
293 [8] Python http://www.python.org/
294 [9] spawn http://en.wikipedia.org/wiki/Spawn_(computing)
295 [10] protocol http://en.wikipedia.org/wiki/Communications_protocol
296 [11] thread http://en.wikipedia.org/wiki/Thread_(computer_science)
297 [12] ghost http://www.youtube.com/watch?v=9WrEDyIzdjY from 3rd minute
298 [13] logs http://www.nawwal.org/~mrgoff/photojournal/2004/winspr/pictures/03-20nurselog.jpg
299 [14] pstrees http://en.wikipedia.org/wiki/Pstree
300 [15] Anjuta http://www.anjuta.org/
301 [16] curses http://en.wikipedia.org/wiki/Curse
302 [17] Ncurses http://en.wikipedia.org/wiki/Ncurses
303 [18] Mutex http://en.wikipedia.org/wiki/Mutual_exclusion
304 [19] Rainbow Colors http://idfetch.isgreat.org/_content2/tuiclient_rainbow_colors.jpg see "DISTFILES" window.
305
306 Best regards,
307 Kostyantyn aka simka

Attachments

File name MIME type
signature.asc application/pgp-signature