higgs 0.1.2 → 0.1.3

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/lib/higgs/store.rb CHANGED
@@ -1,15 +1,14 @@
1
1
  # = storage like pstore
2
2
  #
3
3
  # Author:: $Author: toki $
4
- # Date:: $Date: 2007-10-02 01:05:07 +0900 (Tue, 02 Oct 2007) $
5
- # Revision:: $Revision: 600 $
4
+ # Date:: $Date: 2007-10-24 00:46:00 +0900 (Wed, 24 Oct 2007) $
5
+ # Revision:: $Revision: 653 $
6
6
  #
7
7
  # == license
8
8
  # :include:LICENSE
9
9
  #
10
10
 
11
- require 'higgs/storage'
12
- require 'higgs/tman'
11
+ require 'higgs/sman'
13
12
 
14
13
  module Higgs
15
14
  # = storage like pstore
@@ -217,34 +216,19 @@ module Higgs
217
216
  # 1000
218
217
  # %
219
218
  #
220
- class Store
219
+ class Store < StorageManager
221
220
  # for ident(1)
222
- CVS_ID = '$Id: store.rb 600 2007-10-01 16:05:07Z toki $'
223
-
224
- include Storage::Export
225
- include TransactionManager::Export
221
+ CVS_ID = '$Id: store.rb 653 2007-10-23 15:46:00Z toki $'
226
222
 
227
223
  DECODE = proc{|r| Marshal.load(r) }
228
224
  ENCODE = proc{|w| Marshal.dump(w) }
229
225
 
230
- # <tt>name</tt> is a storage name and see Higgs::Storage.new for
231
- # detail. see Higgs::Storage::InitOptions and
232
- # Higgs::TransactionManager::InitOptions for <tt>options</tt>.
226
+ # see Higgs::StorageManager.new for <tt>name</tt> and <tt>options</tt>.
233
227
  def initialize(name, options={})
228
+ options = options.dup
234
229
  options[:decode] = DECODE
235
230
  options[:encode] = ENCODE
236
- @storage = Storage.new(name, options)
237
- @tman = TransactionManager.new(@storage, options)
238
- end
239
-
240
- def self.open(*args)
241
- store = new(*args)
242
- begin
243
- r = yield(store)
244
- ensure
245
- store.shutdown
246
- end
247
- r
231
+ super(name, options)
248
232
  end
249
233
  end
250
234
  end
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-09-26 00:20:20 +0900 (Wed, 26 Sep 2007) $
5
- # Revision:: $Revision: 559 $
4
+ # Date:: $Date: 2007-10-31 00:36:09 +0900 (Wed, 31 Oct 2007) $
5
+ # Revision:: $Revision: 659 $
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 559 2007-09-25 15:20:20Z toki $'
18
+ CVS_ID = '$Id: thread.rb 659 2007-10-30 15:36:09Z 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 559 2007-09-25 15:20:20Z toki $'
46
+ CVS_ID = '$Id: thread.rb 659 2007-10-30 15:36:09Z 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 559 2007-09-25 15:20:20Z toki $'
76
+ CVS_ID = '$Id: thread.rb 659 2007-10-30 15:36:09Z toki $'
77
77
 
78
78
  def initialize(count)
79
79
  @count = count
@@ -102,11 +102,11 @@ module Higgs
102
102
 
103
103
  class SharedWork
104
104
  # for ident(1)
105
- CVS_ID = '$Id: thread.rb 559 2007-09-25 15:20:20Z toki $'
105
+ CVS_ID = '$Id: thread.rb 659 2007-10-30 15:36:09Z toki $'
106
106
 
107
107
  def initialize(&work)
108
108
  unless (work) then
109
- raise 'required work block'
109
+ raise ArgumentError, 'required work block'
110
110
  end
111
111
  @work = work
112
112
  @lock = Mutex.new
@@ -158,7 +158,7 @@ module Higgs
158
158
 
159
159
  class ReadWriteLock
160
160
  # for ident(1)
161
- CVS_ID = '$Id: thread.rb 559 2007-09-25 15:20:20Z toki $'
161
+ CVS_ID = '$Id: thread.rb 659 2007-10-30 15:36:09Z toki $'
162
162
 
163
163
  def initialize
164
164
  @lock = Mutex.new
@@ -295,7 +295,7 @@ module Higgs
295
295
 
296
296
  class Pool
297
297
  # for ident(1)
298
- CVS_ID = '$Id: thread.rb 559 2007-09-25 15:20:20Z toki $'
298
+ CVS_ID = '$Id: thread.rb 659 2007-10-30 15:36:09Z toki $'
299
299
 
300
300
  class ShutdownException < Exceptions::ShutdownException
301
301
  end
data/lib/higgs/tman.rb CHANGED
@@ -1,14 +1,13 @@
1
1
  # = transaction manager
2
2
  #
3
3
  # Author:: $Author: toki $
4
- # Date:: $Date: 2007-09-26 00:20:20 +0900 (Wed, 26 Sep 2007) $
5
- # Revision:: $Revision: 559 $
4
+ # Date:: $Date: 2007-11-06 00:55:14 +0900 (Tue, 06 Nov 2007) $
5
+ # Revision:: $Revision: 674 $
6
6
  #
7
7
  # == license
8
8
  # :include:LICENSE
9
9
  #
10
10
 
11
- require 'forwardable'
12
11
  require 'higgs/cache'
13
12
  require 'higgs/exceptions'
14
13
  require 'higgs/lock'
@@ -18,7 +17,7 @@ require 'singleton'
18
17
  module Higgs
19
18
  class TransactionManager
20
19
  # for ident(1)
21
- CVS_ID = '$Id: tman.rb 559 2007-09-25 15:20:20Z toki $'
20
+ CVS_ID = '$Id: tman.rb 674 2007-11-05 15:55:14Z toki $'
22
21
 
23
22
  include Exceptions
24
23
 
@@ -47,6 +46,10 @@ module Higgs
47
46
  # these options are defined.
48
47
  # [<tt>:read_only</tt>] if <tt>true</tt> then transaction is always read-only.
49
48
  # default is <tt>false</tt>.
49
+ # <tt>:standby</tt> is standby mode. in standby mode, transaction is
50
+ # read-only and Higgs::TransactionManager#apply_journal_log is callable.
51
+ # if Higgs::TransactionManager#switch_to_write is called in standby mode
52
+ # then state of manager changes from standby mode to read-write mode.
50
53
  # [<tt>:decode</tt>] procedure to decode data on read. if <tt>:string_only</tt>
51
54
  # property at an entry is <tt>true</tt> then <tt>decode</tt>
52
55
  # is not used to read the entry. default is <tt>proc{|r| r }</tt>.
@@ -60,6 +63,9 @@ module Higgs
60
63
  # [<tt>:secondary_cache</tt>] secondary read-cache for encoded string data.
61
64
  # key of cache is always unique string.
62
65
  # default is no effect.
66
+ # [<tt>:jlog_apply_dir</tt>] journal logs under the directory of this parameter is
67
+ # applied to storage on call of
68
+ # Higgs::TransactionManager#apply_journal_log
63
69
  def init_options(options)
64
70
  if (options.key? :read_only) then
65
71
  @read_only = options[:read_only]
@@ -72,31 +78,23 @@ module Higgs
72
78
  @lock_manager = options[:lock_manager] || GiantLockManager.new
73
79
  @master_cache = options[:master_cache] || LRUCache.new
74
80
  @secondary_cache = options[:secondary_cache] || PseudoSecondaryCache.instance
81
+ @jlog_apply_dir = options[:jlog_apply_dir] || nil
75
82
  end
76
83
 
77
84
  attr_reader :read_only
78
85
  end
79
86
  include InitOptions
80
87
 
81
- # export Higgs::TransactionManager methods from <tt>@tman</tt> instance variable.
82
- #
83
- # these methods are delegated.
84
- # * Higgs::TransactionManager#read_only
85
- # * Higgs::TransactionManager#transaction
86
- #
87
- module Export
88
- extend Forwardable
89
-
90
- def_delegator :@tman, :read_only
91
- def_delegator :@tman, :transaction
92
- end
93
-
88
+ # see Higgs::TransactionManager::InitOptions for <tt>options</tt>.
94
89
  def initialize(storage, options={})
95
90
  @storage = storage
96
91
  init_options(options)
92
+ if (@read_only == :standby && ! @jlog_apply_dir) then
93
+ raise ArgumentError, "need for `:jlog_apply_dir' parameter in standby mode"
94
+ end
97
95
  @master_cache = SharedWorkCache.new(@master_cache) {|key|
98
- (id = @storage.identity(key) and @secondary_cache[id]) or
99
- (value = @storage.fetch(key) and @secondary_cache[@storage.identity(key)] = value.freeze)
96
+ (id = @storage.unique_data_id(key) and @secondary_cache[id]) or
97
+ (value = @storage.fetch(key) and @secondary_cache[@storage.unique_data_id(key)] = value.freeze)
100
98
  }
101
99
  end
102
100
 
@@ -134,11 +132,38 @@ module Higgs
134
132
  def self.current_transaction
135
133
  Thread.current[:higgs_current_transaction]
136
134
  end
135
+
136
+ def apply_journal_log(not_delete=false)
137
+ @lock_manager.exclusive{
138
+ if (@read_only != :standby) then
139
+ raise "not standby mode: #{@read_only}"
140
+ end
141
+ name = File.join(@jlog_apply_dir, File.basename(@storage.name))
142
+ for jlog_path in Storage.rotated_entries("#{name}.jlog")
143
+ @storage.apply_journal_log(jlog_path) {|key|
144
+ @master_cache.delete(key)
145
+ }
146
+ File.unlink(jlog_path) unless not_delete
147
+ end
148
+ }
149
+ nil
150
+ end
151
+
152
+ def switch_to_write
153
+ @lock_manager.exclusive{
154
+ if (@read_only != :standby) then
155
+ raise "not standby mode: #{@read_only}"
156
+ end
157
+ @read_only = false
158
+ @storage.switch_to_write
159
+ }
160
+ nil
161
+ end
137
162
  end
138
163
 
139
164
  class TransactionContext
140
165
  # for ident(1)
141
- CVS_ID = '$Id: tman.rb 559 2007-09-25 15:20:20Z toki $'
166
+ CVS_ID = '$Id: tman.rb 674 2007-11-05 15:55:14Z toki $'
142
167
 
143
168
  include Enumerable
144
169
 
@@ -330,6 +355,12 @@ module Higgs
330
355
  if (@ope_map[key] != :delete) then
331
356
  if (properties = @local_properties_cache[key]) then
332
357
  case (name)
358
+ when :identity
359
+ @storage.identity(key)
360
+ when :data_change_number
361
+ @storage.data_change_number(key)
362
+ when :properties_change_number
363
+ @storage.properties_change_number(key)
333
364
  when Symbol
334
365
  properties['system_properties'][name.to_s]
335
366
  when String
@@ -384,6 +415,12 @@ module Higgs
384
415
 
385
416
  if (self.key? key) then # lock
386
417
  case (name)
418
+ when :identity
419
+ return @storage.identity(key) != nil
420
+ when :data_change_number
421
+ return @storage.data_change_number(key) != nil
422
+ when :properties_change_number
423
+ return @storage.properties_change_number(key) != nil
387
424
  when Symbol
388
425
  return (@local_properties_cache[key]['system_properties'].key? name.to_s)
389
426
  when String
@@ -399,6 +436,15 @@ module Higgs
399
436
  unless (self.key? key) then # lock
400
437
  raise IndexError, "not exist properties at key: #{key}"
401
438
  end
439
+ if (value = @storage.identity(key)) then
440
+ yield(:identity, value)
441
+ end
442
+ if (value = @storage.data_change_number(key)) then
443
+ yield(:data_change_number, value)
444
+ end
445
+ if (value = @storage.properties_change_number(key)) then
446
+ yield(:properties_change_number, value)
447
+ end
402
448
  @local_properties_cache[key]['system_properties'].each_pair do |name, value|
403
449
  yield(name.to_sym, value)
404
450
  end
@@ -467,7 +513,6 @@ module Higgs
467
513
  case (ope)
468
514
  when :write
469
515
  @master_cache.delete(key)
470
- @secondary_cache[key] = value
471
516
  when :delete
472
517
  @master_cache.delete(key)
473
518
  @secondary_cache.delete(key)
@@ -1,8 +1,8 @@
1
1
  # = backup manager
2
2
  #
3
3
  # Author:: $Author: toki $
4
- # Date:: $Date: 2007-10-10 00:49:33 +0900 (Wed, 10 Oct 2007) $
5
- # Revision:: $Revision: 626 $
4
+ # Date:: $Date: 2007-11-11 11:20:51 +0900 (Sun, 11 Nov 2007) $
5
+ # Revision:: $Revision: 682 $
6
6
  #
7
7
  # == license
8
8
  # :include:LICENSE
@@ -11,6 +11,7 @@
11
11
  require 'drb'
12
12
  require 'fileutils'
13
13
  require 'higgs/flock'
14
+ require 'higgs/jlog'
14
15
  require 'higgs/storage'
15
16
 
16
17
  module Higgs
@@ -18,11 +19,16 @@ module Higgs
18
19
  # = backup manager
19
20
  # == requirements for online-backup
20
21
  #
21
- # these parameters should be required when Higgs::Storage is opened.
22
+ # these parameters should be required when Higgs::StorageManager
23
+ # of backup target is opened.
22
24
  #
23
25
  # [<tt>:jlog_rotate_max</tt>] value is <tt>0</tt>. rotated journal logs shuold be preserved.
24
- # [<tt>:jlog_rotate_service_uri</tt>] value is <tt>"druby://localhost:<em>appropriate_port_number</em>"</tt>.
25
- # journal log rotation remote service should be enabled.
26
+ # [<tt>:remote_services_uri</tt>] value is <tt>"druby://<em>host</em>:<em>port</em>"</tt>.
27
+ # journal log rotation remote service should be enabled.
28
+ #
29
+ # DRb service should be started before Higgs::BackupManager is used.
30
+ #
31
+ # DRb.start_service
26
32
  #
27
33
  # == online-backup
28
34
  #
@@ -104,8 +110,7 @@ module Higgs
104
110
  # -f, --from=BACKUP_TARGET_STORAGE
105
111
  # -t, --to-dir=DIR_TO_BACKUP
106
112
  # -n, --to-name=NAME_TO_BACKUP
107
- # -u=URI
108
- # --jlog-rotate-service-uri
113
+ # -U, --remote-services-uri=URI
109
114
  # -v, --verbose, --[no-]verbose
110
115
  # --verbose-level=LEVEL
111
116
  #
@@ -145,27 +150,30 @@ module Higgs
145
150
  # if this option is omitted then <tt>NAME_TO_BACKUP</tt> is the same
146
151
  # as <tt>BACKUP_TARGET_STORAGE</tt>.
147
152
  #
148
- # === OPTION: <tt>--jlog-rotate-service-uri=URI</tt>
153
+ # === OPTION: <tt>--remote-services-uri=URI</tt>
149
154
  # access point for journal log rotation remote service.
150
- # <tt>URI</tt> is the same as <tt>:jlog_rotate_service_uri</tt>
151
- # when Higgs::Storage is opened.
155
+ # <tt>URI</tt> is the same as <tt>:remote_services_uri</tt>
156
+ # when Higgs::StorageManager is opened.
152
157
  #
153
158
  # === OPTION: <tt>--verbose</tt>
154
159
  # verbose level up.
155
160
  #
161
+ # === OPTION: <tt>--no-verbose</tt>
162
+ # verbose level down.
163
+ #
156
164
  # === OPTION: <tt>--verbose-level=LEVEL</tt>
157
165
  # set verbose level to <tt>LEVEL</tt>.
158
166
  #
159
167
  class BackupManager
160
168
  # for ident(1)
161
- CVS_ID = '$Id: bman.rb 626 2007-10-09 15:49:33Z toki $'
169
+ CVS_ID = '$Id: bman.rb 682 2007-11-11 02:20:51Z toki $'
162
170
 
163
171
  def initialize(options={})
164
172
  @from = options[:from]
165
173
  to_dir = options[:to_dir]
166
174
  to_name = options[:to_name] || (@from && File.basename(@from))
167
175
  @to = File.join(to_dir, to_name) if (to_dir && to_name)
168
- @jlog_rotate_service_uri = options[:jlog_rotate_service_uri]
176
+ @remote_services_uri = options[:remote_services_uri]
169
177
  @verbose = options[:verbose] || 0
170
178
  @out = options[:out] || STDOUT
171
179
  end
@@ -179,11 +187,20 @@ module Higgs
179
187
  private :log
180
188
 
181
189
  def connect_service
182
- unless (@jlog_rotate_service_uri) then
183
- raise 'required jlog_rotate_service_uri'
190
+ unless (@remote_services_uri) then
191
+ raise 'required remote_services_uri'
184
192
  end
185
- @out << log("connect to jlog_rotate_service: #{@jlog_rotate_service_uri}") if (@verbose >= 2)
186
- @jlog_rotate_service = DRbObject.new_with_uri(@jlog_rotate_service_uri)
193
+ @out << log("connect to remote services: #{@remote_services_uri}") if (@verbose >= 2)
194
+ @services = DRbObject.new_with_uri(@remote_services_uri)
195
+
196
+ localhost_check_service = @services[:localhost_check_service_v1] or
197
+ raise 'not provided remote service: localhost_check_service_v1'
198
+ localhost_check_service.call{|localhost_check|
199
+ localhost_check.call
200
+ }
201
+
202
+ @jlog_rotate_service = @services[:jlog_rotate_service_v1] or
203
+ raise 'not provided remote service: jlog_rotate_service_v1'
187
204
  end
188
205
  private :connect_service
189
206
 
@@ -231,8 +248,11 @@ module Higgs
231
248
  unless (@to) then
232
249
  raise 'required to_storage'
233
250
  end
234
- for path in Storage.rotate_entries("#{@from}.jlog")
251
+ for path in Storage.rotated_entries("#{@from}.jlog")
235
252
  path =~ /\.jlog\.\d+$/ or raise "mismatch jlog name: #{path}"
253
+ unless (JournalLogger.has_eof_mark? path) then
254
+ raise "broken journal log: #{path}"
255
+ end
236
256
  ext = $&
237
257
  FileUtils.cp(path, "#{@to}#{ext}", :preserve => true, :verbose => @verbose >= 2)
238
258
  end
@@ -275,7 +295,7 @@ module Higgs
275
295
  raise 'required to_storage'
276
296
  end
277
297
 
278
- for to_jlog in Storage.rotate_entries("#{@to}.jlog")
298
+ for to_jlog in Storage.rotated_entries("#{@to}.jlog")
279
299
  to_jlog =~ /\.jlog\.\d+$/ or raise "mismatch jlog name: #{to_jlog}"
280
300
  ext = $&
281
301
  from_jlog = @from + ext
@@ -295,7 +315,7 @@ module Higgs
295
315
  raise 'required to_storage'
296
316
  end
297
317
 
298
- for to_jlog in Storage.rotate_entries("#{@to}.jlog")
318
+ for to_jlog in Storage.rotated_entries("#{@to}.jlog")
299
319
  FileUtils.rm(to_jlog, :verbose => @verbose >= 2)
300
320
  end
301
321
 
@@ -330,7 +350,7 @@ module Higgs
330
350
  flock.synchronize{
331
351
  FileUtils.cp("#{@to}.idx", "#{@from}.idx", :preserve => true, :verbose => @verbose >= 2)
332
352
  FileUtils.cp("#{@to}.tar", "#{@from}.tar", :preserve => true, :verbose => @verbose >= 2)
333
- for path in Storage.rotate_entries("#{@to}.jlog")
353
+ for path in Storage.rotated_entries("#{@to}.jlog")
334
354
  path =~ /\.jlog\.\d+$/ or raise "mismatch jlog name: #{path}"
335
355
  ext = $&
336
356
  FileUtils.cp(path, "#{@from}#{ext}", :preserve => true, :verbose => @verbose >= 2)
data/lib/higgs/version.rb CHANGED
@@ -1,8 +1,8 @@
1
1
  # = version
2
2
  #
3
3
  # Author:: $Author: toki $
4
- # Date:: $Date: 2007-10-12 16:19:52 +0900 (Fri, 12 Oct 2007) $
5
- # Revision:: $Revision: 628 $
4
+ # Date:: $Date: 2007-11-11 11:22:01 +0900 (Sun, 11 Nov 2007) $
5
+ # Revision:: $Revision: 683 $
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 628 2007-10-12 07:19:52Z toki $'
13
+ CVS_ID = '$Id: version.rb 683 2007-11-11 02:22:01Z toki $'
14
14
 
15
- VERSION = '0.1.2'
15
+ VERSION = '0.1.3'
16
16
  end
17
17
 
18
18
  # Local Variables:
data/lib/higgs.rb CHANGED
@@ -1,8 +1,8 @@
1
1
  # = pure ruby transactional storage compatible with unix TAR format
2
2
  #
3
3
  # Author:: $Author: toki $
4
- # Date:: $Date: 2007-09-27 00:51:39 +0900 (Thu, 27 Sep 2007) $
5
- # Revision:: $Revision: 562 $
4
+ # Date:: $Date: 2007-10-14 18:43:23 +0900 (Sun, 14 Oct 2007) $
5
+ # Revision:: $Revision: 636 $
6
6
  #
7
7
  # == license
8
8
  # :include:LICENSE
@@ -37,9 +37,9 @@ require 'higgs/version'
37
37
  #
38
38
  # === case of online backup
39
39
  #
40
- # [REQUIREMENTS] open with parameters:
40
+ # [REQUIREMENTS] open Higgs::StorageManager with these parameters:
41
41
  # <tt>jlog_rotate_max => 0</tt>,
42
- # <tt>jlog_rotate_service_uri => "druby://localhost:<em>appropriate_port_number</em>"</tt>,
42
+ # <tt>remtoe_services_uri => "druby://<em>host</em>:<em>port</em>"</tt>,
43
43
  # and execute <tt>higgs_backup</tt> (see Higgs::Utils::BackupManager)
44
44
  # [NORMAL SHUTDOWN] OK, no recovery
45
45
  # [PROCESS ABORT] OK, automatic recovery on read-write open
data/test/test_block.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/local/bin/ruby
2
2
 
3
- require 'digest/sha2'
3
+ require 'digest'
4
4
  require 'fileutils'
5
5
  require 'higgs/block'
6
6
  require 'test/unit'
@@ -10,7 +10,7 @@ module Higgs::Test
10
10
  include Higgs::Block
11
11
 
12
12
  # for ident(1)
13
- CVS_ID = '$Id: test_block.rb 591 2007-09-30 06:20:15Z toki $'
13
+ CVS_ID = '$Id: test_block.rb 654 2007-10-23 16:04:47Z toki $'
14
14
 
15
15
  def setup
16
16
  @io = File.open('block.test_io', 'w+')
data/test/test_cache.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_cache.rb 588 2007-09-30 05:39:54Z toki $'
13
+ CVS_ID = '$Id: test_cache.rb 659 2007-10-30 15:36:09Z toki $'
14
14
 
15
15
  CACHE_LIMIT_SIZE = 10
16
16
 
@@ -84,7 +84,7 @@ module Higgs::Test
84
84
  include Higgs
85
85
 
86
86
  # for ident(1)
87
- CVS_ID = '$Id: test_cache.rb 588 2007-09-30 05:39:54Z toki $'
87
+ CVS_ID = '$Id: test_cache.rb 659 2007-10-30 15:36:09Z toki $'
88
88
 
89
89
  def setup
90
90
  @calc_calls = 0
@@ -212,10 +212,10 @@ module Higgs::Test
212
212
  include Higgs
213
213
 
214
214
  # for ident(1)
215
- CVS_ID = '$Id: test_cache.rb 588 2007-09-30 05:39:54Z toki $'
215
+ CVS_ID = '$Id: test_cache.rb 659 2007-10-30 15:36:09Z toki $'
216
216
 
217
217
  def test_no_work_block
218
- assert_raise(RuntimeError) {
218
+ assert_raise(ArgumentError) {
219
219
  SharedWorkCache.new
220
220
  }
221
221
  end
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 589 2007-09-30 05:54:30Z toki $'
13
+ CVS_ID = '$Id: test_index.rb 650 2007-10-21 13:47:29Z 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 589 2007-09-30 05:54:30Z toki $'
48
+ CVS_ID = '$Id: test_index.rb 650 2007-10-21 13:47:29Z 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 589 2007-09-30 05:54:30Z toki $'
94
+ CVS_ID = '$Id: test_index.rb 650 2007-10-21 13:47:29Z 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 589 2007-09-30 05:54:30Z toki $'
167
+ CVS_ID = '$Id: test_index.rb 650 2007-10-21 13:47:29Z toki $'
168
168
 
169
169
  def setup
170
170
  @idx = Index.new
@@ -205,7 +205,7 @@ module Higgs::Test
205
205
  include Higgs
206
206
 
207
207
  # for ident(1)
208
- CVS_ID = '$Id: test_index.rb 589 2007-09-30 05:54:30Z toki $'
208
+ CVS_ID = '$Id: test_index.rb 650 2007-10-21 13:47:29Z toki $'
209
209
 
210
210
  def setup
211
211
  @path = 'test.idx'
@@ -246,12 +246,24 @@ module Higgs::Test
246
246
  }
247
247
 
248
248
  i = Index.new
249
+ i.storage_id = '68c6b76688d84b4d72856d8f589a5551'
249
250
  i.load(@path)
251
+
252
+ h = i.to_h
253
+ assert_equal([ Index::MAJOR_VERSION, Index::MINOR_VERSION ], h[:version])
254
+ assert_equal(0, h[:change_number])
255
+ assert_equal(1024, h[:eoa])
256
+ assert_equal({ 512 => [ 512 ] }, h[:free_lists])
257
+ assert_equal({ :foo => [ 'foo', 0 ] }, h[:index], 'index format version: 0.1')
258
+ assert_equal({ 'foo' => :foo }, h[:identities], 'index format version: 0.1')
259
+ assert_equal('68c6b76688d84b4d72856d8f589a5551', h[:storage_id], 'index format version: 0.2')
260
+
250
261
  assert_equal(0, i.change_number)
251
262
  assert_equal(1024, i.eoa)
252
263
  assert_equal(512, i.free_fetch(512))
253
264
  assert_equal(0, i[:foo])
254
265
  assert_equal('foo', i.identity(:foo))
266
+ assert_equal('68c6b76688d84b4d72856d8f589a5551', i.storage_id)
255
267
  end
256
268
 
257
269
  def test_migration_RuntimeError_unsupported_version
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 559 2007-09-25 15:20:20Z toki $'
13
+ CVS_ID = '$Id: test_jlog.rb 657 2007-10-28 14:35:37Z toki $'
14
14
 
15
15
  def setup
16
16
  @path = 't.jlog'
@@ -110,7 +110,9 @@ module Higgs::Test
110
110
 
111
111
  def test_eof_mark_no_file
112
112
  assert_equal(false, (File.exist? @path))
113
- assert_equal(true, (JournalLogger.has_eof_mark? @path))
113
+ assert_raise(Errno::ENOENT) {
114
+ JournalLogger.has_eof_mark? @path
115
+ }
114
116
  end
115
117
 
116
118
  def test_eof_mark_empty_file