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
data/PostInstall.txt
DELETED
@@ -1,77 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8; -*-
|
2
|
-
# Authors:: Kiyoshi Ikehara <kiyoshi.ikehara@gree.net>
|
3
|
-
# Copyright:: Copyright (C) GREE, Inc. 2011.
|
4
|
-
# License:: MIT-style
|
5
|
-
|
6
|
-
require 'flare/tools/index_server'
|
7
|
-
|
8
|
-
module Flare
|
9
|
-
module Tools
|
10
|
-
module Cli
|
11
|
-
module CliUtil
|
12
|
-
FLARE_INDEX_SERVERS = "FLARE_INDEX_SERVERS"
|
13
|
-
FLARE_INDEX_SERVER = "FLARE_INDEX_SERVER"
|
14
|
-
|
15
|
-
def get_index_server_from_cluster(name, envname = FLARE_INDEX_SERVERS)
|
16
|
-
return nil if name.nil?
|
17
|
-
if ENV.has_key? envname
|
18
|
-
clusters = ENV[envname].split(';').map{|s| s.split(':')}
|
19
|
-
clusters.each do |cluster_name,index_name,index_port|
|
20
|
-
return [index_name, index_port] if cluster_name == name
|
21
|
-
end
|
22
|
-
end
|
23
|
-
return nil
|
24
|
-
end
|
25
|
-
|
26
|
-
def get_index_server_from_nodekeys(dnodekeys, envname = FLARE_INDEX_SERVERS)
|
27
|
-
nodekeys = []
|
28
|
-
return nil if dnodekeys.empty?
|
29
|
-
dnodekeys.each do |n|
|
30
|
-
l = n.split(':')
|
31
|
-
return nil if l.size < 2
|
32
|
-
nodekeys << "#{l[0]}:#{l[1]}"
|
33
|
-
end
|
34
|
-
if ENV.has_key? envname
|
35
|
-
clusters = ENV[envname].split(';').map{|s| s.split(':')}
|
36
|
-
clusters.each do |cluster_name,index_name,index_port|
|
37
|
-
ret = Flare::Tools::IndexServer.open(index_name, index_port.to_i) do |s|
|
38
|
-
cluster_nodekeys = s.stats_nodes.map {|x| x[0]}
|
39
|
-
included = true
|
40
|
-
nodekeys.each do |nodekey|
|
41
|
-
included = false unless cluster_nodekeys.include? nodekey
|
42
|
-
end
|
43
|
-
if included
|
44
|
-
[index_name, index_port]
|
45
|
-
else
|
46
|
-
nil
|
47
|
-
end
|
48
|
-
end
|
49
|
-
return ret unless ret.nil?
|
50
|
-
end
|
51
|
-
end
|
52
|
-
nil
|
53
|
-
rescue => e
|
54
|
-
nil
|
55
|
-
end
|
56
|
-
|
57
|
-
def get_index_server_name_and_port(index_server_hostname, index_server_port, envname = FLARE_INDEX_SERVER)
|
58
|
-
env_ihostname = nil
|
59
|
-
env_iport = nil
|
60
|
-
if ENV.has_key? envname
|
61
|
-
env_ihostname, env_iport = ENV[envname].split(':')
|
62
|
-
end
|
63
|
-
ihostname, iport = index_server_hostname.split(':') unless index_server_hostname.nil?
|
64
|
-
ihostname = ihostname || env_ihostname || DefaultIndexServerName
|
65
|
-
if iport && index_server_port
|
66
|
-
raise "--index-server-port option isn't allowed."
|
67
|
-
else
|
68
|
-
iport = index_server_port || env_iport || DefaultIndexServerPort if iport.nil?
|
69
|
-
end
|
70
|
-
[ihostname, iport]
|
71
|
-
end
|
72
|
-
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
@@ -1,79 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8; -*-
|
2
|
-
# Authors:: Kiyoshi Ikehara <kiyoshi.ikehara@gree.net>
|
3
|
-
# Copyright:: Copyright (C) GREE, Inc. 2011.
|
4
|
-
# License:: MIT-style
|
5
|
-
|
6
|
-
require 'optparse'
|
7
|
-
require 'flare/util/logging'
|
8
|
-
|
9
|
-
#
|
10
|
-
module Flare
|
11
|
-
module Util
|
12
|
-
|
13
|
-
# == Description
|
14
|
-
# CommandLine is a mix-in module for the top level.
|
15
|
-
#
|
16
|
-
# require 'flare/util/command_line'
|
17
|
-
#
|
18
|
-
# option do |opt|
|
19
|
-
# ...
|
20
|
-
# end
|
21
|
-
#
|
22
|
-
# setup do |opt|
|
23
|
-
# ...
|
24
|
-
# end
|
25
|
-
#
|
26
|
-
# execute do |args|
|
27
|
-
# ...
|
28
|
-
# end
|
29
|
-
module CommandLine
|
30
|
-
@@option = OptionParser.new
|
31
|
-
S_OK = 0
|
32
|
-
S_NG = 1
|
33
|
-
|
34
|
-
def option(&block)
|
35
|
-
block.call(@@option)
|
36
|
-
end
|
37
|
-
|
38
|
-
def setup(&block)
|
39
|
-
block.call(@@option)
|
40
|
-
begin
|
41
|
-
@@option.parse!(ARGV)
|
42
|
-
rescue OptionParser::ParseError => err
|
43
|
-
puts err.message
|
44
|
-
puts @@option.to_s
|
45
|
-
exit S_NG
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
def execute(&block)
|
50
|
-
status = S_OK
|
51
|
-
if block
|
52
|
-
args = ARGV.dup
|
53
|
-
ARGV.clear
|
54
|
-
status = block.call(args)
|
55
|
-
end
|
56
|
-
status
|
57
|
-
rescue => e
|
58
|
-
level = 1
|
59
|
-
Logging.logger.error(e.to_s)
|
60
|
-
e.backtrace.each do |line|
|
61
|
-
Logging.logger.error(" %3s: %s" % [level, line])
|
62
|
-
level += 1
|
63
|
-
end
|
64
|
-
raise e if $DEBUG
|
65
|
-
S_NG
|
66
|
-
end
|
67
|
-
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
extend Flare::Util::CommandLine
|
73
|
-
|
74
|
-
option do |opt|
|
75
|
-
opt.on('-h', '--help', "show this message") {puts opt.help; exit 1}
|
76
|
-
opt.on( '--debug', "enable debug mode") {$DEBUG = true}
|
77
|
-
opt.on( '--warn', "turn on warnings") {$-w = true}
|
78
|
-
end
|
79
|
-
|