ls4 0.9.0

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.
Files changed (100) hide show
  1. data/AUTHORS +1 -0
  2. data/COPYING +661 -0
  3. data/ChangeLog +9 -0
  4. data/NOTICE +8 -0
  5. data/README.rdoc +61 -0
  6. data/bin/ls4-cs +3 -0
  7. data/bin/ls4-ds +3 -0
  8. data/bin/ls4-gw +3 -0
  9. data/bin/ls4-standalone +3 -0
  10. data/bin/ls4cmd +3 -0
  11. data/bin/ls4ctl +3 -0
  12. data/bin/ls4rpc +3 -0
  13. data/bin/ls4stat +3 -0
  14. data/bin/ls4top +3 -0
  15. data/lib/ls4/command/cmd.rb +241 -0
  16. data/lib/ls4/command/cs.rb +190 -0
  17. data/lib/ls4/command/ctl.rb +278 -0
  18. data/lib/ls4/command/ds.rb +335 -0
  19. data/lib/ls4/command/gw.rb +256 -0
  20. data/lib/ls4/command/rpc.rb +172 -0
  21. data/lib/ls4/command/standalone.rb +318 -0
  22. data/lib/ls4/command/stat.rb +244 -0
  23. data/lib/ls4/command/top.rb +291 -0
  24. data/lib/ls4/default.rb +26 -0
  25. data/lib/ls4/lib/cclog.rb +220 -0
  26. data/lib/ls4/lib/ebus.rb +553 -0
  27. data/lib/ls4/lib/vbcode.rb +228 -0
  28. data/lib/ls4/logic/fault_detector.rb +212 -0
  29. data/lib/ls4/logic/membership.rb +253 -0
  30. data/lib/ls4/logic/node.rb +66 -0
  31. data/lib/ls4/logic/okey.rb +45 -0
  32. data/lib/ls4/logic/tsv_data.rb +81 -0
  33. data/lib/ls4/logic/weight.rb +166 -0
  34. data/lib/ls4/service/balance.rb +62 -0
  35. data/lib/ls4/service/base.rb +29 -0
  36. data/lib/ls4/service/bus.rb +37 -0
  37. data/lib/ls4/service/config.rb +63 -0
  38. data/lib/ls4/service/config_cs.rb +33 -0
  39. data/lib/ls4/service/config_ds.rb +56 -0
  40. data/lib/ls4/service/config_gw.rb +42 -0
  41. data/lib/ls4/service/data_client.rb +122 -0
  42. data/lib/ls4/service/data_server.rb +168 -0
  43. data/lib/ls4/service/data_server_url.rb +83 -0
  44. data/lib/ls4/service/gateway.rb +375 -0
  45. data/lib/ls4/service/gateway_ro.rb +91 -0
  46. data/lib/ls4/service/gw_http.rb +821 -0
  47. data/lib/ls4/service/heartbeat.rb +182 -0
  48. data/lib/ls4/service/log.rb +81 -0
  49. data/lib/ls4/service/master_select.rb +148 -0
  50. data/lib/ls4/service/mds.rb +292 -0
  51. data/lib/ls4/service/mds_cache.rb +294 -0
  52. data/lib/ls4/service/mds_cache_mem.rb +63 -0
  53. data/lib/ls4/service/mds_cache_memcached.rb +65 -0
  54. data/lib/ls4/service/mds_ha.rb +176 -0
  55. data/lib/ls4/service/mds_memcache.rb +209 -0
  56. data/lib/ls4/service/mds_tc.rb +508 -0
  57. data/lib/ls4/service/mds_tt.rb +472 -0
  58. data/lib/ls4/service/membership.rb +331 -0
  59. data/lib/ls4/service/process.rb +90 -0
  60. data/lib/ls4/service/rpc.rb +50 -0
  61. data/lib/ls4/service/rpc_cs.rb +101 -0
  62. data/lib/ls4/service/rpc_ds.rb +96 -0
  63. data/lib/ls4/service/rpc_gw.rb +255 -0
  64. data/lib/ls4/service/rts.rb +94 -0
  65. data/lib/ls4/service/rts_file.rb +76 -0
  66. data/lib/ls4/service/rts_memory.rb +55 -0
  67. data/lib/ls4/service/slave.rb +132 -0
  68. data/lib/ls4/service/stat.rb +91 -0
  69. data/lib/ls4/service/stat_cs.rb +25 -0
  70. data/lib/ls4/service/stat_ds.rb +40 -0
  71. data/lib/ls4/service/stat_gw.rb +25 -0
  72. data/lib/ls4/service/storage.rb +116 -0
  73. data/lib/ls4/service/storage_dir.rb +201 -0
  74. data/lib/ls4/service/sync.rb +206 -0
  75. data/lib/ls4/service/time_check.rb +80 -0
  76. data/lib/ls4/service/ulog.rb +159 -0
  77. data/lib/ls4/service/ulog_file.rb +398 -0
  78. data/lib/ls4/service/ulog_memory.rb +53 -0
  79. data/lib/ls4/service/weight.rb +134 -0
  80. data/lib/ls4/version.rb +5 -0
  81. data/test/01_add_get_remove.rt +84 -0
  82. data/test/02_read.rt +61 -0
  83. data/test/03_getd_readd.rt +69 -0
  84. data/test/04_version_time.rt +170 -0
  85. data/test/05_version_name.rt +161 -0
  86. data/test/06_http_get_set_remove_1.rt +119 -0
  87. data/test/07_http_get_set_remove_2.rt +116 -0
  88. data/test/08_read_only_time.rt +177 -0
  89. data/test/09_read_only_name.rt +173 -0
  90. data/test/10_http_get_set_remove_3.rt +73 -0
  91. data/test/11_mds_cache_memcached.rt +88 -0
  92. data/test/12_mds_cache_local_memory.rt +86 -0
  93. data/test/13_memcache_mds.rt +84 -0
  94. data/test/14_delete.rt +63 -0
  95. data/test/15_standalone.rt +71 -0
  96. data/test/chukan.rb +516 -0
  97. data/test/common.rb +250 -0
  98. data/test/load_test.rb +79 -0
  99. data/test/load_test_offload.rb +86 -0
  100. metadata +295 -0
@@ -0,0 +1,101 @@
1
+ #
2
+ # LS4
3
+ # Copyright (C) 2010-2011 FURUHASHI Sadayuki
4
+ #
5
+ # This program is free software: you can redistribute it and/or modify
6
+ # it under the terms of the GNU Affero General Public License as
7
+ # published by the Free Software Foundation, either version 3 of the
8
+ # License, or (at your option) any later version.
9
+ #
10
+ # This program is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU Affero General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU Affero General Public License
16
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
17
+ #
18
+ module LS4
19
+
20
+
21
+ class CSRPCBus < Bus
22
+ call_slot :heartbeat
23
+ call_slot :sync_config
24
+ call_slot :add_node
25
+ call_slot :remove_node
26
+ call_slot :update_node_info
27
+ call_slot :recover_node
28
+ call_slot :set_replset_weight
29
+ call_slot :reset_replset_weight
30
+ call_slot :get_mds_uri
31
+ call_slot :set_mds_uri
32
+ call_slot :get_mds_cache_uri
33
+ call_slot :set_mds_cache_uri
34
+ end
35
+
36
+
37
+ class CSRPCService < RPCService
38
+ #def heartbeat(nid=nil, sync_hash)
39
+ def heartbeat(nid, sync_hash)
40
+ force_binary!(sync_hash) if sync_hash
41
+ dispatch(CSRPCBus, :heartbeat, nid, sync_hash)
42
+ end
43
+
44
+ def sync_config(hash_array)
45
+ hash_array = hash_array.map {|str|
46
+ force_binary!(str) if str
47
+ }
48
+ dispatch(CSRPCBus, :sync_config, hash_array)
49
+ end
50
+
51
+ def add_node(nid, address, name, rsids, self_location)
52
+ address = Address.load(address)
53
+ dispatch(CSRPCBus, :add_node, nid, address, name, rsids, self_location)
54
+ end
55
+
56
+ def remove_node(nid)
57
+ dispatch(CSRPCBus, :remove_node, nid)
58
+ end
59
+
60
+ def update_node_info(nid, address, name, rsids)
61
+ address = Address.load(address)
62
+ dispatch(CSRPCBus, :update_node_info, nid, address, name, rsids)
63
+ end
64
+
65
+ def recover_node(nid)
66
+ dispatch(CSRPCBus, :recover_node, nid)
67
+ end
68
+
69
+ def set_replset_weight(rsid, weight)
70
+ dispatch(CSRPCBus, :set_replset_weight, rsid, weight)
71
+ end
72
+
73
+ def reset_replset_weight(rsid)
74
+ dispatch(CSRPCBus, :reset_replset_weight, rsid)
75
+ end
76
+
77
+ def get_mds_uri
78
+ dispatch(CSRPCBus, :get_mds_uri)
79
+ end
80
+
81
+ def set_mds_uri(uri)
82
+ force_binary!(uri)
83
+ dispatch(CSRPCBus, :set_mds_uri, uri)
84
+ end
85
+
86
+ def get_mds_cache_uri
87
+ dispatch(CSRPCBus, :get_mds_cache_uri)
88
+ end
89
+
90
+ def set_mds_cache_uri(uri)
91
+ force_binary!(uri)
92
+ dispatch(CSRPCBus, :set_mds_cache_uri, uri)
93
+ end
94
+
95
+ def stat(cmd)
96
+ dispatch(RPCBus, :stat, cmd)
97
+ end
98
+ end
99
+
100
+
101
+ end
@@ -0,0 +1,96 @@
1
+ #
2
+ # LS4
3
+ # Copyright (C) 2010-2011 FURUHASHI Sadayuki
4
+ #
5
+ # This program is free software: you can redistribute it and/or modify
6
+ # it under the terms of the GNU Affero General Public License as
7
+ # published by the Free Software Foundation, either version 3 of the
8
+ # License, or (at your option) any later version.
9
+ #
10
+ # This program is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU Affero General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU Affero General Public License
16
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
17
+ #
18
+ module LS4
19
+
20
+
21
+ class DSRPCBus < Bus
22
+ call_slot :get_direct
23
+ call_slot :set_direct
24
+ call_slot :delete_direct
25
+ call_slot :copy
26
+ call_slot :read_direct
27
+ call_slot :url_direct
28
+ #call_slot :write_direct
29
+ #call_slot :append_direct
30
+ call_slot :resize_direct
31
+ call_slot :replicate_pull
32
+ call_slot :replicate_notify
33
+ end
34
+
35
+
36
+ class DSRPCService < GWRPCService
37
+ def get_direct(okey)
38
+ okey = ObjectKey.new.from_msgpack(okey)
39
+ dispatch(DSRPCBus, :get_direct, okey)
40
+ end
41
+
42
+ def set_direct(okey, data)
43
+ okey = ObjectKey.new.from_msgpack(okey)
44
+ force_binary!(data)
45
+ dispatch(DSRPCBus, :set_direct, okey, data)
46
+ end
47
+
48
+ def delete_direct(okey)
49
+ okey = ObjectKey.new.from_msgpack(okey)
50
+ dispatch(DSRPCBus, :delete_direct, okey)
51
+ end
52
+
53
+ #def copy(okey, noid)
54
+ # okey = ObjectKey.new.from_msgpack(okey)
55
+ # noid = ObjectKey.new.from_msgpack(noid)
56
+ # dispatch(DSRPCBus, :copy, okey, noid)
57
+ #end
58
+
59
+ def read_direct(okey, offset, size)
60
+ okey = ObjectKey.new.from_msgpack(okey)
61
+ dispatch(DSRPCBus, :read_direct, okey, offset, size)
62
+ end
63
+
64
+ #def write_direct(okey, offset, data)
65
+ # okey = ObjectKey.new.from_msgpack(okey)
66
+ # force_binary!(data)
67
+ # dispatch(DSRPCBus, :write_direct, okey, offset, data)
68
+ #end
69
+
70
+ #def append_direct(okey, data)
71
+ # okey = ObjectKey.new.from_msgpack(okey)
72
+ # force_binary!(data)
73
+ # dispatch(DSRPCBus, :append_direct, okey, data)
74
+ #end
75
+
76
+ def url_direct(okey)
77
+ okey = ObjectKey.new.from_msgpack(okey)
78
+ dispatch(DSRPCBus, :url_direct, okey)
79
+ end
80
+
81
+ def resize_direct(okey, size)
82
+ okey = ObjectKey.new.from_msgpack(okey)
83
+ dispatch(DSRPCBus, :resize_direct, okey, size)
84
+ end
85
+
86
+ def replicate_pull(pos, limit)
87
+ dispatch(DSRPCBus, :replicate_pull, pos, limit)
88
+ end
89
+
90
+ def replicate_notify(nid)
91
+ dispatch(DSRPCBus, :replicate_notify, nid)
92
+ end
93
+ end
94
+
95
+
96
+ end
@@ -0,0 +1,255 @@
1
+ #
2
+ # LS4
3
+ # Copyright (C) 2010-2011 FURUHASHI Sadayuki
4
+ #
5
+ # This program is free software: you can redistribute it and/or modify
6
+ # it under the terms of the GNU Affero General Public License as
7
+ # published by the Free Software Foundation, either version 3 of the
8
+ # License, or (at your option) any later version.
9
+ #
10
+ # This program is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU Affero General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU Affero General Public License
16
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
17
+ #
18
+ module LS4
19
+
20
+
21
+ class GWRPCBus < Bus
22
+ call_slot :get
23
+ call_slot :get_data
24
+ call_slot :get_attrs
25
+ call_slot :read
26
+ call_slot :gett
27
+ call_slot :gett_data
28
+ call_slot :gett_attrs
29
+ call_slot :readt
30
+ call_slot :getv
31
+ call_slot :getv_data
32
+ call_slot :getv_attrs
33
+ call_slot :readv
34
+ call_slot :getd_data
35
+ call_slot :readd
36
+ call_slot :add
37
+ call_slot :add_data
38
+ call_slot :addv
39
+ call_slot :addv_data
40
+ call_slot :update_attrs
41
+ call_slot :remove
42
+ call_slot :delete
43
+ call_slot :deletet
44
+ call_slot :deletev
45
+ call_slot :url
46
+ call_slot :urlt
47
+ call_slot :urlv
48
+ call_slot :util_locate
49
+ end
50
+
51
+
52
+ class GWRPCService < RPCService
53
+ ####
54
+ ## get head
55
+ ##
56
+ def get(key)
57
+ dispatch(GWRPCBus, :get, key)
58
+ end
59
+
60
+ def get_data(key)
61
+ dispatch(GWRPCBus, :get_data, key)
62
+ end
63
+
64
+ def get_attrs(key)
65
+ dispatch(GWRPCBus, :get_attrs, key)
66
+ end
67
+
68
+ def read(key, offset, size)
69
+ dispatch(GWRPCBus, :read, key, offset, size)
70
+ end
71
+
72
+
73
+ ####
74
+ ## time-based get version
75
+ ##
76
+ def gett(vtime, key)
77
+ vtime = vtime.to_i # TODO type check
78
+ dispatch(GWRPCBus, :gett, vtime, key)
79
+ end
80
+
81
+ def gett_data(vtime, key)
82
+ vtime = vtime.to_i # TODO type check
83
+ dispatch(GWRPCBus, :gett_data, vtime, key)
84
+ end
85
+
86
+ def gett_attrs(vtime, key)
87
+ vtime = vtime.to_i # TODO type check
88
+ dispatch(GWRPCBus, :gett_attrs, vtime, key)
89
+ end
90
+
91
+ def readt(vtime, key, offset, size)
92
+ vtime = vtime.to_i # TODO type check
93
+ dispatch(GWRPCBus, :readt, vtime, key, offset, size)
94
+ end
95
+
96
+
97
+ ####
98
+ ## name-based get version
99
+ ##
100
+ def getv(vname, key)
101
+ vname = vname.to_s # TODO type check
102
+ dispatch(GWRPCBus, :getv, vname, key)
103
+ end
104
+
105
+ def getv_data(vname, key)
106
+ vname = vname.to_s # TODO type check
107
+ dispatch(GWRPCBus, :getv_data, vname, key)
108
+ end
109
+
110
+ def getv_attrs(vname, key)
111
+ vname = vname.to_s # TODO type check
112
+ dispatch(GWRPCBus, :getv_attrs, vname, key)
113
+ end
114
+
115
+ def readv(vname, key, offset, size)
116
+ vname = vname.to_s # TODO type check
117
+ dispatch(GWRPCBus, :readt, vname, key, offset, size)
118
+ end
119
+
120
+
121
+
122
+ ####
123
+ ## direct get
124
+ ##
125
+ def getd_data(okey)
126
+ okey = ObjectKey.new.from_msgpack(okey)
127
+ dispatch(GWRPCBus, :getd_data, okey)
128
+ end
129
+
130
+ def readd(okey, offset, size)
131
+ okey = ObjectKey.new.from_msgpack(okey)
132
+ dispatch(GWRPCBus, :readd, okey, offset, size)
133
+ end
134
+
135
+
136
+ ####
137
+ ## add
138
+ ##
139
+ def add(key, data, attrs)
140
+ force_binary!(data)
141
+ dispatch(GWRPCBus, :add, key, data, attrs)
142
+ end
143
+
144
+ def add_data(key, data)
145
+ force_binary!(data)
146
+ dispatch(GWRPCBus, :add_data, key, data)
147
+ end
148
+
149
+
150
+ ####
151
+ ## add with version name
152
+ ##
153
+ def addv(vname, key, data, attrs)
154
+ vname = vname.to_s # TODO type check
155
+ force_binary!(data)
156
+ dispatch(GWRPCBus, :addv, vname, key, data, attrs)
157
+ end
158
+
159
+ def addv_data(vname, key, data)
160
+ vname = vname.to_s # TODO type check
161
+ force_binary!(data)
162
+ dispatch(GWRPCBus, :addv_data, vname, key, data)
163
+ end
164
+
165
+
166
+ ####
167
+ ## in-place update data
168
+ ##
169
+ #def write(key, offset, data)
170
+ # force_binary!(data)
171
+ # dispatch(GWRPCBus, :write, key, offset, data)
172
+ #end
173
+ #
174
+ #def resize(key, size)
175
+ # dispatch(GWRPCBus, :resize, key, size)
176
+ #end
177
+ #
178
+ #def append(key, data)
179
+ # force_binary!(data)
180
+ # dispatch(GWRPCBus, :append, key, data)
181
+ #end
182
+
183
+
184
+ ####
185
+ ## in-place update attributes
186
+ ##
187
+ def update_attrs(key, attrs)
188
+ dispatch(GWRPCBus, :update_attrs, key, attrs)
189
+ end
190
+
191
+
192
+ ####
193
+ ## remove
194
+ ##
195
+ def remove(key)
196
+ dispatch(GWRPCBus, :remove, key)
197
+ end
198
+
199
+
200
+ ####
201
+ ## delete
202
+ ##
203
+ def delete(key)
204
+ dispatch(GWRPCBus, :delete, key)
205
+ end
206
+
207
+ def deletet(vtime, key)
208
+ vtime = vtime.to_i # TODO type check
209
+ dispatch(GWRPCBus, :deletet, vtime, key)
210
+ end
211
+
212
+ def deletev(vname, key)
213
+ vname = vname.to_s # TODO type check
214
+ dispatch(GWRPCBus, :deletev, vname, key)
215
+ end
216
+
217
+
218
+ #def purge(key)
219
+ # dispatch(GWRPCBus, :purge, key)
220
+ #end
221
+
222
+
223
+ ####
224
+ ## URL
225
+ ##
226
+ def url(key)
227
+ dispatch(GWRPCBus, :url, key)
228
+ end
229
+
230
+ def urlt(vtime, key)
231
+ vtime = vtime.to_i # TODO type check
232
+ dispatch(GWRPCBus, :urlt, vtime, key)
233
+ end
234
+
235
+ def urlv(vname, key)
236
+ vname = vname.to_s # TODO type check
237
+ dispatch(GWRPCBus, :urlv, vname, key)
238
+ end
239
+
240
+
241
+ ####
242
+ ## Utility
243
+ ##
244
+ def util_locate(key)
245
+ dispatch(GWRPCBus, :util_locate, key)
246
+ end
247
+
248
+
249
+ def stat(cmd)
250
+ dispatch(RPCBus, :stat, cmd)
251
+ end
252
+ end
253
+
254
+
255
+ end