higgs 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/ChangeLog CHANGED
@@ -1,3 +1,21 @@
1
+ 2007-11-28 TOKI Yoshinori <toki@freedom.ne.jp>
2
+
3
+ * lib/higgs/version.rb: version 0.1.4.
4
+
5
+ 2007-11-21 TOKI Yoshinori <toki@freedom.ne.jp>
6
+
7
+ * bin/higgs_backup, lib/higgs/utils/bman.rb
8
+ (Higgs::Utils::BackupManager class): autostart of DRb service.
9
+
10
+ 2007-11-19 TOKI Yoshinori <toki@freedom.ne.jp>
11
+
12
+ * bin/higgs_backup: fixed a bug of some COMMANDs.
13
+
14
+ 2007-11-14 TOKI Yoshinori <toki@freedom.ne.jp>
15
+
16
+ * lib/higgs/thread.rb (Higgs::SharedWork class): fixed a bug of
17
+ hung up on exception.
18
+
1
19
  2007-11-11 TOKI Yoshinori <toki@freedom.ne.jp>
2
20
 
3
21
  * lib/higgs/version.rb: version 0.1.3.
data/bin/higgs_backup CHANGED
@@ -5,24 +5,24 @@ require 'higgs/utils/bman'
5
5
  require 'optparse'
6
6
 
7
7
  # for ident(1)
8
- CVS_ID = '$Id: higgs_backup 641 2007-10-18 16:04:02Z toki $'
8
+ CVS_ID = '$Id: higgs_backup 688 2007-11-21 14:35:49Z toki $'
9
9
 
10
10
  STDOUT.sync = true
11
11
 
12
- COMMANDs = %w[
13
- online_backup
14
- index
15
- data
16
- rotate
17
- jlog
18
- recover
19
- verify
20
- clean_from
21
- clean_to
22
- restore
23
- restore_files
24
- restore_recover
25
- restore_verify
12
+ COMMANDs = [
13
+ 'online_backup',
14
+ %w[ index backup_index ],
15
+ %w[ data backup_data ],
16
+ %w[ rotate rotate_jlog ],
17
+ %w[ jlog backup_jlog ],
18
+ 'recover',
19
+ 'verify',
20
+ %w[ clean_from clean_jlog_from ],
21
+ %w[ clean_to clean_jlog_to ],
22
+ 'restore',
23
+ 'restore_files',
24
+ 'restore_recover',
25
+ 'restore_verify'
26
26
  ]
27
27
 
28
28
  commands = %w[ online_backup ]
@@ -31,7 +31,7 @@ options = { :verbose => 0 }
31
31
  opts = OptionParser.new
32
32
  opts.banner = "Usage: #{opts.program_name} [OPTIONs] [COMMANDs]\n"
33
33
  opts.banner << "COMMANDs:\n"
34
- opts.banner << COMMANDs.map{|s| opts.summary_indent + s }.join("\n") << "\n"
34
+ opts.banner << COMMANDs.map{|n, m| opts.summary_indent + n }.join("\n") << "\n"
35
35
  opts.banner << "OPTIONs:\n"
36
36
 
37
37
  opts.on('-f', '--from=BACKUP_TARGET_STORAGE', String) {|value|
@@ -61,7 +61,7 @@ opts.parse!
61
61
  unless (ARGV.empty?) then
62
62
  count = 0
63
63
  for cmd in ARGV
64
- unless (COMMANDs.include? cmd) then
64
+ unless (COMMANDs.map{|n, m| n }.include? cmd) then
65
65
  STDERR.puts "error: unknown command: #{cmd}"
66
66
  count += 1
67
67
  end
@@ -72,13 +72,13 @@ unless (ARGV.empty?) then
72
72
  commands = ARGV
73
73
  end
74
74
 
75
- DRb.start_service
76
75
  bman = Higgs::Utils::BackupManager.new(options)
77
76
  for cmd in commands
78
- unless (bman.public_methods(false).include? cmd) then
77
+ name, method = COMMANDs.find{|n, m| n == cmd }
78
+ unless (name) then
79
79
  raise "unknown command: #{cmd}"
80
80
  end
81
- bman.__send__(cmd)
81
+ bman.__send__(method || name)
82
82
  end
83
83
 
84
84
  # Local Variables:
data/lib/higgs/thread.rb CHANGED
@@ -1,8 +1,8 @@
1
1
  # = multi-thread utilities
2
2
  #
3
3
  # Author:: $Author: toki $
4
- # Date:: $Date: 2007-10-31 00:36:09 +0900 (Wed, 31 Oct 2007) $
5
- # Revision:: $Revision: 659 $
4
+ # Date:: $Date: 2007-11-14 01:42:21 +0900 (Wed, 14 Nov 2007) $
5
+ # Revision:: $Revision: 686 $
6
6
  #
7
7
  # == license
8
8
  # :include:LICENSE
@@ -15,7 +15,7 @@ require 'thread'
15
15
  module Higgs
16
16
  class Latch
17
17
  # for ident(1)
18
- CVS_ID = '$Id: thread.rb 659 2007-10-30 15:36:09Z toki $'
18
+ CVS_ID = '$Id: thread.rb 686 2007-11-13 16:42:21Z toki $'
19
19
 
20
20
  def initialize
21
21
  @lock = Mutex.new
@@ -43,7 +43,7 @@ module Higgs
43
43
 
44
44
  class CountDownLatch
45
45
  # for ident(1)
46
- CVS_ID = '$Id: thread.rb 659 2007-10-30 15:36:09Z toki $'
46
+ CVS_ID = '$Id: thread.rb 686 2007-11-13 16:42:21Z toki $'
47
47
 
48
48
  def initialize(count)
49
49
  @count = count
@@ -73,7 +73,7 @@ module Higgs
73
73
 
74
74
  class Barrier
75
75
  # for ident(1)
76
- CVS_ID = '$Id: thread.rb 659 2007-10-30 15:36:09Z toki $'
76
+ CVS_ID = '$Id: thread.rb 686 2007-11-13 16:42:21Z toki $'
77
77
 
78
78
  def initialize(count)
79
79
  @count = count
@@ -102,7 +102,7 @@ module Higgs
102
102
 
103
103
  class SharedWork
104
104
  # for ident(1)
105
- CVS_ID = '$Id: thread.rb 659 2007-10-30 15:36:09Z toki $'
105
+ CVS_ID = '$Id: thread.rb 686 2007-11-13 16:42:21Z toki $'
106
106
 
107
107
  def initialize(&work)
108
108
  unless (work) then
@@ -112,14 +112,31 @@ module Higgs
112
112
  @lock = Mutex.new
113
113
  @cond = ConditionVariable.new
114
114
  @state = :init
115
+ @abort = nil
116
+ @error = nil
115
117
  @result = nil
116
118
  end
117
119
 
120
+ def abort_msg
121
+ msg = 'abort'
122
+ msg << " - #{@error.inspect}" if @error
123
+ msg
124
+ end
125
+ private :abort_msg
126
+
127
+ def __result__
128
+ if (@abort) then
129
+ raise RuntimeError, abort_msg
130
+ end
131
+ @result
132
+ end
133
+ private :__result__
134
+
118
135
  def result
119
136
  @lock.synchronize{
120
137
  case (@state)
121
138
  when :done
122
- return @result
139
+ return __result__
123
140
  when :init
124
141
  @state = :working
125
142
  # fall through
@@ -127,17 +144,26 @@ module Higgs
127
144
  until (@state == :done)
128
145
  @cond.wait(@lock)
129
146
  end
130
- return @result
147
+ return __result__
131
148
  else
132
149
  raise 'internal error'
133
150
  end
134
151
  }
135
152
 
136
- r = @result = @work.call
137
- @lock.synchronize{
138
- @state = :done
139
- @cond.broadcast
140
- }
153
+ completed = false
154
+ begin
155
+ r = @result = @work.call
156
+ completed = true
157
+ ensure
158
+ @lock.synchronize{
159
+ @state = :done
160
+ unless (completed) then
161
+ @abort = true
162
+ @error = $!
163
+ end
164
+ @cond.broadcast
165
+ }
166
+ end
141
167
  r
142
168
  end
143
169
 
@@ -150,6 +176,13 @@ module Higgs
150
176
  until (@state == :done)
151
177
  @cond.wait(@lock)
152
178
  end
179
+ when :done
180
+ # nothing to do.
181
+ else
182
+ raise 'internal error'
183
+ end
184
+ if (@abort) then
185
+ raise RuntimeError, abort_msg
153
186
  end
154
187
  @result = value
155
188
  }
@@ -158,7 +191,7 @@ module Higgs
158
191
 
159
192
  class ReadWriteLock
160
193
  # for ident(1)
161
- CVS_ID = '$Id: thread.rb 659 2007-10-30 15:36:09Z toki $'
194
+ CVS_ID = '$Id: thread.rb 686 2007-11-13 16:42:21Z toki $'
162
195
 
163
196
  def initialize
164
197
  @lock = Mutex.new
@@ -295,7 +328,7 @@ module Higgs
295
328
 
296
329
  class Pool
297
330
  # for ident(1)
298
- CVS_ID = '$Id: thread.rb 659 2007-10-30 15:36:09Z toki $'
331
+ CVS_ID = '$Id: thread.rb 686 2007-11-13 16:42:21Z toki $'
299
332
 
300
333
  class ShutdownException < Exceptions::ShutdownException
301
334
  end
@@ -1,8 +1,8 @@
1
1
  # = backup manager
2
2
  #
3
3
  # Author:: $Author: toki $
4
- # Date:: $Date: 2007-11-11 11:20:51 +0900 (Sun, 11 Nov 2007) $
5
- # Revision:: $Revision: 682 $
4
+ # Date:: $Date: 2007-11-21 23:35:49 +0900 (Wed, 21 Nov 2007) $
5
+ # Revision:: $Revision: 688 $
6
6
  #
7
7
  # == license
8
8
  # :include:LICENSE
@@ -26,10 +26,6 @@ module Higgs
26
26
  # [<tt>:remote_services_uri</tt>] value is <tt>"druby://<em>host</em>:<em>port</em>"</tt>.
27
27
  # journal log rotation remote service should be enabled.
28
28
  #
29
- # DRb service should be started before Higgs::BackupManager is used.
30
- #
31
- # DRb.start_service
32
- #
33
29
  # == online-backup
34
30
  #
35
31
  # online-backup is controlled by <tt>higgs_backup</tt> command that
@@ -38,24 +34,26 @@ module Higgs
38
34
  # simple online-backup is like this...
39
35
  #
40
36
  # % higgs_backup -v -f foo -t backup_dir -u druby://localhost:17320
41
- # 2007-10-03 00:32:58.117 [7558]: **** START BACKUP SCENARIO ****
42
- # 2007-10-03 00:32:58.118 [7558]: start index backup.
43
- # 2007-10-03 00:32:58.550 [7558]: completed index backup.
44
- # 2007-10-03 00:32:58.551 [7558]: start data backup.
45
- # 2007-10-03 00:42:00.637 [7558]: completed data backup.
46
- # 2007-10-03 00:42:00.665 [7558]: start journal log rotation.
47
- # 2007-10-03 00:42:00.907 [7558]: completed journal log rotation.
48
- # 2007-10-03 00:42:00.909 [7558]: start journal logs backup.
49
- # 2007-10-03 00:42:00.958 [7558]: completed journal logs backup.
50
- # 2007-10-03 00:42:00.959 [7558]: start backup storage recovery.
51
- # 2007-10-03 00:42:01.550 [7558]: completed backup storage recovery.
52
- # 2007-10-03 00:42:01.552 [7558]: start backup storage verify.
53
- # 2007-10-03 00:58:56.885 [7558]: completed backup storage verify.
54
- # 2007-10-03 00:58:56.904 [7558]: start journal logs clean of from-storage.
55
- # 2007-10-03 00:58:56.954 [7558]: completed jounal logs clean of from-storage.
56
- # 2007-10-03 00:58:56.955 [7558]: start journal logs clean of to-storage.
57
- # 2007-10-03 00:58:56.977 [7558]: completed jounal logs clean of to-storage.
58
- # 2007-10-03 00:58:56.978 [7558]: **** COMPLETED BACKUP SCENARIO ****
37
+ # 2007-11-21 22:33:08.127 [18215]: **** START BACKUP SCENARIO ****
38
+ # 2007-11-21 22:33:08.129 [18215]: connect to remote services: druby://localhost:17320
39
+ # 2007-11-21 22:33:13.227 [18215]: DRb service started.
40
+ # 2007-11-21 22:33:13.233 [18215]: start index backup.
41
+ # 2007-11-21 22:33:13.724 [18215]: completed index backup.
42
+ # 2007-11-21 22:33:13.725 [18215]: start data backup.
43
+ # 2007-11-21 22:44:09.738 [18215]: completed data backup.
44
+ # 2007-11-21 22:44:09.763 [18215]: start journal log rotation.
45
+ # 2007-11-21 22:44:10.092 [18215]: completed journal log rotation.
46
+ # 2007-11-21 22:44:10.200 [18215]: start journal logs backup.
47
+ # 2007-11-21 22:44:10.339 [18215]: completed journal logs backup.
48
+ # 2007-11-21 22:44:10.340 [18215]: start backup storage recovery.
49
+ # 2007-11-21 22:44:11.101 [18215]: completed backup storage recovery.
50
+ # 2007-11-21 22:44:11.103 [18215]: start backup storage verify.
51
+ # 2007-11-21 22:58:04.552 [18215]: completed backup storage verify.
52
+ # 2007-11-21 22:58:04.581 [18215]: start journal logs clean of from-storage.
53
+ # 2007-11-21 22:58:04.638 [18215]: completed jounal logs clean of from-storage.
54
+ # 2007-11-21 22:58:04.640 [18215]: start journal logs clean of to-storage.
55
+ # 2007-11-21 22:58:04.668 [18215]: completed jounal logs clean of to-storage.
56
+ # 2007-11-21 22:58:04.669 [18215]: **** COMPLETED BACKUP SCENARIO ****
59
57
  #
60
58
  # online-backup scenario includes these processes.
61
59
  #
@@ -166,7 +164,7 @@ module Higgs
166
164
  #
167
165
  class BackupManager
168
166
  # for ident(1)
169
- CVS_ID = '$Id: bman.rb 682 2007-11-11 02:20:51Z toki $'
167
+ CVS_ID = '$Id: bman.rb 688 2007-11-21 14:35:49Z toki $'
170
168
 
171
169
  def initialize(options={})
172
170
  @from = options[:from]
@@ -174,6 +172,11 @@ module Higgs
174
172
  to_name = options[:to_name] || (@from && File.basename(@from))
175
173
  @to = File.join(to_dir, to_name) if (to_dir && to_name)
176
174
  @remote_services_uri = options[:remote_services_uri]
175
+ if (options.key? :drb_service_autostart) then
176
+ @drb_service_autostart = options[:drb_service_autostart]
177
+ else
178
+ @drb_service_autostart = true
179
+ end
177
180
  @verbose = options[:verbose] || 0
178
181
  @out = options[:out] || STDOUT
179
182
  end
@@ -190,8 +193,14 @@ module Higgs
190
193
  unless (@remote_services_uri) then
191
194
  raise 'required remote_services_uri'
192
195
  end
193
- @out << log("connect to remote services: #{@remote_services_uri}") if (@verbose >= 2)
196
+
197
+ return if @services
198
+ @out << log("connect to remote services: #{@remote_services_uri}") if (@verbose >= 1)
194
199
  @services = DRbObject.new_with_uri(@remote_services_uri)
200
+ if (@drb_service_autostart) then
201
+ DRb.start_service
202
+ @out << log("DRb service started.") if (@verbose >= 1)
203
+ end
195
204
 
196
205
  localhost_check_service = @services[:localhost_check_service_v1] or
197
206
  raise 'not provided remote service: localhost_check_service_v1'
@@ -205,7 +214,6 @@ module Higgs
205
214
  private :connect_service
206
215
 
207
216
  def backup_index
208
- @out << log('start index backup.') if (@verbose >= 1)
209
217
  unless (@from) then
210
218
  raise 'required from_storage'
211
219
  end
@@ -213,6 +221,7 @@ module Higgs
213
221
  raise 'required to_storage'
214
222
  end
215
223
  connect_service
224
+ @out << log('start index backup.') if (@verbose >= 1)
216
225
  @out << log("save to #{@to}.idx") if (@verbose >= 2)
217
226
  @jlog_rotate_service.call(File.expand_path(@to) + '.idx')
218
227
  @out << log('completed index backup.') if (@verbose >= 1)
@@ -220,34 +229,34 @@ module Higgs
220
229
  end
221
230
 
222
231
  def backup_data
223
- @out << log('start data backup.') if (@verbose >= 1)
224
232
  unless (@from) then
225
233
  raise 'required from_storage'
226
234
  end
227
235
  unless (@to) then
228
236
  raise 'required to_storage'
229
237
  end
238
+ @out << log('start data backup.') if (@verbose >= 1)
230
239
  FileUtils.cp("#{@from}.tar", "#{@to}.tar", :preserve => true, :verbose => @verbose >= 2)
231
240
  @out << log('completed data backup.') if (@verbose >= 1)
232
241
  nil
233
242
  end
234
243
 
235
244
  def rotate_jlog
236
- @out << log('start journal log rotation.') if (@verbose >= 1)
237
245
  connect_service
246
+ @out << log('start journal log rotation.') if (@verbose >= 1)
238
247
  @jlog_rotate_service.call(true)
239
248
  @out << log('completed journal log rotation.') if (@verbose >= 1)
240
249
  nil
241
250
  end
242
251
 
243
252
  def backup_jlog
244
- @out << log('start journal logs backup.') if (@verbose >= 1)
245
253
  unless (@from) then
246
254
  raise 'required from_storage'
247
255
  end
248
256
  unless (@to) then
249
257
  raise 'required to_storage'
250
258
  end
259
+ @out << log('start journal logs backup.') if (@verbose >= 1)
251
260
  for path in Storage.rotated_entries("#{@from}.jlog")
252
261
  path =~ /\.jlog\.\d+$/ or raise "mismatch jlog name: #{path}"
253
262
  unless (JournalLogger.has_eof_mark? path) then
@@ -261,20 +270,20 @@ module Higgs
261
270
  end
262
271
 
263
272
  def recover
264
- @out << log('start backup storage recovery.') if (@verbose >= 1)
265
273
  unless (@to) then
266
274
  raise 'required to_storage'
267
275
  end
276
+ @out << log('start backup storage recovery.') if (@verbose >= 1)
268
277
  Storage.recover(@to, @out, @verbose - 1)
269
278
  @out << log('completed backup storage recovery.') if (@verbose >= 1)
270
279
  nil
271
280
  end
272
281
 
273
282
  def verify
274
- @out << log('start backup storage verify.') if (@verbose >= 1)
275
283
  unless (@to) then
276
284
  raise 'required to_storage'
277
285
  end
286
+ @out << log('start backup storage verify.') if (@verbose >= 1)
278
287
  st = Storage.new(@to, :read_only => true)
279
288
  begin
280
289
  st.verify(@out, @verbose - 1)
@@ -286,15 +295,13 @@ module Higgs
286
295
  end
287
296
 
288
297
  def clean_jlog_from
289
- @out << log('start journal logs clean of from-storage.') if (@verbose >= 1)
290
-
291
298
  unless (@from) then
292
299
  raise 'required from_storage'
293
300
  end
294
301
  unless (@to) then
295
302
  raise 'required to_storage'
296
303
  end
297
-
304
+ @out << log('start journal logs clean of from-storage.') if (@verbose >= 1)
298
305
  for to_jlog in Storage.rotated_entries("#{@to}.jlog")
299
306
  to_jlog =~ /\.jlog\.\d+$/ or raise "mismatch jlog name: #{to_jlog}"
300
307
  ext = $&
@@ -303,22 +310,18 @@ module Higgs
303
310
  FileUtils.rm(from_jlog, :verbose => @verbose >= 2)
304
311
  end
305
312
  end
306
-
307
313
  @out << log('completed jounal logs clean of from-storage.') if (@verbose >= 1)
308
314
  nil
309
315
  end
310
316
 
311
317
  def clean_jlog_to
312
- @out << log('start journal logs clean of to-storage.') if (@verbose >= 1)
313
-
314
318
  unless (@to) then
315
319
  raise 'required to_storage'
316
320
  end
317
-
321
+ @out << log('start journal logs clean of to-storage.') if (@verbose >= 1)
318
322
  for to_jlog in Storage.rotated_entries("#{@to}.jlog")
319
323
  FileUtils.rm(to_jlog, :verbose => @verbose >= 2)
320
324
  end
321
-
322
325
  @out << log('completed jounal logs clean of to-storage.') if (@verbose >= 1)
323
326
  nil
324
327
  end
@@ -339,13 +342,13 @@ module Higgs
339
342
  end
340
343
 
341
344
  def restore_files
342
- @out << log('start storage files restore.') if (@verbose >= 1)
343
345
  unless (@from) then
344
346
  raise 'required from_storage'
345
347
  end
346
348
  unless (@to) then
347
349
  raise 'required to_storage'
348
350
  end
351
+ @out << log('start storage files restore.') if (@verbose >= 1)
349
352
  FileLock.open("#{@from}.lock") {|flock|
350
353
  flock.synchronize{
351
354
  FileUtils.cp("#{@to}.idx", "#{@from}.idx", :preserve => true, :verbose => @verbose >= 2)
@@ -362,20 +365,20 @@ module Higgs
362
365
  end
363
366
 
364
367
  def restore_recover
365
- @out << log('start restored storage recovery.') if (@verbose >= 1)
366
368
  unless (@from) then
367
369
  raise 'required from_storage'
368
370
  end
371
+ @out << log('start restored storage recovery.') if (@verbose >= 1)
369
372
  Storage.recover(@from, @out, @verbose - 1)
370
373
  @out << log('completed restored storage recovery.') if (@verbose >= 1)
371
374
  nil
372
375
  end
373
376
 
374
377
  def restore_verify
375
- @out << log('start restored storage verify.') if (@verbose >= 1)
376
378
  unless (@from) then
377
379
  raise 'required from_storage'
378
380
  end
381
+ @out << log('start restored storage verify.') if (@verbose >= 1)
379
382
  st = Storage.new(@from) # read-write open for recovery
380
383
  begin
381
384
  st.verify(@out, @verbose - 1)
data/lib/higgs/version.rb CHANGED
@@ -1,8 +1,8 @@
1
1
  # = version
2
2
  #
3
3
  # Author:: $Author: toki $
4
- # Date:: $Date: 2007-11-11 11:22:01 +0900 (Sun, 11 Nov 2007) $
5
- # Revision:: $Revision: 683 $
4
+ # Date:: $Date: 2007-11-28 22:51:52 +0900 (Wed, 28 Nov 2007) $
5
+ # Revision:: $Revision: 689 $
6
6
  #
7
7
  # == license
8
8
  # :include:LICENSE
@@ -10,9 +10,9 @@
10
10
 
11
11
  module Higgs
12
12
  # for ident(1)
13
- CVS_ID = '$Id: version.rb 683 2007-11-11 02:22:01Z toki $'
13
+ CVS_ID = '$Id: version.rb 689 2007-11-28 13:51:52Z toki $'
14
14
 
15
- VERSION = '0.1.3'
15
+ VERSION = '0.1.4'
16
16
  end
17
17
 
18
18
  # Local Variables:
data/test/test_thread.rb CHANGED
@@ -27,7 +27,7 @@ module Higgs::Test
27
27
  include Timeout
28
28
 
29
29
  # for ident(1)
30
- CVS_ID = '$Id: test_thread.rb 659 2007-10-30 15:36:09Z toki $'
30
+ CVS_ID = '$Id: test_thread.rb 686 2007-11-13 16:42:21Z toki $'
31
31
 
32
32
  def test_start_wait
33
33
  latch = Latch.new
@@ -61,7 +61,7 @@ module Higgs::Test
61
61
  include Timeout
62
62
 
63
63
  # for ident(1)
64
- CVS_ID = '$Id: test_thread.rb 659 2007-10-30 15:36:09Z toki $'
64
+ CVS_ID = '$Id: test_thread.rb 686 2007-11-13 16:42:21Z toki $'
65
65
 
66
66
  def test_count_down_wait
67
67
  latch = CountDownLatch.new(3)
@@ -103,7 +103,7 @@ module Higgs::Test
103
103
  include Timeout
104
104
 
105
105
  # for ident(1)
106
- CVS_ID = '$Id: test_thread.rb 659 2007-10-30 15:36:09Z toki $'
106
+ CVS_ID = '$Id: test_thread.rb 686 2007-11-13 16:42:21Z toki $'
107
107
 
108
108
  def test_wait
109
109
  barrier = Barrier.new(COUNT_OF_THREADS)
@@ -147,7 +147,7 @@ module Higgs::Test
147
147
  include Timeout
148
148
 
149
149
  # for ident(1)
150
- CVS_ID = '$Id: test_thread.rb 659 2007-10-30 15:36:09Z toki $'
150
+ CVS_ID = '$Id: test_thread.rb 686 2007-11-13 16:42:21Z toki $'
151
151
 
152
152
  def calc
153
153
  @s = 0 # @s's scope is over multi-threading
@@ -261,6 +261,63 @@ module Higgs::Test
261
261
 
262
262
  assert_equal(:bar, work.result)
263
263
  end
264
+
265
+ def test_abort_work
266
+ work = SharedWork.new{
267
+ raise ThreadError, 'abort'
268
+ }
269
+
270
+ barrier = Barrier.new(2 + 1)
271
+ latch = Latch.new
272
+
273
+ t1 = Thread.new{
274
+ barrier.wait
275
+ assert_raise(ThreadError) {
276
+ work.result
277
+ }
278
+ latch.start
279
+ }
280
+
281
+ t2 = Thread.new{
282
+ barrier.wait
283
+ latch.wait
284
+ timeout(10) {
285
+ assert_raise(RuntimeError) {
286
+ work.result
287
+ }
288
+ }
289
+ }
290
+
291
+ barrier.wait
292
+ t1.join
293
+ t2.join
294
+
295
+ assert_raise(RuntimeError) {
296
+ work.result = nil
297
+ }
298
+ end
299
+
300
+ def test_abort_work_many_threads
301
+ work = SharedWork.new{
302
+ raise RuntimeError, 'abort'
303
+ }
304
+
305
+ barrier = Barrier.new(COUNT_OF_THREADS + 1)
306
+ th_grp = ThreadGroup.new
307
+ COUNT_OF_THREADS.times{|i|# `i' should be local scope of thread block
308
+ th_grp.add Thread.new{
309
+ barrier.wait
310
+ assert_raise(RuntimeError, "thread: #{i}") {
311
+ work.result
312
+ }
313
+ }
314
+ }
315
+
316
+ barrier.wait
317
+ for t in th_grp.list
318
+ t.join
319
+ end
320
+ end
264
321
  end
265
322
 
266
323
  class ReadWriteLockTest < Test::Unit::TestCase
@@ -268,7 +325,7 @@ module Higgs::Test
268
325
  include ThreadParams
269
326
 
270
327
  # for ident(1)
271
- CVS_ID = '$Id: test_thread.rb 659 2007-10-30 15:36:09Z toki $'
328
+ CVS_ID = '$Id: test_thread.rb 686 2007-11-13 16:42:21Z toki $'
272
329
 
273
330
  def setup
274
331
  @rw_lock = ReadWriteLock.new
@@ -452,7 +509,7 @@ module Higgs::Test
452
509
  include ThreadParams
453
510
 
454
511
  # for ident(1)
455
- CVS_ID = '$Id: test_thread.rb 659 2007-10-30 15:36:09Z toki $'
512
+ CVS_ID = '$Id: test_thread.rb 686 2007-11-13 16:42:21Z toki $'
456
513
 
457
514
  class Counter
458
515
  def initialize
data/test/test_tman.rb CHANGED
@@ -13,7 +13,7 @@ module Higgs::Test
13
13
  include Higgs
14
14
 
15
15
  # for ident(1)
16
- CVS_ID = '$Id: test_tman.rb 663 2007-11-04 14:17:45Z toki $'
16
+ CVS_ID = '$Id: test_tman.rb 685 2007-11-12 14:58:12Z toki $'
17
17
 
18
18
  def setup
19
19
  @test_dir = 'st_test'
@@ -172,8 +172,8 @@ module Higgs::Test
172
172
  assert(expected_keys.empty?)
173
173
 
174
174
  @tman.transaction{|tx|
175
- tx['alice'] # load to cache
176
- tx['bob'] # load to cache
175
+ tx[:foo] # load to cache
176
+ tx[:bar] # load to cache
177
177
 
178
178
  expected_keys = [ :foo, :bar, :baz ]
179
179
  tx.each_key do |key|
@@ -1104,7 +1104,7 @@ module Higgs::Test
1104
1104
 
1105
1105
  class TransactionManagerTest_with_SecondaryCache < TransactionManagerTest
1106
1106
  # for ident(1)
1107
- CVS_ID = '$Id: test_tman.rb 663 2007-11-04 14:17:45Z toki $'
1107
+ CVS_ID = '$Id: test_tman.rb 685 2007-11-12 14:58:12Z toki $'
1108
1108
 
1109
1109
  def setup
1110
1110
  super
@@ -13,7 +13,7 @@ module Higgs::Test
13
13
  include Higgs
14
14
 
15
15
  # for ident(1)
16
- CVS_ID = '$Id: test_utils_bman.rb 661 2007-10-30 15:37:54Z toki $'
16
+ CVS_ID = '$Id: test_utils_bman.rb 688 2007-11-21 14:35:49Z toki $'
17
17
 
18
18
  STORAGE_ITEMS = (ENV['STORAGE_ITEMS'] || '100').to_i
19
19
  WARM_START_ITEMS = (ENV['WARM_START_ITEMS'] || '1000').to_i
@@ -46,6 +46,7 @@ module Higgs::Test
46
46
  :to_dir => @to_dir,
47
47
  :to_name => @to_name,
48
48
  :remote_services_uri => @remote_services_uri,
49
+ :drb_service_autostart => false,
49
50
  :verbose => $DEBUG ? 2 : 0,
50
51
  :out => $DEBUG ? STDERR : '')
51
52
  end
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.4
3
3
  specification_version: 1
4
4
  name: higgs
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.1.3
7
- date: 2007-11-11 00:00:00 +09:00
6
+ version: 0.1.4
7
+ date: 2007-11-28 00:00:00 +09:00
8
8
  summary: pure ruby transactional storage compatible with unix TAR format
9
9
  require_paths:
10
10
  - lib