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.
- data/ChangeLog +28 -1
- data/Rakefile +80 -0
- data/bin/higgs_apply_jlog +1 -1
- data/bin/higgs_backup +1 -1
- data/bin/higgs_dump_index +1 -1
- data/bin/higgs_dump_jlog +1 -1
- data/bin/higgs_ping +1 -1
- data/bin/higgs_verify +1 -1
- data/{LICENSE → lib/LICENSE} +1 -1
- data/lib/cgi/session/higgs.rb +3 -3
- data/lib/higgs/block.rb +4 -4
- data/lib/higgs/cache.rb +5 -5
- data/lib/higgs/dbm.rb +4 -4
- data/lib/higgs/exceptions.rb +4 -4
- data/lib/higgs/flock.rb +4 -4
- data/lib/higgs/index.rb +9 -9
- data/lib/higgs/jcompat.rb +102 -0
- data/lib/higgs/jlog.rb +4 -4
- data/lib/higgs/lock.rb +6 -6
- data/lib/higgs/services.rb +4 -4
- data/lib/higgs/sman.rb +4 -4
- data/lib/higgs/storage.rb +6 -7
- data/lib/higgs/store.rb +4 -4
- data/lib/higgs/tar.rb +10 -4
- data/lib/higgs/thread.rb +58 -90
- data/lib/higgs/tman.rb +5 -5
- data/lib/higgs/utils/bman.rb +4 -4
- data/lib/higgs/utils.rb +4 -4
- data/lib/higgs/version.rb +5 -5
- data/lib/higgs.rb +4 -3
- data/misc/cache_bench/cache_bench.rb +1 -1
- data/misc/dbm_bench/.strc +1 -1
- data/misc/dbm_bench/Rakefile +1 -1
- data/misc/dbm_bench/dbm_multi_thread.rb +1 -1
- data/misc/dbm_bench/dbm_rnd_delete.rb +1 -1
- data/misc/dbm_bench/dbm_rnd_read.rb +1 -1
- data/misc/dbm_bench/dbm_rnd_update.rb +1 -1
- data/misc/dbm_bench/dbm_seq_read.rb +1 -1
- data/misc/dbm_bench/dbm_seq_write.rb +1 -1
- data/misc/dbm_bench/run.rb +1 -1
- data/misc/dbm_bench/st_verify.rb +1 -1
- data/misc/io_bench/cksum_bench.rb +1 -1
- data/misc/io_bench/jlog_bench.rb +1 -1
- data/misc/io_bench/write_bench.rb +1 -1
- data/misc/thread_bench/lock_bench.rb +1 -1
- data/mkrdoc.rb +11 -0
- data/rdoc.yml +9 -0
- data/test/Rakefile +1 -1
- data/test/run.rb +3 -1
- data/test/test_block.rb +1 -1
- data/test/test_cache.rb +3 -3
- data/test/test_cache_mvcc.rb +5 -5
- data/test/test_cgi_session.rb +3 -3
- data/test/test_dbm.rb +7 -7
- data/test/test_flock.rb +1 -1
- data/test/test_index.rb +5 -5
- data/test/test_jlog.rb +1 -1
- data/test/test_lock.rb +3 -3
- data/test/test_online_backup.rb +1 -1
- data/test/test_replication.rb +3 -3
- data/test/test_services.rb +1 -1
- data/test/test_storage.rb +78 -66
- data/test/test_storage_conf.rb +1 -1
- data/test/test_storage_init_opts.rb +1 -1
- data/test/test_store.rb +7 -7
- data/test/test_tar.rb +11 -11
- data/test/test_thread.rb +6 -6
- data/test/test_tman.rb +4 -4
- data/test/test_tman_init_opts.rb +1 -1
- data/test/test_tman_mvcc.rb +2 -2
- data/test/test_utils_bman.rb +1 -1
- metadata +7 -5
    
        data/test/test_cgi_session.rb
    CHANGED
    
    | @@ -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  | 
| 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  | 
| 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  | 
| 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  | 
| 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 | 
            -
                  @ | 
| 20 | 
            -
                  @db = DBM.new(@ | 
| 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  | 
| 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 | 
            -
                  @ | 
| 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(@ | 
| 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(@ | 
| 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
    
    
    
        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  | 
| 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  | 
| 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  | 
| 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  | 
| 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  | 
| 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
    
    
    
        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  | 
| 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  | 
| 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  | 
| 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
         | 
    
        data/test/test_online_backup.rb
    CHANGED
    
    
    
        data/test/test_replication.rb
    CHANGED
    
    | @@ -26,15 +26,15 @@ module Higgs::Test | |
| 26 26 | 
             
                def setup
         | 
| 27 27 | 
             
                  srand(0)
         | 
| 28 28 |  | 
| 29 | 
            -
                  @ | 
| 29 | 
            +
                  @st_name = 'foo'
         | 
| 30 30 |  | 
| 31 31 | 
             
                  @src_dir = 'rep_src'
         | 
| 32 | 
            -
                  @src_name = File.join(@src_dir, @ | 
| 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, @ | 
| 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 |  | 
    
        data/test/test_services.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_services.rb  | 
| 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  | 
| 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 | 
            -
                  @ | 
| 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  | 
| 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(@ | 
| 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(@ | 
| 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(@ | 
| 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(@ | 
| 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(@ | 
| 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(@ | 
| 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(@ | 
| 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(@ | 
| 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(@ | 
| 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(@ | 
| 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(@ | 
| 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(@ | 
| 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  | 
| 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(@ | 
| 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("#{@ | 
| 504 | 
            -
                  FileUtils.cp("#{@ | 
| 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("#{@ | 
| 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("#{@ | 
| 524 | 
            -
                  assert(Index.new.load("#{@ | 
| 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("#{@ | 
| 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("#{@ | 
| 560 | 
            -
                  FileUtils.cp("#{@ | 
| 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("#{@ | 
| 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("#{@ | 
| 575 | 
            -
                  assert(Index.new.load("#{@ | 
| 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("#{@ | 
| 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("#{@ | 
| 586 | 
            -
                  FileUtils.cp("#{@ | 
| 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("#{@ | 
| 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("#{@ | 
| 601 | 
            -
                  assert(Index.new.load("#{@ | 
| 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("#{@ | 
| 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("#{@ | 
| 612 | 
            -
                  FileUtils.cp("#{@ | 
| 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("#{@ | 
| 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("#{@ | 
| 636 | 
            -
                  FileUtils.cp("#{@ | 
| 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("#{@ | 
| 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("#{@ | 
| 652 | 
            -
                  FileUtils.cp("#{@ | 
| 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("#{@ | 
| 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("#{@ | 
| 668 | 
            -
                  assert(Index.new.load("#{@ | 
| 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("#{@ | 
| 675 | 
            -
                  FileUtils.cp("#{@ | 
| 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("#{@ | 
| 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("#{@ | 
| 691 | 
            -
                  assert(Index.new.load("#{@ | 
| 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("#{@ | 
| 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("#{@ | 
| 724 | 
            -
                  FileUtils.cp("#{@ | 
| 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("#{@ | 
| 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("#{@ | 
| 760 | 
            -
                  FileUtils.cp("#{@ | 
| 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("#{@ | 
| 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("#{@ | 
| 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("#{@ | 
| 785 | 
            -
                  assert(Index.new.load("#{@ | 
| 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  | 
| 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 | 
            -
                  @ | 
| 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 | 
            -
                   | 
| 814 | 
            -
                    Storage.new(@ | 
| 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
         | 
    
        data/test/test_storage_conf.rb
    CHANGED
    
    | @@ -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  | 
| 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  | 
| 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 |  |