higgs 0.1.6 → 0.1.7

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.
Files changed (72) hide show
  1. data/ChangeLog +28 -1
  2. data/Rakefile +80 -0
  3. data/bin/higgs_apply_jlog +1 -1
  4. data/bin/higgs_backup +1 -1
  5. data/bin/higgs_dump_index +1 -1
  6. data/bin/higgs_dump_jlog +1 -1
  7. data/bin/higgs_ping +1 -1
  8. data/bin/higgs_verify +1 -1
  9. data/{LICENSE → lib/LICENSE} +1 -1
  10. data/lib/cgi/session/higgs.rb +3 -3
  11. data/lib/higgs/block.rb +4 -4
  12. data/lib/higgs/cache.rb +5 -5
  13. data/lib/higgs/dbm.rb +4 -4
  14. data/lib/higgs/exceptions.rb +4 -4
  15. data/lib/higgs/flock.rb +4 -4
  16. data/lib/higgs/index.rb +9 -9
  17. data/lib/higgs/jcompat.rb +102 -0
  18. data/lib/higgs/jlog.rb +4 -4
  19. data/lib/higgs/lock.rb +6 -6
  20. data/lib/higgs/services.rb +4 -4
  21. data/lib/higgs/sman.rb +4 -4
  22. data/lib/higgs/storage.rb +6 -7
  23. data/lib/higgs/store.rb +4 -4
  24. data/lib/higgs/tar.rb +10 -4
  25. data/lib/higgs/thread.rb +58 -90
  26. data/lib/higgs/tman.rb +5 -5
  27. data/lib/higgs/utils/bman.rb +4 -4
  28. data/lib/higgs/utils.rb +4 -4
  29. data/lib/higgs/version.rb +5 -5
  30. data/lib/higgs.rb +4 -3
  31. data/misc/cache_bench/cache_bench.rb +1 -1
  32. data/misc/dbm_bench/.strc +1 -1
  33. data/misc/dbm_bench/Rakefile +1 -1
  34. data/misc/dbm_bench/dbm_multi_thread.rb +1 -1
  35. data/misc/dbm_bench/dbm_rnd_delete.rb +1 -1
  36. data/misc/dbm_bench/dbm_rnd_read.rb +1 -1
  37. data/misc/dbm_bench/dbm_rnd_update.rb +1 -1
  38. data/misc/dbm_bench/dbm_seq_read.rb +1 -1
  39. data/misc/dbm_bench/dbm_seq_write.rb +1 -1
  40. data/misc/dbm_bench/run.rb +1 -1
  41. data/misc/dbm_bench/st_verify.rb +1 -1
  42. data/misc/io_bench/cksum_bench.rb +1 -1
  43. data/misc/io_bench/jlog_bench.rb +1 -1
  44. data/misc/io_bench/write_bench.rb +1 -1
  45. data/misc/thread_bench/lock_bench.rb +1 -1
  46. data/mkrdoc.rb +11 -0
  47. data/rdoc.yml +9 -0
  48. data/test/Rakefile +1 -1
  49. data/test/run.rb +3 -1
  50. data/test/test_block.rb +1 -1
  51. data/test/test_cache.rb +3 -3
  52. data/test/test_cache_mvcc.rb +5 -5
  53. data/test/test_cgi_session.rb +3 -3
  54. data/test/test_dbm.rb +7 -7
  55. data/test/test_flock.rb +1 -1
  56. data/test/test_index.rb +5 -5
  57. data/test/test_jlog.rb +1 -1
  58. data/test/test_lock.rb +3 -3
  59. data/test/test_online_backup.rb +1 -1
  60. data/test/test_replication.rb +3 -3
  61. data/test/test_services.rb +1 -1
  62. data/test/test_storage.rb +78 -66
  63. data/test/test_storage_conf.rb +1 -1
  64. data/test/test_storage_init_opts.rb +1 -1
  65. data/test/test_store.rb +7 -7
  66. data/test/test_tar.rb +11 -11
  67. data/test/test_thread.rb +6 -6
  68. data/test/test_tman.rb +4 -4
  69. data/test/test_tman_init_opts.rb +1 -1
  70. data/test/test_tman_mvcc.rb +2 -2
  71. data/test/test_utils_bman.rb +1 -1
  72. metadata +7 -5
@@ -9,7 +9,7 @@ require 'test/unit'
9
9
  module Higgs::Test
10
10
  module CGISessionTest
11
11
  # for ident(1)
12
- CVS_ID = '$Id: test_cgi_session.rb 781 2008-07-28 15:13:27Z toki $'
12
+ CVS_ID = '$Id: test_cgi_session.rb 562 2007-09-25 15:34:24Z toki $'
13
13
 
14
14
  def new_store(session, options={})
15
15
  options.update('tmpdir' => @tmpdir, :logger => @logger)
@@ -119,7 +119,7 @@ module Higgs::Test
119
119
  include CGISessionTest
120
120
 
121
121
  # for ident(1)
122
- CVS_ID = '$Id: test_cgi_session.rb 781 2008-07-28 15:13:27Z toki $'
122
+ CVS_ID = '$Id: test_cgi_session.rb 562 2007-09-25 15:34:24Z toki $'
123
123
 
124
124
  def store_type
125
125
  CGI::Session::PStore
@@ -133,7 +133,7 @@ module Higgs::Test
133
133
  include CGISessionTest
134
134
 
135
135
  # for ident(1)
136
- CVS_ID = '$Id: test_cgi_session.rb 781 2008-07-28 15:13:27Z toki $'
136
+ CVS_ID = '$Id: test_cgi_session.rb 562 2007-09-25 15:34:24Z toki $'
137
137
 
138
138
  def store_type
139
139
  CGI::Session::HiggsStore
data/test/test_dbm.rb CHANGED
@@ -10,14 +10,14 @@ module Higgs::Test
10
10
  include Higgs
11
11
 
12
12
  # for ident(1)
13
- CVS_ID = '$Id: test_dbm.rb 781 2008-07-28 15:13:27Z toki $'
13
+ CVS_ID = '$Id: test_dbm.rb 1609 2009-05-09 11:39:26Z toki $'
14
14
 
15
15
  def setup
16
16
  @test_dir = 'dbm_test'
17
17
  FileUtils.rm_rf(@test_dir) # for debug
18
18
  FileUtils.mkdir_p(@test_dir)
19
- @name = File.join(@test_dir, 'foo')
20
- @db = DBM.new(@name,
19
+ @st_name = File.join(@test_dir, 'foo')
20
+ @db = DBM.new(@st_name,
21
21
  :logger => proc{|path|
22
22
  logger = Logger.new(path, 1)
23
23
  logger.level = Logger::DEBUG
@@ -137,13 +137,13 @@ module Higgs::Test
137
137
  include Higgs
138
138
 
139
139
  # for ident(1)
140
- CVS_ID = '$Id: test_dbm.rb 781 2008-07-28 15:13:27Z toki $'
140
+ CVS_ID = '$Id: test_dbm.rb 1609 2009-05-09 11:39:26Z toki $'
141
141
 
142
142
  def setup
143
143
  @test_dir = 'dbm_test'
144
144
  FileUtils.rm_rf(@test_dir) # for debug
145
145
  FileUtils.mkdir_p(@test_dir)
146
- @name = File.join(@test_dir, 'foo')
146
+ @st_name = File.join(@test_dir, 'foo')
147
147
  end
148
148
 
149
149
  def teardown
@@ -151,13 +151,13 @@ module Higgs::Test
151
151
  end
152
152
 
153
153
  def test_open
154
- DBM.open(@name) {|db|
154
+ DBM.open(@st_name) {|db|
155
155
  db.transaction{|tx|
156
156
  tx['foo'] = 'apple'
157
157
  }
158
158
  }
159
159
 
160
- DBM.open(@name, :read_only => true) {|db|
160
+ DBM.open(@st_name, :read_only => true) {|db|
161
161
  db.transaction{|tx|
162
162
  assert_equal('apple', tx['foo'])
163
163
  }
data/test/test_flock.rb CHANGED
@@ -9,7 +9,7 @@ module Higgs::Test
9
9
  include Higgs
10
10
 
11
11
  # for ident(1)
12
- CVS_ID = '$Id: test_flock.rb 781 2008-07-28 15:13:27Z toki $'
12
+ CVS_ID = '$Id: test_flock.rb 561 2007-09-25 15:20:20Z toki $'
13
13
 
14
14
  def setup
15
15
  @test_dir = 'flock_test'
data/test/test_index.rb CHANGED
@@ -10,7 +10,7 @@ module Higgs::Test
10
10
  include Higgs
11
11
 
12
12
  # for ident(1)
13
- CVS_ID = '$Id: test_index.rb 781 2008-07-28 15:13:27Z toki $'
13
+ CVS_ID = '$Id: test_index.rb 770 2008-02-13 11:26:09Z toki $'
14
14
 
15
15
  def setup
16
16
  @idx = Index.new
@@ -45,7 +45,7 @@ module Higgs::Test
45
45
  include Higgs
46
46
 
47
47
  # for ident(1)
48
- CVS_ID = '$Id: test_index.rb 781 2008-07-28 15:13:27Z toki $'
48
+ CVS_ID = '$Id: test_index.rb 770 2008-02-13 11:26:09Z toki $'
49
49
 
50
50
  def setup
51
51
  @idx = Index.new
@@ -91,7 +91,7 @@ module Higgs::Test
91
91
  include Higgs
92
92
 
93
93
  # for ident(1)
94
- CVS_ID = '$Id: test_index.rb 781 2008-07-28 15:13:27Z toki $'
94
+ CVS_ID = '$Id: test_index.rb 770 2008-02-13 11:26:09Z toki $'
95
95
 
96
96
  def setup
97
97
  @idx = Index.new
@@ -164,7 +164,7 @@ module Higgs::Test
164
164
  include Higgs
165
165
 
166
166
  # for ident(1)
167
- CVS_ID = '$Id: test_index.rb 781 2008-07-28 15:13:27Z toki $'
167
+ CVS_ID = '$Id: test_index.rb 770 2008-02-13 11:26:09Z toki $'
168
168
 
169
169
  def setup
170
170
  @idx = Index.new
@@ -203,7 +203,7 @@ module Higgs::Test
203
203
  include Higgs
204
204
 
205
205
  # for ident(1)
206
- CVS_ID = '$Id: test_index.rb 781 2008-07-28 15:13:27Z toki $'
206
+ CVS_ID = '$Id: test_index.rb 770 2008-02-13 11:26:09Z toki $'
207
207
 
208
208
  def setup
209
209
  @path = 'test.idx'
data/test/test_jlog.rb CHANGED
@@ -10,7 +10,7 @@ module Higgs::Test
10
10
  include Higgs
11
11
 
12
12
  # for ident(1)
13
- CVS_ID = '$Id: test_jlog.rb 781 2008-07-28 15:13:27Z toki $'
13
+ CVS_ID = '$Id: test_jlog.rb 659 2007-10-28 14:35:37Z toki $'
14
14
 
15
15
  def setup
16
16
  @path = 't.jlog'
data/test/test_lock.rb CHANGED
@@ -11,7 +11,7 @@ module Higgs::Test
11
11
  include Higgs
12
12
 
13
13
  # for ident(1)
14
- CVS_ID = '$Id: test_lock.rb 781 2008-07-28 15:13:27Z toki $'
14
+ CVS_ID = '$Id: test_lock.rb 752 2008-01-23 16:46:25Z toki $'
15
15
 
16
16
  WORK_COUNT = 1000
17
17
  THREAD_COUNT = 10
@@ -306,7 +306,7 @@ module Higgs::Test
306
306
  include LockManagerTest
307
307
 
308
308
  # for ident(1)
309
- CVS_ID = '$Id: test_lock.rb 781 2008-07-28 15:13:27Z toki $'
309
+ CVS_ID = '$Id: test_lock.rb 752 2008-01-23 16:46:25Z toki $'
310
310
 
311
311
  def setup
312
312
  @lock_manager = GiantLockManager.new
@@ -324,7 +324,7 @@ module Higgs::Test
324
324
  include LockManagerTest
325
325
 
326
326
  # for ident(1)
327
- CVS_ID = '$Id: test_lock.rb 781 2008-07-28 15:13:27Z toki $'
327
+ CVS_ID = '$Id: test_lock.rb 752 2008-01-23 16:46:25Z toki $'
328
328
 
329
329
  def setup
330
330
  @lock_manager = OptimisticLockManager.new
@@ -31,7 +31,7 @@ module Higgs::Test
31
31
  include OnlineBackupParams
32
32
 
33
33
  # for ident(1)
34
- CVS_ID = '$Id: test_online_backup.rb 781 2008-07-28 15:13:27Z toki $'
34
+ CVS_ID = '$Id: test_online_backup.rb 657 2007-10-23 16:32:59Z toki $'
35
35
 
36
36
  def setup
37
37
  srand(0)
@@ -26,15 +26,15 @@ module Higgs::Test
26
26
  def setup
27
27
  srand(0)
28
28
 
29
- @name = 'foo'
29
+ @st_name = 'foo'
30
30
 
31
31
  @src_dir = 'rep_src'
32
- @src_name = File.join(@src_dir, @name)
32
+ @src_name = File.join(@src_dir, @st_name)
33
33
  FileUtils.rm_rf(@src_dir)
34
34
  FileUtils.mkdir_p(@src_dir)
35
35
 
36
36
  @dst_dir = 'rep_dst'
37
- @dst_name = File.join(@dst_dir, @name)
37
+ @dst_name = File.join(@dst_dir, @st_name)
38
38
  FileUtils.rm_rf(@dst_dir)
39
39
  FileUtils.mkdir_p(@dst_dir)
40
40
 
@@ -10,7 +10,7 @@ module Higgs::Test
10
10
  include Higgs
11
11
 
12
12
  # for ident(1)
13
- CVS_ID = '$Id: test_services.rb 781 2008-07-28 15:13:27Z toki $'
13
+ CVS_ID = '$Id: test_services.rb 678 2007-11-08 16:09:51Z toki $'
14
14
 
15
15
  STORAGE_DIR = 'remote_storage'
16
16
  REMOTE_SERVICES_URI = 'druby://localhost:31415'
data/test/test_storage.rb CHANGED
@@ -11,14 +11,14 @@ module Higgs::Test
11
11
  include Higgs
12
12
 
13
13
  # for ident(1)
14
- CVS_ID = '$Id: test_storage.rb 781 2008-07-28 15:13:27Z toki $'
14
+ CVS_ID = '$Id: test_storage.rb 1609 2009-05-09 11:39:26Z toki $'
15
15
 
16
16
  def setup
17
17
  srand(0) # preset for rand
18
18
  @test_dir = 'st_test'
19
19
  FileUtils.rm_rf(@test_dir) # for debug
20
20
  FileUtils.mkdir_p(@test_dir)
21
- @name = File.join(@test_dir, 'foo')
21
+ @st_name = File.join(@test_dir, 'foo')
22
22
  @logger = proc{|path|
23
23
  logger = Logger.new(path, 1)
24
24
  logger.level = Logger::DEBUG
@@ -37,10 +37,10 @@ module Higgs::Test
37
37
  include StorageTestCase
38
38
 
39
39
  # for ident(1)
40
- CVS_ID = '$Id: test_storage.rb 781 2008-07-28 15:13:27Z toki $'
40
+ CVS_ID = '$Id: test_storage.rb 1609 2009-05-09 11:39:26Z toki $'
41
41
 
42
42
  def new_storage
43
- Storage.new(@name, :logger => @logger)
43
+ Storage.new(@st_name, :logger => @logger)
44
44
  end
45
45
 
46
46
  def test_raw_write_and_commit
@@ -132,7 +132,7 @@ module Higgs::Test
132
132
  def test_write_and_commit_read_only_NotWritableError
133
133
  @st.shutdown
134
134
  @st = nil
135
- @st = Storage.new(@name, :read_only => true, :logger => @logger)
135
+ @st = Storage.new(@st_name, :read_only => true, :logger => @logger)
136
136
  assert_raise(Storage::NotWritableError) {
137
137
  @st.write_and_commit([ [ :write, 'foo', "Hello world.\n" ] ])
138
138
  }
@@ -141,7 +141,7 @@ module Higgs::Test
141
141
  def test_write_and_commit_standby_NotWritableError
142
142
  @st.shutdown
143
143
  @st = nil
144
- @st = Storage.new(@name, :read_only => :standby, :logger => @logger)
144
+ @st = Storage.new(@st_name, :read_only => :standby, :logger => @logger)
145
145
  assert_raise(Storage::NotWritableError) {
146
146
  @st.write_and_commit([ [ :write, 'foo', "Hello world.\n" ] ])
147
147
  }
@@ -268,7 +268,7 @@ module Higgs::Test
268
268
  @st.write_and_commit([ [ :write, 'foo', "Hello world.\n" ] ])
269
269
  @st.shutdown
270
270
  @st = nil
271
- @st = Storage.new(@name, :read_only => true, :logger => @logger)
271
+ @st = Storage.new(@st_name, :read_only => true, :logger => @logger)
272
272
 
273
273
  assert_equal(true, (@st.key? 'foo'))
274
274
  assert_equal(false, (@st.key? 'bar'))
@@ -278,7 +278,7 @@ module Higgs::Test
278
278
  @st.write_and_commit([ [ :write, 'foo', "Hello world.\n" ] ])
279
279
  @st.shutdown
280
280
  @st = nil
281
- @st = Storage.new(@name, :read_only => :standby, :logger => @logger)
281
+ @st = Storage.new(@st_name, :read_only => :standby, :logger => @logger)
282
282
 
283
283
  assert_equal(true, (@st.key? 'foo'))
284
284
  assert_equal(false, (@st.key? 'bar'))
@@ -316,7 +316,7 @@ module Higgs::Test
316
316
  ])
317
317
  @st.shutdown
318
318
  @st = nil
319
- @st = Storage.new(@name, :read_only => true, :logger => @logger)
319
+ @st = Storage.new(@st_name, :read_only => true, :logger => @logger)
320
320
 
321
321
  expected_keys = %w[ foo bar baz ]
322
322
  @st.each_key do |key|
@@ -332,7 +332,7 @@ module Higgs::Test
332
332
  ])
333
333
  @st.shutdown
334
334
  @st = nil
335
- @st = Storage.new(@name, :read_only => :standby, :logger => @logger)
335
+ @st = Storage.new(@st_name, :read_only => :standby, :logger => @logger)
336
336
 
337
337
  expected_keys = %w[ foo bar baz ]
338
338
  @st.each_key do |key|
@@ -348,7 +348,7 @@ module Higgs::Test
348
348
 
349
349
  def test_verify_BrokenError_mismatch_content_hash
350
350
  @st.write_and_commit([ [ :write, 'foo', "Hello world.\n" ] ])
351
- File.open(@name + '.tar', File::WRONLY) {|w|
351
+ File.open(@st_name + '.tar', File::WRONLY) {|w|
352
352
  size = w.stat.size
353
353
 
354
354
  data_body_offset = size - Tar::Block::BLKSIZ * 5
@@ -368,7 +368,7 @@ module Higgs::Test
368
368
 
369
369
  def test_verify_BrokenError_failed_to_read_data
370
370
  @st.write_and_commit([ [ :write, 'foo', "Hello world.\n" ] ])
371
- File.open(@name + '.tar', File::WRONLY) {|w|
371
+ File.open(@st_name + '.tar', File::WRONLY) {|w|
372
372
  size = w.stat.size
373
373
 
374
374
  data_head_offset = size - Tar::Block::BLKSIZ * 6
@@ -391,7 +391,7 @@ module Higgs::Test
391
391
 
392
392
  def test_verify_BrokenError_failed_to_read_properties
393
393
  @st.write_and_commit([ [ :write, 'foo', "Hello world.\n" ] ])
394
- File.open(@name + '.tar', File::WRONLY) {|w|
394
+ File.open(@st_name + '.tar', File::WRONLY) {|w|
395
395
  size = w.stat.size
396
396
 
397
397
  props_head_offset = size - Tar::Block::BLKSIZ * 4
@@ -439,7 +439,7 @@ module Higgs::Test
439
439
  def test_switch_to_write_RuntimeError_not_standby_mode_on_read_only_mode
440
440
  @st.shutdown
441
441
  @st = nil
442
- @st = Storage.new(@name, :read_only => true, :logger => @logger)
442
+ @st = Storage.new(@st_name, :read_only => true, :logger => @logger)
443
443
 
444
444
  assert_equal(true, @st.read_only)
445
445
  assert_raise(RuntimeError) {
@@ -450,7 +450,7 @@ module Higgs::Test
450
450
 
451
451
  class StorageSwitchToWriteTest < StorageTest
452
452
  def new_storage
453
- st = Storage.new(@name, :logger => @logger, :read_only => :standby)
453
+ st = Storage.new(@st_name, :logger => @logger, :read_only => :standby)
454
454
  assert_equal(:standby, st.read_only)
455
455
  st.switch_to_write
456
456
  assert_equal(false, st.read_only)
@@ -469,10 +469,10 @@ module Higgs::Test
469
469
  include StorageTestCase
470
470
 
471
471
  # for ident(1)
472
- CVS_ID = '$Id: test_storage.rb 781 2008-07-28 15:13:27Z toki $'
472
+ CVS_ID = '$Id: test_storage.rb 1609 2009-05-09 11:39:26Z toki $'
473
473
 
474
474
  def new_storage
475
- Storage.new(@name,
475
+ Storage.new(@st_name,
476
476
  :jlog_rotate_max => 0, # unlimited rotation
477
477
  :logger => @logger)
478
478
  end
@@ -500,8 +500,8 @@ module Higgs::Test
500
500
 
501
501
  def test_manual_recovery
502
502
  other_name = File.join(@test_dir, 'bar')
503
- FileUtils.cp("#{@name}.tar", "#{other_name}.tar", :preserve => true)
504
- FileUtils.cp("#{@name}.idx", "#{other_name}.idx", :preserve => true)
503
+ FileUtils.cp("#{@st_name}.tar", "#{other_name}.tar", :preserve => true)
504
+ FileUtils.cp("#{@st_name}.idx", "#{other_name}.idx", :preserve => true)
505
505
 
506
506
  write_data
507
507
 
@@ -514,14 +514,14 @@ module Higgs::Test
514
514
 
515
515
  @st.shutdown
516
516
 
517
- for name in Storage.rotated_entries("#{@name}.jlog")
517
+ for name in Storage.rotated_entries("#{@st_name}.jlog")
518
518
  name =~ /\.jlog.*$/ or raise 'mismatch'
519
519
  FileUtils.cp(name, other_name + $&, :preserve => true)
520
520
  end
521
521
  Storage.recover(other_name)
522
522
 
523
- assert(FileUtils.cmp("#{@name}.tar", "#{other_name}.tar"), 'DATA should be same.')
524
- assert(Index.new.load("#{@name}.idx").to_h ==
523
+ assert(FileUtils.cmp("#{@st_name}.tar", "#{other_name}.tar"), 'DATA should be same.')
524
+ assert(Index.new.load("#{@st_name}.idx").to_h ==
525
525
  Index.new.load("#{other_name}.idx").to_h, 'INDEX should be same.')
526
526
  end
527
527
 
@@ -541,7 +541,7 @@ module Higgs::Test
541
541
 
542
542
  @st.shutdown
543
543
 
544
- for name in Storage.rotated_entries("#{@name}.jlog")
544
+ for name in Storage.rotated_entries("#{@st_name}.jlog")
545
545
  name =~ /\.jlog.*$/ or raise 'mismatch'
546
546
  FileUtils.cp(name, other_name + $&, :preserve => true)
547
547
  end
@@ -556,14 +556,14 @@ module Higgs::Test
556
556
  @st.rotate_journal_log(true)
557
557
 
558
558
  other_name = File.join(@test_dir, 'bar')
559
- FileUtils.cp("#{@name}.tar", "#{other_name}.tar", :preserve => true)
560
- FileUtils.cp("#{@name}.idx", "#{other_name}.idx", :preserve => true)
559
+ FileUtils.cp("#{@st_name}.tar", "#{other_name}.tar", :preserve => true)
560
+ FileUtils.cp("#{@st_name}.idx", "#{other_name}.idx", :preserve => true)
561
561
 
562
562
  # write_data(10 * 10 * 256) < jlog_rotate_size(256 * 1024)
563
563
  write_data(10, 10, 256)
564
564
 
565
565
  # not closed journal log for other storage.
566
- FileUtils.cp("#{@name}.jlog", "#{other_name}.jlog", :preserve => true)
566
+ FileUtils.cp("#{@st_name}.jlog", "#{other_name}.jlog", :preserve => true)
567
567
 
568
568
  @st.shutdown
569
569
 
@@ -571,10 +571,10 @@ module Higgs::Test
571
571
  st2 = Storage.new(other_name, :logger => @logger)
572
572
  st2.shutdown
573
573
 
574
- assert(FileUtils.cmp("#{@name}.tar", "#{other_name}.tar"), 'DATA should be same.')
575
- assert(Index.new.load("#{@name}.idx").to_h ==
574
+ assert(FileUtils.cmp("#{@st_name}.tar", "#{other_name}.tar"), 'DATA should be same.')
575
+ assert(Index.new.load("#{@st_name}.idx").to_h ==
576
576
  Index.new.load("#{other_name}.idx").to_h, 'INDEX should be same.')
577
- assert(FileUtils.cmp("#{@name}.jlog", "#{other_name}.jlog"), 'JOURNAL LOG should be same.')
577
+ assert(FileUtils.cmp("#{@st_name}.jlog", "#{other_name}.jlog"), 'JOURNAL LOG should be same.')
578
578
  end
579
579
 
580
580
  def test_auto_recovery_on_standby_mode
@@ -582,14 +582,14 @@ module Higgs::Test
582
582
  @st.rotate_journal_log(true)
583
583
 
584
584
  other_name = File.join(@test_dir, 'bar')
585
- FileUtils.cp("#{@name}.tar", "#{other_name}.tar", :preserve => true)
586
- FileUtils.cp("#{@name}.idx", "#{other_name}.idx", :preserve => true)
585
+ FileUtils.cp("#{@st_name}.tar", "#{other_name}.tar", :preserve => true)
586
+ FileUtils.cp("#{@st_name}.idx", "#{other_name}.idx", :preserve => true)
587
587
 
588
588
  # write_data(10 * 10 * 256) < jlog_rotate_size(256 * 1024)
589
589
  write_data(10, 10, 256)
590
590
 
591
591
  # not closed journal log for other storage.
592
- FileUtils.cp("#{@name}.jlog", "#{other_name}.jlog", :preserve => true)
592
+ FileUtils.cp("#{@st_name}.jlog", "#{other_name}.jlog", :preserve => true)
593
593
 
594
594
  @st.shutdown
595
595
 
@@ -597,10 +597,10 @@ module Higgs::Test
597
597
  st2 = Storage.new(other_name, :logger => @logger, :read_only => :standby)
598
598
  st2.shutdown
599
599
 
600
- assert(FileUtils.cmp("#{@name}.tar", "#{other_name}.tar"), 'DATA should be same.')
601
- assert(Index.new.load("#{@name}.idx").to_h ==
600
+ assert(FileUtils.cmp("#{@st_name}.tar", "#{other_name}.tar"), 'DATA should be same.')
601
+ assert(Index.new.load("#{@st_name}.idx").to_h ==
602
602
  Index.new.load("#{other_name}.idx").to_h, 'INDEX should be same.')
603
- assert(FileUtils.cmp("#{@name}.jlog", "#{other_name}.jlog"), 'JOURNAL LOG should be same.')
603
+ assert(FileUtils.cmp("#{@st_name}.jlog", "#{other_name}.jlog"), 'JOURNAL LOG should be same.')
604
604
  end
605
605
 
606
606
  def test_auto_recovery_NotWritableError
@@ -608,14 +608,14 @@ module Higgs::Test
608
608
  @st.rotate_journal_log(true)
609
609
 
610
610
  other_name = File.join(@test_dir, 'bar')
611
- FileUtils.cp("#{@name}.tar", "#{other_name}.tar", :preserve => true)
612
- FileUtils.cp("#{@name}.idx", "#{other_name}.idx", :preserve => true)
611
+ FileUtils.cp("#{@st_name}.tar", "#{other_name}.tar", :preserve => true)
612
+ FileUtils.cp("#{@st_name}.idx", "#{other_name}.idx", :preserve => true)
613
613
 
614
614
  # write_data(10 * 10 * 256) < jlog_rotate_size(256 * 1024)
615
615
  write_data(10, 10, 256)
616
616
 
617
617
  # not closed journal log for other storage.
618
- FileUtils.cp("#{@name}.jlog", "#{other_name}.jlog", :preserve => true)
618
+ FileUtils.cp("#{@st_name}.jlog", "#{other_name}.jlog", :preserve => true)
619
619
 
620
620
  @st.shutdown
621
621
 
@@ -632,14 +632,14 @@ module Higgs::Test
632
632
  @st.rotate_journal_log(true)
633
633
 
634
634
  other_name = File.join(@test_dir, 'bar')
635
- FileUtils.cp("#{@name}.tar", "#{other_name}.tar", :preserve => true)
636
- FileUtils.cp("#{@name}.idx", "#{other_name}.idx", :preserve => true)
635
+ FileUtils.cp("#{@st_name}.tar", "#{other_name}.tar", :preserve => true)
636
+ FileUtils.cp("#{@st_name}.idx", "#{other_name}.idx", :preserve => true)
637
637
 
638
638
  write_data
639
639
  @st.rotate_journal_log(true)
640
640
  write_data
641
641
 
642
- FileUtils.cp("#{@name}.jlog", "#{other_name}.jlog", :preserve => true)
642
+ FileUtils.cp("#{@st_name}.jlog", "#{other_name}.jlog", :preserve => true)
643
643
 
644
644
  assert_raise(Storage::PanicError) {
645
645
  st2 = Storage.new(other_name, :logger => @logger)
@@ -648,8 +648,8 @@ module Higgs::Test
648
648
 
649
649
  def test_apply_journal_log
650
650
  other_name = File.join(@test_dir, 'bar')
651
- FileUtils.cp("#{@name}.tar", "#{other_name}.tar", :preserve => true)
652
- FileUtils.cp("#{@name}.idx", "#{other_name}.idx", :preserve => true)
651
+ FileUtils.cp("#{@st_name}.tar", "#{other_name}.tar", :preserve => true)
652
+ FileUtils.cp("#{@st_name}.idx", "#{other_name}.idx", :preserve => true)
653
653
 
654
654
  write_data
655
655
  @st.rotate_journal_log(true)
@@ -657,22 +657,22 @@ module Higgs::Test
657
657
 
658
658
  st2 = Storage.new(other_name, :jlog_rotate_size => 1024 * 8)
659
659
  begin
660
- for path in Storage.rotated_entries("#{@name}.jlog")
660
+ for path in Storage.rotated_entries("#{@st_name}.jlog")
661
661
  st2.apply_journal_log(path)
662
662
  end
663
663
  ensure
664
664
  st2.shutdown
665
665
  end
666
666
 
667
- assert(FileUtils.cmp("#{@name}.tar", "#{other_name}.tar"), 'DATA should be same.')
668
- assert(Index.new.load("#{@name}.idx").to_h ==
667
+ assert(FileUtils.cmp("#{@st_name}.tar", "#{other_name}.tar"), 'DATA should be same.')
668
+ assert(Index.new.load("#{@st_name}.idx").to_h ==
669
669
  Index.new.load("#{other_name}.idx").to_h, 'INDEX should be same.')
670
670
  end
671
671
 
672
672
  def test_apply_journal_log_on_standby_mode
673
673
  other_name = File.join(@test_dir, 'bar')
674
- FileUtils.cp("#{@name}.tar", "#{other_name}.tar", :preserve => true)
675
- FileUtils.cp("#{@name}.idx", "#{other_name}.idx", :preserve => true)
674
+ FileUtils.cp("#{@st_name}.tar", "#{other_name}.tar", :preserve => true)
675
+ FileUtils.cp("#{@st_name}.idx", "#{other_name}.idx", :preserve => true)
676
676
 
677
677
  write_data
678
678
  @st.rotate_journal_log(true)
@@ -680,15 +680,15 @@ module Higgs::Test
680
680
 
681
681
  st2 = Storage.new(other_name, :jlog_rotate_size => 1024 * 8, :read_only => :standby)
682
682
  begin
683
- for path in Storage.rotated_entries("#{@name}.jlog")
683
+ for path in Storage.rotated_entries("#{@st_name}.jlog")
684
684
  st2.apply_journal_log(path)
685
685
  end
686
686
  ensure
687
687
  st2.shutdown
688
688
  end
689
689
 
690
- assert(FileUtils.cmp("#{@name}.tar", "#{other_name}.tar"), 'DATA should be same.')
691
- assert(Index.new.load("#{@name}.idx").to_h ==
690
+ assert(FileUtils.cmp("#{@st_name}.tar", "#{other_name}.tar"), 'DATA should be same.')
691
+ assert(Index.new.load("#{@st_name}.idx").to_h ==
692
692
  Index.new.load("#{other_name}.idx").to_h, 'INDEX should be same.')
693
693
  end
694
694
 
@@ -703,7 +703,7 @@ module Higgs::Test
703
703
  assert_equal(false, st2.shutdown?)
704
704
 
705
705
  begin
706
- for path in Storage.rotated_entries("#{@name}.jlog")
706
+ for path in Storage.rotated_entries("#{@st_name}.jlog")
707
707
  assert_raise(Storage::PanicError) {
708
708
  st2.apply_journal_log(path)
709
709
  }
@@ -720,8 +720,8 @@ module Higgs::Test
720
720
 
721
721
  def test_apply_journal_log_PanicError_lost_journal_log
722
722
  other_name = File.join(@test_dir, 'bar')
723
- FileUtils.cp("#{@name}.tar", "#{other_name}.tar", :preserve => true)
724
- FileUtils.cp("#{@name}.idx", "#{other_name}.idx", :preserve => true)
723
+ FileUtils.cp("#{@st_name}.tar", "#{other_name}.tar", :preserve => true)
724
+ FileUtils.cp("#{@st_name}.idx", "#{other_name}.idx", :preserve => true)
725
725
 
726
726
  write_data
727
727
  write_data
@@ -734,7 +734,7 @@ module Higgs::Test
734
734
  assert_equal(false, st2.shutdown?)
735
735
 
736
736
  begin
737
- entries = Storage.rotated_entries("#{@name}.jlog")
737
+ entries = Storage.rotated_entries("#{@st_name}.jlog")
738
738
  entries.shift # skip first journal log
739
739
  for path in entries
740
740
  assert_raise(Storage::PanicError) {
@@ -756,11 +756,11 @@ module Higgs::Test
756
756
  @st.rotate_journal_log(true)
757
757
 
758
758
  other_name = File.join(@test_dir, 'bar')
759
- FileUtils.cp("#{@name}.tar", "#{other_name}.tar", :preserve => true)
760
- FileUtils.cp("#{@name}.idx", "#{other_name}.idx", :preserve => true)
759
+ FileUtils.cp("#{@st_name}.tar", "#{other_name}.tar", :preserve => true)
760
+ FileUtils.cp("#{@st_name}.idx", "#{other_name}.idx", :preserve => true)
761
761
 
762
762
  other_name = File.join(@test_dir, 'bar')
763
- for name in Storage.rotated_entries("#{@name}.jlog")
763
+ for name in Storage.rotated_entries("#{@st_name}.jlog")
764
764
  name =~ /\.jlog.*$/ or raise 'mismatch'
765
765
  FileUtils.cp(name, other_name + $&, :preserve => true)
766
766
  FileUtils.rm(name)
@@ -774,15 +774,15 @@ module Higgs::Test
774
774
  other_name = File.join(@test_dir, 'bar')
775
775
  st2 = Storage.new(other_name, :jlog_rotate_size => 1024 * 8)
776
776
  begin
777
- for path in Storage.rotated_entries("#{@name}.jlog")
777
+ for path in Storage.rotated_entries("#{@st_name}.jlog")
778
778
  st2.apply_journal_log(path)
779
779
  end
780
780
  ensure
781
781
  st2.shutdown
782
782
  end
783
783
 
784
- assert(FileUtils.cmp("#{@name}.tar", "#{other_name}.tar"), 'DATA should be same.')
785
- assert(Index.new.load("#{@name}.idx").to_h ==
784
+ assert(FileUtils.cmp("#{@st_name}.tar", "#{other_name}.tar"), 'DATA should be same.')
785
+ assert(Index.new.load("#{@st_name}.idx").to_h ==
786
786
  Index.new.load("#{other_name}.idx").to_h, 'INDEX should be same.')
787
787
  end
788
788
  end
@@ -791,13 +791,13 @@ module Higgs::Test
791
791
  include Higgs
792
792
 
793
793
  # for ident(1)
794
- CVS_ID = '$Id: test_storage.rb 781 2008-07-28 15:13:27Z toki $'
794
+ CVS_ID = '$Id: test_storage.rb 1609 2009-05-09 11:39:26Z toki $'
795
795
 
796
796
  def setup
797
797
  @test_dir = 'st_test'
798
798
  FileUtils.rm_rf(@test_dir) # for debug
799
799
  FileUtils.mkdir_p(@test_dir)
800
- @name = File.join(@test_dir, 'foo')
800
+ @st_name = File.join(@test_dir, 'foo')
801
801
  @logger = proc{|path|
802
802
  logger = Logger.new(path, 1)
803
803
  logger.level = Logger::DEBUG
@@ -810,9 +810,21 @@ module Higgs::Test
810
810
  end
811
811
 
812
812
  def test_read_only_first_open_error
813
- assert_raise(Errno::ENOENT) {
814
- Storage.new(@name, :read_only => true, :logger => @logger)
815
- }
813
+ begin
814
+ Storage.new(@st_name, :read_only => true, :logger => @logger)
815
+ rescue Errno::ENOENT
816
+ return
817
+ rescue java.io.FileNotFoundException
818
+ return
819
+ ensure
820
+ error = $!
821
+ end
822
+
823
+ if (error) then
824
+ flunk("unexpected error: #{error}")
825
+ else
826
+ flunk('no raise!')
827
+ end
816
828
  end
817
829
  end
818
830
  end
@@ -7,7 +7,7 @@ require 'test/unit'
7
7
  module Higgs::Test
8
8
  class StorageConfTest < Test::Unit::TestCase
9
9
  # for ident(1)
10
- CVS_ID = '$Id: test_storage_conf.rb 781 2008-07-28 15:13:27Z toki $'
10
+ CVS_ID = '$Id: test_storage_conf.rb 638 2007-10-14 09:43:23Z toki $'
11
11
 
12
12
  include Higgs
13
13
 
@@ -6,7 +6,7 @@ require 'test/unit'
6
6
  module Higgs::Test
7
7
  class StorageInitOptionsTest < Test::Unit::TestCase
8
8
  # for ident(1)
9
- CVS_ID = '$Id: test_storage_init_opts.rb 781 2008-07-28 15:13:27Z toki $'
9
+ CVS_ID = '$Id: test_storage_init_opts.rb 638 2007-10-14 09:43:23Z toki $'
10
10
 
11
11
  include Higgs::Storage::InitOptions
12
12