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.
Files changed (78) hide show
  1. data/.gitignore +24 -0
  2. data/.travis.yml +15 -0
  3. data/Gemfile +9 -0
  4. data/Gemfile.lock +28 -0
  5. data/History.txt +5 -0
  6. data/Makefile +25 -0
  7. data/README.txt +2 -2
  8. data/Rakefile +36 -34
  9. data/flare-tools.gemspec +26 -0
  10. data/lib/flare/entity/server.rb +4 -0
  11. data/lib/flare/tools.rb +3 -3
  12. data/lib/flare/tools/cli.rb +1 -0
  13. data/lib/flare/tools/cli/activate.rb +19 -13
  14. data/lib/flare/tools/cli/balance.rb +15 -8
  15. data/lib/flare/tools/cli/deploy.rb +53 -49
  16. data/lib/flare/tools/cli/dispatch.rb +101 -0
  17. data/lib/flare/tools/cli/down.rb +19 -14
  18. data/lib/flare/tools/cli/dump.rb +19 -14
  19. data/lib/flare/tools/cli/dumpkey.rb +21 -16
  20. data/lib/flare/tools/cli/flare_admin.rb +16 -72
  21. data/lib/flare/tools/cli/flare_argv0.rb +7 -51
  22. data/lib/flare/tools/cli/index.rb +10 -7
  23. data/lib/flare/tools/cli/index_server_config.rb +94 -0
  24. data/lib/flare/tools/cli/list.rb +14 -12
  25. data/lib/flare/tools/cli/master.rb +18 -12
  26. data/lib/flare/tools/cli/option.rb +55 -0
  27. data/lib/flare/tools/cli/part.rb +13 -12
  28. data/lib/flare/tools/cli/ping.rb +11 -13
  29. data/lib/flare/tools/cli/reconstruct.rb +22 -15
  30. data/lib/flare/tools/cli/remove.rb +20 -17
  31. data/lib/flare/tools/cli/restore.rb +20 -20
  32. data/lib/flare/tools/cli/slave.rb +20 -14
  33. data/lib/flare/tools/cli/stats.rb +171 -118
  34. data/lib/flare/tools/cli/sub_command.rb +16 -5
  35. data/lib/flare/tools/cli/summary.rb +12 -10
  36. data/lib/flare/tools/cli/threads.rb +15 -9
  37. data/lib/flare/tools/cli/verify.rb +20 -18
  38. data/lib/flare/tools/cluster.rb +3 -2
  39. data/lib/flare/util/constant.rb +3 -0
  40. data/lib/flare/util/pretty_table.rb +8 -0
  41. data/lib/flare/util/pretty_table/column.rb +41 -0
  42. data/lib/flare/util/pretty_table/row.rb +29 -0
  43. data/lib/flare/util/pretty_table/table.rb +37 -0
  44. data/package/Rakefile +44 -0
  45. data/package/flare-tools/Makefile +23 -0
  46. data/package/flare-tools/debian/changelog +135 -0
  47. data/package/flare-tools/debian/compat +1 -0
  48. data/package/flare-tools/debian/control +20 -0
  49. data/package/flare-tools/debian/copyright +35 -0
  50. data/package/flare-tools/debian/dirs +2 -0
  51. data/{.gemtest → package/flare-tools/debian/docs} +0 -0
  52. data/package/flare-tools/debian/rules +125 -0
  53. data/test/{test/experimental → experimental}/cache_test.rb +0 -0
  54. data/test/{test/experimental → experimental}/key_distribution_test.rb +0 -0
  55. data/test/{test/experimental → experimental}/keychecker_test.rb +0 -0
  56. data/test/{test/experimental → experimental}/list_test.rb +0 -0
  57. data/test/{test/extra → extra}/replication_test.rb +0 -0
  58. data/test/{test/integration → integration}/cli_test.rb +9 -7
  59. data/test/{test/integration → integration}/dump_expired_test.rb +4 -3
  60. data/test/{test/integration → integration}/dump_test.rb +5 -5
  61. data/test/{test/integration → integration}/index_server_test.rb +1 -1
  62. data/test/{test/integration → integration}/node_test.rb +1 -1
  63. data/test/{test/integration → integration}/partition_test.rb +6 -5
  64. data/test/{test/integration → integration}/proxy_test.rb +4 -3
  65. data/test/{test/integration → integration}/stats_test.rb +1 -1
  66. data/test/integration/subcommands.rb +128 -0
  67. data/test/{test/system → system}/flare_admin_test.rb +7 -5
  68. data/test/{test/unit → unit}/bwlimit_test.rb +0 -0
  69. data/test/{test/unit → unit}/cluster_test.rb +1 -1
  70. data/test/{test/unit → unit}/daemon_test.rb +0 -0
  71. data/test/{test/unit → unit}/logger_test.rb +0 -0
  72. data/test/{test/unit → unit}/tools_test.rb +0 -0
  73. data/test/unit/util/pretty_table_test.rb +46 -0
  74. data/test/{test/unit → unit}/util_test.rb +7 -2
  75. metadata +88 -100
  76. data/PostInstall.txt +0 -7
  77. data/lib/flare/tools/cli/cli_util.rb +0 -77
  78. data/lib/flare/util/command_line.rb +0 -79
data/PostInstall.txt DELETED
@@ -1,7 +0,0 @@
1
-
2
- For more information on flare-tools, see http://flare-tools.rubyforge.org
3
-
4
- NOTE: Change this information in PostInstall.txt
5
- You can also delete it if you don't want it.
6
-
7
-
@@ -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
-