higgs 0.1.0 → 0.1.1
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 +50 -0
- data/Rakefile +1 -2
- data/bin/higgs_backup +47 -29
- data/lib/higgs/block.rb +5 -4
- data/lib/higgs/dbm.rb +39 -3
- data/lib/higgs/index.rb +11 -8
- data/lib/higgs/jlog.rb +5 -5
- data/lib/higgs/storage.rb +64 -45
- data/lib/higgs/store.rb +30 -3
- data/lib/higgs/utils/bman.rb +149 -51
- data/lib/higgs/version.rb +4 -4
- data/mkrdoc.rb +5 -2
- data/test/test_block.rb +59 -1
- data/test/test_cache.rb +17 -3
- data/test/test_dbm.rb +163 -0
- data/test/test_index.rb +28 -5
- data/test/test_online_backup.rb +2 -2
- data/test/test_storage.rb +120 -53
- data/test/test_storage_init_opts.rb +27 -1
- data/test/test_store.rb +45 -6
- data/test/test_tman.rb +62 -2
- data/test/test_utils_bman.rb +257 -39
- metadata +3 -2
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
|
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
|
7
|
+
CVS_ID = '$Id: higgs_backup 619 2007-10-08 12:42:36Z toki $'
|
8
8
|
|
9
9
|
STDOUT.sync = true
|
10
10
|
|
11
|
-
|
12
|
-
|
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
|
-
|
27
|
+
commands = %w[ online_backup ]
|
15
28
|
options = { :verbose => 0 }
|
16
29
|
|
17
|
-
opts.
|
18
|
-
|
19
|
-
|
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
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
bman.
|
65
|
-
|
66
|
-
|
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-
|
5
|
-
# Revision:: $Revision:
|
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
|
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
|
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-
|
5
|
-
# Revision:: $Revision:
|
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
|
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-
|
5
|
-
# Revision:: $Revision:
|
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
|
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
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
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 (
|
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-
|
5
|
-
# Revision:: $Revision:
|
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
|
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)
|
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-
|
5
|
-
# Revision:: $Revision:
|
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
|
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 |
|
67
|
-
DATA_HASH_BIN[
|
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
|
-
@
|
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
|
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
|
-
@
|
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 (@
|
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)
|
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{ @
|
434
|
-
@logger.error("
|
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 (@
|
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 (! @
|
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{ @
|
572
|
-
@logger.error("
|
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{ @
|
768
|
-
@logger.error("
|
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,
|
824
|
+
raise PanicError, "invalid journal log (succ: #{cmd[:cnum]})"
|
818
825
|
end
|
819
826
|
else
|
820
|
-
raise "unknown operation
|
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
|
-
|
849
|
-
|
850
|
-
|
851
|
-
|
852
|
-
|
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{ @
|
959
|
-
@logger.error("
|
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{ @
|
986
|
-
@logger.error("
|
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{ @
|
991
|
-
@logger.error("
|
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{ @
|
1013
|
-
@logger.error("
|
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 (
|
1018
|
-
@state_lock.synchronize{ @
|
1019
|
-
@logger.error("
|
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 =
|
1034
|
+
hash_value = hash_proc.call(value)
|
1023
1035
|
if (hash_value != properties['system_properties']['hash_value']) then
|
1024
|
-
@state_lock.synchronize{ @
|
1025
|
-
@logger.error("
|
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
|
-
|
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-
|
5
|
-
# Revision:: $Revision:
|
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
|
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
|