JBoss Community Archive (Read Only)

RHQ 4.9

Adding Server Configuration

There are two kinds of server configuration settings:

  1. Individual Server Configuration Settings

    • These are settings found in rhq-server.properties

    • These settings take effect for a single server - the server where the .properties file is installed.

    • Because these settings take effect on a server-by-server basis, you will want a configuration setting to be here if you want to allow each server to have its own, potentially different value compared to other servers in the cloud. Things like IP bind addresses, bind port numbers and the like are typically candidates to be individual server configuration settings.

    • These take effect only when you restart a server - changing this file while the server is running has no effect on that running server.

    • These become system properties and are therefore accessible to the server via System.getProperty

    • You can use these values in the jbossas service .xml files via "${rhq.server.property.name.here}"

    • This file is passed to JBossAS via the -p command line argument

  2. Server Cloud Configuration Settings

    • These are settings found in the RHQ_SYSTEM_CONFIG database type

    • These are set when you change their values in the Administration > ServerConfiguration UI page

    • These settings are applied to all servers in the cloud. Each server in the cloud therefore cannot have different values for a server cloud configuration setting - the same value applies to all the servers

    • Typically, changing the value of server-cloud configuration setting via the Administration > ServerConfiguration UI page takes effect immediately. There may be exceptions to this rule, however. But, we should try our best to get these settings to take immediate effect when they are changed.

    • These settings are accessed via the SystemManager SLSB (SystemManagerLocal.getSystemConfiguration returns a Properties object containing the server cloud settings).

Adding a new Individual Server Configuration Setting

It is very easy to add a new individual server configuration setting - just add the "name=value" property to the rhq-container.build.xml (in the place where that build file writes out the default rhq-server.properties file). At this point, you are free to use System.getProperty anywhere in the server code to retrieve the value of the configuration setting. You are also free to use that setting in a JBossAS service .xml file found in the deploy/ directory or its subdirectories (via "${rhq.server.property.name.here}")

If you add a setting to the rhq-server.properties, consider providing a mechanism by which the rhq-server-plugin can set it. This way, if you import an RHQ Server JBossAS resource into inventory, you can change the value of your new setting via the Config tab.

Some of these settings need to be defined at the time the server is installed. If this is the case, you need to add code to the installer to have the installer provide a text field for the user to enter a value for your new setting (or provide a default value if the user doesn't change the value). You will want to add code to the class org.rhq.enterprise.installer.ServerProperties and/or ConfigurationBean, found in the install-war module.

Adding a new Server Cloud Configuration Setting

More development effort is required in order to add a new server cloud configuration setting. It involves adding GUI code to allow the user to view and modify the value from the Administration > ServerConfiguration page, and some Java code to integrate that UI page with the backend storage code.

The following provides a basic set of step-by-step instructions you should follow in order to properly add a new server cloud configuration setting to the RHQ Server:

  1. Add a constant that defines the name of the new setting. Right now, we can add them to HQConstants, but that class is deprecated - we should refactor these into some other class outside the legacy code.

    • Constant Definition
      public static final String AgentMaxQuietTimeAllowed = "AGENT_MAX_QUIET_TIME_ALLOWED";
  2. If you want the setting to be set at the time the installer installs the database, you need to add your new row to RHQ_SYSTEM_CONFIG in sysconfig-data.xml (for dbsetup) and to db-upgrade.xml (for db ugrades).

    • sysconfig-data.xml
      <!-- How long an agent is allowed to be quiet before we consider it down and backfill it -->
                    DEFAULT_PROPERTY_VALUE="120000" FREAD_ONLY="FALSE"/>
    • db-upgrade.xml
         <schemaSpec version="2.27">
               <statement desc="Adding Agent Max Quiet Time Allowed system configuration setting">
                  INSERT INTO rhq_system_config (id, property_key, property_value, default_property_value)
                         VALUES (52, 'AGENT_MAX_QUIET_TIME_ALLOWED', '120000', '120000')
    • Do not forget to edit the dbutil module's pom.xml file to bump up the db schema version.

  3. Add the new setting to the SystemConfigForm class located at enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/config. You'll want to create two variables to represent your one setting. See "agentMaxQuietTimeAllowed" and "agentMaxQuietTimeAllowedVal" as examples.

  4. Add the UI components (labels, text fields, drop down menus) to the server configuration UI .jsp page located at enterprise/gui/portal-war/src/main/webapp/admin/config/EditServerConfigForm.jsp. Do not forget to add the label text to enterprise/gui/portal-war/src/main/webapp-filtered/WEB-INF/classes/ApplicationResources.properties

  5. At this point, your server cloud configuration setting has been added. To access it, your server-side code should look something like this (note: SLSB's should use @EJB injection, other places, like Quartz jobs or MBeans, should use the LookupUtil):

    @EJB private SystemManagerLocal systemManager;
    // using the EJB injected manager
    // using LookupUtil
JBoss.org Content Archive (Read Only), exported from JBoss Community Documentation Editor at 2020-03-13 08:06:02 UTC, last content change 2013-09-18 19:41:44 UTC.