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.
- 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
data/ChangeLog
ADDED
data/NOTICE
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
MessagePack-RPC for Ruby is developed by FURUHASHI Sadayuki, licensed under
|
2
|
+
Apache License, Version 2.0. The original software and related information
|
3
|
+
is available at http://msgpack.org/.
|
4
|
+
|
5
|
+
MessagePack is developed by FURUHASHI Sadayuki, licensed under Apache License,
|
6
|
+
Version 2.0. The original software and related information is available at
|
7
|
+
http://msgpack.org/.
|
8
|
+
|
data/README.rdoc
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
= LS4, a Large-Scale Simple Storage System
|
2
|
+
|
3
|
+
LS4 is a distributed storage system that can store large data like photos, music or movies.
|
4
|
+
|
5
|
+
[Scalability] Grows storage capacity and I/O throughput dynamically without any modification of applications.
|
6
|
+
[Availability] Prevents whole system falt from partial hardware crashes by failing-over within very small downtime.
|
7
|
+
[Versioning] Takes back old data by creation time or version name of the stored objects.
|
8
|
+
[Continuous snapshot] Supported based on time-based versioning.
|
9
|
+
[Geo-redundancy] Supports replication of objects across multiple datacenters.
|
10
|
+
[Direct data transfer] Reduces local network traffic and load of front-end servers by cooperating with proxy servers.
|
11
|
+
[Traffic offloading] Enhances performance of data servers by offloading traffics to native web servers.
|
12
|
+
|
13
|
+
|
14
|
+
== Data model
|
15
|
+
|
16
|
+
LS4 stores a set of objects identified by a key. Each object consists with data and attributes, and can have multiple versions.
|
17
|
+
|
18
|
+
key object
|
19
|
+
data attributes
|
20
|
+
+-----------------+---------------------------------+ ---+
|
21
|
+
"image1" => | "HTJ PNG ..." | { type:png, model:NEX-5 } |--+ | each object can
|
22
|
+
+-----------------+---------------------------------+ |--+ | have multiple
|
23
|
+
+-----------------+----------------------------------+ | | versoins
|
24
|
+
+----------------+-----------------------------------+ |
|
25
|
+
---+
|
26
|
+
+-----------------+---------------------------------+
|
27
|
+
key => | bytes ....... | { key:value, key:value, ... } |--+
|
28
|
+
+-----------------+---------------------------------+ |--+
|
29
|
+
+-----------------+----------------------------------+ |
|
30
|
+
+----------------+-----------------------------------+
|
31
|
+
|
32
|
+
... => ...
|
33
|
+
|
34
|
+
For more details, see {LS4 Documents}[http://ls4.sourceforge.net/doc/].
|
35
|
+
|
36
|
+
|
37
|
+
== Quick Start
|
38
|
+
|
39
|
+
$ gem install ls4
|
40
|
+
$ ls4-standalone -s ./data -h 18080 &
|
41
|
+
|
42
|
+
$ curl -X POST -d 'data=value1&attrs={"test":"attr"}' http://localhost:18080/data/key1
|
43
|
+
|
44
|
+
$ curl -X GET http://localhost:18080/data/key1
|
45
|
+
value1
|
46
|
+
|
47
|
+
$ curl -X GET http://localhost:18080/attrs/key1
|
48
|
+
{"test":"attr"}
|
49
|
+
|
50
|
+
|
51
|
+
|
52
|
+
Project web site:: http://ls4.sourceforge.net/
|
53
|
+
Documents:: http://ls4.sourceforge.net/doc/
|
54
|
+
Documents (Japanese):: http://ls4.sourceforge.net/doc/ja/
|
55
|
+
Source repository:: http://github.com/ls4
|
56
|
+
Author:: FURUHASHI Sadayuki
|
57
|
+
Copyright:: (c) 2010-2011 FURUHASHI Sadayuki
|
58
|
+
License:: AGPL
|
59
|
+
|
60
|
+
See also NOTICE[https://github.com/ls4/ls4/blob/master/NOTICE] file.
|
61
|
+
|
data/bin/ls4-cs
ADDED
data/bin/ls4-ds
ADDED
data/bin/ls4-gw
ADDED
data/bin/ls4-standalone
ADDED
data/bin/ls4cmd
ADDED
data/bin/ls4ctl
ADDED
data/bin/ls4rpc
ADDED
data/bin/ls4stat
ADDED
data/bin/ls4top
ADDED
@@ -0,0 +1,241 @@
|
|
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
|
+
require 'msgpack/rpc'
|
19
|
+
require 'json'
|
20
|
+
require 'pp'
|
21
|
+
|
22
|
+
def usage
|
23
|
+
puts "Usage: #{File.basename($0)} <cs address[:port]> <command> [options]"
|
24
|
+
puts "command:"
|
25
|
+
puts " get <key> get data and attributes"
|
26
|
+
puts " gett <time> <key> get data and attributes using the time"
|
27
|
+
puts " getv <vname> <key> get data and attributes using the version name"
|
28
|
+
puts " get_data <key> get data"
|
29
|
+
puts " gett_data <time> <key> get data using the time"
|
30
|
+
puts " getv_data <vname> <key> get data using the version name"
|
31
|
+
puts " get_attrs <key> get attributes"
|
32
|
+
puts " gett_attrs <time> <key> get attributes using the time"
|
33
|
+
puts " getv_attrs <vname> <key> get attributes using the version name"
|
34
|
+
puts " read <key> <offset> <size> get data with the offset and the size"
|
35
|
+
puts " readt <time> <key> <offset> <size> get data with the offset and the size using version time"
|
36
|
+
puts " readv <vname> <key> <offset> <size> get data with the offset and the size using version name"
|
37
|
+
puts " add <key> <data> <json> set data and attributes"
|
38
|
+
puts " addv <vname> <key> <data> <json> set data and attributes with version name"
|
39
|
+
puts " add_data <key> <data> set data"
|
40
|
+
puts " addv_data <vname> <key> <data> set data with version name"
|
41
|
+
puts " update_attrs <key> <json> update attributes"
|
42
|
+
puts " delete <key> delete the data and attributes"
|
43
|
+
puts " deletet <time> <key> delete the data and attributes using the time"
|
44
|
+
puts " deletev <vname> <key> delete the data and attributes using the version name"
|
45
|
+
puts " remove <key> remove the data and attributes"
|
46
|
+
exit 1
|
47
|
+
end
|
48
|
+
|
49
|
+
if ARGV.length < 2
|
50
|
+
usage
|
51
|
+
end
|
52
|
+
|
53
|
+
$net = MessagePack::RPC::SessionPool.new
|
54
|
+
addr = ARGV.shift
|
55
|
+
host, port = addr.split(':', 2)
|
56
|
+
port = port.to_i
|
57
|
+
port = 18800 if port == 0
|
58
|
+
$addr = [host,port]#Address.new(host, port)
|
59
|
+
|
60
|
+
cmd = ARGV.shift
|
61
|
+
|
62
|
+
def cmd_args(n)
|
63
|
+
if n < 0
|
64
|
+
return ARGV
|
65
|
+
end
|
66
|
+
usage if ARGV.length != n
|
67
|
+
ARGV.map! {|ar| ar == '-' ? $stdin.read : ar }
|
68
|
+
if n == 1
|
69
|
+
ARGV[0]
|
70
|
+
else
|
71
|
+
ARGV
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def call(klass, *args)
|
76
|
+
start = Time.now
|
77
|
+
|
78
|
+
s = $net.get_session(*$addr)
|
79
|
+
s.timeout = 20
|
80
|
+
result = s.call(*args)
|
81
|
+
if klass && result
|
82
|
+
result = klass.new.from_msgpack(result)
|
83
|
+
end
|
84
|
+
|
85
|
+
finish = Time.now
|
86
|
+
$stderr.puts "#{finish - start} sec."
|
87
|
+
|
88
|
+
result
|
89
|
+
end
|
90
|
+
|
91
|
+
case cmd
|
92
|
+
when 'get'
|
93
|
+
key = cmd_args(1)
|
94
|
+
data, attrs = call(nil, :get, key)
|
95
|
+
if data
|
96
|
+
puts attrs.to_json
|
97
|
+
$stdout.write data
|
98
|
+
else
|
99
|
+
$stderr.puts "nil"
|
100
|
+
end
|
101
|
+
|
102
|
+
when 'gett'
|
103
|
+
vtime, key = cmd_args(2)
|
104
|
+
data, attrs = call(nil, :gett, vtime.to_i, key)
|
105
|
+
if data
|
106
|
+
puts attrs.to_json
|
107
|
+
$stdout.write data
|
108
|
+
else
|
109
|
+
$stderr.puts "nil"
|
110
|
+
end
|
111
|
+
|
112
|
+
when 'getv'
|
113
|
+
vname, key = cmd_args(2)
|
114
|
+
data, attrs = call(nil, :getv, vname, key)
|
115
|
+
if data
|
116
|
+
puts attrs.to_json
|
117
|
+
$stdout.write data
|
118
|
+
else
|
119
|
+
$stderr.puts "nil"
|
120
|
+
end
|
121
|
+
|
122
|
+
when 'get_data'
|
123
|
+
key = cmd_args(1)
|
124
|
+
data = call(nil, :get_data, key)
|
125
|
+
if data
|
126
|
+
$stderr.puts "#{data.size} bytes"
|
127
|
+
$stdout.write data
|
128
|
+
else
|
129
|
+
$stderr.puts "nil"
|
130
|
+
end
|
131
|
+
|
132
|
+
when 'gett_data'
|
133
|
+
vtime, key = cmd_args(2)
|
134
|
+
data = call(nil, :gett_data, vtime.to_i, key)
|
135
|
+
if data
|
136
|
+
$stderr.puts "#{data.size} bytes"
|
137
|
+
$stdout.write data
|
138
|
+
else
|
139
|
+
$stderr.puts "nil"
|
140
|
+
end
|
141
|
+
|
142
|
+
when 'getv_data'
|
143
|
+
vname, key = cmd_args(2)
|
144
|
+
data = call(nil, :getv_data, vname, key)
|
145
|
+
if data
|
146
|
+
$stderr.puts "#{data.size} bytes"
|
147
|
+
$stdout.write data
|
148
|
+
else
|
149
|
+
$stderr.puts "nil"
|
150
|
+
end
|
151
|
+
|
152
|
+
when 'get_attrs'
|
153
|
+
key = cmd_args(1)
|
154
|
+
attrs = call(nil, :get_attrs, key)
|
155
|
+
if attrs
|
156
|
+
puts attrs.to_json
|
157
|
+
else
|
158
|
+
puts "nil"
|
159
|
+
end
|
160
|
+
|
161
|
+
when 'gett_attrs'
|
162
|
+
vtime, key = cmd_args(2)
|
163
|
+
attrs = call(nil, :gett_attrs, vtime.to_i, key)
|
164
|
+
if attrs
|
165
|
+
puts attrs.to_json
|
166
|
+
else
|
167
|
+
puts "nil"
|
168
|
+
end
|
169
|
+
|
170
|
+
when 'getv_attrs'
|
171
|
+
vname, key = cmd_args(2)
|
172
|
+
attrs = call(nil, :getv_attrs, vname, key)
|
173
|
+
if attrs
|
174
|
+
puts attrs.to_json
|
175
|
+
else
|
176
|
+
puts "nil"
|
177
|
+
end
|
178
|
+
|
179
|
+
when 'read'
|
180
|
+
key, offset, size = cmd_args(3)
|
181
|
+
data = call(nil, :read, key, offset.to_i, size.to_i)
|
182
|
+
$stderr.puts "#{data.size} bytes"
|
183
|
+
$stdout.write data
|
184
|
+
|
185
|
+
when 'readt'
|
186
|
+
vtime, key, offset, size = cmd_args(4)
|
187
|
+
data = call(nil, :readt, vtime.to_i, key, offset.to_i, size.to_i)
|
188
|
+
$stderr.puts "#{data.size} bytes"
|
189
|
+
$stdout.write data
|
190
|
+
|
191
|
+
when 'readt'
|
192
|
+
vname, key, offset, size = cmd_args(4)
|
193
|
+
data = call(nil, :readv, vname.to_i, key, offset.to_i, size.to_i)
|
194
|
+
$stderr.puts "#{data.size} bytes"
|
195
|
+
$stdout.write data
|
196
|
+
|
197
|
+
when 'add'
|
198
|
+
key, data, json = cmd_args(3)
|
199
|
+
attrs = JSON.parse(json)
|
200
|
+
pp call(nil, :add, key, data, attrs)
|
201
|
+
|
202
|
+
when 'addv'
|
203
|
+
vname, key, data, json = cmd_args(4)
|
204
|
+
attrs = JSON.parse(json)
|
205
|
+
pp call(nil, :addv, vname, key, data, attrs)
|
206
|
+
|
207
|
+
when 'add_data'
|
208
|
+
key, data = cmd_args(2)
|
209
|
+
pp call(nil, :add_data, key, data)
|
210
|
+
|
211
|
+
when 'addv_data'
|
212
|
+
vname, key, data = cmd_args(3)
|
213
|
+
pp call(nil, :addv_data, vname, key, data)
|
214
|
+
|
215
|
+
when 'update_attrs'
|
216
|
+
key, json = cmd_args(2)
|
217
|
+
attrs = JSON.parse(json)
|
218
|
+
pp call(nil, :update_attrs, key, attrs)
|
219
|
+
|
220
|
+
when 'delete'
|
221
|
+
key = cmd_args(1)
|
222
|
+
pp call(nil, :delete, key)
|
223
|
+
|
224
|
+
when 'deletet'
|
225
|
+
vtime, key = cmd_args(1)
|
226
|
+
pp call(nil, :deletet, vtime.to_i, key)
|
227
|
+
|
228
|
+
when 'deletev'
|
229
|
+
vname, key = cmd_args(2)
|
230
|
+
pp call(nil, :deletev, vname, key)
|
231
|
+
|
232
|
+
when 'remove'
|
233
|
+
key = cmd_args(1)
|
234
|
+
pp call(nil, :remove, key)
|
235
|
+
|
236
|
+
else
|
237
|
+
$stderr.puts "unknown command #{cmd}"
|
238
|
+
$stderr.puts ""
|
239
|
+
usage
|
240
|
+
end
|
241
|
+
|
@@ -0,0 +1,190 @@
|
|
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
|
+
require 'msgpack/rpc'
|
19
|
+
require 'digest/md5'
|
20
|
+
require 'digest/sha1'
|
21
|
+
require 'csv'
|
22
|
+
require 'fileutils'
|
23
|
+
require 'ls4/lib/cclog'
|
24
|
+
require 'ls4/lib/ebus'
|
25
|
+
require 'ls4/lib/vbcode'
|
26
|
+
require 'ls4/logic/tsv_data'
|
27
|
+
require 'ls4/logic/weight'
|
28
|
+
require 'ls4/logic/fault_detector'
|
29
|
+
require 'ls4/logic/membership'
|
30
|
+
require 'ls4/logic/node'
|
31
|
+
require 'ls4/logic/okey'
|
32
|
+
require 'ls4/service/base'
|
33
|
+
require 'ls4/service/bus'
|
34
|
+
require 'ls4/service/process'
|
35
|
+
require 'ls4/service/rpc'
|
36
|
+
require 'ls4/service/rpc_cs'
|
37
|
+
require 'ls4/service/stat'
|
38
|
+
require 'ls4/service/stat_cs'
|
39
|
+
require 'ls4/service/config'
|
40
|
+
require 'ls4/service/config_cs'
|
41
|
+
require 'ls4/service/sync'
|
42
|
+
require 'ls4/service/heartbeat'
|
43
|
+
require 'ls4/service/membership'
|
44
|
+
require 'ls4/service/weight'
|
45
|
+
require 'ls4/service/balance'
|
46
|
+
require 'ls4/service/master_select'
|
47
|
+
require 'ls4/service/mds'
|
48
|
+
require 'ls4/service/mds_cache'
|
49
|
+
require 'ls4/service/log'
|
50
|
+
require 'ls4/default'
|
51
|
+
require 'ls4/version'
|
52
|
+
require 'optparse'
|
53
|
+
|
54
|
+
include LS4
|
55
|
+
|
56
|
+
conf = CSConfigService.init
|
57
|
+
|
58
|
+
op = OptionParser.new
|
59
|
+
|
60
|
+
(class<<self;self;end).module_eval do
|
61
|
+
define_method(:usage) do |msg|
|
62
|
+
puts op.to_s
|
63
|
+
puts "error: #{msg}" if msg
|
64
|
+
exit 1
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
store_path = nil
|
69
|
+
|
70
|
+
listen_host = '0.0.0.0'
|
71
|
+
listen_port = CS_DEFAULT_PORT
|
72
|
+
|
73
|
+
op.on('-p', '--port PORT', "listen port") do |addr|
|
74
|
+
if addr.include?(':')
|
75
|
+
listen_host, listen_port = addr.split(':',2)
|
76
|
+
listen_port = listen_port.to_i
|
77
|
+
listen_port = CS_DEFAULT_PORT if listen_port == 0
|
78
|
+
else
|
79
|
+
listen_port = addr.to_i
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
op.on('-l', '--listen HOST', "listen address") do |addr|
|
84
|
+
if addr.include?(':')
|
85
|
+
host, port = addr.split(':',2)
|
86
|
+
port = port.to_i
|
87
|
+
port = CS_DEFAULT_PORT if port == 0
|
88
|
+
listen_host = host
|
89
|
+
listen_port = port
|
90
|
+
else
|
91
|
+
listen_host = addr
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
op.on('-m', '--mds EXPR', "address of metadata servers (required)") do |s|
|
96
|
+
conf.mds_uri = s
|
97
|
+
end
|
98
|
+
|
99
|
+
op.on('-M', '--mds-cache EXPR', "address of metadata cache servers") do |s|
|
100
|
+
conf.mds_cache_uri = s
|
101
|
+
end
|
102
|
+
|
103
|
+
op.on('-s', '--store PATH', "path to default directory to store various data (required for production use)") do |path|
|
104
|
+
store_path = path
|
105
|
+
end
|
106
|
+
|
107
|
+
op.on('--fault_store PATH', "path to fault status file") do |path|
|
108
|
+
conf.fault_path = path
|
109
|
+
end
|
110
|
+
|
111
|
+
op.on('--membership_store PATH', "path to membership status file") do |path|
|
112
|
+
conf.membership_path = path
|
113
|
+
end
|
114
|
+
|
115
|
+
op.on('--weight_store PATH', "path to weight status file") do |path|
|
116
|
+
conf.weight_path = path
|
117
|
+
end
|
118
|
+
|
119
|
+
op.on('-o', '--log PATH') do |path|
|
120
|
+
conf.log_path = path
|
121
|
+
end
|
122
|
+
|
123
|
+
op.on('-v', '--verbose', "show debug messages", TrueClass) do |b|
|
124
|
+
$log.level = 1 if b
|
125
|
+
end
|
126
|
+
|
127
|
+
op.on('--trace', "show debug and trace messages", TrueClass) do |b|
|
128
|
+
$log.level = 0 if b
|
129
|
+
end
|
130
|
+
|
131
|
+
op.on('--color-log', "force to enable color log", TrueClass) do |b|
|
132
|
+
$log.enable_color
|
133
|
+
end
|
134
|
+
|
135
|
+
|
136
|
+
begin
|
137
|
+
op.parse!(ARGV)
|
138
|
+
|
139
|
+
if ARGV.length != 0
|
140
|
+
raise "unknown option: #{ARGV[0].dump}"
|
141
|
+
end
|
142
|
+
|
143
|
+
unless conf.mds_uri
|
144
|
+
raise "--mds option is required"
|
145
|
+
end
|
146
|
+
|
147
|
+
if store_path
|
148
|
+
FileUtils.mkdir_p(store_path)
|
149
|
+
end
|
150
|
+
|
151
|
+
if !conf.fault_path && store_path
|
152
|
+
conf.fault_path = File.join(store_path, "fault")
|
153
|
+
end
|
154
|
+
|
155
|
+
if !conf.membership_path && store_path
|
156
|
+
conf.membership_path = File.join(store_path, "membership")
|
157
|
+
end
|
158
|
+
|
159
|
+
if !conf.weight_path && store_path
|
160
|
+
conf.weight_path = File.join(store_path, "weight")
|
161
|
+
end
|
162
|
+
|
163
|
+
rescue
|
164
|
+
usage $!.to_s
|
165
|
+
end
|
166
|
+
|
167
|
+
|
168
|
+
ProcessService.init
|
169
|
+
LogService.open!
|
170
|
+
SyncServerService.init
|
171
|
+
HeartbeatServerService.init
|
172
|
+
MembershipManagerService.init
|
173
|
+
WeightManagerService.init
|
174
|
+
MDSConfigService.init
|
175
|
+
MDSCacheConfigService.init
|
176
|
+
CSStatService.init
|
177
|
+
|
178
|
+
LogService.instance.log_event_bus
|
179
|
+
|
180
|
+
ProcessBus.run
|
181
|
+
|
182
|
+
net = ProcessBus.serve_rpc(CSRPCService.instance)
|
183
|
+
net.listen(listen_host, listen_port)
|
184
|
+
|
185
|
+
$log.info "start on #{listen_host}:#{listen_port}"
|
186
|
+
|
187
|
+
net.run
|
188
|
+
|
189
|
+
ProcessBus.shutdown
|
190
|
+
|