rboss 0.6.0 → 0.6.1

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.
Files changed (53) hide show
  1. data/README.md +2 -2
  2. data/bin/jboss-profile +1 -1
  3. data/bin/rboss-cli +8 -2
  4. data/bin/twiddle +3 -3
  5. data/lib/rboss.rb +6 -2
  6. data/lib/rboss/bin/command_actions.rb +3 -2
  7. data/lib/rboss/cli/jboss_cli.rb +3 -3
  8. data/lib/rboss/cli/mappings.rb +12 -2
  9. data/lib/rboss/cli/mappings/resources/connector.yaml +10 -35
  10. data/lib/rboss/cli/mappings/resources/datasource.yaml +19 -26
  11. data/lib/rboss/cli/mappings/resources/jdbc_driver.yaml +0 -1
  12. data/lib/rboss/cli/mappings/resources/server.yaml +151 -34
  13. data/lib/rboss/cli/resource.rb +18 -10
  14. data/lib/rboss/component_processor.rb +87 -85
  15. data/lib/rboss/components/component.rb +2 -2
  16. data/lib/rboss/components/datasource.rb +1 -1
  17. data/lib/rboss/components/deploy_folder.rb +1 -1
  18. data/lib/rboss/components/hypersonic_replacer.rb +1 -1
  19. data/lib/rboss/components/jbossweb.rb +1 -1
  20. data/lib/rboss/components/jmx.rb +1 -1
  21. data/lib/rboss/components/mod_cluster.rb +1 -1
  22. data/lib/rboss/components/org/6.0/deploy_folder.rb +1 -1
  23. data/lib/rboss/components/org/jmx.rb +1 -1
  24. data/lib/rboss/components/profile_folder.rb +1 -1
  25. data/lib/rboss/components/resource.rb +1 -1
  26. data/lib/rboss/components/restore_slimming.rb +3 -3
  27. data/lib/rboss/components/run_conf.rb +4 -4
  28. data/lib/rboss/components/service_script.rb +1 -1
  29. data/lib/rboss/components/slimming.rb +1 -1
  30. data/lib/rboss/components/soa-p/hypersonic_replacer.rb +1 -1
  31. data/lib/rboss/components/soa-p/jmx.rb +1 -1
  32. data/lib/rboss/components/xadatasource.rb +2 -2
  33. data/lib/rboss/file_processor.rb +70 -66
  34. data/lib/rboss/jboss_path.rb +1 -1
  35. data/lib/rboss/jboss_profile.rb +28 -27
  36. data/lib/rboss/plaftorm.rb +64 -0
  37. data/lib/rboss/resources/run.conf.bat.erb +60 -0
  38. data/lib/rboss/twiddle/base_monitor.rb +2 -2
  39. data/lib/rboss/twiddle/mbean.rb +1 -1
  40. data/lib/rboss/twiddle/monitor.rb +26 -39
  41. data/lib/rboss/twiddle/twiddle.rb +3 -2
  42. data/lib/rboss/utils.rb +0 -62
  43. data/lib/rboss/version.rb +1 -1
  44. data/lib/rboss/view/colorizers.rb +20 -0
  45. data/lib/rboss/view/formatters.rb +21 -0
  46. data/lib/rboss/view/health_checkers.rb +41 -0
  47. data/lib/rboss/view/table_builder.rb +93 -0
  48. data/test/test_helper.rb +1 -1
  49. metadata +8 -6
  50. data/lib/rboss/cli.rb +0 -22
  51. data/lib/rboss/cli/colorizers.rb +0 -22
  52. data/lib/rboss/cli/formatters.rb +0 -17
  53. data/lib/rboss/cli/health_checkers.rb +0 -43
@@ -0,0 +1,60 @@
1
+ rem ### -*- batch file -*- ######################################################
2
+ rem # ##
3
+ rem # JBoss Bootstrap Script Configuration ##
4
+ rem # ##
5
+ rem #############################################################################
6
+
7
+ rem # $Id: run.conf.bat 112288 2011-10-04 14:59:56Z mbenitez $
8
+
9
+ rem #
10
+ rem # This batch file is executed by run.bat to initialize the environment
11
+ rem # variables that run.bat uses. It is recommended to use this file to
12
+ rem # configure these variables, rather than modifying run.bat itself.
13
+ rem #
14
+
15
+ if not "x%JAVA_OPTS%" == "x" goto JAVA_OPTS_SET
16
+
17
+ rem #
18
+ rem # Specify the JBoss Profiler configuration file to load.
19
+ rem #
20
+ rem # Default is to not load a JBoss Profiler configuration file.
21
+ rem #
22
+ rem set "PROFILER=%JBOSS_HOME%\bin\jboss-profiler.properties"
23
+
24
+ rem #
25
+ rem # Specify the location of the Java home directory (it is recommended that
26
+ rem # this always be set). If set, then "%JAVA_HOME%\bin\java" will be used as
27
+ rem # the Java VM executable; otherwise, "%JAVA%" will be used (see below).
28
+ rem #
29
+ rem set "JAVA_HOME=C:\opt\jdk1.6.0_13"
30
+
31
+ rem #
32
+ rem # Specify the exact Java VM executable to use - only used if JAVA_HOME is
33
+ rem # not set. Default is "java".
34
+ rem #
35
+ rem set "JAVA=C:\opt\jdk1.6.0_13\bin\java"
36
+
37
+ rem #
38
+ rem # Specify options to pass to the Java VM. Note, there are some additional
39
+ rem # options that are always passed by run.bat.
40
+ rem #
41
+
42
+ rem # JVM memory allocation pool parameters - modify as appropriate.
43
+ set "JAVA_OPTS=-Xms<%= @config[:heap_size] %> -Xmx<%= @config[:heap_size] %>"
44
+ set "JAVA_OPTS=%JAVA_OPTS% -XX:PermSize=<%= @config[:perm_size] %> -XX:MaxPermSize=<%= @config[:perm_size] %>"
45
+ set "JAVA_OPTS=%JAVA_OPTS% -Xss<%= @config[:stack_size] %>"
46
+ set "JAVA_OPTS=%JAVA_OPTS% -Dorg.jboss.resolver.warning=true -Dsun.lang.ClassLoader.allowArraySyntax=true"
47
+
48
+ rem # Reduce the RMI GCs to once per hour for Sun JVMs.
49
+ set "JAVA_OPTS=%JAVA_OPTS% -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000"
50
+
51
+ rem # Warn when resolving remote XML DTDs or schemas.
52
+ set "JAVA_OPTS=%JAVA_OPTS% -Dorg.jboss.resolver.warning=true"
53
+
54
+ rem # Sample JPDA settings for remote socket debugging
55
+ <%= "rem" unless @config[:debug] == :socket %> set "JAVA_OPTS=%JAVA_OPTS% -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n"
56
+
57
+ rem # Sample JPDA settings for shared memory debugging
58
+ <%= "rem" unless @config[:debug] == :shared_memory %> set "JAVA_OPTS=%JAVA_OPTS% -Xrunjdwp:transport=dt_shmem,address=jboss,server=y,suspend=n"
59
+
60
+ :JAVA_OPTS_SET
@@ -23,11 +23,11 @@
23
23
  require_relative 'monitor'
24
24
  require_relative 'twiddle'
25
25
 
26
- module JBoss
26
+ module RBoss
27
27
  module Twiddle
28
28
 
29
29
  class BaseMonitor
30
- include JBoss::Twiddle::Monitor
30
+ include RBoss::Twiddle::Monitor
31
31
 
32
32
  def initialize twiddle
33
33
  @twiddle = twiddle
@@ -22,7 +22,7 @@
22
22
 
23
23
  require_relative 'twiddle'
24
24
 
25
- module JBoss
25
+ module RBoss
26
26
  class MBean
27
27
 
28
28
  attr_reader :pattern
@@ -22,7 +22,7 @@
22
22
 
23
23
  require_relative 'mbean'
24
24
 
25
- module JBoss
25
+ module RBoss
26
26
  module Twiddle
27
27
 
28
28
  module Monitor
@@ -53,15 +53,14 @@ module JBoss
53
53
  :pattern => 'jboss.web:type=ThreadPool,name=#{resource}',
54
54
  :properties => %W(maxThreads currentThreadCount currentThreadsBusy),
55
55
  :header => ['Max Threads', 'Current Threads', 'Busy Threads'],
56
- :health => [
57
- {:column => :current_threads,
58
- :component => :percentage,
59
- :params => {
60
- :max => :max_threads,
61
- :using => :current_threads
62
- }
56
+ :health => {
57
+ :current_threads => {
58
+ :percentage => {
59
+ :max => :max_threads,
60
+ :using => :current_threads
61
+ }
63
62
  }
64
- ],
63
+ },
65
64
  :scan => proc do
66
65
  query "jboss.web:type=ThreadPool,*" do |path|
67
66
  path.gsub "jboss.web:type=ThreadPool,name=", ""
@@ -105,26 +104,18 @@ module JBoss
105
104
  :header => ["Active Threads", "Max Memory", "Free Memory",
106
105
  "Processors", "Java Vendor", "Java Version", "OS Name", "OS Arch"],
107
106
  :layout => :vertical,
108
- :format => [
109
- {
110
- :column => :max_memory,
111
- :component => :byte
112
- },
113
- {
114
- :column => :free_memory,
115
- :component => :byte
116
- }
117
- ],
118
- :health => [
119
- {
120
- :column => :free_memory,
121
- :component => :percentage,
122
- :params => {
107
+ :format => {
108
+ :max_memory => :byte,
109
+ :free_memory => :byte
110
+ },
111
+ :health => {
112
+ :free_memory => {
113
+ :percentage => {
123
114
  :max => :max_memory,
124
115
  :free => :free_memory
125
116
  }
126
117
  }
127
- ],
118
+ }
128
119
  },
129
120
  :server_config => {
130
121
  :description => 'JBoss Server configuration',
@@ -142,16 +133,14 @@ module JBoss
142
133
  :pattern => 'jboss.web:type=GlobalRequestProcessor,name=#{resource}',
143
134
  :properties => %W(requestCount errorCount maxTime),
144
135
  :header => ['Requests', 'Errors', 'Max Time'],
145
- :health => [
146
- {
147
- :column => :errors,
148
- :component => :percentage,
149
- :params => {
136
+ :health => {
137
+ :errors => {
138
+ :percentage => {
150
139
  :max => :requests,
151
140
  :using => :errors
152
141
  }
153
142
  }
154
- ],
143
+ },
155
144
  :scan => proc do
156
145
  query "jboss.web:type=ThreadPool,*" do |path|
157
146
  path.gsub "jboss.web:type=ThreadPool,name=", ""
@@ -165,16 +154,14 @@ module JBoss
165
154
  InUseConnectionCount ConnectionCount),
166
155
  :header => ["Min\nSize", "Max\nSize", "Avaliable\nConnections",
167
156
  "In Use\nConnections", "Connection\nCount"],
168
- :health => [
169
- {
170
- :column => :in_use_connections,
171
- :component => :percentage,
172
- :params => {
157
+ :health => {
158
+ :in_use_connections => {
159
+ :percentage => {
173
160
  :max => :max_size,
174
161
  :using => :in_use_connections
175
162
  }
176
163
  }
177
- ],
164
+ },
178
165
  :scan => proc do
179
166
  query "jboss.jca:service=ManagedConnectionPool,*" do |path|
180
167
  path.gsub "jboss.jca:service=ManagedConnectionPool,name=", ""
@@ -208,12 +195,12 @@ module JBoss
208
195
  end
209
196
 
210
197
  def monitor(mbean_id, params)
211
- mbeans[mbean_id] = JBoss::MBean::new params.merge(:twiddle => @twiddle)
198
+ mbeans[mbean_id] = RBoss::MBean::new params.merge(:twiddle => @twiddle)
212
199
  end
213
200
 
214
201
  def mbean(mbean_id)
215
202
  mbean = mbeans[mbean_id]
216
- return JBoss::MBean::new :pattern => mbean_id.to_s, :twiddle => @twiddle unless mbean
203
+ return RBoss::MBean::new :pattern => mbean_id.to_s, :twiddle => @twiddle unless mbean
217
204
  if @current_resource
218
205
  mbean.with @current_resource
219
206
  end
@@ -22,9 +22,10 @@
22
22
 
23
23
  require 'logger'
24
24
 
25
- module JBoss
25
+ module RBoss
26
26
  module Twiddle
27
27
  class Invoker
28
+ include RBoss::Platform
28
29
 
29
30
  attr_reader :server, :host, :port, :user, :password
30
31
  attr_accessor :command
@@ -48,7 +49,7 @@ module JBoss
48
49
  @user = params[:user]
49
50
  @password = params[:password]
50
51
 
51
- @command = "#{@jboss_home}/bin/twiddle.sh -s #{@server} -u '#{@user}' -p '#{@password}'"
52
+ @command = "#{twiddle} -s #{@server} -u '#{@user}' -p '#{@password}'"
52
53
 
53
54
  @logger = params[:logger]
54
55
  unless @logger
@@ -48,65 +48,3 @@ class Hash
48
48
  end)
49
49
  end
50
50
  end
51
-
52
- class TableBuilder
53
-
54
- def initialize(config)
55
- @config = config
56
- add_name_column if config[:scan]
57
- end
58
-
59
- def add_name_column(name = 'Name')
60
- @name_column = name
61
- end
62
-
63
- def show_only_name
64
- @only_name = true
65
- end
66
-
67
- def build_table
68
- table = Yummi::Table::new
69
- table.title = (@config[:title] or @config[:description])
70
- header = @config[:header]
71
- header = [@name_column] + header if @name_column
72
- if @config[:aliases]
73
- aliases = @config[:aliases]
74
- aliases = [:name] + aliases if @name_column
75
- table.aliases = aliases
76
- end
77
- table.header = header
78
- table.layout = @config[:layout].to_sym if @config[:layout]
79
-
80
- parse_component @config[:format], JBoss::Cli::Formatters do |column, params|
81
- table.format column, params
82
- end
83
- parse_component @config[:color], JBoss::Cli::Colorizers do |column, params|
84
- table.colorize column, params
85
- end
86
- parse_component @config[:health], JBoss::Cli::HealthCheckers do |column, params|
87
- table.using_row do
88
- table.colorize column, params
89
- end
90
- end
91
-
92
- table.header = [@name_column] if @only_name
93
-
94
- table.format_null :with => 'undefined'
95
- table.colorize_null :with => :red
96
-
97
- table.colorize :name, :with => :white if @name_column
98
-
99
- table
100
- end
101
-
102
- def parse_component(config, repository)
103
- if config
104
- config.each do |component_config|
105
- component = repository.send(component_config[:component]) unless component_config[:params]
106
- component ||= repository.send(component_config[:component], component_config[:params])
107
- yield(component_config[:column].to_sym, :using => component)
108
- end
109
- end
110
- end
111
-
112
- end
@@ -21,5 +21,5 @@
21
21
  # THE SOFTWARE.
22
22
 
23
23
  module RBoss
24
- VERSION = "0.6.0"
24
+ VERSION = "0.6.1"
25
25
  end
@@ -0,0 +1,20 @@
1
+ require 'yummi'
2
+
3
+ module RBoss
4
+ module Colorizers
5
+
6
+ def self.boolean params = {}
7
+ lambda do |value|
8
+ return (params[:if_true] or :green) if value
9
+ params[:if_false] or :brown
10
+ end
11
+ end
12
+
13
+ def self.with color
14
+ lambda do |value|
15
+ color
16
+ end
17
+ end
18
+
19
+ end
20
+ end
@@ -0,0 +1,21 @@
1
+ require 'yummi'
2
+
3
+ module RBoss
4
+ module Formatters
5
+
6
+ def self.yes_or_no
7
+ Yummi::Formatters.yes_or_no
8
+ end
9
+
10
+ def self.byte params = {}
11
+ Yummi::Formatters.byte params
12
+ end
13
+
14
+ def self.percentage
15
+ Yummi::to_format do |value|
16
+ "%.2f%%" % (value * 100)
17
+ end
18
+ end
19
+
20
+ end
21
+ end
@@ -0,0 +1,41 @@
1
+ require 'yummi'
2
+
3
+ module RBoss
4
+ module HealthCheckers
5
+
6
+ def self.percentage params
7
+ PercentageColorizer::new params
8
+ end
9
+
10
+ class PercentageColorizer
11
+
12
+ def initialize(params)
13
+ @max = params[:max]
14
+ @free = params[:free]
15
+ @using = params[:using]
16
+ @color = params[:color] || {
17
+ :bad => :red,
18
+ :warn => :brown,
19
+ :good => :green
20
+ }
21
+ @threshold = params[:threshold] || {
22
+ :warn => 0.30,
23
+ :bad => 0.15
24
+ }
25
+ end
26
+
27
+ def call(data)
28
+ max = data[@max.to_sym].to_f
29
+ free = @using ? max - data[@using.to_sym].to_f : data[@free.to_sym].to_f
30
+
31
+ percentage = free / max
32
+
33
+ return @color[:bad] if percentage <= @threshold[:bad]
34
+ return @color[:warn] if percentage <= @threshold[:warn]
35
+ @color[:good]
36
+ end
37
+
38
+ end
39
+
40
+ end
41
+ end
@@ -0,0 +1,93 @@
1
+ # The MIT License
2
+ #
3
+ # Copyright (c) 2011-2012 Marcelo Guimarães <ataxexe@gmail.com>
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ # of this software and associated documentation files (the "Software"), to deal
7
+ # in the Software without restriction, including without limitation the rights
8
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ # copies of the Software, and to permit persons to whom the Software is
10
+ # furnished to do so, subject to the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be included in
13
+ # all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ # THE SOFTWARE.
22
+
23
+ module RBoss
24
+ class TableBuilder
25
+
26
+ def initialize(config)
27
+ @config = config
28
+ add_name_column if config[:scan]
29
+ end
30
+
31
+ def add_name_column(name = 'Name')
32
+ @name_column = name
33
+ end
34
+
35
+ def show_only_name
36
+ @only_name = true
37
+ end
38
+
39
+ def build_table
40
+ table = Yummi::Table::new
41
+ table.title = (@config[:title] or @config[:description])
42
+ header = @config[:header]
43
+ header = [@name_column] + header if @name_column
44
+ if @config[:aliases]
45
+ aliases = @config[:aliases]
46
+ aliases = [:name] + aliases if @name_column
47
+ table.aliases = aliases
48
+ end
49
+ table.header = header if header
50
+ table.layout = @config[:layout].to_sym if @config[:layout]
51
+
52
+ parse_component @config[:format], RBoss::Formatters do |column, params|
53
+ table.format column, params
54
+ end
55
+ parse_component @config[:color], RBoss::Colorizers do |column, params|
56
+ table.colorize column, params
57
+ end
58
+ parse_component @config[:health], RBoss::HealthCheckers do |column, params|
59
+ table.using_row do
60
+ table.colorize column, params
61
+ end
62
+ end
63
+
64
+ table.header = [@name_column] if @only_name
65
+
66
+ table.format_null :with => 'undefined'
67
+ table.colorize_null :with => :red
68
+
69
+ table.colorize :name, :with => :white if @name_column
70
+
71
+ table
72
+ end
73
+
74
+ def parse_component(config, repository)
75
+ if config
76
+ config.each do |column, component_config|
77
+ component = nil
78
+ if component_config.is_a? Hash
79
+ component = Yummi::GroupedComponent::new
80
+ component_config.each do |component_name, params|
81
+ component << repository.send(component_name, params)
82
+ end
83
+ else
84
+ component = repository.send(component_config)
85
+ end
86
+ yield(column, :using => component)
87
+ end
88
+ end
89
+ end
90
+
91
+ end
92
+
93
+ end