rboss 0.1.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.
Files changed (51) hide show
  1. data/.gitignore +9 -0
  2. data/Gemfile +4 -0
  3. data/Rakefile +1 -0
  4. data/bin/jboss-profile +90 -0
  5. data/bin/twiddle +230 -0
  6. data/examples/jboss_profile/jbb_profile_1.yaml +32 -0
  7. data/examples/jboss_profile/jbb_profile_2.yaml +32 -0
  8. data/examples/jboss_profile/jboss_profile.yaml +7 -0
  9. data/examples/monitor/simple_monitor.rb +61 -0
  10. data/lib/rboss.rb +25 -0
  11. data/lib/rboss/component_processor.rb +177 -0
  12. data/lib/rboss/components/component.rb +52 -0
  13. data/lib/rboss/components/datasource.rb +198 -0
  14. data/lib/rboss/components/deploy_folder.rb +104 -0
  15. data/lib/rboss/components/hypersonic_replacer.rb +58 -0
  16. data/lib/rboss/components/jbossweb.rb +117 -0
  17. data/lib/rboss/components/jmx.rb +88 -0
  18. data/lib/rboss/components/mod_cluster.rb +81 -0
  19. data/lib/rboss/components/org/6.0/deploy_folder.rb +33 -0
  20. data/lib/rboss/components/org/jmx.rb +59 -0
  21. data/lib/rboss/components/profile_folder.rb +44 -0
  22. data/lib/rboss/components/resource.rb +53 -0
  23. data/lib/rboss/components/run_conf.rb +90 -0
  24. data/lib/rboss/components/run_conf.yaml +22 -0
  25. data/lib/rboss/components/service_script.rb +55 -0
  26. data/lib/rboss/components/slimming.rb +124 -0
  27. data/lib/rboss/components/soa-p/hypersonic_replacer.rb +79 -0
  28. data/lib/rboss/components/soa-p/jmx.rb +47 -0
  29. data/lib/rboss/components/xadatasource.rb +67 -0
  30. data/lib/rboss/file_processor.rb +107 -0
  31. data/lib/rboss/jboss_path.rb +53 -0
  32. data/lib/rboss/jboss_profile.rb +344 -0
  33. data/lib/rboss/resources/jboss_init_redhat.sh.erb +140 -0
  34. data/lib/rboss/resources/mod_cluster.sar/META-INF/mod_cluster-jboss-beans.xml +282 -0
  35. data/lib/rboss/resources/mod_cluster.sar/mod_cluster-1.1.2.Final.jar +0 -0
  36. data/lib/rboss/resources/run.conf.erb +62 -0
  37. data/lib/rboss/twiddle.rb +25 -0
  38. data/lib/rboss/twiddle/base_monitor.rb +57 -0
  39. data/lib/rboss/twiddle/mbean.rb +82 -0
  40. data/lib/rboss/twiddle/monitor.rb +144 -0
  41. data/lib/rboss/twiddle/scanner.rb +92 -0
  42. data/lib/rboss/twiddle/twiddle.rb +71 -0
  43. data/lib/rboss/utils.rb +33 -0
  44. data/lib/rboss/version.rb +25 -0
  45. data/rboss.gemspec +20 -0
  46. data/test/datasource_test.rb +211 -0
  47. data/test/deploy_folder_test.rb +126 -0
  48. data/test/mbean_test.rb +53 -0
  49. data/test/test_helper.rb +124 -0
  50. data/test/test_suite.rb +35 -0
  51. metadata +109 -0
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ out
2
+ rboss.iws
3
+ rboss.ipr
4
+ rboss.iml
5
+ *.gem
6
+ .bundle
7
+ Gemfile.lock
8
+ pkg/*
9
+ .rakeTasks
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in rboss.gemspec
4
+ gemspec
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require 'bundler/gem_tasks'
data/bin/jboss-profile ADDED
@@ -0,0 +1,90 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # The MIT License
4
+ #
5
+ # Copyright (c) 2011 Marcelo Guimarães <ataxexe@gmail.com>
6
+ #
7
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ # of this software and associated documentation files (the "Software"), to deal
9
+ # in the Software without restriction, including without limitation the rights
10
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ # copies of the Software, and to permit persons to whom the Software is
12
+ # furnished to do so, subject to the following conditions:
13
+ #
14
+ # The above copyright notice and this permission notice shall be included in
15
+ # all copies or substantial portions of the Software.
16
+ #
17
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23
+ # THE SOFTWARE.
24
+
25
+ require 'rboss'
26
+ require 'optparse'
27
+ require 'yaml'
28
+ require 'logger'
29
+
30
+ params = {}
31
+ params[:jboss_home] = Dir.pwd unless ENV["JBOSS_HOME"]
32
+ config = nil
33
+ create = true
34
+
35
+ opts = OptionParser::new
36
+ opts.on('-j', '--jboss-home PATH', 'Defines the JBOSS_HOME variable') do |home|
37
+ params[:jboss_home] = home
38
+ end
39
+ opts.on('-t', '--type TYPE', 'Defines the JBoss Type (org, eap, soa_p, epp)') do |type|
40
+ params[:type] = type.to_sym
41
+ end
42
+ opts.on('-v', '--version VERSION', 'Defines the JBoss version (5, 6, 5.1, ...)') do |version|
43
+ params[:version] = version
44
+ end
45
+ opts.on('-b', '--base-profile PROFILE', 'Defines the base profile') do |profile|
46
+ params[:base_profile] = profile
47
+ end
48
+ opts.on('-p', '--profile PROFILE', 'Defines the custom profile') do |profile|
49
+ params[:profile] = profile
50
+ end
51
+ opts.on('-u', '--update', 'Just update the profile folder') do
52
+ create = false
53
+ end
54
+ opts.on('-c', '--config-file FILE',
55
+ 'Defines the configuration file for the instance
56
+ (see the examples for more details)') do |yaml|
57
+ config_file = File.expand_path(yaml)
58
+ config = YAML::load File.open(config_file)
59
+ config.each do |c|
60
+ if c.is_a? Hash and c[:params]
61
+ c.delete(:params).each do |key, value|
62
+ params[key] = value
63
+ end
64
+ end
65
+ end
66
+ end
67
+ opts.on('-d', '--debug', '--verbose', 'Displays shell commands') do
68
+ include FileUtils::Verbose
69
+ params[:log_level] = Logger::DEBUG
70
+ end
71
+ opts.on("-h", "--help", "Shows this help message") { puts opts; exit }
72
+ opts.parse!(ARGV) rescue abort 'Invalid Option! Use --help or -h for usage help.'
73
+
74
+ profile = JBoss::Profile::new params
75
+
76
+ if config
77
+ config.each do |var|
78
+ if var.is_a? Hash
79
+ var.each do |key, value|
80
+ key = key.to_sym if key.is_a? String
81
+ profile.add key, value
82
+ end
83
+ else
84
+ profile.add var.to_sym
85
+ end
86
+ end
87
+ end
88
+
89
+ profile.create if create
90
+ profile.update unless create
data/bin/twiddle ADDED
@@ -0,0 +1,230 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # The MIT License
4
+ #
5
+ # Copyright (c) 2011 Marcelo Guimarães <ataxexe@gmail.com>
6
+ #
7
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ # of this software and associated documentation files (the "Software"), to deal
9
+ # in the Software without restriction, including without limitation the rights
10
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ # copies of the Software, and to permit persons to whom the Software is
12
+ # furnished to do so, subject to the following conditions:
13
+ #
14
+ # The above copyright notice and this permission notice shall be included in
15
+ # all copies or substantial portions of the Software.
16
+ #
17
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23
+ # THE SOFTWARE.
24
+
25
+ require 'rboss'
26
+ require 'optparse'
27
+ require 'yaml'
28
+
29
+ params = {}
30
+ resources = {}
31
+ list_only = false
32
+ params[:jboss_home] = Dir.pwd unless ENV["JBOSS_HOME"]
33
+ exec_file = nil
34
+ eval_expression = nil
35
+
36
+ opts = OptionParser::new
37
+ opts.on('-j', '--jboss-home PATH', 'Defines the JBOSS_HOME variable') do |home|
38
+ params[:jboss_home] = home
39
+ end
40
+ opts.on('-s', '--jboss-server URL', 'Defines the JBoss server') do |server|
41
+ params[:jboss_server] = server
42
+ end
43
+ opts.on('--jboss-host HOST', 'Defines the JBoss host') do |host|
44
+ params[:jboss_host] = host
45
+ end
46
+ opts.on('--jboss-port PORT', 'Defines the JBoss jnp port') do |port|
47
+ params[:jboss_port] = port
48
+ end
49
+ opts.on('-e', '--exec-file PATH',
50
+ 'Defines the ruby file to exec using the vars twiddle and monitor') do |path|
51
+ exec_file = File.expand_path path
52
+ end
53
+ opts.on('--eval EXPRESSION',
54
+ 'Evaluates the given expression using the vars twiddle and monitor') do |expression|
55
+ eval_expression = expression
56
+ end
57
+ opts.on('--show-all', 'Shows all resources available') do
58
+ [
59
+ :server_info,
60
+ :deployments,
61
+ :datasources,
62
+ :webapps,
63
+ :connectors,
64
+ :queues,
65
+ :ejbs
66
+ ].each do |option|
67
+ resources[option] = :all
68
+ end
69
+ end
70
+ opts.on('--server-info', 'Shows server information') do
71
+ resources[:server_info] = true
72
+ end
73
+ opts.on('--deployments', 'Shows deployments on server') do
74
+ resources[:deployments] = true
75
+ end
76
+ opts.on('--connectors [name_a, name_b, name_c, ...]', Array,
77
+ 'Defines the connectors to show or scan if not specified') do |connectors|
78
+ resources[:connectors] = connectors || :all
79
+ end
80
+ opts.on('--datasources [name_a, name_b, name_c, ...]', Array,
81
+ 'Defines the datasources to show or scan if not specified') do |datasources|
82
+ resources[:datasources] = datasources || :all
83
+ end
84
+ opts.on('--ejbs [name_a, name_b, name_c, ...]', Array,
85
+ 'Defines the EJBs to show or scan if not specified') do |ejbs|
86
+ resources[:ejbs] = ejbs || :all
87
+ end
88
+ opts.on('--queues [name_a, name_b, name_c, ...]', Array,
89
+ 'Defines the JMS queues to show or scan if not specified') do |queues|
90
+ resources[:queues] = queues || :all
91
+ end
92
+ opts.on('--webapps [name_a, name_b, name_c, ...]', Array,
93
+ 'Defines the webapps to show or scan if not specified') do |webapps|
94
+ resources[:webapps] = webapps || :all
95
+ end
96
+ opts.on('--system-properties [name_a, name_b, name_c, ...]', Array,
97
+ 'Defines the System properties to show or scan if not specified') do |properties|
98
+ resources[:system_properties] = properties || :all
99
+ end
100
+ opts.on('--list', 'Only lists the required info (datasources, queues, ...)') do
101
+ list_only = true
102
+ end
103
+ opts.on('-u', '--jmx-user USER', 'Defines the JMX User') do |user|
104
+ params[:jmx_user] = user
105
+ end
106
+ opts.on('-p', '--jmx-password PASSWORD', 'Defines the JMX Password') do |password|
107
+ params[:jmx_password] = password
108
+ end
109
+ opts.on("-h", "--help", "Shows this help message") do
110
+ puts opts; exit
111
+ end
112
+ opts.parse!(ARGV) rescue abort 'Invalid Option! Use --help or -h for usage help.'
113
+
114
+ twiddle = JBoss::Twiddle::Invoker::new params
115
+ monitor = twiddle.monitor
116
+
117
+ if resources.empty? and not (exec_file or eval_expression)
118
+ puts opts
119
+ exit
120
+ end
121
+
122
+ eval File.read(exec_file), binding, exec_file if exec_file
123
+
124
+ puts (eval eval_expression, binding) if eval_expression
125
+
126
+ if resources[:server_info]
127
+ puts "Server Info:"
128
+ monitor.properties[:server].each do |property|
129
+ puts " - #{monitor.server[property]}"
130
+ end
131
+ monitor.properties[:server_info].each do |property|
132
+ puts " - #{monitor.server_info[property]}"
133
+ end
134
+ end
135
+ if resources[:system_properties]
136
+ puts "System Properties:"
137
+ properties = resources[:system_properties]
138
+ if properties == :all
139
+ properties = monitor.system_properties.showAll
140
+ puts properties
141
+ else
142
+ properties.each do |property|
143
+ puts " - #{property}=#{monitor.system_properties.get(property)}"
144
+ end
145
+ end
146
+ end
147
+ if resources[:deployments]
148
+ puts "Deployments:"
149
+ monitor.deployments.each do |deployment|
150
+ puts " - #{deployment}"
151
+ end
152
+ end
153
+ if resources[:connectors]
154
+ puts "Connectors:"
155
+ connectors = resources[:connectors]
156
+ connectors = monitor.connectors if connectors == :all
157
+ connectors.each do |connector|
158
+ monitor.with connector do
159
+ puts " - #{connector}"
160
+ unless list_only
161
+ monitor.properties[:connector].each do |property|
162
+ puts " - #{monitor.connector[property]}"
163
+ end
164
+ monitor.properties[:request].each do |property|
165
+ puts " - #{monitor.request[property]}"
166
+ end
167
+ end
168
+ end
169
+ end
170
+ end
171
+ if resources[:datasources]
172
+ puts "Datasources:"
173
+ datasources = resources[:datasources]
174
+ datasources = monitor.datasources if datasources == :all
175
+ datasources.each do |datasource|
176
+ monitor.with datasource do
177
+ puts " - #{datasource}"
178
+ unless list_only
179
+ monitor.properties[:datasource].each do |property|
180
+ puts " - #{monitor.datasource[property]}"
181
+ end
182
+ end
183
+ end
184
+ end
185
+ end
186
+ if resources[:webapps]
187
+ puts "Webapps:"
188
+ webapps = resources[:webapps]
189
+ webapps = monitor.webapps if webapps == :all
190
+ webapps.each do |webapp|
191
+ monitor.with webapp do
192
+ puts " - #{webapp}"
193
+ unless list_only
194
+ monitor.properties[:webapp].each do |property|
195
+ puts " - #{monitor.webapp[property]}"
196
+ end
197
+ end
198
+ end
199
+ end
200
+ end
201
+ if resources[:ejbs]
202
+ puts "EJBs:"
203
+ ejbs = resources[:ejbs]
204
+ ejbs = monitor.ejbs if ejbs == :all
205
+ ejbs.each do |ejb|
206
+ monitor.with ejb do
207
+ puts " - #{ejb}"
208
+ unless list_only
209
+ monitor.properties[:ejb].each do |property|
210
+ puts " - #{monitor.ejb[property]}"
211
+ end
212
+ end
213
+ end
214
+ end
215
+ end
216
+ if resources[:queues]
217
+ puts "Queues:"
218
+ queues = resources[:queues]
219
+ queues = monitor.queues if queues == :all
220
+ queues.each do |queue|
221
+ monitor.with queue do
222
+ puts " - #{queue}"
223
+ unless list_only
224
+ monitor.properties[:queue].each do |property|
225
+ puts " - #{monitor.queue[property]}"
226
+ end
227
+ end
228
+ end
229
+ end
230
+ end
@@ -0,0 +1,32 @@
1
+ - :params:
2
+ :type: org
3
+ :version: 5.1
4
+ :base_profile: all
5
+ :profile: jbb1
6
+ - mod_cluster
7
+ - jms:
8
+ :peer_id: 1
9
+ - deploy_folder: deploy/datasources
10
+ - deploy_folder: deploy/apps
11
+ - resource:
12
+ lib: ~/jdbc/postgresql/postgresql.jar
13
+ - jmx:
14
+ :password: jbb
15
+ - default_ds:
16
+ :type: postgres
17
+ :attributes:
18
+ :user_name: postgres
19
+ :password: postgres
20
+ :connection_url: jdbc:postgresql://localhost:5432/jboss_org_db
21
+ :min_pool_size: 5
22
+ :max_pool_size: 15
23
+ - jboss_web:
24
+ :connectors:
25
+ ajp:
26
+ :max_threads: 600
27
+ - run_conf:
28
+ :heap_size: 1024m
29
+ :perm_size: 512m
30
+ :stack_size: 128k
31
+ - slimming:
32
+ - web_console
@@ -0,0 +1,32 @@
1
+ - :params:
2
+ :type: org
3
+ :version: 5.1
4
+ :base_profile: all
5
+ :profile: jbb1
6
+ - mod_cluster
7
+ - jms:
8
+ :peer_id: 2
9
+ - deploy_folder: deploy/datasources
10
+ - deploy_folder: deploy/apps
11
+ - resource:
12
+ lib: ~/jdbc/postgresql/postgresql.jar
13
+ - jmx:
14
+ :password: jbb
15
+ - default_ds:
16
+ :type: postgres
17
+ :attributes:
18
+ :user_name: postgres
19
+ :password: postgres
20
+ :connection_url: jdbc:postgresql://localhost:5432/jboss_org_db
21
+ :min_pool_size: 5
22
+ :max_pool_size: 15
23
+ - jboss_web:
24
+ :connectors:
25
+ ajp:
26
+ :max_threads: 600
27
+ - run_conf:
28
+ :heap_size: 1024m
29
+ :perm_size: 512m
30
+ :stack_size: 128k
31
+ - slimming:
32
+ - web_console
@@ -0,0 +1,7 @@
1
+ - deploy_folder: deploy/datasources
2
+ - deploy_folder: deploy/apps
3
+ - jmx
4
+ - run_conf:
5
+ :heap_size: 1024m
6
+ :perm_size: 512m
7
+ :debug: :socket
@@ -0,0 +1,61 @@
1
+ # The MIT License
2
+ #
3
+ # Copyright (c) 2011 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
+ puts "Server Info:"
24
+ monitor.properties[:server_info].each do |property|
25
+ puts " |--> #{monitor.server_info[property]}"
26
+ end
27
+
28
+ puts "Connectors:"
29
+ monitor.with :connectors do |connector|
30
+ puts " |--> #{connector}"
31
+ monitor.properties[:connector].each do |property|
32
+ puts " |--> #{monitor.connector[property]}"
33
+ end
34
+ monitor.properties[:request].each do |property|
35
+ puts " |--> #{monitor.request[property]}"
36
+ end
37
+ end
38
+
39
+ puts "Datasources:"
40
+ monitor.with :datasources do |datasource|
41
+ puts " |--> #{datasource}"
42
+ monitor.properties[:datasource].each do |property|
43
+ puts " |--> #{monitor.datasource[property]}"
44
+ end
45
+ end
46
+
47
+ puts "Webapps:"
48
+ monitor.with :webapps do |webapp|
49
+ puts " |--> #{webapp}"
50
+ monitor.properties[:webapp].each do |property|
51
+ puts " |--> #{monitor.webapp[property]}"
52
+ end
53
+ end
54
+
55
+ puts "Queues:"
56
+ monitor.with :queues do |queue|
57
+ puts " |--> #{queue}"
58
+ monitor.properties[:queue].each do |property|
59
+ puts " |--> #{monitor.queue[property]}"
60
+ end
61
+ end