higgs 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. data/ChangeLog +67 -0
  2. data/bin/higgs_apply_jlog +1 -1
  3. data/bin/higgs_backup +1 -1
  4. data/bin/higgs_dump_index +1 -1
  5. data/bin/higgs_dump_jlog +1 -1
  6. data/bin/higgs_ping +1 -1
  7. data/bin/higgs_verify +1 -1
  8. data/lib/cgi/session/higgs.rb +3 -3
  9. data/lib/higgs/block.rb +3 -3
  10. data/lib/higgs/cache.rb +17 -13
  11. data/lib/higgs/dbm.rb +3 -3
  12. data/lib/higgs/exceptions.rb +3 -3
  13. data/lib/higgs/flock.rb +3 -3
  14. data/lib/higgs/index.rb +35 -17
  15. data/lib/higgs/jlog.rb +3 -3
  16. data/lib/higgs/lock.rb +5 -5
  17. data/lib/higgs/services.rb +3 -3
  18. data/lib/higgs/sman.rb +7 -3
  19. data/lib/higgs/storage.rb +14 -3
  20. data/lib/higgs/store.rb +3 -3
  21. data/lib/higgs/tar.rb +3 -3
  22. data/lib/higgs/thread.rb +130 -8
  23. data/lib/higgs/tman.rb +15 -13
  24. data/lib/higgs/utils/bman.rb +3 -3
  25. data/lib/higgs/utils.rb +3 -3
  26. data/lib/higgs/version.rb +4 -4
  27. data/lib/higgs.rb +2 -2
  28. data/misc/cache_bench/cache_bench.rb +2 -2
  29. data/misc/dbm_bench/.strc +1 -1
  30. data/misc/dbm_bench/Rakefile +1 -1
  31. data/misc/dbm_bench/dbm_multi_thread.rb +2 -2
  32. data/misc/dbm_bench/dbm_rnd_delete.rb +2 -2
  33. data/misc/dbm_bench/dbm_rnd_read.rb +2 -2
  34. data/misc/dbm_bench/dbm_rnd_update.rb +2 -2
  35. data/misc/dbm_bench/dbm_seq_read.rb +2 -2
  36. data/misc/dbm_bench/dbm_seq_write.rb +2 -2
  37. data/misc/dbm_bench/run.rb +52 -0
  38. data/misc/dbm_bench/st_verify.rb +2 -2
  39. data/misc/io_bench/cksum_bench.rb +1 -1
  40. data/misc/io_bench/jlog_bench.rb +2 -2
  41. data/misc/io_bench/write_bench.rb +1 -1
  42. data/misc/thread_bench/lock_bench.rb +2 -2
  43. data/test/Rakefile +1 -1
  44. data/test/run.rb +3 -3
  45. data/test/test_block.rb +1 -1
  46. data/test/test_cache.rb +9 -9
  47. data/test/test_cache_mvcc.rb +403 -168
  48. data/test/test_cgi_session.rb +3 -3
  49. data/test/test_dbm.rb +14 -5
  50. data/test/test_flock.rb +1 -1
  51. data/test/test_index.rb +5 -7
  52. data/test/test_jlog.rb +1 -1
  53. data/test/test_lock.rb +21 -21
  54. data/test/test_online_backup.rb +1 -1
  55. data/test/test_services.rb +1 -1
  56. data/test/test_storage.rb +4 -4
  57. data/test/test_storage_conf.rb +1 -1
  58. data/test/test_storage_init_opts.rb +1 -1
  59. data/test/test_store.rb +2 -2
  60. data/test/test_tar.rb +19 -19
  61. data/test/test_thread.rb +46 -46
  62. data/test/test_tman.rb +2 -2
  63. data/test/test_tman_init_opts.rb +1 -1
  64. data/test/test_tman_mvcc.rb +11 -11
  65. data/test/test_utils_bman.rb +4 -2
  66. metadata +10 -18
  67. data/Rakefile +0 -81
  68. data/mkrdoc.rb +0 -11
  69. data/rdoc.yml +0 -13
data/ChangeLog CHANGED
@@ -1,3 +1,70 @@
1
+ 2008-07-26 TOKI Yoshinori <toki@freedom.ne.jp>
2
+
3
+ * check ruby 1.9.0 (2008-07-25 revision 18217) [i686-linux]
4
+ Loaded suite run
5
+ Started
6
+ ............................................................................................................................................................................................................................................................................................................................................................
7
+ Finished in 2076.798714343 seconds.
8
+
9
+ 348 tests, 30406771 assertions, 0 failures, 0 errors
10
+
11
+ * check ruby 1.8.7 (2008-06-20 patchlevel 22) [i686-linux]
12
+ Loaded suite run
13
+ Started
14
+ ............................................................................................................................................................................................................................................................................................................................................................
15
+ Finished in 422.501347 seconds.
16
+
17
+ 348 tests, 3098555 assertions, 0 failures, 0 errors
18
+
19
+
20
+ 2008-07-11 TOKI Yoshinori <toki@freedom.ne.jp>
21
+
22
+ * lib/higgs/version.rb: version 0.1.6.
23
+
24
+ * check ruby 1.9.0 (2008-06-20 revision 17482) [i686-linux]
25
+ Loaded suite run
26
+ Started
27
+ ............................................................................................................................................................................................................................................................................................................................................................
28
+ Finished in 1152.566426031 seconds.
29
+
30
+ 348 tests, 14579396 assertions, 0 failures, 0 errors
31
+
32
+ * check ruby 1.8.7 (2008-06-09 patchlevel 17) [i686-linux]
33
+ Loaded suite run
34
+ Started
35
+ ............................................................................................................................................................................................................................................................................................................................................................
36
+ Finished in 426.574262 seconds.
37
+
38
+ 348 tests, 3140575 assertions, 0 failures, 0 errors
39
+
40
+ 2008-02-13 TOKI Yoshinori <toki@freedom.ne.jp>
41
+
42
+ * merge from development branch of ruby-1.9.
43
+ branch: branches/higgs_develop_ruby1_9
44
+ snapshot of start: tag/higgs_develop_mvcc_snapshot_20080114_merge_to_trunk
45
+ snapshot of end: tags/higgs_develop_ruby1_9_snapshot_20080213_merge_to_trunk
46
+
47
+ 2008-02-02 TOKI Yoshinori <toki@freedom.ne.jp>
48
+
49
+ * lib/higgs/cache.rb (Higgs::MVCCCache class): fixed a bug of race
50
+ condition.
51
+
52
+ * lib/higgs/index.rb (Higgs::Index class): multi-thread guard on
53
+ update.
54
+
55
+ * lib/higgs/thread.rb: HiggsSynchronized module is new.
56
+ multi-thread guard syntax like java.
57
+
58
+ 2008-02-01 TOKI Yoshinori <toki@freedom.ne.jp>
59
+
60
+ * development branch of ruby-1.9.
61
+ branch: branches/higgs_develop_ruby1_9
62
+ snapshot of start: tag/higgs_develop_mvcc_snapshot_20080114_merge_to_trunk
63
+
64
+ 2008-01-24 TOKI Yoshinori <toki@freedom.ne.jp>
65
+
66
+ * refactoring of multi-thread test.
67
+
1
68
  2008-01-20 TOKI Yoshinori <toki@freedom.ne.jp>
2
69
 
3
70
  * lib/higgs/version.rb: version 0.1.5.
data/bin/higgs_apply_jlog CHANGED
@@ -4,7 +4,7 @@ require 'drb'
4
4
  require 'optparse'
5
5
 
6
6
  # for ident(1)
7
- CVS_ID = '$Id: higgs_apply_jlog 680 2007-11-11 02:04:47Z toki $'
7
+ CVS_ID = '$Id: higgs_apply_jlog 781 2008-07-28 15:13:27Z toki $'
8
8
 
9
9
  opt_not_delete = false
10
10
  opt_switch_to_write = false
data/bin/higgs_backup CHANGED
@@ -5,7 +5,7 @@ require 'higgs/utils/bman'
5
5
  require 'optparse'
6
6
 
7
7
  # for ident(1)
8
- CVS_ID = '$Id: higgs_backup 688 2007-11-21 14:35:49Z toki $'
8
+ CVS_ID = '$Id: higgs_backup 781 2008-07-28 15:13:27Z toki $'
9
9
 
10
10
  STDOUT.sync = true
11
11
 
data/bin/higgs_dump_index CHANGED
@@ -6,7 +6,7 @@ require 'pp'
6
6
  require 'yaml'
7
7
 
8
8
  # for ident(1)
9
- CVS_ID = '$Id: higgs_dump_index 462 2007-07-15 09:25:07Z toki $'
9
+ CVS_ID = '$Id: higgs_dump_index 781 2008-07-28 15:13:27Z toki $'
10
10
 
11
11
  opts = OptionParser.new
12
12
  opts.banner = "Usage: #{opts.program_name} [options] INDEX_PATH"
data/bin/higgs_dump_jlog CHANGED
@@ -6,7 +6,7 @@ require 'pp'
6
6
  require 'yaml'
7
7
 
8
8
  # for ident(1)
9
- CVS_ID = '$Id: higgs_dump_jlog 677 2007-11-08 16:22:02Z toki $'
9
+ CVS_ID = '$Id: higgs_dump_jlog 781 2008-07-28 15:13:27Z toki $'
10
10
 
11
11
  opts = OptionParser.new
12
12
  opts.banner = "Usage: #{opts.program_name} [options] [JOURNAL_LOG_PATHs]"
data/bin/higgs_ping CHANGED
@@ -4,7 +4,7 @@ require 'drb'
4
4
  require 'optparse'
5
5
 
6
6
  # for ident(1)
7
- CVS_ID = '$Id: higgs_ping 679 2007-11-11 01:41:18Z toki $'
7
+ CVS_ID = '$Id: higgs_ping 781 2008-07-28 15:13:27Z toki $'
8
8
 
9
9
  opt_verbose = 0
10
10
 
data/bin/higgs_verify CHANGED
@@ -4,7 +4,7 @@ require 'higgs/storage'
4
4
  require 'optparse'
5
5
 
6
6
  # for ident(1)
7
- CVS_ID = '$Id: higgs_verify 463 2007-07-15 09:52:12Z toki $'
7
+ CVS_ID = '$Id: higgs_verify 781 2008-07-28 15:13:27Z toki $'
8
8
 
9
9
  opts = OptionParser.new
10
10
  opts.banner = "Usage: #{opts.program_name} [options] HIGGS_NAME"
@@ -1,8 +1,8 @@
1
1
  # like cgi/session/pstore.rb
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: 2008-07-29 00:13:27 +0900 (Tue, 29 Jul 2008) $
5
+ # Revision:: $Revision: 781 $
6
6
  #
7
7
 
8
8
  require 'cgi/session'
@@ -15,7 +15,7 @@ class CGI
15
15
  # like cgi/session/pstore.rb
16
16
  class HiggsStore
17
17
  # for ident(1)
18
- CVS_ID = '$Id: higgs.rb 559 2007-09-25 15:20:20Z toki $'
18
+ CVS_ID = '$Id: higgs.rb 781 2008-07-28 15:13:27Z toki $'
19
19
 
20
20
  def initialize(session, options={})
21
21
  dir = options['tmpdir'] || Dir.tmpdir
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-10-24 01:04:47 +0900 (Wed, 24 Oct 2007) $
5
- # Revision:: $Revision: 654 $
4
+ # Date:: $Date: 2008-07-29 00:13:27 +0900 (Tue, 29 Jul 2008) $
5
+ # Revision:: $Revision: 781 $
6
6
  #
7
7
  # == license
8
8
  # :include:LICENSE
@@ -28,7 +28,7 @@ module Higgs
28
28
  #
29
29
  module Block
30
30
  # for ident(1)
31
- CVS_ID = '$Id: block.rb 654 2007-10-23 16:04:47Z toki $'
31
+ CVS_ID = '$Id: block.rb 781 2008-07-28 15:13:27Z toki $'
32
32
 
33
33
  include Exceptions
34
34
 
data/lib/higgs/cache.rb CHANGED
@@ -1,8 +1,8 @@
1
1
  # = cache utilities
2
2
  #
3
3
  # Author:: $Author: toki $
4
- # Date:: $Date: 2008-01-14 00:55:53 +0900 (Mon, 14 Jan 2008) $
5
- # Revision:: $Revision: 742 $
4
+ # Date:: $Date: 2008-07-29 00:13:27 +0900 (Tue, 29 Jul 2008) $
5
+ # Revision:: $Revision: 781 $
6
6
  #
7
7
  # == license
8
8
  # :include:LICENSE
@@ -16,7 +16,7 @@ module Higgs
16
16
  # = cache by Least Recently Used strategy
17
17
  class LRUCache
18
18
  # for ident(1)
19
- CVS_ID = '$Id: cache.rb 742 2008-01-13 15:55:53Z toki $'
19
+ CVS_ID = '$Id: cache.rb 781 2008-07-28 15:13:27Z toki $'
20
20
 
21
21
  extend Forwardable
22
22
 
@@ -73,7 +73,7 @@ module Higgs
73
73
  # = multi-thread safe cache
74
74
  class SharedWorkCache
75
75
  # for ident(1)
76
- CVS_ID = '$Id: cache.rb 742 2008-01-13 15:55:53Z toki $'
76
+ CVS_ID = '$Id: cache.rb 781 2008-07-28 15:13:27Z toki $'
77
77
 
78
78
  def initialize(cache={}, &work)
79
79
  unless (work) then
@@ -123,7 +123,10 @@ module Higgs
123
123
  def_delegator :@snapshots, :empty?
124
124
 
125
125
  def write_old_values(cnum, write_list)
126
- @lock.synchronize{
126
+ # new snapshot is not created until the update ends.
127
+ snapshot_list = @lock.synchronize{ @snapshots.values }
128
+
129
+ for snapshot in snapshot_list
127
130
  @snapshots.each_value do |snapshot|
128
131
  lock = snapshot[:lock].write_lock
129
132
  cache = snapshot[:cache]
@@ -148,15 +151,17 @@ module Higgs
148
151
  end
149
152
  }
150
153
  end
151
- }
154
+ end
155
+
152
156
  nil
153
157
  end
154
158
 
155
- def ref_count_up(cnum)
159
+ def ref_count_up(cnum_func)
156
160
  @lock.synchronize{
161
+ cnum = cnum_func.call
157
162
  @snapshots[cnum] = { :lock => ReadWriteLock.new, :cache => {}, :ref_count => 0 } unless (@snapshots.key? cnum)
158
163
  @snapshots[cnum][:ref_count] += 1
159
- return @snapshots[cnum][:lock].read_lock, @snapshots[cnum][:cache]
164
+ return cnum, @snapshots[cnum][:lock].read_lock, @snapshots[cnum][:cache]
160
165
  }
161
166
  end
162
167
 
@@ -173,9 +178,8 @@ module Higgs
173
178
  @parent = parent
174
179
  end
175
180
 
176
- def ref_count_up(cnum)
177
- @cnum = cnum
178
- @lock, @cache = @parent.ref_count_up(@cnum)
181
+ def ref_count_up(cnum_func)
182
+ @cnum, @lock, @cache = @parent.ref_count_up(cnum_func)
179
183
  nil
180
184
  end
181
185
 
@@ -254,10 +258,10 @@ module Higgs
254
258
  end
255
259
  end
256
260
 
257
- def transaction(cnum)
261
+ def transaction(cnum_func)
258
262
  r = nil
259
263
  snapshot = Snapshot.new(self)
260
- snapshot.ref_count_up(cnum)
264
+ snapshot.ref_count_up(cnum_func)
261
265
  begin
262
266
  r = yield(snapshot)
263
267
  ensure
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-10-24 00:46:00 +0900 (Wed, 24 Oct 2007) $
5
- # Revision:: $Revision: 653 $
4
+ # Date:: $Date: 2008-07-29 00:13:27 +0900 (Tue, 29 Jul 2008) $
5
+ # Revision:: $Revision: 781 $
6
6
  #
7
7
  # == license
8
8
  # :include:LICENSE
@@ -54,7 +54,7 @@ module Higgs
54
54
  #
55
55
  class DBM < StorageManager
56
56
  # for ident(1)
57
- CVS_ID = '$Id: dbm.rb 653 2007-10-23 15:46:00Z toki $'
57
+ CVS_ID = '$Id: dbm.rb 781 2008-07-28 15:13:27Z toki $'
58
58
 
59
59
  DECODE = proc{|r| r }
60
60
  ENCODE = proc{|w| w }
@@ -1,8 +1,8 @@
1
1
  # = exceptions
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: 2008-07-29 00:13:27 +0900 (Tue, 29 Jul 2008) $
5
+ # Revision:: $Revision: 781 $
6
6
  #
7
7
  # == license
8
8
  # :include:LICENSE
@@ -11,7 +11,7 @@
11
11
  module Higgs
12
12
  module Exceptions
13
13
  # for ident(1)
14
- CVS_ID = '$Id: exceptions.rb 559 2007-09-25 15:20:20Z toki $'
14
+ CVS_ID = '$Id: exceptions.rb 781 2008-07-28 15:13:27Z toki $'
15
15
 
16
16
  class HiggsError < StandardError
17
17
  end
data/lib/higgs/flock.rb CHANGED
@@ -1,8 +1,8 @@
1
1
  # = file lock
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: 2008-07-29 00:13:27 +0900 (Tue, 29 Jul 2008) $
5
+ # Revision:: $Revision: 781 $
6
6
  #
7
7
  # == license
8
8
  # :include:LICENSE
@@ -11,7 +11,7 @@
11
11
  module Higgs
12
12
  class FileLock
13
13
  # for ident(1)
14
- CVS_ID = '$Id: flock.rb 626 2007-10-09 15:49:33Z toki $'
14
+ CVS_ID = '$Id: flock.rb 781 2008-07-28 15:13:27Z toki $'
15
15
 
16
16
  def initialize(path, read_only=false)
17
17
  @path = path
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-10-21 22:40:57 +0900 (Sun, 21 Oct 2007) $
5
- # Revision:: $Revision: 649 $
4
+ # Date:: $Date: 2008-07-29 00:13:27 +0900 (Tue, 29 Jul 2008) $
5
+ # Revision:: $Revision: 781 $
6
6
  #
7
7
  # == license
8
8
  # :include:LICENSE
@@ -10,15 +10,18 @@
10
10
 
11
11
  require 'forwardable'
12
12
  require 'higgs/block'
13
+ require 'higgs/thread'
14
+ require 'thread'
13
15
 
14
16
  module Higgs
15
17
  # = storage index
16
18
  class Index
17
19
  # for ident(1)
18
- CVS_ID = '$Id: index.rb 649 2007-10-21 13:40:57Z toki $'
20
+ CVS_ID = '$Id: index.rb 781 2008-07-28 15:13:27Z toki $'
19
21
 
20
22
  extend Forwardable
21
23
  include Block
24
+ include Synchronized
22
25
 
23
26
  MAGIC_SYMBOL = 'HIGGS_INDEX'
24
27
  MAJOR_VERSION = 0
@@ -31,41 +34,48 @@ module Higgs
31
34
  @index = {}
32
35
  @identities = {}
33
36
  @storage_id = nil
37
+ self.__lock__ = Mutex.new
34
38
  end
35
39
 
36
- attr_reader :change_number
37
- attr_accessor :eoa
38
- attr_accessor :storage_id
40
+ synchronized attr_reader(:change_number)
41
+ synchronized attr_accessor(:eoa)
42
+ synchronized attr_accessor(:storage_id)
39
43
 
40
44
  def succ!
41
45
  @change_number = @change_number.succ
42
46
  self
43
47
  end
48
+ synchronized :succ!
44
49
 
45
50
  def free_fetch(size)
46
51
  @free_lists[size].shift if (@free_lists.key? size)
47
52
  end
53
+ synchronized :free_fetch
48
54
 
49
55
  def free_fetch_at(pos, size)
50
56
  @free_lists[size].delete(pos) or raise "not found free region: (#{pos},#{size})"
51
57
  end
58
+ synchronized :free_fetch_at
52
59
 
53
60
  def free_store(pos, size)
54
61
  @free_lists[size] = [] unless (@free_lists.key? size)
55
62
  @free_lists[size] << pos
56
63
  nil
57
64
  end
65
+ synchronized :free_store
58
66
 
59
- def_delegator :@index, :key?
60
- def_delegator :@index, :keys
67
+ synchronized def_delegator(:@index, :key?)
68
+ synchronized def_delegator(:@index, :keys)
61
69
 
62
70
  def identity(key)
63
71
  i = @index[key] and i[0]
64
72
  end
73
+ synchronized :identity
65
74
 
66
75
  def [](key)
67
76
  i = @index[key] and i[1]
68
77
  end
78
+ synchronized :[]
69
79
 
70
80
  def self.create_id(key, identities)
71
81
  id = key.to_s
@@ -86,15 +96,18 @@ module Higgs
86
96
  end
87
97
  value
88
98
  end
99
+ synchronized :[]=
89
100
 
90
101
  def delete(key)
91
102
  id, value = @index.delete(key)
92
103
  @identities.delete(id) if id
93
104
  value
94
105
  end
106
+ synchronized :delete
95
107
 
96
108
  def each_key
97
- @index.each_key do |key|
109
+ keys = __lock__.synchronize{ @index.keys }
110
+ for key in keys
98
111
  yield(key)
99
112
  end
100
113
  self
@@ -110,6 +123,7 @@ module Higgs
110
123
  :storage_id => @storage_id
111
124
  }
112
125
  end
126
+ synchronized :to_h
113
127
 
114
128
  def migration_0_0_to_0_1(index_data)
115
129
  if ((index_data[:version] <=> [ 0, 0 ]) > 0) then
@@ -152,8 +166,10 @@ module Higgs
152
166
  tmp_path = "#{path}.tmp.#{$$}"
153
167
  File.open(tmp_path, File::WRONLY | File::CREAT | File::TRUNC, 0660) {|f|
154
168
  f.binmode
155
- index_data = self.to_h
156
- block_write(f, MAGIC_SYMBOL, Marshal.dump(index_data))
169
+ block_write(f, MAGIC_SYMBOL,
170
+ __lock__.synchronize{
171
+ Marshal.dump(thread_unsafe_to_h)
172
+ })
157
173
  f.fsync
158
174
  }
159
175
  File.rename(tmp_path, path)
@@ -169,12 +185,14 @@ module Higgs
169
185
  if (index_data[:version] != [ MAJOR_VERSION, MINOR_VERSION ]) then
170
186
  raise "unsupported version: #{index_data[:version].join('.')}"
171
187
  end
172
- @change_number = index_data[:change_number]
173
- @eoa = index_data[:eoa]
174
- @free_lists = index_data[:free_lists]
175
- @index = index_data[:index]
176
- @identities = index_data[:identities]
177
- @storage_id = index_data[:storage_id]
188
+ __lock__.synchronize{
189
+ @change_number = index_data[:change_number]
190
+ @eoa = index_data[:eoa]
191
+ @free_lists = index_data[:free_lists]
192
+ @index = index_data[:index]
193
+ @identities = index_data[:identities]
194
+ @storage_id = index_data[:storage_id]
195
+ }
178
196
  }
179
197
  self
180
198
  end
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-10-28 23:35:37 +0900 (Sun, 28 Oct 2007) $
5
- # Revision:: $Revision: 657 $
4
+ # Date:: $Date: 2008-07-29 00:13:27 +0900 (Tue, 29 Jul 2008) $
5
+ # Revision:: $Revision: 781 $
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 657 2007-10-28 14:35:37Z toki $'
17
+ CVS_ID = '$Id: jlog.rb 781 2008-07-28 15:13:27Z toki $'
18
18
 
19
19
  include Block
20
20
 
data/lib/higgs/lock.rb CHANGED
@@ -1,8 +1,8 @@
1
1
  # = multi-thread lock manager
2
2
  #
3
3
  # Author:: $Author: toki $
4
- # Date:: $Date: 2008-01-14 00:55:53 +0900 (Mon, 14 Jan 2008) $
5
- # Revision:: $Revision: 742 $
4
+ # Date:: $Date: 2008-07-29 00:13:27 +0900 (Tue, 29 Jul 2008) $
5
+ # Revision:: $Revision: 781 $
6
6
  #
7
7
  # == license
8
8
  # :include:LICENSE
@@ -17,7 +17,7 @@ module Higgs
17
17
  # = multi-thread lock manager
18
18
  class LockManager
19
19
  # for ident(1)
20
- CVS_ID = '$Id: lock.rb 742 2008-01-13 15:55:53Z toki $'
20
+ CVS_ID = '$Id: lock.rb 781 2008-07-28 15:13:27Z toki $'
21
21
 
22
22
  include Exceptions
23
23
 
@@ -102,7 +102,7 @@ module Higgs
102
102
 
103
103
  class GiantLockManager < LockManager
104
104
  # for ident(1)
105
- CVS_ID = '$Id: lock.rb 742 2008-01-13 15:55:53Z toki $'
105
+ CVS_ID = '$Id: lock.rb 781 2008-07-28 15:13:27Z toki $'
106
106
 
107
107
  def initialize(*args)
108
108
  super
@@ -126,7 +126,7 @@ module Higgs
126
126
 
127
127
  class OptimisticLockManager < LockManager
128
128
  # for ident(1)
129
- CVS_ID = '$Id: lock.rb 742 2008-01-13 15:55:53Z toki $'
129
+ CVS_ID = '$Id: lock.rb 781 2008-07-28 15:13:27Z toki $'
130
130
 
131
131
  def initialize(*args)
132
132
  super
@@ -1,8 +1,8 @@
1
1
  # = remote services
2
2
  #
3
3
  # Author:: $Author $
4
- # Date:: $Date: 2007-11-09 01:09:51 +0900 (Fri, 09 Nov 2007) $
5
- # Revision:: $Revision: 676 $
4
+ # Date:: $Date: 2008-07-29 00:13:27 +0900 (Tue, 29 Jul 2008) $
5
+ # Revision:: $Revision: 781 $
6
6
  #
7
7
  # == license
8
8
  # :include:LICENSE
@@ -14,7 +14,7 @@ module Higgs
14
14
  # = remote services
15
15
  class RemoteServices
16
16
  # for ident(1)
17
- CVS_ID = '$Id: services.rb 676 2007-11-08 16:09:51Z toki $'
17
+ CVS_ID = '$Id: services.rb 781 2008-07-28 15:13:27Z toki $'
18
18
 
19
19
  # theses options are defined.
20
20
  # [<tt>:remote_services_uri</tt>] URI for DRb remote call to provide services.
data/lib/higgs/sman.rb CHANGED
@@ -1,8 +1,8 @@
1
1
  # = storage manager
2
2
  #
3
3
  # Author:: $Author: toki $
4
- # Date:: $Date: 2007-11-05 00:06:41 +0900 (Mon, 05 Nov 2007) $
5
- # Revision:: $Revision: 665 $
4
+ # Date:: $Date: 2008-07-29 00:13:27 +0900 (Tue, 29 Jul 2008) $
5
+ # Revision:: $Revision: 781 $
6
6
  #
7
7
  # == license
8
8
  # :include:LICENSE
@@ -29,6 +29,8 @@ module Higgs
29
29
  # * Higgs::Storage#jlog_rotate_size
30
30
  # * Higgs::Storage#jlog_rotate_max
31
31
  # * Higgs::Storage#shutdown?
32
+ # * Higgs::Storage#alive?
33
+ # * Higgs::Storage#change_number
32
34
  # * Higgs::Storage#rotate_journal_log
33
35
  #
34
36
  # these methods are delegated to Higgs::TransactionManager.
@@ -42,7 +44,7 @@ module Higgs
42
44
  #
43
45
  class StorageManager
44
46
  # for ident(1)
45
- CVS_ID = '$Id: sman.rb 665 2007-11-04 15:06:41Z toki $'
47
+ CVS_ID = '$Id: sman.rb 781 2008-07-28 15:13:27Z toki $'
46
48
 
47
49
  extend Forwardable
48
50
 
@@ -67,6 +69,8 @@ module Higgs
67
69
  def_delegator :@storage, :jlog_rotate_size
68
70
  def_delegator :@storage, :jlog_rotate_max
69
71
  def_delegator :@storage, :shutdown?
72
+ def_delegator :@storage, :alive?
73
+ def_delegator :@storage, :change_number
70
74
  def_delegator :@storage, :rotate_journal_log
71
75
  def_delegator :@tman, :read_only
72
76
  def_delegator :@tman, :transaction
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: 2008-01-14 00:55:53 +0900 (Mon, 14 Jan 2008) $
5
- # Revision:: $Revision: 742 $
4
+ # Date:: $Date: 2008-07-29 00:13:27 +0900 (Tue, 29 Jul 2008) $
5
+ # Revision:: $Revision: 781 $
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 742 2008-01-13 15:55:53Z toki $'
26
+ CVS_ID = '$Id: storage.rb 781 2008-07-28 15:13:27Z toki $'
27
27
 
28
28
  include Exceptions
29
29
 
@@ -624,7 +624,9 @@ module Higgs
624
624
  :val => value
625
625
  }
626
626
  if (i = @index[key]) then
627
+ i = i.dup
627
628
  if (j = i[type]) then
629
+ j = j.dup; i[type] = j
628
630
  commit_log << {
629
631
  :ope => :free_store,
630
632
  :pos => j[:pos],
@@ -638,6 +640,7 @@ module Higgs
638
640
  else
639
641
  i[type] = { :pos => pos, :siz => blocked_size, :cnum => @index.change_number }
640
642
  end
643
+ @index[key] = i
641
644
  else
642
645
  @index[key] = { type => { :pos => pos, :siz => blocked_size, :cnum => @index.change_number } }
643
646
  end
@@ -648,6 +651,7 @@ module Higgs
648
651
  if (i = @index[key]) then
649
652
  if (j = i[type]) then
650
653
  if (j[:siz] >= blocked_size) then
654
+ i = i.dup; j = j.dup; i[type] = j
651
655
  @logger.debug("write type of overwrite: (pos,size)=(#{j[:pos]},#{blocked_size})") if @logger.debug?
652
656
  commit_log << {
653
657
  :ope => :write,
@@ -670,6 +674,7 @@ module Higgs
670
674
  @index.free_store(commit_log.last[:pos], commit_log.last[:siz])
671
675
  j[:siz] = blocked_size
672
676
  end
677
+ @index[key] = i
673
678
  next
674
679
  end
675
680
  end
@@ -687,7 +692,9 @@ module Higgs
687
692
  :val => value
688
693
  }
689
694
  if (i = @index[key]) then
695
+ i = i.dup
690
696
  if (j = i[type]) then
697
+ j = j.dup; i[type] = j
691
698
  commit_log << {
692
699
  :ope => :free_store,
693
700
  :pos => j[:pos],
@@ -701,6 +708,7 @@ module Higgs
701
708
  else
702
709
  i[type] = { :pos => eoa, :siz => blocked_size, :cnum => @index.change_number }
703
710
  end
711
+ @index[key] = i
704
712
  else
705
713
  @index[key] = { type => { :pos => eoa, :siz => blocked_size, :cnum => @index.change_number } }
706
714
  end
@@ -804,13 +812,16 @@ module Higgs
804
812
  w_tar.add(cmd[:nam], cmd[:val], :mtime => cmd[:mod])
805
813
  blocked_size = Tar::Block::BLKSIZ + Tar::Block.blocked_size(cmd[:val].length)
806
814
  if (i = index[cmd[:key]]) then
815
+ i = i.dup
807
816
  if (j = i[cmd[:typ]]) then
817
+ j = j.dup; i[cmd[:typ]] = j
808
818
  j[:pos] = cmd[:pos]
809
819
  j[:siz] = blocked_size
810
820
  j[:cnum] = index.change_number
811
821
  else
812
822
  i[cmd[:typ]] = { :pos => cmd[:pos], :siz => blocked_size, :cnum => index.change_number }
813
823
  end
824
+ index[cmd[:key]] = i
814
825
  else
815
826
  index[cmd[:key]] = { cmd[:typ] => { :pos => cmd[:pos], :siz => blocked_size, :cnum => index.change_number } }
816
827
  end