ls4 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- data/AUTHORS +1 -0
- data/COPYING +661 -0
- data/ChangeLog +9 -0
- data/NOTICE +8 -0
- data/README.rdoc +61 -0
- data/bin/ls4-cs +3 -0
- data/bin/ls4-ds +3 -0
- data/bin/ls4-gw +3 -0
- data/bin/ls4-standalone +3 -0
- data/bin/ls4cmd +3 -0
- data/bin/ls4ctl +3 -0
- data/bin/ls4rpc +3 -0
- data/bin/ls4stat +3 -0
- data/bin/ls4top +3 -0
- data/lib/ls4/command/cmd.rb +241 -0
- data/lib/ls4/command/cs.rb +190 -0
- data/lib/ls4/command/ctl.rb +278 -0
- data/lib/ls4/command/ds.rb +335 -0
- data/lib/ls4/command/gw.rb +256 -0
- data/lib/ls4/command/rpc.rb +172 -0
- data/lib/ls4/command/standalone.rb +318 -0
- data/lib/ls4/command/stat.rb +244 -0
- data/lib/ls4/command/top.rb +291 -0
- data/lib/ls4/default.rb +26 -0
- data/lib/ls4/lib/cclog.rb +220 -0
- data/lib/ls4/lib/ebus.rb +553 -0
- data/lib/ls4/lib/vbcode.rb +228 -0
- data/lib/ls4/logic/fault_detector.rb +212 -0
- data/lib/ls4/logic/membership.rb +253 -0
- data/lib/ls4/logic/node.rb +66 -0
- data/lib/ls4/logic/okey.rb +45 -0
- data/lib/ls4/logic/tsv_data.rb +81 -0
- data/lib/ls4/logic/weight.rb +166 -0
- data/lib/ls4/service/balance.rb +62 -0
- data/lib/ls4/service/base.rb +29 -0
- data/lib/ls4/service/bus.rb +37 -0
- data/lib/ls4/service/config.rb +63 -0
- data/lib/ls4/service/config_cs.rb +33 -0
- data/lib/ls4/service/config_ds.rb +56 -0
- data/lib/ls4/service/config_gw.rb +42 -0
- data/lib/ls4/service/data_client.rb +122 -0
- data/lib/ls4/service/data_server.rb +168 -0
- data/lib/ls4/service/data_server_url.rb +83 -0
- data/lib/ls4/service/gateway.rb +375 -0
- data/lib/ls4/service/gateway_ro.rb +91 -0
- data/lib/ls4/service/gw_http.rb +821 -0
- data/lib/ls4/service/heartbeat.rb +182 -0
- data/lib/ls4/service/log.rb +81 -0
- data/lib/ls4/service/master_select.rb +148 -0
- data/lib/ls4/service/mds.rb +292 -0
- data/lib/ls4/service/mds_cache.rb +294 -0
- data/lib/ls4/service/mds_cache_mem.rb +63 -0
- data/lib/ls4/service/mds_cache_memcached.rb +65 -0
- data/lib/ls4/service/mds_ha.rb +176 -0
- data/lib/ls4/service/mds_memcache.rb +209 -0
- data/lib/ls4/service/mds_tc.rb +508 -0
- data/lib/ls4/service/mds_tt.rb +472 -0
- data/lib/ls4/service/membership.rb +331 -0
- data/lib/ls4/service/process.rb +90 -0
- data/lib/ls4/service/rpc.rb +50 -0
- data/lib/ls4/service/rpc_cs.rb +101 -0
- data/lib/ls4/service/rpc_ds.rb +96 -0
- data/lib/ls4/service/rpc_gw.rb +255 -0
- data/lib/ls4/service/rts.rb +94 -0
- data/lib/ls4/service/rts_file.rb +76 -0
- data/lib/ls4/service/rts_memory.rb +55 -0
- data/lib/ls4/service/slave.rb +132 -0
- data/lib/ls4/service/stat.rb +91 -0
- data/lib/ls4/service/stat_cs.rb +25 -0
- data/lib/ls4/service/stat_ds.rb +40 -0
- data/lib/ls4/service/stat_gw.rb +25 -0
- data/lib/ls4/service/storage.rb +116 -0
- data/lib/ls4/service/storage_dir.rb +201 -0
- data/lib/ls4/service/sync.rb +206 -0
- data/lib/ls4/service/time_check.rb +80 -0
- data/lib/ls4/service/ulog.rb +159 -0
- data/lib/ls4/service/ulog_file.rb +398 -0
- data/lib/ls4/service/ulog_memory.rb +53 -0
- data/lib/ls4/service/weight.rb +134 -0
- data/lib/ls4/version.rb +5 -0
- data/test/01_add_get_remove.rt +84 -0
- data/test/02_read.rt +61 -0
- data/test/03_getd_readd.rt +69 -0
- data/test/04_version_time.rt +170 -0
- data/test/05_version_name.rt +161 -0
- data/test/06_http_get_set_remove_1.rt +119 -0
- data/test/07_http_get_set_remove_2.rt +116 -0
- data/test/08_read_only_time.rt +177 -0
- data/test/09_read_only_name.rt +173 -0
- data/test/10_http_get_set_remove_3.rt +73 -0
- data/test/11_mds_cache_memcached.rt +88 -0
- data/test/12_mds_cache_local_memory.rt +86 -0
- data/test/13_memcache_mds.rt +84 -0
- data/test/14_delete.rt +63 -0
- data/test/15_standalone.rt +71 -0
- data/test/chukan.rb +516 -0
- data/test/common.rb +250 -0
- data/test/load_test.rb +79 -0
- data/test/load_test_offload.rb +86 -0
- metadata +295 -0
@@ -0,0 +1,37 @@
|
|
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 Bus < EventBus::Bus
|
22
|
+
def self.ebus_call_log(method, args, &block)
|
23
|
+
$log.trace { "ebus call #{method}" }
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.ebus_signal_log(methods, args, &block)
|
27
|
+
$log.trace { "ebus signal #{methods.join(', ')}" }
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.ebus_signal_error(err)
|
31
|
+
$log.warn err
|
32
|
+
$log.debug_backtrace err.backtrace
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
end
|
@@ -0,0 +1,63 @@
|
|
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 ConfigBus < Bus
|
22
|
+
call_slot :self_nid
|
23
|
+
call_slot :self_name
|
24
|
+
call_slot :self_address
|
25
|
+
call_slot :self_rsids
|
26
|
+
call_slot :self_location
|
27
|
+
call_slot :self_node
|
28
|
+
call_slot :get_storage_path
|
29
|
+
call_slot :get_ulog_path
|
30
|
+
call_slot :get_rts_path
|
31
|
+
call_slot :get_fault_path
|
32
|
+
call_slot :get_membership_path
|
33
|
+
call_slot :get_weight_path
|
34
|
+
call_slot :get_log_path
|
35
|
+
|
36
|
+
call_slot :get_initial_mds_uri
|
37
|
+
call_slot :get_initial_mds_cache_uri
|
38
|
+
|
39
|
+
call_slot :http_redirect_port
|
40
|
+
call_slot :http_redirect_path_format
|
41
|
+
|
42
|
+
call_slot :get_cs_address
|
43
|
+
call_slot :read_only_version
|
44
|
+
call_slot :http_gateway_address
|
45
|
+
call_slot :http_gateway_error_template_file
|
46
|
+
end
|
47
|
+
|
48
|
+
|
49
|
+
class ConfigService < Service
|
50
|
+
attr_accessor :fault_path
|
51
|
+
attr_accessor :membership_path
|
52
|
+
attr_accessor :weight_path
|
53
|
+
attr_accessor :log_path
|
54
|
+
|
55
|
+
ebus_connect :ConfigBus,
|
56
|
+
:get_fault_path => :fault_path,
|
57
|
+
:get_membership_path => :membership_path,
|
58
|
+
:get_weight_path => :weight_path,
|
59
|
+
:get_log_path => :log_path
|
60
|
+
end
|
61
|
+
|
62
|
+
|
63
|
+
end
|
@@ -0,0 +1,33 @@
|
|
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 CSConfigService < ConfigService
|
22
|
+
#attr_accessor :self_address
|
23
|
+
|
24
|
+
attr_accessor :mds_uri
|
25
|
+
attr_accessor :mds_cache_uri
|
26
|
+
|
27
|
+
ebus_connect :ConfigBus,
|
28
|
+
:get_initial_mds_uri => :mds_uri,
|
29
|
+
:get_initial_mds_cache_uri => :mds_cache_uri
|
30
|
+
end
|
31
|
+
|
32
|
+
|
33
|
+
end
|
@@ -0,0 +1,56 @@
|
|
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 DSConfigService < GWConfigService
|
22
|
+
def run
|
23
|
+
@self_node = Node.new(@self_nid, @self_address, @self_name, @self_rsids, @self_location)
|
24
|
+
end
|
25
|
+
|
26
|
+
attr_accessor :self_nid
|
27
|
+
attr_accessor :self_name
|
28
|
+
attr_accessor :self_address
|
29
|
+
attr_accessor :self_rsids
|
30
|
+
attr_accessor :storage_path
|
31
|
+
attr_accessor :ulog_path
|
32
|
+
attr_accessor :rts_path
|
33
|
+
|
34
|
+
attr_accessor :http_redirect_port
|
35
|
+
attr_accessor :http_redirect_path_format
|
36
|
+
|
37
|
+
attr_reader :self_node
|
38
|
+
|
39
|
+
ebus_connect :ConfigBus,
|
40
|
+
:self_nid,
|
41
|
+
:self_name,
|
42
|
+
:self_address,
|
43
|
+
:self_rsids,
|
44
|
+
:self_node,
|
45
|
+
:http_redirect_port,
|
46
|
+
:http_redirect_path_format,
|
47
|
+
:get_storage_path => :storage_path,
|
48
|
+
:get_ulog_path => :ulog_path,
|
49
|
+
:get_rts_path => :rts_path
|
50
|
+
|
51
|
+
ebus_connect :ProcessBus,
|
52
|
+
:run
|
53
|
+
end
|
54
|
+
|
55
|
+
|
56
|
+
end
|
@@ -0,0 +1,42 @@
|
|
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 GWConfigService < ConfigService
|
22
|
+
def initialize
|
23
|
+
@self_location = ""
|
24
|
+
end
|
25
|
+
|
26
|
+
attr_accessor :self_location
|
27
|
+
attr_accessor :cs_address
|
28
|
+
|
29
|
+
attr_accessor :read_only_version
|
30
|
+
attr_accessor :http_gateway_address
|
31
|
+
attr_accessor :http_gateway_error_template_file
|
32
|
+
|
33
|
+
ebus_connect :ConfigBus,
|
34
|
+
:self_location,
|
35
|
+
:read_only_version,
|
36
|
+
:http_gateway_address,
|
37
|
+
:http_gateway_error_template_file,
|
38
|
+
:get_cs_address => :cs_address
|
39
|
+
end
|
40
|
+
|
41
|
+
|
42
|
+
end
|
@@ -0,0 +1,122 @@
|
|
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 DataClientBus < Bus
|
22
|
+
# @return
|
23
|
+
# found: raw data
|
24
|
+
# not found: nil
|
25
|
+
call_slot :get
|
26
|
+
|
27
|
+
# @return
|
28
|
+
# found: raw data
|
29
|
+
# not found: nil
|
30
|
+
call_slot :read
|
31
|
+
|
32
|
+
# @return nil
|
33
|
+
call_slot :set
|
34
|
+
|
35
|
+
# @return
|
36
|
+
# deleted: true
|
37
|
+
# not found: nil
|
38
|
+
call_slot :delete
|
39
|
+
|
40
|
+
## @return nil
|
41
|
+
#call_slot :write
|
42
|
+
|
43
|
+
# @return nil
|
44
|
+
#call_slot :resize
|
45
|
+
|
46
|
+
# @return
|
47
|
+
# found: url string
|
48
|
+
# not found: nil
|
49
|
+
call_slot :url
|
50
|
+
end
|
51
|
+
|
52
|
+
|
53
|
+
class DataClientService < Service
|
54
|
+
# TODO localhost optimization if DataServer is connected
|
55
|
+
|
56
|
+
def get(okey, found_expected=false, &cb)
|
57
|
+
call_rsid(okey, :get_direct, [okey], found_expected, &cb)
|
58
|
+
end
|
59
|
+
|
60
|
+
def read(okey, offset, size, found_expected=false, &cb)
|
61
|
+
call_rsid(okey, :read_direct, [okey, offset, size], found_expected, &cb)
|
62
|
+
end
|
63
|
+
|
64
|
+
def set(okey, data, &cb)
|
65
|
+
call_rsid(okey, :set_direct, [okey, data], &cb)
|
66
|
+
end
|
67
|
+
|
68
|
+
def delete(okey, &cb)
|
69
|
+
call_rsid(okey, :delete_direct, [okey], &cb)
|
70
|
+
end
|
71
|
+
|
72
|
+
#def write(okey, offset, data, &cb)
|
73
|
+
# call_rsid(okey, :write_direct, [okey, offset, data], &cb)
|
74
|
+
#end
|
75
|
+
|
76
|
+
#def resize(okey, size, &cb)
|
77
|
+
# call_rsid(okey, :resize_direct, [okey], size)
|
78
|
+
#end
|
79
|
+
|
80
|
+
def url(okey, found_expected, &cb)
|
81
|
+
call_rsid(okey, :url_direct, [okey], found_expected, &cb)
|
82
|
+
end
|
83
|
+
|
84
|
+
ebus_connect :DataClientBus,
|
85
|
+
:get,
|
86
|
+
:read,
|
87
|
+
:set,
|
88
|
+
:delete,
|
89
|
+
:url
|
90
|
+
|
91
|
+
private
|
92
|
+
def call_rsid(okey, method, args, not_nil_required=false, &cb)
|
93
|
+
nids = MasterSelectBus.select_master(okey.rsid, okey.key)
|
94
|
+
target_nids = nids.reject {|nid|
|
95
|
+
MembershipBus.is_fault(nid)
|
96
|
+
}
|
97
|
+
if target_nids.empty?
|
98
|
+
target_nids = nids
|
99
|
+
end
|
100
|
+
ha_call(target_nids, method, args, not_nil_required, &cb)
|
101
|
+
rescue
|
102
|
+
cb.call(nil, $!)
|
103
|
+
end
|
104
|
+
|
105
|
+
def ha_call(nids, method, args, not_nil_required=false, &cb)
|
106
|
+
nid = nids.shift
|
107
|
+
MembershipBus.get_session_nid(nid).callback(method, *args) do |f|
|
108
|
+
if f.error || (not_nil_required && f.result == nil)
|
109
|
+
if nids.empty?
|
110
|
+
cb.call(nil, f.error) rescue nil
|
111
|
+
else
|
112
|
+
ha_call(nids, method, args, not_nil_required, &cb)
|
113
|
+
end
|
114
|
+
else
|
115
|
+
cb.call(f.result, nil) rescue nil
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
|
122
|
+
end
|
@@ -0,0 +1,168 @@
|
|
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 DataServerService < Service
|
22
|
+
def initialize
|
23
|
+
@self_nid = ConfigBus.self_nid
|
24
|
+
@self_rsids = ConfigBus.self_rsids
|
25
|
+
@stat_cmd_read = 0
|
26
|
+
@stat_cmd_write = 0
|
27
|
+
@stat_cmd_delete = 0
|
28
|
+
end
|
29
|
+
|
30
|
+
def rpc_get_direct(okey)
|
31
|
+
@stat_cmd_read += 1
|
32
|
+
StorageBus.get(okey.vtime, okey.key)
|
33
|
+
end
|
34
|
+
|
35
|
+
def rpc_read_direct(okey, offset, size)
|
36
|
+
@stat_cmd_read += 1
|
37
|
+
StorageBus.read(okey.vtime, okey.key, offset, size)
|
38
|
+
end
|
39
|
+
|
40
|
+
def rpc_set_direct(okey, data)
|
41
|
+
@stat_cmd_write += 1
|
42
|
+
d = UpdateLogData.new(okey.vtime, okey.key)
|
43
|
+
UpdateLogBus.append(d.dump) do
|
44
|
+
StorageBus.set(okey.vtime, okey.key, data)
|
45
|
+
end
|
46
|
+
nil
|
47
|
+
end
|
48
|
+
|
49
|
+
#def rpc_write_direct(okey, offset, data)
|
50
|
+
# @stat_cmd_write += 1
|
51
|
+
# d = UpdateLogData.new(okey.vtime, okey.key, offset, data.size)
|
52
|
+
# UpdateLogBus.append(d.dump) do
|
53
|
+
# StorageBus.write(okey.vtime, okey.key, offset, data)
|
54
|
+
# end
|
55
|
+
# nil
|
56
|
+
#end
|
57
|
+
|
58
|
+
#def rpc_resize_direct(okey, size)
|
59
|
+
# # TODO: stat_cmd_resize?
|
60
|
+
# # FIXME size field?
|
61
|
+
# d = UpdateLogData.new(okey.vtime, okey.key, nil, size)
|
62
|
+
# UpdateLogBus.append(d.dump) do
|
63
|
+
# StorageBus.resize(okey.vtime, okey.key, size)
|
64
|
+
# end
|
65
|
+
# nil
|
66
|
+
#end
|
67
|
+
|
68
|
+
def rpc_exist_direct(okey)
|
69
|
+
StorageBus.exist(okey.vtime, okey.key)
|
70
|
+
end
|
71
|
+
|
72
|
+
def rpc_delete_direct(okey)
|
73
|
+
@stat_cmd_delete += 1
|
74
|
+
d = UpdateLogData.new(okey.vtime, okey.key)
|
75
|
+
deleted = nil
|
76
|
+
UpdateLogBus.append(d.dump) do
|
77
|
+
deleted = StorageBus.delete(okey.vtime, okey.key)
|
78
|
+
end
|
79
|
+
deleted
|
80
|
+
end
|
81
|
+
|
82
|
+
def rpc_replicate_pull(pos, limit)
|
83
|
+
mkeys = []
|
84
|
+
msgs = []
|
85
|
+
msize = 0
|
86
|
+
while true
|
87
|
+
raw, npos = UpdateLogBus.get(pos)
|
88
|
+
unless raw
|
89
|
+
break
|
90
|
+
end
|
91
|
+
d = UpdateLogData.load(raw)
|
92
|
+
# set or delete
|
93
|
+
if mkeys.include?(d.key)
|
94
|
+
pos = npos
|
95
|
+
else
|
96
|
+
if d.offset && d.size
|
97
|
+
data = StorageBus.read(d.vtime, d.key, d.offset, d.size)
|
98
|
+
else
|
99
|
+
data = StorageBus.get(d.vtime, d.key)
|
100
|
+
mkeys << d.key
|
101
|
+
end
|
102
|
+
# data may be null => deleted
|
103
|
+
if data
|
104
|
+
msgs << [d.vtime, d.key, d.offset, data]
|
105
|
+
msize += data.size
|
106
|
+
else
|
107
|
+
# data is deleted
|
108
|
+
msgs << [d.vtime, d.key, 0, nil]
|
109
|
+
end
|
110
|
+
pos = npos
|
111
|
+
break if msize > limit
|
112
|
+
end
|
113
|
+
end
|
114
|
+
[pos, msgs]
|
115
|
+
end
|
116
|
+
|
117
|
+
def rpc_replicate_notify(nid)
|
118
|
+
session = MembershipBus.get_session_nid(nid)
|
119
|
+
SlaveBus.try_replicate(nid, session)
|
120
|
+
nil
|
121
|
+
end
|
122
|
+
|
123
|
+
def stat_db_items
|
124
|
+
StorageBus.get_items
|
125
|
+
end
|
126
|
+
|
127
|
+
def on_timer
|
128
|
+
nids = []
|
129
|
+
@self_rsids.each {|rsid|
|
130
|
+
begin
|
131
|
+
nids.concat MasterSelectBus.select_master_static(rsid)
|
132
|
+
rescue
|
133
|
+
end
|
134
|
+
}
|
135
|
+
done = [@self_nid]
|
136
|
+
nids.each {|nid|
|
137
|
+
if !done.include?(nid) && !MembershipBus.is_fault(nid)
|
138
|
+
session = MembershipBus.get_session_nid(nid)
|
139
|
+
SlaveBus.try_replicate(nid, session)
|
140
|
+
done << nid
|
141
|
+
end
|
142
|
+
}
|
143
|
+
end
|
144
|
+
|
145
|
+
attr_reader :stat_cmd_read
|
146
|
+
attr_reader :stat_cmd_write
|
147
|
+
attr_reader :stat_cmd_delete
|
148
|
+
|
149
|
+
ebus_connect :ProcessBus,
|
150
|
+
:on_timer
|
151
|
+
|
152
|
+
ebus_connect :StatBus,
|
153
|
+
:db_items => :stat_db_items,
|
154
|
+
:cmd_read => :stat_cmd_read,
|
155
|
+
:cmd_write => :stat_cmd_write,
|
156
|
+
:cmd_delete => :stat_cmd_delete
|
157
|
+
|
158
|
+
ebus_connect :DSRPCBus,
|
159
|
+
:get_direct => :rpc_get_direct,
|
160
|
+
:set_direct => :rpc_set_direct,
|
161
|
+
:read_direct => :rpc_read_direct,
|
162
|
+
:delete_direct => :rpc_delete_direct,
|
163
|
+
:replicate_pull => :rpc_replicate_pull,
|
164
|
+
:replicate_notify => :rpc_replicate_notify
|
165
|
+
end
|
166
|
+
|
167
|
+
|
168
|
+
end
|