higgs 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/ChangeLog CHANGED
@@ -1,3 +1,53 @@
1
+ 2007-10-08 TOKI Yoshinori <toki@freedom.ne.jp>
2
+
3
+ * lib/higgs/version.rb: version 0.1.1.
4
+
5
+ * lib/higgs/utils/bman.rb: added variation of incremental backup.
6
+
7
+ * bin/higgs_backup: changed command line syntax. added restore
8
+ commands.
9
+
10
+ * lib/higgs/utils/bman.rb: restore operations.
11
+
12
+ 2007-10-06 TOKI Yoshinori <toki@freedom.ne.jp>
13
+
14
+ * check ruby-1.8.6-p111
15
+ ruby 1.8.6 (2007-09-24 patchlevel 111) [i686-linux], OK.
16
+ ruby 1.8.6 (2007-09-24 patchlevel 111) [i386-cygwin], OK.
17
+
18
+ 2007-10-05 TOKI Yoshinori <toki@freedom.ne.jp>
19
+
20
+ * lib/higgs/storage.rb (Higgs::Storage class): journal log is
21
+ applied to the broken block point.
22
+
23
+ * lib/higgs/storage.rb (Higgs::Storage class): in recover class
24
+ method, when latest journal log exists, it is applied.
25
+
26
+ 2007-10-04 TOKI Yoshinori <toki@freedom.ne.jp>
27
+
28
+ * lib/higgs/storage.rb (Higgs::Storage class): rough sequential
29
+ access at verify method.
30
+
31
+ 2007-10-03 TOKI Yoshinori <toki@freedom.ne.jp>
32
+
33
+ * lib/higgs/storage.rb (Higgs::Storage::Export module): disable
34
+ verify method.
35
+
36
+ * lib/higgs/utils/bman.rb (Higgs::Utils::BackupManager class):
37
+ clean_jlog method is divided to clean_jlog_from method and
38
+ clean_jlog_to method.
39
+
40
+ 2007-09-30 TOKI Yoshinori <toki@freedom.ne.jp>
41
+
42
+ * lib/higgs/storage.rb (Higgs::Storage class): fixed a bug of EOA
43
+ lost on recovery.
44
+
45
+ * lib/higgs/block.rb (Higgs::Block module): fixed a bug of
46
+ body_hash_type check leakage.
47
+
48
+ * lib/higgs/storage.rb (Higgs::Storage::InitOptions module):
49
+ exceptions of the argument check are unified to ArgumentError.
50
+
1
51
  2007-09-29 TOKI Yoshinori <toki@freedom.ne.jp>
2
52
 
3
53
  * lib/higgs/version.rb: version 0.1.0.
data/Rakefile CHANGED
@@ -1,5 +1,5 @@
1
1
  # for ident(1)
2
- CVS_ID = '$Id: Rakefile 576 2007-09-29 08:35:19Z toki $'
2
+ CVS_ID = '$Id: Rakefile 586 2007-09-30 03:03:12Z toki $'
3
3
 
4
4
  require 'lib/higgs/version'
5
5
  require 'rake/gempackagetask'
@@ -8,7 +8,6 @@ require 'yaml'
8
8
  LIB_DIR = 'lib'
9
9
  TEST_DIR = 'test'
10
10
  RDOC_DIR = 'api'
11
- RDOC_MAIN = 'Higgs'
12
11
 
13
12
  def cd_v(dir)
14
13
  cd(dir, :verbose => true) {
data/bin/higgs_backup CHANGED
@@ -4,20 +4,34 @@ require 'higgs/utils/bman'
4
4
  require 'optparse'
5
5
 
6
6
  # for ident(1)
7
- CVS_ID = '$Id: higgs_backup 546 2007-09-23 14:20:23Z toki $'
7
+ CVS_ID = '$Id: higgs_backup 619 2007-10-08 12:42:36Z toki $'
8
8
 
9
9
  STDOUT.sync = true
10
10
 
11
- opts = OptionParser.new
12
- opts.banner = "Usage: #{opts.program_name} [options]"
11
+ COMMANDs = %w[
12
+ online_backup
13
+ index
14
+ data
15
+ rotate
16
+ jlog
17
+ recover
18
+ verify
19
+ clean_from
20
+ clean_to
21
+ restore
22
+ restore_files
23
+ restore_recover
24
+ restore_verify
25
+ ]
13
26
 
14
- command = :online_backup
27
+ commands = %w[ online_backup ]
15
28
  options = { :verbose => 0 }
16
29
 
17
- opts.on('--command=BACKUP_COMMAND',
18
- [ :index, :data, :rotate, :jlog, :recover, :verify, :clean, :online_backup ]) {|value|
19
- command = value
20
- }
30
+ opts = OptionParser.new
31
+ opts.banner = "Usage: #{opts.program_name} [OPTIONs] [COMMANDs]\n"
32
+ opts.banner << "COMMANDs:\n"
33
+ opts.banner << COMMANDs.map{|s| opts.summary_indent + s }.join("\n") << "\n"
34
+ opts.banner << "OPTIONs:\n"
21
35
 
22
36
  opts.on('-f', '--from=BACKUP_TARGET_STORAGE', String) {|value|
23
37
  options[:from] = value
@@ -41,27 +55,31 @@ opts.on('-v', '--verbose', '--[no-]verbose') {|value|
41
55
  opts.on('--verbose-level=LEVEL', Integer) {|value|
42
56
  options[:verbose] = value
43
57
  }
44
-
45
58
  opts.parse!
46
- bman = Higgs::Utils::BackupManager.new(options)
47
59
 
48
- case (command)
49
- when :online_backup
50
- bman.online_backup
51
- when :index
52
- bman.backup_index
53
- when :data
54
- bman.backup_data
55
- when :rotate
56
- bman.rotate_jlog
57
- when :jlog
58
- bman.backup_jlog
59
- when :recover
60
- bman.recover
61
- when :verify
62
- bman.verify
63
- when :clean
64
- bman.clean_jlog
65
- else
66
- raise "unknown backup command: #{command}"
60
+ unless (ARGV.empty?) then
61
+ count = 0
62
+ for cmd in ARGV
63
+ unless (COMMANDs.include? cmd) then
64
+ STDERR.puts "error: unknown command: #{cmd}"
65
+ count += 1
66
+ end
67
+ end
68
+ if (count > 0) then
69
+ exit 1
70
+ end
71
+ commands = ARGV
72
+ end
73
+
74
+ bman = Higgs::Utils::BackupManager.new(options)
75
+ for cmd in commands
76
+ unless (bman.public_methods(false).include? cmd) then
77
+ raise "unknown command: #{cmd}"
78
+ end
79
+ bman.__send__(cmd)
67
80
  end
81
+
82
+ # Local Variables:
83
+ # mode: Ruby
84
+ # indent-tabs-mode: nil
85
+ # End:
data/lib/higgs/block.rb CHANGED
@@ -1,8 +1,8 @@
1
1
  # = block read/write
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-09-30 15:20:15 +0900 (Sun, 30 Sep 2007) $
5
+ # Revision:: $Revision: 591 $
6
6
  #
7
7
  # == license
8
8
  # :include:LICENSE
@@ -27,7 +27,7 @@ module Higgs
27
27
  #
28
28
  module Block
29
29
  # for ident(1)
30
- CVS_ID = '$Id: block.rb 559 2007-09-25 15:20:20Z toki $'
30
+ CVS_ID = '$Id: block.rb 591 2007-09-30 06:20:15Z toki $'
31
31
 
32
32
  include Exceptions
33
33
 
@@ -165,7 +165,8 @@ module Higgs
165
165
  module_function :block_read
166
166
 
167
167
  def block_write(io, magic_symbol, body, body_hash_type=:MD5)
168
- hash_proc = BODY_HASH[body_hash_type.to_sym] or "unknown body hash type: #{body_hash_type}"
168
+ hash_proc = BODY_HASH[body_hash_type.to_sym] or
169
+ raise ArgumentError, "unknown body hash type: #{body_hash_type}"
169
170
  body_hash = hash_proc.call(body)
170
171
  head_write(io, magic_symbol, body.length, body_hash_type.to_s, body_hash)
171
172
 
data/lib/higgs/dbm.rb CHANGED
@@ -1,8 +1,8 @@
1
1
  # = storage like dbm
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-02 01:05:07 +0900 (Tue, 02 Oct 2007) $
5
+ # Revision:: $Revision: 600 $
6
6
  #
7
7
  # == license
8
8
  # :include:LICENSE
@@ -14,12 +14,48 @@ require 'higgs/tman'
14
14
  module Higgs
15
15
  # = storage like dbm
16
16
  # == sample script
17
+ #
17
18
  # sample/dbmtest.rb
18
19
  # :include: sample/dbmtest.rb
19
20
  #
21
+ # result of sample script.
22
+ # % ruby dbmtest.rb
23
+ # % ruby dbmtest.rb
24
+ # -
25
+ # key: quux
26
+ # value: QX
27
+ # system_property[hash_type]: MD5
28
+ # system_property[modified_time]: Tue Oct 02 00:52:58 +0900 2007
29
+ # system_property[created_time]: Tue Oct 02 00:52:58 +0900 2007
30
+ # system_property[hash_value]: 2e8e88f56e5d52ce42f59592efbc2831
31
+ # system_property[changed_time]: Tue Oct 02 00:52:58 +0900 2007
32
+ # system_property[string_only]: false
33
+ # custom_property[number]: 2
34
+ # -
35
+ # key: baz
36
+ # value: BZ
37
+ # system_property[hash_type]: MD5
38
+ # system_property[modified_time]: Tue Oct 02 00:52:58 +0900 2007
39
+ # system_property[created_time]: Tue Oct 02 00:52:58 +0900 2007
40
+ # system_property[hash_value]: e45fbcf6ca3b21f17c5f355728a2fbec
41
+ # system_property[changed_time]: Tue Oct 02 00:52:58 +0900 2007
42
+ # system_property[string_only]: false
43
+ # custom_property[number]: 1
44
+ # -
45
+ # key: foobar
46
+ # value: FB
47
+ # system_property[hash_type]: MD5
48
+ # system_property[modified_time]: Tue Oct 02 00:52:58 +0900 2007
49
+ # system_property[created_time]: Tue Oct 02 00:52:58 +0900 2007
50
+ # system_property[hash_value]: 30781f1fc2f9342ceb1ad2f6f35a51db
51
+ # system_property[changed_time]: Tue Oct 02 00:52:58 +0900 2007
52
+ # system_property[string_only]: false
53
+ # custom_property[number]: 0
54
+ # %
55
+ #
20
56
  class DBM
21
57
  # for ident(1)
22
- CVS_ID = '$Id: dbm.rb 559 2007-09-25 15:20:20Z toki $'
58
+ CVS_ID = '$Id: dbm.rb 600 2007-10-01 16:05:07Z toki $'
23
59
 
24
60
  include Storage::Export
25
61
  include TransactionManager::Export
data/lib/higgs/index.rb CHANGED
@@ -1,8 +1,8 @@
1
1
  # = storage index
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-09-30 14:54:30 +0900 (Sun, 30 Sep 2007) $
5
+ # Revision:: $Revision: 589 $
6
6
  #
7
7
  # == license
8
8
  # :include:LICENSE
@@ -15,7 +15,7 @@ module Higgs
15
15
  # = storage index
16
16
  class Index
17
17
  # for ident(1)
18
- CVS_ID = '$Id: index.rb 559 2007-09-25 15:20:20Z toki $'
18
+ CVS_ID = '$Id: index.rb 589 2007-09-30 05:54:30Z toki $'
19
19
 
20
20
  extend Forwardable
21
21
  include Block
@@ -75,10 +75,13 @@ module Higgs
75
75
  end
76
76
 
77
77
  def []=(key, value)
78
- delete(key)
79
- id = Index.create_id(key, @identities)
80
- @identities[id] = key
81
- @index[key] = [ id, value ]
78
+ if (i = @index[key]) then
79
+ i[1] = value
80
+ else
81
+ id = Index.create_id(key, @identities)
82
+ @identities[id] = key
83
+ @index[key] = [ id, value ]
84
+ end
82
85
  value
83
86
  end
84
87
 
@@ -144,7 +147,7 @@ module Higgs
144
147
  f.binmode
145
148
  index_data = Marshal.load(block_read(f, MAGIC_SYMBOL))
146
149
  migration_0_0_to_0_1(index_data)
147
- if ((index_data[:version] <=> [ MAJOR_VERSION, MINOR_VERSION ]) > 0) then
150
+ if (index_data[:version] != [ MAJOR_VERSION, MINOR_VERSION ]) then
148
151
  raise "unsupported version: #{index_data[:version].join('.')}"
149
152
  end
150
153
  @change_number = index_data[:change_number]
data/lib/higgs/jlog.rb CHANGED
@@ -1,8 +1,8 @@
1
1
  # = journal log writer
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-03 00:02:48 +0900 (Wed, 03 Oct 2007) $
5
+ # Revision:: $Revision: 603 $
6
6
  #
7
7
  # == license
8
8
  # :include:LICENSE
@@ -14,7 +14,7 @@ module Higgs
14
14
  # = journal log writer
15
15
  class JournalLogger
16
16
  # for ident(1)
17
- CVS_ID = '$Id: jlog.rb 559 2007-09-25 15:20:20Z toki $'
17
+ CVS_ID = '$Id: jlog.rb 603 2007-10-02 15:02:48Z toki $'
18
18
 
19
19
  include Block
20
20
 
@@ -143,9 +143,9 @@ module Higgs
143
143
  def each_log(path)
144
144
  File.open(path, 'r') {|f|
145
145
  f.binmode
146
- scan_log(f) {|log|
146
+ scan_log(f) do |log|
147
147
  yield(log)
148
- }
148
+ end
149
149
  }
150
150
  nil
151
151
  end
data/lib/higgs/storage.rb CHANGED
@@ -1,8 +1,8 @@
1
1
  # = transactional storage core
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-05 02:35:02 +0900 (Fri, 05 Oct 2007) $
5
+ # Revision:: $Revision: 614 $
6
6
  #
7
7
  # == license
8
8
  # :include:LICENSE
@@ -23,7 +23,7 @@ module Higgs
23
23
  # = transactional storage core
24
24
  class Storage
25
25
  # for ident(1)
26
- CVS_ID = '$Id: storage.rb 559 2007-09-25 15:20:20Z toki $'
26
+ CVS_ID = '$Id: storage.rb 614 2007-10-04 17:35:02Z toki $'
27
27
 
28
28
  extend Forwardable
29
29
  include Exceptions
@@ -63,8 +63,8 @@ module Higgs
63
63
  end
64
64
 
65
65
  DATA_HASH_BIN = {}
66
- DATA_HASH.each do |cksum_symbol, cksum_proc|
67
- DATA_HASH_BIN[cksum_symbol.to_s] = cksum_proc
66
+ DATA_HASH.each do |hash_symbol, hash_proc|
67
+ DATA_HASH_BIN[hash_symbol.to_s] = hash_proc
68
68
  end
69
69
 
70
70
  # options for Higgs::Storage
@@ -106,7 +106,7 @@ module Higgs
106
106
 
107
107
  @data_hash_type = options[:data_hash_type] || :MD5
108
108
  unless (DATA_HASH.key? @data_hash_type) then
109
- raise "unknown data hash type: #{@data_hash_type}"
109
+ raise ArgumentError, "unknown data hash type: #{@data_hash_type}"
110
110
  end
111
111
 
112
112
  if (options.key? :jlog_sync) then
@@ -116,6 +116,10 @@ module Higgs
116
116
  end
117
117
 
118
118
  @jlog_hash_type = options[:jlog_hash_type] || :MD5
119
+ unless (Block::BODY_HASH.key? @jlog_hash_type) then
120
+ raise ArgumentError, "unknown journal log hash type: #{@jlog_hash_type}"
121
+ end
122
+
119
123
  @jlog_rotate_size = options[:jlog_rotate_size] || 1024 * 256
120
124
  @jlog_rotate_max = options[:jlog_rotate_max] || 1
121
125
  @jlog_rotate_service_uri = options[:jlog_rotate_service_uri]
@@ -159,7 +163,6 @@ module Higgs
159
163
  # * Higgs::Storage#shutdown
160
164
  # * Higgs::Storage#shutdown?
161
165
  # * Higgs::Storage#rotate_journal_log
162
- # * Higgs::Storage#verify
163
166
  #
164
167
  module Export
165
168
  extend Forwardable
@@ -176,7 +179,6 @@ module Higgs
176
179
  def_delegator :@storage, :shutdown
177
180
  def_delegator :@storage, :shutdown?
178
181
  def_delegator :@storage, :rotate_journal_log
179
- def_delegator :@storage, :verify
180
182
  end
181
183
 
182
184
  def self.load_conf(path)
@@ -230,7 +232,7 @@ module Higgs
230
232
 
231
233
  @commit_lock = Mutex.new
232
234
  @state_lock = Mutex.new
233
- @broken = false
235
+ @panic = false
234
236
  @shutdown = false
235
237
 
236
238
  init_options(options)
@@ -266,7 +268,7 @@ module Higgs
266
268
  unless (@read_only) then
267
269
  begin
268
270
  w_io = File.open(@tar_name, File::WRONLY | File::CREAT | File::EXCL, 0660)
269
- @logger.info("create and get I/O handle for write: #{@tar_name}")
271
+ @logger.info("create and open I/O handle for write: #{@tar_name}")
270
272
  rescue Errno::EEXIST
271
273
  @logger.info("open I/O handle for write: #{@tar_name}")
272
274
  w_io = File.open(@tar_name, File::WRONLY, 0660)
@@ -311,7 +313,7 @@ module Higgs
311
313
  if (init_completed) then
312
314
  @logger.info("completed storage open.")
313
315
  else
314
- @broken = true
316
+ @panic = true
315
317
 
316
318
  if ($! && @logger) then
317
319
  begin
@@ -384,7 +386,7 @@ module Higgs
384
386
  if (@shutdown) then
385
387
  raise ShutdownException, 'storage shutdown'
386
388
  end
387
- if (@broken) then
389
+ if (@panic) then
388
390
  raise PanicError, 'broken storage'
389
391
  end
390
392
  }
@@ -407,11 +409,11 @@ module Higgs
407
409
  File.open(@jlog_name, File::RDONLY) {|f|
408
410
  f.binmode
409
411
  begin
410
- JournalLogger.scan_log(f) {|log|
412
+ JournalLogger.scan_log(f) do |log|
411
413
  change_number = log[0]
412
414
  @logger.info("apply journal log: #{change_number}")
413
415
  Storage.apply_journal(@w_tar, @index, log)
414
- }
416
+ end
415
417
  rescue Block::BrokenError
416
418
  # nothing to do.
417
419
  end
@@ -427,11 +429,16 @@ module Higgs
427
429
  @logger.info("write eof mark to journal log.")
428
430
  JournalLogger.eof_mark(f)
429
431
  }
432
+
433
+ @logger.info("write EOA to storage: #{@index.eoa}")
434
+ @w_tar.seek(@index.eoa)
435
+ @w_tar.write_EOA
436
+
430
437
  recover_completed = true
431
438
  ensure
432
439
  unless (recover_completed) then
433
- @state_lock.synchronize{ @broken = true }
434
- @logger.error("BROKEN: failed to recover.")
440
+ @state_lock.synchronize{ @panic = true }
441
+ @logger.error("panic: failed to recover.")
435
442
  @logger.error($!) if $!
436
443
  end
437
444
  end
@@ -457,7 +464,7 @@ module Higgs
457
464
  end
458
465
 
459
466
  unless (@read_only) then
460
- if (@broken) then
467
+ if (@panic) then
461
468
  @logger.warn("abort journal log: #{@jlog_name}")
462
469
  @jlog.close(false)
463
470
  else
@@ -466,7 +473,7 @@ module Higgs
466
473
  end
467
474
  end
468
475
 
469
- if (! @broken && ! @read_only) then
476
+ if (! @panic && ! @read_only) then
470
477
  @logger.info("save index: #{@idx_name}")
471
478
  @index.save(@idx_name)
472
479
  end
@@ -568,8 +575,8 @@ module Higgs
568
575
  rotate_completed = true
569
576
  ensure
570
577
  unless (rotate_completed) then
571
- @state_lock.synchronize{ @broken = true }
572
- @logger.error("BROKEN: failed to rotate journal log.")
578
+ @state_lock.synchronize{ @panic = true }
579
+ @logger.error("panic: failed to rotate journal log.")
573
580
  @logger.error($!) if $!
574
581
  end
575
582
  end
@@ -764,8 +771,8 @@ module Higgs
764
771
  commit_completed = true
765
772
  ensure
766
773
  unless (commit_completed) then
767
- @state_lock.synchronize{ @broken = true }
768
- @logger.error("BROKEN: failed to commit.")
774
+ @state_lock.synchronize{ @panic = true }
775
+ @logger.error("panic: failed to commit.")
769
776
  @logger.error($!) if $!
770
777
  end
771
778
  end
@@ -814,10 +821,10 @@ module Higgs
814
821
  when :succ
815
822
  index.succ!
816
823
  if (index.change_number != cmd[:cnum]) then
817
- raise PanicError, 'lost journal log'
824
+ raise PanicError, "invalid journal log (succ: #{cmd[:cnum]})"
818
825
  end
819
826
  else
820
- raise "unknown operation from #{curr_jlog_name}: #{cmd[:ope]}"
827
+ raise "unknown operation: #{cmd[:ope]}"
821
828
  end
822
829
  end
823
830
  end
@@ -843,13 +850,18 @@ module Higgs
843
850
  index = Index.new
844
851
  index.load(idx_name) if (File.exist? idx_name)
845
852
 
846
-
847
853
  out << "recovery target: #{name}\n" if (out && verbose_level >= 1)
848
- for curr_name in rotate_entries(jlog_name)
849
- JournalLogger.each_log(curr_name) do |log|
850
- change_number = log[0]
851
- out << "apply journal log: #{change_number}\n" if (out && verbose_level >= 1)
852
- apply_journal(w_tar, index, log)
854
+ jlog_list = rotate_entries(jlog_name)
855
+ jlog_list << jlog_name if (File.exist? jlog_name)
856
+ for curr_name in jlog_list
857
+ begin
858
+ JournalLogger.each_log(curr_name) do |log|
859
+ change_number = log[0]
860
+ out << "apply journal log: #{change_number}\n" if (out && verbose_level >= 1)
861
+ apply_journal(w_tar, index, log)
862
+ end
863
+ rescue Block::BrokenError
864
+ out << "warning: incompleted journal log and stopped at #{curr_name}\n" if out
853
865
  end
854
866
  end
855
867
  w_tar.seek(index.eoa)
@@ -955,8 +967,8 @@ module Higgs
955
967
  head_and_body = r_tar.fetch
956
968
  }
957
969
  unless (head_and_body) then
958
- @state_lock.synchronize{ @broken = true }
959
- @logger.error("BROKEN: failed to read record: #{key}")
970
+ @state_lock.synchronize{ @panic = true }
971
+ @logger.error("panic: failed to read record: #{key}")
960
972
  raise PanicError, "failed to read record: #{key}"
961
973
  end
962
974
  end
@@ -982,13 +994,13 @@ module Higgs
982
994
  head, body = value.split(/\n/, 2)
983
995
  cksum_type, cksum_value = head.sub(/^#\s+/, '').split(/\s+/, 2)
984
996
  if (cksum_type != PROPERTIES_CKSUM_TYPE) then
985
- @state_lock.synchronize{ @broken = true }
986
- @logger.error("BROKEN: unknown properties cksum type: #{cksum_type}")
997
+ @state_lock.synchronize{ @panic = true }
998
+ @logger.error("panic: unknown properties cksum type: #{cksum_type}")
987
999
  raise PanicError, "unknown properties cksum type: #{cksum_type}"
988
1000
  end
989
1001
  if (body.sum(PROPERTIES_CKSUM_BITS) != Integer(cksum_value)) then
990
- @state_lock.synchronize{ @broken = true }
991
- @logger.error("BROKEN: mismatch properties cksum at #{key}")
1002
+ @state_lock.synchronize{ @panic = true }
1003
+ @logger.error("panic: mismatch properties cksum at #{key}")
992
1004
  raise PanicError, "mismatch properties cksum at #{key}"
993
1005
  end
994
1006
  YAML.load(body)
@@ -1009,20 +1021,20 @@ module Higgs
1009
1021
  check_panic
1010
1022
  value = read_record_body(key, :d) or return
1011
1023
  unless (properties = internal_fetch_properties(key)) then
1012
- @state_lock.synchronize{ @broken = true }
1013
- @logger.error("BROKEN: failed to read properties: #{key}")
1024
+ @state_lock.synchronize{ @panic = true }
1025
+ @logger.error("panic: failed to read properties: #{key}")
1014
1026
  raise PanicError, "failed to read properties: #{key}"
1015
1027
  end
1016
1028
  hash_type = properties['system_properties']['hash_type']
1017
- unless (cksum_proc = DATA_HASH_BIN[hash_type]) then
1018
- @state_lock.synchronize{ @broken = true }
1019
- @logger.error("BROKEN: unknown data hash type: #{hash_type}")
1029
+ unless (hash_proc = DATA_HASH_BIN[hash_type]) then
1030
+ @state_lock.synchronize{ @panic = true }
1031
+ @logger.error("panic: unknown data hash type: #{hash_type}")
1020
1032
  raise PanicError, "unknown data hash type: #{hash_type}"
1021
1033
  end
1022
- hash_value = cksum_proc.call(value)
1034
+ hash_value = hash_proc.call(value)
1023
1035
  if (hash_value != properties['system_properties']['hash_value']) then
1024
- @state_lock.synchronize{ @broken = true }
1025
- @logger.error("BROKEN: mismatch hash value at #{key}")
1036
+ @state_lock.synchronize{ @panic = true }
1037
+ @logger.error("panic: mismatch hash value at #{key}")
1026
1038
  raise PanicError, "mismatch hash value at #{key}"
1027
1039
  end
1028
1040
  value
@@ -1059,7 +1071,13 @@ module Higgs
1059
1071
 
1060
1072
  def verify(out=nil, verbose_level=1)
1061
1073
  check_panic
1062
- @index.each_key do |key|
1074
+
1075
+ keys = @index.keys
1076
+ keys.sort!{|a, b|
1077
+ @index[a][:d][:pos] <=> @index[b][:d][:pos]
1078
+ }
1079
+
1080
+ for key in keys
1063
1081
  if (out && verbose_level >= 1) then
1064
1082
  out << "check #{key}\n"
1065
1083
  end
@@ -1075,6 +1093,7 @@ module Higgs
1075
1093
  end
1076
1094
  end
1077
1095
  end
1096
+
1078
1097
  nil
1079
1098
  end
1080
1099
  end
data/lib/higgs/store.rb CHANGED
@@ -1,8 +1,8 @@
1
1
  # = storage like pstore
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-02 01:05:07 +0900 (Tue, 02 Oct 2007) $
5
+ # Revision:: $Revision: 600 $
6
6
  #
7
7
  # == license
8
8
  # :include:LICENSE
@@ -190,9 +190,36 @@ module Higgs
190
190
  # sample/count.rb
191
191
  # :include: sample/count.rb
192
192
  #
193
+ # result of sample script.
194
+ # % ruby count.rb
195
+ # start - Tue Oct 02 00:50:14 +0900 2007
196
+ # nil
197
+ #
198
+ # 1
199
+ # 70
200
+ # 134
201
+ # 200
202
+ # 256
203
+ # 318
204
+ # 382
205
+ # 446
206
+ # 508
207
+ # 554
208
+ # 620
209
+ # 685
210
+ # 751
211
+ # 796
212
+ # 862
213
+ # 927
214
+ # 992
215
+ #
216
+ # last - Tue Oct 02 00:50:15 +0900 2007
217
+ # 1000
218
+ # %
219
+ #
193
220
  class Store
194
221
  # for ident(1)
195
- CVS_ID = '$Id: store.rb 559 2007-09-25 15:20:20Z toki $'
222
+ CVS_ID = '$Id: store.rb 600 2007-10-01 16:05:07Z toki $'
196
223
 
197
224
  include Storage::Export
198
225
  include TransactionManager::Export