flare-tools 0.4.5.1 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +24 -0
- data/.travis.yml +15 -0
- data/Gemfile +9 -0
- data/Gemfile.lock +28 -0
- data/History.txt +5 -0
- data/Makefile +25 -0
- data/README.txt +2 -2
- data/Rakefile +36 -34
- data/flare-tools.gemspec +26 -0
- data/lib/flare/entity/server.rb +4 -0
- data/lib/flare/tools.rb +3 -3
- data/lib/flare/tools/cli.rb +1 -0
- data/lib/flare/tools/cli/activate.rb +19 -13
- data/lib/flare/tools/cli/balance.rb +15 -8
- data/lib/flare/tools/cli/deploy.rb +53 -49
- data/lib/flare/tools/cli/dispatch.rb +101 -0
- data/lib/flare/tools/cli/down.rb +19 -14
- data/lib/flare/tools/cli/dump.rb +19 -14
- data/lib/flare/tools/cli/dumpkey.rb +21 -16
- data/lib/flare/tools/cli/flare_admin.rb +16 -72
- data/lib/flare/tools/cli/flare_argv0.rb +7 -51
- data/lib/flare/tools/cli/index.rb +10 -7
- data/lib/flare/tools/cli/index_server_config.rb +94 -0
- data/lib/flare/tools/cli/list.rb +14 -12
- data/lib/flare/tools/cli/master.rb +18 -12
- data/lib/flare/tools/cli/option.rb +55 -0
- data/lib/flare/tools/cli/part.rb +13 -12
- data/lib/flare/tools/cli/ping.rb +11 -13
- data/lib/flare/tools/cli/reconstruct.rb +22 -15
- data/lib/flare/tools/cli/remove.rb +20 -17
- data/lib/flare/tools/cli/restore.rb +20 -20
- data/lib/flare/tools/cli/slave.rb +20 -14
- data/lib/flare/tools/cli/stats.rb +171 -118
- data/lib/flare/tools/cli/sub_command.rb +16 -5
- data/lib/flare/tools/cli/summary.rb +12 -10
- data/lib/flare/tools/cli/threads.rb +15 -9
- data/lib/flare/tools/cli/verify.rb +20 -18
- data/lib/flare/tools/cluster.rb +3 -2
- data/lib/flare/util/constant.rb +3 -0
- data/lib/flare/util/pretty_table.rb +8 -0
- data/lib/flare/util/pretty_table/column.rb +41 -0
- data/lib/flare/util/pretty_table/row.rb +29 -0
- data/lib/flare/util/pretty_table/table.rb +37 -0
- data/package/Rakefile +44 -0
- data/package/flare-tools/Makefile +23 -0
- data/package/flare-tools/debian/changelog +135 -0
- data/package/flare-tools/debian/compat +1 -0
- data/package/flare-tools/debian/control +20 -0
- data/package/flare-tools/debian/copyright +35 -0
- data/package/flare-tools/debian/dirs +2 -0
- data/{.gemtest → package/flare-tools/debian/docs} +0 -0
- data/package/flare-tools/debian/rules +125 -0
- data/test/{test/experimental → experimental}/cache_test.rb +0 -0
- data/test/{test/experimental → experimental}/key_distribution_test.rb +0 -0
- data/test/{test/experimental → experimental}/keychecker_test.rb +0 -0
- data/test/{test/experimental → experimental}/list_test.rb +0 -0
- data/test/{test/extra → extra}/replication_test.rb +0 -0
- data/test/{test/integration → integration}/cli_test.rb +9 -7
- data/test/{test/integration → integration}/dump_expired_test.rb +4 -3
- data/test/{test/integration → integration}/dump_test.rb +5 -5
- data/test/{test/integration → integration}/index_server_test.rb +1 -1
- data/test/{test/integration → integration}/node_test.rb +1 -1
- data/test/{test/integration → integration}/partition_test.rb +6 -5
- data/test/{test/integration → integration}/proxy_test.rb +4 -3
- data/test/{test/integration → integration}/stats_test.rb +1 -1
- data/test/integration/subcommands.rb +128 -0
- data/test/{test/system → system}/flare_admin_test.rb +7 -5
- data/test/{test/unit → unit}/bwlimit_test.rb +0 -0
- data/test/{test/unit → unit}/cluster_test.rb +1 -1
- data/test/{test/unit → unit}/daemon_test.rb +0 -0
- data/test/{test/unit → unit}/logger_test.rb +0 -0
- data/test/{test/unit → unit}/tools_test.rb +0 -0
- data/test/unit/util/pretty_table_test.rb +46 -0
- data/test/{test/unit → unit}/util_test.rb +7 -2
- metadata +88 -100
- data/PostInstall.txt +0 -7
- data/lib/flare/tools/cli/cli_util.rb +0 -77
- data/lib/flare/util/command_line.rb +0 -79
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'flare/entity/server'
|
2
|
+
require 'flare/util/constant'
|
3
|
+
|
4
|
+
module Flare; end
|
5
|
+
module Flare::Tools; end
|
6
|
+
module Flare::Tools::Cli; end
|
7
|
+
module Flare::Tools::Cli::Option
|
8
|
+
include Flare::Util::Constant
|
9
|
+
|
10
|
+
attr_reader :optp
|
11
|
+
|
12
|
+
def option_init
|
13
|
+
@optp = OptionParser.new
|
14
|
+
end
|
15
|
+
|
16
|
+
def set_option_global
|
17
|
+
@optp.on('-h', '--help', "show this message") { puts @optp.help; exit 1 }
|
18
|
+
@optp.on( '--debug', "enable debug mode") { $DEBUG = true }
|
19
|
+
@optp.on( '--warn', "turn on warnings") { $-w = true }
|
20
|
+
@optp.on( '--log-file=LOGFILE', "output log to LOGFILE") {|v| Flare::Util::Logging.set_logger(v)}
|
21
|
+
|
22
|
+
@timeout ||= DefaultTimeout
|
23
|
+
@optp.on( '--timeout=SECOND', "specify timeout") {|v| @timeout = v.to_i}
|
24
|
+
end
|
25
|
+
|
26
|
+
def set_option_index_server
|
27
|
+
@index_server_entity ||= Flare::Entity::Server.new(nil, nil)
|
28
|
+
@cluster ||= nil
|
29
|
+
|
30
|
+
@optp.on('-i HOSTNAME', '--index-server=HOSTNAME', "index server hostname(default:#{DefaultIndexServerName})") {|v| @index_server_host = v}
|
31
|
+
@optp.on('-p PORT', '--index-server-port=PORT', "index server port(default:#{DefaultIndexServerPort})") {|v| @index_server_port = v.to_i}
|
32
|
+
@optp.on( '--cluster=NAME', "specify a cluster name") {|v| @cluster = v}
|
33
|
+
end
|
34
|
+
|
35
|
+
def set_option_dry_run
|
36
|
+
@dry_run ||= false
|
37
|
+
@optp.on('-n', '--dry-run', "dry run") { @dry_run = true }
|
38
|
+
end
|
39
|
+
|
40
|
+
def set_option_force
|
41
|
+
@force ||= false
|
42
|
+
@optp.on('--force', "commit changes without confirmation") { @force = true }
|
43
|
+
end
|
44
|
+
|
45
|
+
def parse_options(config, argv)
|
46
|
+
begin
|
47
|
+
rest = @optp.parse(argv)
|
48
|
+
rescue OptionParser::ParseError => err
|
49
|
+
puts err.message
|
50
|
+
puts @optp.to_s
|
51
|
+
exit STATUS_NG
|
52
|
+
end
|
53
|
+
rest
|
54
|
+
end
|
55
|
+
end
|
data/lib/flare/tools/cli/part.rb
CHANGED
@@ -11,6 +11,7 @@ require 'flare/util/constant'
|
|
11
11
|
require 'flare/tools/cli/sub_command'
|
12
12
|
require 'flare/tools/cli/slave'
|
13
13
|
require 'flare/tools/cli/master'
|
14
|
+
require 'flare/tools/cli/index_server_config'
|
14
15
|
|
15
16
|
module Flare
|
16
17
|
module Tools
|
@@ -19,14 +20,17 @@ module Flare
|
|
19
20
|
include Flare::Util::Conversion
|
20
21
|
include Flare::Util::Constant
|
21
22
|
include Flare::Tools::Common
|
23
|
+
include Flare::Tools::Cli::IndexServerConfig
|
22
24
|
|
23
25
|
myname :part
|
24
26
|
desc "set the master of a partition."
|
25
27
|
usage "master [hostname:port:balance:partition] ..."
|
26
28
|
|
27
|
-
def setup
|
28
|
-
|
29
|
-
|
29
|
+
def setup
|
30
|
+
super
|
31
|
+
set_option_index_server
|
32
|
+
set_option_force
|
33
|
+
@optp.on('--retry=COUNT', "retry count" ) {|v| @retry = v.to_i}
|
30
34
|
end
|
31
35
|
|
32
36
|
def initialize
|
@@ -34,8 +38,9 @@ module Flare
|
|
34
38
|
@force = false
|
35
39
|
@retry = nil
|
36
40
|
end
|
37
|
-
|
38
|
-
def execute(config,
|
41
|
+
|
42
|
+
def execute(config, args)
|
43
|
+
parse_index_server(config, args)
|
39
44
|
return S_NG if args.size < 1
|
40
45
|
|
41
46
|
hosts = args.map {|x| x.to_s.split(':')}
|
@@ -49,7 +54,7 @@ module Flare
|
|
49
54
|
masters = []
|
50
55
|
slaves = []
|
51
56
|
|
52
|
-
Flare::Tools::IndexServer.open(config[:index_server_hostname], config[:index_server_port],
|
57
|
+
Flare::Tools::IndexServer.open(config[:index_server_hostname], config[:index_server_port], @timeout) do |s|
|
53
58
|
cluster = Flare::Tools::Cluster.new(s.host, s.port, s.stats_nodes)
|
54
59
|
|
55
60
|
partitions = {}
|
@@ -71,24 +76,20 @@ module Flare
|
|
71
76
|
begin
|
72
77
|
opt = OptionParser.new
|
73
78
|
subc = Flare::Tools::Cli::Master.new
|
74
|
-
subc.setup(opt)
|
75
79
|
args = masters
|
76
80
|
args << "--force" if @force
|
77
81
|
args << "--activate"
|
78
|
-
|
79
|
-
subc.execute(config, *args)
|
82
|
+
subc.execute_subcommand(config, args)
|
80
83
|
end
|
81
84
|
|
82
85
|
puts "slaves:"
|
83
86
|
begin
|
84
87
|
opt = OptionParser.new
|
85
88
|
subc = Flare::Tools::Cli::Slave.new
|
86
|
-
subc.setup(opt)
|
87
89
|
args = slaves
|
88
90
|
args << "--force" if @force
|
89
91
|
args << "--retry=#{@retry}" unless @retry.nil?
|
90
|
-
|
91
|
-
subc.execute(config, *args)
|
92
|
+
subc.execute_subcommand(config, args)
|
92
93
|
end
|
93
94
|
|
94
95
|
S_OK
|
data/lib/flare/tools/cli/ping.rb
CHANGED
@@ -8,31 +8,29 @@ require 'flare/util/conversion'
|
|
8
8
|
require 'flare/util/logging'
|
9
9
|
require 'flare/tools/cli/sub_command'
|
10
10
|
|
11
|
-
#
|
12
11
|
module Flare
|
13
12
|
module Tools
|
14
13
|
|
15
|
-
# == Description
|
16
|
-
#
|
17
14
|
module Cli
|
18
15
|
class Ping < SubCommand
|
19
16
|
include Flare::Util::Conversion
|
20
17
|
include Flare::Util::Logging
|
21
|
-
|
18
|
+
|
22
19
|
myname :ping
|
23
20
|
desc "ping"
|
24
21
|
usage "ping [hostname:port] ..."
|
25
|
-
|
26
|
-
def setup
|
27
|
-
|
22
|
+
|
23
|
+
def setup
|
24
|
+
super
|
25
|
+
@optp.on('--wait', "wait for OK responses from nodes") {@wait = true}
|
28
26
|
end
|
29
|
-
|
27
|
+
|
30
28
|
def initialize
|
31
29
|
super
|
32
30
|
@wait = false
|
33
31
|
end
|
34
|
-
|
35
|
-
def execute(config,
|
32
|
+
|
33
|
+
def execute(config, args)
|
36
34
|
|
37
35
|
hosts = args.map do |arg|
|
38
36
|
hostname, port, rest = arg.split(':', 3)
|
@@ -55,7 +53,7 @@ module Flare
|
|
55
53
|
begin
|
56
54
|
debug "trying..."
|
57
55
|
interruptible do
|
58
|
-
Flare::Tools::Stats.open(hostname, port,
|
56
|
+
Flare::Tools::Stats.open(hostname, port, @timeout) do |s|
|
59
57
|
resp = s.ping
|
60
58
|
end
|
61
59
|
end
|
@@ -70,11 +68,11 @@ module Flare
|
|
70
68
|
end
|
71
69
|
end
|
72
70
|
end
|
73
|
-
|
71
|
+
|
74
72
|
puts "alive"
|
75
73
|
S_OK
|
76
74
|
end
|
77
|
-
|
75
|
+
|
78
76
|
end
|
79
77
|
end
|
80
78
|
end
|
@@ -11,6 +11,7 @@ require 'flare/tools/common'
|
|
11
11
|
require 'flare/util/conversion'
|
12
12
|
require 'flare/util/constant'
|
13
13
|
require 'flare/tools/cli/sub_command'
|
14
|
+
require 'flare/tools/cli/index_server_config'
|
14
15
|
|
15
16
|
module Flare
|
16
17
|
module Tools
|
@@ -19,16 +20,20 @@ module Flare
|
|
19
20
|
include Flare::Util::Conversion
|
20
21
|
include Flare::Util::Constant
|
21
22
|
include Flare::Tools::Common
|
22
|
-
|
23
|
+
include Flare::Tools::Cli::IndexServerConfig
|
24
|
+
|
23
25
|
myname :reconstruct
|
24
26
|
desc "reconstruct the database of nodes by copying."
|
25
27
|
usage "reconstruct [hostname:port] ..."
|
26
28
|
|
27
|
-
def setup
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
29
|
+
def setup
|
30
|
+
super
|
31
|
+
set_option_index_server
|
32
|
+
set_option_dry_run
|
33
|
+
set_option_force
|
34
|
+
@optp.on('--safe', "reconstruct a node safely" ) {@safe = true}
|
35
|
+
@optp.on('--retry=COUNT', "specify retry count (default:#{@retry})") {|v| @retry = v.to_i}
|
36
|
+
@optp.on('--all', "reconstruct all nodes" ) {@all = true}
|
32
37
|
end
|
33
38
|
|
34
39
|
def initialize
|
@@ -39,13 +44,15 @@ module Flare
|
|
39
44
|
@all = false
|
40
45
|
end
|
41
46
|
|
42
|
-
def execute(config,
|
47
|
+
def execute(config, args)
|
48
|
+
parse_index_server(config, args)
|
49
|
+
|
43
50
|
if @all
|
44
51
|
unless args.empty?
|
45
52
|
puts "don't specify any nodes with --all option."
|
46
53
|
return S_NG
|
47
54
|
else
|
48
|
-
Flare::Tools::IndexServer.open(config[:index_server_hostname], config[:index_server_port],
|
55
|
+
Flare::Tools::IndexServer.open(config[:index_server_hostname], config[:index_server_port], @timeout) do |s|
|
49
56
|
cluster = Flare::Tools::Cluster.new(s.host, s.port, s.stats_nodes)
|
50
57
|
args = cluster.master_and_slave_nodekeys
|
51
58
|
end
|
@@ -61,16 +68,16 @@ module Flare
|
|
61
68
|
return S_NG
|
62
69
|
end
|
63
70
|
end
|
64
|
-
|
71
|
+
|
65
72
|
status = S_OK
|
66
73
|
|
67
|
-
Flare::Tools::IndexServer.open(config[:index_server_hostname], config[:index_server_port],
|
74
|
+
Flare::Tools::IndexServer.open(config[:index_server_hostname], config[:index_server_port], @timeout) do |s|
|
68
75
|
puts string_of_nodelist(s.stats_nodes, hosts.map {|x| nodekey_of(x[0], x[1])})
|
69
76
|
|
70
77
|
hosts.each do |hostname,port|
|
71
78
|
nodekey = nodekey_of hostname, port
|
72
79
|
cluster = Flare::Tools::Cluster.new(s.host, s.port, s.stats_nodes)
|
73
|
-
|
80
|
+
|
74
81
|
unless node = cluster.node_stat(nodekey)
|
75
82
|
puts "#{nodekey} is not found in this cluster."
|
76
83
|
return S_NG
|
@@ -111,14 +118,14 @@ module Flare
|
|
111
118
|
end
|
112
119
|
end
|
113
120
|
end
|
114
|
-
if exec &&
|
121
|
+
if exec && !@dry_run
|
115
122
|
puts "turning down..."
|
116
123
|
s.set_state(hostname, port, 'down')
|
117
124
|
|
118
125
|
puts "waiting for node to be active again..."
|
119
126
|
sleep 3
|
120
127
|
|
121
|
-
Flare::Tools::Node.open(hostname, port,
|
128
|
+
Flare::Tools::Node.open(hostname, port, @timeout) do |n|
|
122
129
|
n.flush_all
|
123
130
|
end
|
124
131
|
|
@@ -137,7 +144,7 @@ module Flare
|
|
137
144
|
end
|
138
145
|
balance = node['balance']
|
139
146
|
if resp
|
140
|
-
wait_for_slave_construction(s, nodekey,
|
147
|
+
wait_for_slave_construction(s, nodekey, @timeout)
|
141
148
|
unless @force
|
142
149
|
print "changing node's balance (node=#{nodekey}, balance=0 -> #{balance}) (y/n): "
|
143
150
|
exec = interruptible {(gets.chomp.upcase == "Y")}
|
@@ -154,7 +161,7 @@ module Flare
|
|
154
161
|
|
155
162
|
puts string_of_nodelist(s.stats_nodes, hosts.map {|x| "#{x[0]}:#{x[1]}"})
|
156
163
|
end # open
|
157
|
-
|
164
|
+
|
158
165
|
status
|
159
166
|
end # execute()
|
160
167
|
|
@@ -7,27 +7,29 @@ require 'flare/tools/index_server'
|
|
7
7
|
require 'flare/util/conversion'
|
8
8
|
require 'flare/tools/common'
|
9
9
|
require 'flare/tools/cli/sub_command'
|
10
|
+
require 'flare/tools/cli/index_server_config'
|
10
11
|
|
11
|
-
#
|
12
12
|
module Flare
|
13
13
|
module Tools
|
14
14
|
module Cli
|
15
15
|
|
16
|
-
# == Description
|
17
|
-
#
|
18
16
|
class Remove < SubCommand
|
19
17
|
include Flare::Util::Conversion
|
20
18
|
include Flare::Tools::Common
|
19
|
+
include Flare::Tools::Cli::IndexServerConfig
|
21
20
|
|
22
21
|
myname :remove
|
23
22
|
desc "remove a node. (experimental)"
|
24
23
|
usage "remove"
|
25
|
-
|
26
|
-
def setup
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
24
|
+
|
25
|
+
def setup
|
26
|
+
super
|
27
|
+
set_option_index_server
|
28
|
+
set_option_dry_run
|
29
|
+
set_option_force
|
30
|
+
@optp.on('--wait=SECOND', "specify the time to wait node for getting ready (default:#{@wait})") {|v| @wait = v.to_i}
|
31
|
+
@optp.on('--retry=COUNT', "retry count(default:#{@retry})") {|v| @retry = v.to_i}
|
32
|
+
@optp.on('--connection-threshold=[COUNT]', "specify connection threashold (default:#{@connection_threshold})") {|v| @connection_threshold = v.to_i}
|
31
33
|
end
|
32
34
|
|
33
35
|
def initialize
|
@@ -38,7 +40,9 @@ module Flare
|
|
38
40
|
@connection_threshold = 2
|
39
41
|
end
|
40
42
|
|
41
|
-
def execute(config,
|
43
|
+
def execute(config, args)
|
44
|
+
parse_index_server(config, args)
|
45
|
+
|
42
46
|
hosts = args.map {|x| x.split(':')}
|
43
47
|
hosts.each do |x|
|
44
48
|
if x.size != 2
|
@@ -46,8 +50,8 @@ module Flare
|
|
46
50
|
return S_NG
|
47
51
|
end
|
48
52
|
end
|
49
|
-
|
50
|
-
Flare::Tools::IndexServer.open(config[:index_server_hostname], config[:index_server_port],
|
53
|
+
|
54
|
+
Flare::Tools::IndexServer.open(config[:index_server_hostname], config[:index_server_port], @timeout) do |s|
|
51
55
|
cluster = fetch_cluster(s)
|
52
56
|
|
53
57
|
hosts.each do |hostname,port|
|
@@ -60,7 +64,7 @@ module Flare
|
|
60
64
|
|
61
65
|
hosts.each do |hostname,port|
|
62
66
|
exec = false
|
63
|
-
Flare::Tools::Node.open(hostname, port,
|
67
|
+
Flare::Tools::Node.open(hostname, port, @timeout) do |n|
|
64
68
|
nwait = @wait
|
65
69
|
node = n.stats
|
66
70
|
cluster = Flare::Tools::Cluster.new(s.host, s.port, s.stats_nodes)
|
@@ -87,14 +91,14 @@ module Flare
|
|
87
91
|
}
|
88
92
|
end
|
89
93
|
end
|
90
|
-
|
94
|
+
|
91
95
|
if exec
|
92
96
|
suc = false
|
93
97
|
nretry = @retry
|
94
98
|
while nretry > 0
|
95
99
|
resp = false
|
96
100
|
info "removing #{hostname}:#{port}."
|
97
|
-
resp = s.node_remove(hostname, port) unless
|
101
|
+
resp = s.node_remove(hostname, port) unless @dry_run
|
98
102
|
if resp
|
99
103
|
suc = true
|
100
104
|
break
|
@@ -109,10 +113,9 @@ module Flare
|
|
109
113
|
end
|
110
114
|
puts string_of_nodelist(s.stats_nodes)
|
111
115
|
end
|
112
|
-
|
116
|
+
|
113
117
|
S_OK
|
114
118
|
end
|
115
|
-
|
116
119
|
end
|
117
120
|
end
|
118
121
|
end
|
@@ -20,7 +20,7 @@ end
|
|
20
20
|
module Flare
|
21
21
|
module Tools
|
22
22
|
module Cli
|
23
|
-
|
23
|
+
|
24
24
|
class Restore < SubCommand
|
25
25
|
|
26
26
|
class Restorer
|
@@ -70,35 +70,37 @@ module Flare
|
|
70
70
|
include Flare::Util::Conversion
|
71
71
|
include Flare::Util::Constant
|
72
72
|
include Flare::Tools::Common
|
73
|
-
|
73
|
+
|
74
74
|
myname :restore
|
75
75
|
desc "restore data to nodes. (experimental)"
|
76
76
|
usage "restore [hostname:port]"
|
77
|
-
|
78
|
-
def setup
|
79
|
-
|
80
|
-
|
77
|
+
|
78
|
+
def setup
|
79
|
+
super
|
80
|
+
set_option_dry_run
|
81
|
+
@optp.on('-i', '--input=FILE', "input from file") {|v| @input = v}
|
82
|
+
@optp.on('-f', '--format=FORMAT', "input format [#{Formats.join(',')}]") {|v|
|
81
83
|
@format = v
|
82
84
|
}
|
83
|
-
|
84
|
-
|
85
|
+
@optp.on('--bwlimit=BANDWIDTH', "bandwidth limit (bps)") {|v| @bwlimit = v}
|
86
|
+
@optp.on('--include=PATTERN', "include pattern") {|v|
|
85
87
|
begin
|
86
88
|
@include = Regexp.new(v)
|
87
89
|
rescue RegexpError => e
|
88
90
|
raise "#{v} isn't a valid regular expression."
|
89
91
|
end
|
90
92
|
}
|
91
|
-
|
93
|
+
@optp.on('--prefix-include=STRING', "prefix string") {|v|
|
92
94
|
@prefix_include = Regexp.new("^"+Regexp.escape(v))
|
93
|
-
}
|
94
|
-
|
95
|
+
}
|
96
|
+
@optp.on('--exclude=PATTERN', "exclude pattern") {|v|
|
95
97
|
begin
|
96
98
|
@exclude = Regexp.new(v)
|
97
99
|
rescue RegexpError => e
|
98
100
|
raise "#{v} isn't a valid regular expression."
|
99
101
|
end
|
100
102
|
}
|
101
|
-
|
103
|
+
@optp.on('--print-keys', "enables key dump to console") {@print_key = true}
|
102
104
|
end
|
103
105
|
|
104
106
|
def initialize
|
@@ -115,16 +117,14 @@ module Flare
|
|
115
117
|
@print_key = false
|
116
118
|
end
|
117
119
|
|
118
|
-
def execute(config,
|
120
|
+
def execute(config, args)
|
119
121
|
STDERR.puts "please install tokyocabinet via gem command." unless defined? TokyoCabinet
|
120
122
|
|
121
|
-
dry_run = config[:dry_run]
|
122
|
-
|
123
123
|
unless @format.nil? || Formats.include?(@format)
|
124
124
|
STDERR.puts "unknown format: #{@format}"
|
125
125
|
return S_NG
|
126
126
|
end
|
127
|
-
|
127
|
+
|
128
128
|
if @prefix_include
|
129
129
|
if @include
|
130
130
|
STDERR.puts "--include option is specified."
|
@@ -140,7 +140,7 @@ module Flare
|
|
140
140
|
return S_NG
|
141
141
|
end
|
142
142
|
end
|
143
|
-
|
143
|
+
|
144
144
|
restorer = case @format
|
145
145
|
when TchRestorer.myname
|
146
146
|
TchRestorer.new(@input)
|
@@ -149,7 +149,7 @@ module Flare
|
|
149
149
|
end
|
150
150
|
|
151
151
|
nodes = hosts.map do |hostname,port|
|
152
|
-
Flare::Tools::Node.open(hostname, port.to_i,
|
152
|
+
Flare::Tools::Node.open(hostname, port.to_i, @timeout, @bwlimit, @bwlimit)
|
153
153
|
end
|
154
154
|
|
155
155
|
count = 0
|
@@ -157,7 +157,7 @@ module Flare
|
|
157
157
|
if @include.nil? || @include =~ key
|
158
158
|
next if @exclude && @exclude =~ key
|
159
159
|
STDOUT.puts key if @print_key
|
160
|
-
nodes[0].set(key, data, flag, expire) unless dry_run
|
160
|
+
nodes[0].set(key, data, flag, expire) unless @dry_run
|
161
161
|
count += 1
|
162
162
|
end
|
163
163
|
end
|
@@ -168,7 +168,7 @@ module Flare
|
|
168
168
|
end
|
169
169
|
|
170
170
|
restorer.close
|
171
|
-
|
171
|
+
|
172
172
|
S_OK
|
173
173
|
end # execute()
|
174
174
|
|