Class: RBoss::Profile

Inherits:
ComponentProcessor show all
Includes:
Platform
Defined in:
lib/rboss/jboss_profile.rb

Overview

A Class to configure a JBoss Profile

Basically, this class is a Component Processor with some components added to configure a JBoss profile, the built-in components are:

:deploy_folder => binded to a RBoss::DeployFolder

:cluster => a shortcut component for :run_conf, sends these attributes to it:

:multicast_ip   => default "239.255.0.1"
:partition_name => default "${profile name}-partition

:jms => a shortcut component for :run_conf, sends these attributes to it:

:peer_id

:bind => a shortcut component, sends these attributes:

To :run_conf
  :ports        => sends as :service_binding
To :init_script
  :address      => default "localhost", sends as :bind_address

:resource => binded to a RBoss::Resource

:jmx => binded to a RBoss::JMX, enabled by default and sends user and password

values to :init_script

:datasource => binded to a RBoss::Datasource

:xa_datasource => binded to a RBoss::XADatasource

:default_ds => binded to a RBoss::HypersonicReplacer

:mod_cluster => binded to a RBoss::ModCluster

Defaults:
  :path => "resources/mod_cluster.sar"
Move to :run_conf (for externalizing mod_cluster configuration)
  :advertise
  :advertise_group_address
  :advertise_port
  :proxy_list
  :excluded_contexts
  :auto_enable_contexts

:run_conf => binded to a RBoss::RunConf

Defaults:
  :path => 'resources/run.conf.erb'
  :stack_size => '128k'
  :heap_size => '2048m'
  :perm_size => '256m'

:slimming => binded to a RBoss::Slimming

:init_script => binded to a RBoss::ServiceScritp

Defaults:
  :path => 'resources/jboss_init_redhat.sh'
  :jmx_user => "admin"
  :jmx_password => "admin"
  :bind_address => "0.0.0.0"
  :java_path => "/usr/java/default"
  :jnp_port => 1099
  :jboss_user => "RUNASIS"

author Marcelo Guimarães <[email protected]>

Constant Summary collapse

@@pre_install =

Priorities for components

0
@@install =
@@pre_install + 10
@@post_install =
@@install + 10
@@pre_setup =
@@post_install + 10
@@setup =
@@pre_setup + 10
@@post_setup =
@@setup + 10
@@final =
@@post_setup + 10

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Platform

#clear, #jboss_cli, #run_conf, #run_conf_template, #twiddle

Methods inherited from ComponentProcessor

#add, #defaults, #process_components, #register

Constructor Details

#initialize(opts = {}) ⇒ Profile

Returns a new instance of Profile.



113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
# File 'lib/rboss/jboss_profile.rb', line 113

def initialize opts = {}
  block = lambda { |type, config| type.new(@jboss, @logger, config).process }
  super &block
  @base_dir = File.dirname(__FILE__)
  @opts = {
    :jboss_home => ENV['JBOSS_HOME'],
    :base_profile => :production,
    :profile => :custom,
    :type => :undefined,
    :version => :undefined
  }.merge! opts
  @jboss_home = File.expand_path @opts[:jboss_home]
  @logger = @opts[:logger]
  unless @logger
    @logger = Logger::new STDOUT
    @logger.level = opts[:log_level] || Logger::INFO
    formatter = Yummi::Formatter::LogFormatter.new do |severity, message|
      "#{severity} : #{message}"
    end

    @logger.formatter = formatter
  end
  @profile = @opts[:profile].to_s
  @base_profile = @opts[:base_profile].to_s
  @jboss = RBoss::Path::new @jboss_home,
                            :profile => @profile,
                            :type => @opts[:type],
                            :version => @opts[:version],
                            :logger => @logger
  initialize_components
end

Instance Attribute Details

#jbossObject (readonly)

Returns the value of attribute jboss.



111
112
113
# File 'lib/rboss/jboss_profile.rb', line 111

def jboss
  @jboss
end

Instance Method Details

#createObject



145
146
147
148
# File 'lib/rboss/jboss_profile.rb', line 145

def create
  add :profile_folder, @base_profile
  process_components
end

#initialize_componentsObject



198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
# File 'lib/rboss/jboss_profile.rb', line 198

def initialize_components
  load_scripts
  load_extensions

  register :cluster,

           :priority => @@pre_install,
           :move_config => {
             :to_run_conf => [:multicast_ip, :partition_name],
             :to_jboss_web => [:jvm_route],
             :to_jms => [:peer_id]
           },
           :defaults => {
             :multicast_ip => "239.255.0.1",
             :partition_name => "#{@profile}-partition",
             :jvm_route => "#{@profile}"
           }

  register :jms,

           :priority => @@pre_install,
           :move_config => {
             :to_run_conf => [:peer_id]
           }

  register :bind,

           :priority => @@pre_install,
           :send_config => {
             :to_init_script => {
               :address => :bind_address
             }
           },
           :move_config => {
             :to_run_conf => {
               :ports => :service_binding
             }
           },
           :defaults => {
             :address => 'localhost'
           }

  register :profile_folder,
           :type => RBoss::ProfileFolder,
           :priority => @@install

  register :deploy_folder,

           :type => RBoss::DeployFolder,
           :priority => @@post_install,
           :multiple_instances => true


  register :resource,

           :type => RBoss::Resource,
           :priority => @@pre_setup,
           :multiple_instances => true

  register :jmx,

           :type => RBoss::JMX,
           :priority => @@setup,
           :send_config => {
             :to_init_script => {
               :password => :jmx_password,
               :user => :jmx_user
             }
           }

  register :datasource,

           :type => RBoss::Datasource,
           :priority => @@setup,
           :multiple_instances => true

  register :xa_datasource,

           :type => RBoss::XADatasource,
           :priority => @@setup,
           :multiple_instances => true

  register :default_ds,

           :type => RBoss::HypersonicReplacer,
           :priority => @@setup

  register :mod_cluster,

           :type => RBoss::ModCluster,
           :priority => @@setup,
           :move_config => {
             :to_run_conf => [
               :advertise,
               :advertise_group_address,
               :advertise_port,
               :proxy_list,
               :excluded_contexts,
               :auto_enable_contexts
             ]
           },
           :defaults => {
             :path => "#{@base_dir}/resources/mod_cluster.sar",
           }

  register :jbossweb,

           :type => RBoss::JBossWeb,
           :priority => @@setup

  register :run_conf,

           :type => RBoss::RunConf,
           :priority => @@post_setup,
           :send_config => {
             :to_init_script => [:service_binding]
           },
           :defaults => {
             :template_path => run_conf_template,

             :stack_size => '128k',
             :heap_size => '2048m',
             :perm_size => '256m'
           }

  register :slimming,

           :type => RBoss::Slimming,
           :priority => @@post_setup

  register :restore,

           :type => RBoss::Restore,
           :priority => @@post_setup + 5

  register :init_script,

           :type => RBoss::ServiceScript,
           :priority => @@final,
           :defaults => {
             :path => "#{@base_dir}/resources/jboss_init_redhat.sh.erb",
             :jmx_user => "admin",
             :jmx_password => "admin",
             :bind_address => "0.0.0.0",
             :java_path => "/usr/java/default",
             :jnp_port => 1099,
             :jboss_user => "RUNASIS"
           }
end

#load_extensionsObject

loads extensions to components based on the type of jboss (eap, soa-p, org, epp…)



170
171
172
173
174
175
176
177
178
179
# File 'lib/rboss/jboss_profile.rb', line 170

def load_extensions
  unless @jboss.type == :undefined
    dir = File.join(@base_dir, "components", @jboss.type.to_s.gsub(/_/, '-'))
    load_scripts_in dir
    unless @jboss.version == :undefined
      dir = File.join(dir, @jboss.version.to_s)
      load_scripts_in dir
    end
  end
end

#load_scriptsObject

Loads manually every script related to jboss. This is necessary to reset the components to its natural state



191
192
193
194
195
196
# File 'lib/rboss/jboss_profile.rb', line 191

def load_scripts
  scripts = Dir.entries("#{@base_dir}/components").find_all { |f| f.end_with?('.rb') }
  scripts.each do |script|
    load File.expand_path(@base_dir) + "/components/" + script
  end
end

#load_scripts_in(dir) ⇒ Object



181
182
183
184
185
186
187
188
# File 'lib/rboss/jboss_profile.rb', line 181

def load_scripts_in dir
  if File.exists? dir
    scripts = Dir.entries(dir).find_all { |f| f.end_with? '.rb' }
    scripts.each do |script|
      load File.join(dir, script)
    end
  end
end

#slim(*args) ⇒ Object

For making code more readable

example: profile.slim :jmx_console, :admin_console



165
166
167
# File 'lib/rboss/jboss_profile.rb', line 165

def slim *args
  add :slimming, args
end