[rhq] Branch 'drift' - 2 commits - modules/core modules/enterprise modules/test-utils
by John Sanda
modules/core/dbutils/pom.xml | 2
modules/core/dbutils/src/main/scripts/dbsetup/sysconfig-data.xml | 6
modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml | 16
modules/core/domain/mvn.out | 194 ----------
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/SystemSettingsView.java | 41 +-
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/RHQConstants.java | 4
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/drift/DriftServerPluginManager.java | 86 ++++
modules/test-utils/src/main/java/org/rhq/test/JPAUtils.java | 2
8 files changed, 150 insertions(+), 201 deletions(-)
New commits:
commit 9aecf5f44f150b18a2454182d12827a52e16f49f
Author: John Sanda <jsanda(a)redhat.com>
Date: Wed Jul 27 14:50:44 2011 -0400
Making the active drift server plugin configurable via system settings
When a drift serer plugin is loaded or unloaded, it is added to or
removed from the systems settings. When the DriftServerBean (SLSB
layers) asks for the drift plugin, the DriftServerPlugin queries the
system settings to find the active drift server plugin. The drift-rhq
plugin is active by default.
diff --git a/modules/core/dbutils/pom.xml b/modules/core/dbutils/pom.xml
index 39f0798..e2a599d 100644
--- a/modules/core/dbutils/pom.xml
+++ b/modules/core/dbutils/pom.xml
@@ -22,7 +22,7 @@
<properties>
<scm.module.path>modules/core/dbutils/</scm.module.path>
- <db.schema.version>2.111</db.schema.version>
+ <db.schema.version>2.112</db.schema.version>
</properties>
<dependencies>
diff --git a/modules/core/dbutils/src/main/scripts/dbsetup/sysconfig-data.xml b/modules/core/dbutils/src/main/scripts/dbsetup/sysconfig-data.xml
index 121e971..6d0e80a 100644
--- a/modules/core/dbutils/src/main/scripts/dbsetup/sysconfig-data.xml
+++ b/modules/core/dbutils/src/main/scripts/dbsetup/sysconfig-data.xml
@@ -125,6 +125,12 @@
<data ID="56" PROPERTY_KEY="RESOURCE_GENERIC_PROPERTIES_UPGRADE" PROPERTY_VALUE="false"
DEFAULT_PROPERTY_VALUE="false" FREAD_ONLY="FALSE"/>
+ <!-- default drift server plugin settings -->
+ <data ID="57" PROPERTY_KEY="ACTIVE_DRIFT_PLUGIN" PROPERTY_VALUE="[drift-rhq$$Drift:RHQ]"
+ DEFAULT_PROPERTY_VALUE="[drift-rhq$$Drift:RHQ]" FREAD_ONLY="FALSE"/>
+ <data ID="58" PROPERTY_KEY="DRIFT_PLUGINS" PROPERTY_VALUE="" DEFAULT_PROPERTY_VALUE="[drift-rhq$$Drift:RHQ]"
+ FREAD_ONLY="FALSE"/>
+
</table>
</dbsetup>
diff --git a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
index 7e38d96..2b1097d 100644
--- a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
+++ b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
@@ -3586,6 +3586,22 @@
</schema-directSQL>
</schemaSpec>
+ <schemaSpec version="2.112">
+ <schema-directSQL>
+ <statement desc="Adding drift server plugin active plugin system configuration property">
+ INSERT INTO rhq_system_config (id, property_key, property_value, default_property_value)
+ VALUES (57, 'ACTIVE_DRIFT_PLUGIN', '[drift-rhq$$Drift:RHQ]', '[drift-rhq$$Drift:RHQ]')
+ </statement>
+ </schema-directSQL>
+
+ <schema-directSQL>
+ <statement desc="Adding drift server plugin plugins system configuration property">
+ INSERT INTO rhq_system_config (id, property_key, property_value, default_property_value)
+ VALUES (58, 'DRIFT_PLUGINS', '', '[drift-rhq$$Drift:RHQ]')
+ </statement>
+ </schema-directSQL>
+ </schemaSpec>
+
</dbupgrade>
</target>
</project>
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/SystemSettingsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/SystemSettingsView.java
index 5e83850..ac861b0 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/SystemSettingsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/SystemSettingsView.java
@@ -19,8 +19,10 @@
package org.rhq.enterprise.gui.coregui.client.admin;
+import java.util.ArrayList;
import java.util.EnumSet;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import com.google.gwt.user.client.rpc.AsyncCallback;
@@ -38,6 +40,7 @@ import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
import org.rhq.core.domain.configuration.definition.PropertyDefinition;
+import org.rhq.core.domain.configuration.definition.PropertyDefinitionEnumeration;
import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple;
import org.rhq.core.domain.configuration.definition.PropertyGroupDefinition;
import org.rhq.core.domain.configuration.definition.PropertySimpleType;
@@ -99,6 +102,9 @@ public class SystemSettingsView extends LocatableVLayout implements PropertyValu
String LDAPBaseDN = "CAM_LDAP_BASE_DN";
String LDAPBindDN = "CAM_LDAP_BIND_DN";
String LDAPBindPW = "CAM_LDAP_BIND_PW";
+
+ String ACTIVE_DRIFT_PLUGIN = "ACTIVE_DRIFT_PLUGIN";
+ String DRIFT_PLUGINS = "DRIFT_PLUGINS";
}
public SystemSettingsView(String locatorId) {
@@ -128,6 +134,7 @@ public class SystemSettingsView extends LocatableVLayout implements PropertyValu
canvas.addMember(getServerDetails());
Configuration config = new Configuration();
+ String[] driftPlugins = null;
for (Map.Entry<String, String> entry : result.entrySet()) {
String name = entry.getKey();
String value = (entry.getValue() == null) ? "" : entry.getValue();
@@ -166,6 +173,9 @@ public class SystemSettingsView extends LocatableVLayout implements PropertyValu
if (value.trim().length() == 0) {
value = "true";
}
+ } else if (Constant.DRIFT_PLUGINS.equals(name)) {
+ driftPlugins = value.split(",");
+ continue;
}
PropertySimple prop = new PropertySimple(name, value);
@@ -173,8 +183,8 @@ public class SystemSettingsView extends LocatableVLayout implements PropertyValu
}
// build our config definition and populate our config editor
- editor = new ConfigurationEditor(extendLocatorId("configEditor"), getSystemSettingsDefinition(config),
- config);
+ editor = new ConfigurationEditor(extendLocatorId("configEditor"), getSystemSettingsDefinition(config,
+ driftPlugins), config);
editor.addPropertyValueChangeListener(SystemSettingsView.this);
canvas.addMember(editor);
@@ -305,7 +315,7 @@ public class SystemSettingsView extends LocatableVLayout implements PropertyValu
*
* @return system settings config def
*/
- private ConfigurationDefinition getSystemSettingsDefinition(Configuration config) {
+ private ConfigurationDefinition getSystemSettingsDefinition(Configuration config, String[] driftPlugins) {
ConfigurationDefinition def = new ConfigurationDefinition("sysset", MSG.view_adminConfig_systemSettings());
///////////////////////////////////
@@ -519,6 +529,31 @@ public class SystemSettingsView extends LocatableVLayout implements PropertyValu
ldapBindPW.setDefaultValue("");
def.put(ldapBindPW);
+ ///////////////////////////////////////////
+ // Drift Server Configuration Properties //
+ ///////////////////////////////////////////
+ PropertyGroupDefinition driftGroup = new PropertyGroupDefinition("drift server");
+ driftGroup.setDisplayName("Drift Server Configuration Settings");
+ driftGroup.setOrder(4);
+ driftGroup.setDefaultHidden(false);
+
+ PropertyDefinitionSimple activeDriftServer = new PropertyDefinitionSimple("ACTIVE_DRIFT_PLUGIN",
+ "The drift server plugin that manages the persistence of drift-related entities and content", true,
+ PropertySimpleType.STRING);
+ activeDriftServer.setDisplayName("Active Drift Server Plugin");
+ activeDriftServer.setPropertyGroupDefinition(driftGroup);
+
+ List<PropertyDefinitionEnumeration> options = new ArrayList<PropertyDefinitionEnumeration>();
+ for (String plugin : driftPlugins) {
+ // plugin is of the form, [plugin_name$$plugin_display_name]]
+ String pluginName = plugin.substring(1, plugin.indexOf("$$"));
+ String pluginDisplayName = plugin.substring(pluginName.length() + 3, plugin.indexOf("]"));
+ options.add(new PropertyDefinitionEnumeration(pluginDisplayName, plugin));
+ }
+ activeDriftServer.setEnumeratedValues(options, false);
+
+ def.put(activeDriftServer);
+
//
// if the config is missing any properties for which we have defaults, set them to their defaults
//
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/RHQConstants.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/RHQConstants.java
index e992271..63037c1 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/RHQConstants.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/RHQConstants.java
@@ -49,6 +49,10 @@ public class RHQConstants {
public static final String LDAPBindDN = "CAM_LDAP_BIND_DN";
public static final String LDAPBindPW = "CAM_LDAP_BIND_PW";
+ // DRIFT Server properties
+ public static final String ACTIVE_DRIFT_PLUGIN = "ACTIVE_DRIFT_PLUGIN";
+ public static final String DRIFT_PLUGINS = "DRIFT_PLUGINS";
+
// Base URL for the application - (i think this is only used for alert emails)
public static final String BaseURL = "CAM_BASE_URL";
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/drift/DriftServerPluginManager.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/drift/DriftServerPluginManager.java
index 8e00b0c..9e405ec 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/drift/DriftServerPluginManager.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/drift/DriftServerPluginManager.java
@@ -18,11 +18,23 @@
*/
package org.rhq.enterprise.server.plugin.pc.drift;
+import java.util.List;
+import java.util.Properties;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.rhq.enterprise.server.auth.SubjectManagerLocal;
import org.rhq.enterprise.server.plugin.pc.ServerPluginEnvironment;
import org.rhq.enterprise.server.plugin.pc.ServerPluginManager;
+import org.rhq.enterprise.server.system.SystemManagerLocal;
+import org.rhq.enterprise.server.util.LookupUtil;
+import org.rhq.enterprise.server.xmlschema.generated.serverplugin.ServerPluginDescriptorType;
+
+import static org.rhq.core.domain.util.StringUtils.getListAsString;
+import static org.rhq.core.domain.util.StringUtils.getStringAsList;
+import static org.rhq.enterprise.server.RHQConstants.ACTIVE_DRIFT_PLUGIN;
+import static org.rhq.enterprise.server.RHQConstants.DRIFT_PLUGINS;
/**
* This loads in all drift server plugins that can be found. You can obtain a loaded plugin's
@@ -32,6 +44,7 @@ import org.rhq.enterprise.server.plugin.pc.ServerPluginManager;
* @author John Sanda
*/
public class DriftServerPluginManager extends ServerPluginManager {
+
private final Log log = LogFactory.getLog(this.getClass());
public DriftServerPluginManager(DriftServerPluginContainer pc) {
@@ -39,7 +52,76 @@ public class DriftServerPluginManager extends ServerPluginManager {
}
public DriftServerPluginFacet getDriftServerPluginComponent() {
- // TODO The name of the drift server plugin probably will need to be obtained from the system config
- return (DriftServerPluginFacet) getServerPluginComponent("drift-rhq");
+ Properties sysConfig = getSysConfig();
+ String value = sysConfig.getProperty(ACTIVE_DRIFT_PLUGIN);
+
+ if (value == null) {
+ throw new RuntimeException(ACTIVE_DRIFT_PLUGIN + " system configuration property is not set.");
+ }
+
+ return (DriftServerPluginFacet) getServerPluginComponent(value.substring(1, value.indexOf("$$")));
+ }
+
+ @Override
+ protected void loadPlugin(ServerPluginEnvironment env, boolean enabled) throws Exception {
+ super.loadPlugin(env, enabled);
+
+ String pluginName = env.getPluginKey().getPluginName();
+ List<String> plugins = getDriftPlugins();
+
+ int index = findPluginIndex(plugins, pluginName);
+ if (index == -1) {
+ plugins.add("[" + pluginName + "$$" + env.getPluginDescriptor().getDisplayName() + "]");
+ saveDriftPlugins(plugins);
+ }
+
+ }
+
+ @Override
+ protected void unloadPlugin(String pluginName) throws Exception {
+ super.unloadPlugin(pluginName);
+
+ List<String> plugins = getDriftPlugins();
+ int index = findPluginIndex(plugins, pluginName);
+
+ if (index != -1) {
+ plugins.remove(index);
+ saveDriftPlugins(plugins);
+ }
+ }
+
+ private List<String> getDriftPlugins() {
+ Properties sysConfig = getSysConfig();
+ return getStringAsList(sysConfig.getProperty(DRIFT_PLUGINS, ""), ",", true);
}
+
+ private void saveDriftPlugins(List<String> plugins) throws Exception {
+ SubjectManagerLocal subjectMgr = LookupUtil.getSubjectManager();
+ SystemManagerLocal systemMgr = LookupUtil.getSystemManager();
+
+ Properties sysConfig = systemMgr.getSystemConfiguration(subjectMgr.getOverlord());
+ sysConfig.put(DRIFT_PLUGINS, getListAsString(plugins, ","));
+ systemMgr.setSystemConfiguration(subjectMgr.getOverlord(), sysConfig, false);
+ }
+
+ private Properties getSysConfig() {
+ SubjectManagerLocal subjectMgr = LookupUtil.getSubjectManager();
+ SystemManagerLocal systemMgr = LookupUtil.getSystemManager();
+
+ return systemMgr.getSystemConfiguration(subjectMgr.getOverlord());
+ }
+
+ private int findPluginIndex(List<String> plugins, String name) {
+ int i = 0;
+ for (String value : plugins) {
+ // value is of the form, [plugin_name$$plugin_display_name]
+ if (name.equals(value.substring(1, value.indexOf("$$")))) {
+ return i;
+ }
+ ++i;
+ }
+ return -1;
+ }
+
+
}
\ No newline at end of file
diff --git a/modules/test-utils/src/main/java/org/rhq/test/JPAUtils.java b/modules/test-utils/src/main/java/org/rhq/test/JPAUtils.java
index 349b84c..b385473 100644
--- a/modules/test-utils/src/main/java/org/rhq/test/JPAUtils.java
+++ b/modules/test-utils/src/main/java/org/rhq/test/JPAUtils.java
@@ -143,7 +143,7 @@ public class JPAUtils {
em.createNativeQuery("delete from rhq_measurement_sched");
em.createNativeQuery("delete from rhq_measurement_def");
em.createNativeQuery("delete from rhq_plugin");
- em.createNativeQuery("delete from rhq_system_config where id not in (1, 2, 3, 4, 9, 10, 32, 34, 35, 36, 51, 52, 53, 54, 55, 56)");
+ em.createNativeQuery("delete from rhq_system_config where id not in (1, 2, 3, 4, 9, 10, 32, 34, 35, 36, 51, 52, 53, 54, 55, 56, 57, 58)");
em.createNativeQuery("delete from rhq_alert_notification");
em.createNativeQuery("delete from rhq_alert_condition_log");
em.createNativeQuery("delete from rhq_alert");
commit fea0df9ea83a2abea14e4f80d3e5143458e7edd3
Author: John Sanda <jsanda(a)redhat.com>
Date: Wed Jul 27 10:03:47 2011 -0400
Deleting scratch file that should not be in git
diff --git a/modules/core/domain/mvn.out b/modules/core/domain/mvn.out
deleted file mode 100644
index 7e78162..0000000
--- a/modules/core/domain/mvn.out
+++ /dev/null
@@ -1,194 +0,0 @@
-[INFO]
-NOTE: Maven is executing in offline mode. Any artifacts not already in your local
-repository will be inaccessible.
-
-[INFO] Scanning for projects...
-[INFO] ------------------------------------------------------------------------
-[INFO] Building RHQ Domain Model
-[INFO] task-segment: [clean, test]
-[INFO] ------------------------------------------------------------------------
-[INFO] [clean:clean {execution: default-clean}]
-[INFO] Deleting /home/jsanda/Development/redhat/rhq/modules/core/domain/target
-[INFO] [enforcer:enforce {execution: enforce-versions}]
-[INFO] [build-helper:maven-version {execution: default}]
-[WARNING] DEPRECATED [tasks]: Use target instead
-[INFO] [antrun:run {execution: write-build-properties-file}]
-[WARNING] Parameter tasks is deprecated, use target instead
-[INFO] Executing tasks
-
-main:
-[INFO] Executed tasks
-[INFO] [properties:read-project-properties {execution: read-build-properties-file}]
-[INFO] [resources:resources {execution: default-resources}]
-[INFO] Using 'ISO-8859-1' encoding to copy filtered resources.
-[INFO] Copying 393 resources
-[INFO] Copying 2 resources
-[INFO] [compiler:compile {execution: default-compile}]
-[INFO] Compiling 391 source files to /home/jsanda/Development/redhat/rhq/modules/core/domain/target/classes
-[WARNING] DEPRECATED [tasks]: Use target instead
-[INFO] [antrun:run {execution: echo-build-properties}]
-[WARNING] Parameter tasks is deprecated, use target instead
-[INFO] Executing tasks
-
-main:
-[INFO] Executed tasks
-[INFO] [resources:testResources {execution: default-testResources}]
-[INFO] Using 'ISO-8859-1' encoding to copy filtered resources.
-[INFO] Copying 13 resources
-[INFO] [compiler:testCompile {execution: default-testCompile}]
-[INFO] Compiling 54 source files to /home/jsanda/Development/redhat/rhq/modules/core/domain/target/test-classes
-[WARNING] /home/jsanda/Development/redhat/rhq/modules/core/domain/src/test/java/org/rhq/core/domain/test/AbstractEJB3Test.java:[116,70] [deprecation] connection() in org.hibernate.Session has been deprecated
-[WARNING] /home/jsanda/Development/redhat/rhq/modules/core/domain/src/test/java/org/rhq/core/domain/content/test/PackageVersionContentSourceTest.java:[118,71] [unchecked] unchecked conversion
-found : java.util.List
-required: java.util.List<org.rhq.core.domain.content.PackageVersionContentSource>
-[WARNING] /home/jsanda/Development/redhat/rhq/modules/core/domain/src/test/java/org/rhq/core/domain/content/test/PackageVersionContentSourceTest.java:[157,80] [unchecked] unchecked conversion
-found : java.util.List
-required: java.util.List<org.rhq.core.domain.content.composite.PackageVersionMetadataComposite>
-[WARNING] /home/jsanda/Development/redhat/rhq/modules/core/domain/src/test/java/org/rhq/core/domain/configuration/TestUtil.java:[42,37] [unchecked] unchecked cast
-found : java.lang.Object
-required: T
-[WARNING] /home/jsanda/Development/redhat/rhq/modules/core/domain/src/test/java/org/rhq/core/domain/configuration/test/ConfigurationTest.java:[198,26] [unchecked] unchecked conversion
-found : java.util.List
-required: java.util.List<org.rhq.core.domain.configuration.Configuration>
-[WARNING] /home/jsanda/Development/redhat/rhq/modules/core/domain/src/test/java/org/rhq/core/domain/resource/test/AgentTest.java:[67,37] [unchecked] unchecked conversion
-found : java.util.List
-required: java.util.List<org.rhq.core.domain.resource.composite.AgentLastAvailabilityReportComposite>
-[WARNING] /home/jsanda/Development/redhat/rhq/modules/core/domain/src/test/java/org/rhq/core/domain/resource/test/AgentTest.java:[90,37] [unchecked] unchecked conversion
-found : java.util.List
-required: java.util.List<org.rhq.core.domain.resource.composite.AgentLastAvailabilityReportComposite>
-[WARNING] /home/jsanda/Development/redhat/rhq/modules/core/domain/src/test/java/org/rhq/core/domain/resource/test/AgentTest.java:[112,37] [unchecked] unchecked conversion
-found : java.util.List
-required: java.util.List<org.rhq.core.domain.resource.composite.AgentLastAvailabilityReportComposite>
-[WARNING] /home/jsanda/Development/redhat/rhq/modules/core/domain/src/test/java/org/rhq/core/domain/resource/test/AgentTest.java:[117,37] [unchecked] unchecked conversion
-found : java.util.List
-required: java.util.List<org.rhq.core.domain.resource.composite.AgentLastAvailabilityReportComposite>
-[WARNING] /home/jsanda/Development/redhat/rhq/modules/core/domain/src/test/java/org/rhq/core/domain/test/SerializableTest.java:[177,19] [unchecked] unchecked cast
-found : java.lang.Object
-required: T
-[WARNING] /home/jsanda/Development/redhat/rhq/modules/core/domain/src/test/java/org/rhq/core/domain/configuration/test/ConfigurationDefinitionTest.java:[98,105] [unchecked] unchecked conversion
-found : java.util.List
-required: java.util.List<org.rhq.core.domain.configuration.definition.ConfigurationDefinition>
-[WARNING] /home/jsanda/Development/redhat/rhq/modules/core/domain/src/test/java/org/rhq/core/domain/configuration/test/ConfigurationDefinitionTest.java:[135,30] [unchecked] unchecked conversion
-found : java.util.List
-required: java.util.List<org.rhq.core.domain.configuration.definition.ConfigurationDefinition>
-[WARNING] /home/jsanda/Development/redhat/rhq/modules/core/domain/src/test/java/org/rhq/core/domain/configuration/test/ConfigurationDefinitionTest.java:[184,26] [unchecked] unchecked conversion
-found : java.util.List
-required: java.util.List<org.rhq.core.domain.configuration.definition.ConfigurationDefinition>
-[WARNING] /home/jsanda/Development/redhat/rhq/modules/core/domain/src/test/java/org/rhq/core/domain/resource/ResourceTypeTest.java:[41,26] [unchecked] unchecked conversion
-found : java.util.List
-required: java.util.List<org.rhq.core.domain.resource.ResourceType>
-[WARNING] /home/jsanda/Development/redhat/rhq/modules/core/domain/src/test/java/org/rhq/core/domain/resource/test/PluginTest.java:[332,50] [unchecked] unchecked conversion
-found : java.util.List
-required: java.util.List<org.rhq.core.domain.plugin.Plugin>
-[WARNING] DEPRECATED [systemProperties]: Use systemPropertyVariables instead.
-[INFO] [surefire:test {execution: default-test}]
-[INFO] Surefire report directory: /home/jsanda/Development/redhat/rhq/modules/core/domain/target/surefire-reports
-
--------------------------------------------------------
- T E S T S
--------------------------------------------------------
-Running TestSuite
-Starting ejb3...
-Loading EJB3 classes from directory: target/classes
-log4j: Threshold ="null".
-log4j: Class name: [org.apache.log4j.ConsoleAppender]
-log4j: Setting property [target] to [System.out].
-log4j: Setting property [threshold] to [WARN].
-log4j: Parsing layout of class: "org.apache.log4j.PatternLayout"
-log4j: Setting property [conversionPattern] to [%-5p %d{dd-MM HH:mm:ss,SSS} (%F:%M:%L) -%m%n].
-log4j: Adding appender named [CONSOLE] to category [root].
-WARN 13-07 15:00:21,151 (Ejb3Configuration.java:addXMLEntities:422) -Persistence provider caller does not implements the EJB3 spec correctly. PersistenceUnitInfo.getNewTempClassLoader() is null.
-lookup
- UserTransaction: org.jboss.ejb3.embedded.UserTransactionImpl
-...... embedded-jboss-beans deployed....
-...... deploying MM ejb3.....
-...... ejb3 deployed....
-...... deployer created....
-WARN 13-07 15:00:29,804 (Ejb3Configuration.java:addXMLEntities:422) -Persistence provider caller does not implements the EJB3 spec correctly. PersistenceUnitInfo.getNewTempClassLoader() is null.
-lookup
- UserTransaction: org.jboss.ejb3.embedded.UserTransactionImpl
-...... deployer started....
-Configuration definition: CONFIG_ENUM_VAL_TEST (test data)
- SimpleProperty[EnumeratedProperty] (Type: STRING)
-Before: [PropertyDefinitionEnumeration{id=10871, name='A', value='a', orderIndex=0}, PropertyDefinitionEnumeration{id=10872, name='B', value='b', orderIndex=1}]
-After: [PropertyDefinitionEnumeration{id=10872, name='B', value='b', orderIndex=1}, PropertyDefinitionEnumeration{id=10871, name='A', value='a', orderIndex=0}]
-Configuration definition: CONFIG_CONSTRAINT_TEST (test data)
- SimpleProperty[ConstrainedProperty] (Type: FLOAT)
-Constraint: FloatRangeConstraint[details=1.0#3.0]
-Configuration definition: TEST_CONFIG (Config definition for the thing)
- SimpleProperty[SimpleProp] (Type: STRING)
- Map Property [MapProp]
- SimpleProperty[IntInMap] (Type: INTEGER)
- SimpleProperty[ConnectionType] (Type: STRING)(Group: Basic Group)
- SimpleProperty[SimpleBool] (Type: BOOLEAN)(Group: Basic Group)
-Serialized version of config was 1367 bytes
-WARN 13-07 15:01:20,904 (JDBCExceptionReporter.java:logExceptions:77) -SQL Error: 0, SQLState: 23505
-ERROR 13-07 15:01:20,905 (JDBCExceptionReporter.java:logExceptions:78) -Batch entry 0 insert into RHQ_DRIFT_FILE (CTIME, DATA_SIZE, STATUS, DATA, HASH_ID) values ('1310583680392', '10485760', 'EMPTY', '1489397', '6486d7a1e0f8a97387e1f1f8780ea7dd1ab212a4b862bcefdfb0f1d1480f9996') was aborted. Call getNextException to see the cause.
-WARN 13-07 15:01:20,906 (JDBCExceptionReporter.java:logExceptions:77) -SQL Error: 0, SQLState: 23505
-ERROR 13-07 15:01:20,906 (JDBCExceptionReporter.java:logExceptions:78) -ERROR: duplicate key value violates unique constraint "rhq_drift_file_pkey"
-ERROR 13-07 15:01:20,907 (AbstractFlushingEventListener.java:performExecutions:301) -Could not synchronize database state with session
-org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
- at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:71)
- at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
- at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:254)
- at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:237)
- at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:141)
- at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
- at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
- at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
- at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
- at org.hibernate.ejb.AbstractEntityManagerImpl$1.beforeCompletion(AbstractEntityManagerImpl.java:515)
- at org.jboss.tm.TransactionImpl.doBeforeCompletion(TransactionImpl.java:3074)
- at org.jboss.tm.TransactionImpl.beforePrepare(TransactionImpl.java:2632)
- at org.jboss.tm.TransactionImpl.commit(TransactionImpl.java:1194)
- at org.jboss.tm.TxManager.commit(TxManager.java:588)
- at org.rhq.core.domain.drift.DriftFileTest.executeInTransaction(DriftFileTest.java:187)
- at org.rhq.core.domain.drift.DriftFileTest.loadSameFile(DriftFileTest.java:152)
- at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
- at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
- at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
- at java.lang.reflect.Method.invoke(Method.java:597)
- at org.testng.internal.MethodHelper.invokeMethod(MethodHelper.java:640)
- at org.testng.internal.Invoker.invokeMethod(Invoker.java:627)
- at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:798)
- at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1102)
- at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:137)
- at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:121)
- at org.testng.TestRunner.runWorkers(TestRunner.java:1009)
- at org.testng.TestRunner.privateRun(TestRunner.java:683)
- at org.testng.TestRunner.run(TestRunner.java:553)
- at org.testng.SuiteRunner.runTest(SuiteRunner.java:311)
- at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:306)
- at org.testng.SuiteRunner.privateRun(SuiteRunner.java:268)
- at org.testng.SuiteRunner.run(SuiteRunner.java:217)
- at org.testng.TestNG.runSuite(TestNG.java:1062)
- at org.testng.TestNG.runSuitesLocally(TestNG.java:956)
- at org.testng.TestNG.run(TestNG.java:874)
- at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:61)
- at org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.execute(TestNGDirectoryTestSuite.java:144)
- at org.apache.maven.surefire.Surefire.run(Surefire.java:169)
- at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
- at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
- at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
- at java.lang.reflect.Method.invoke(Method.java:597)
- at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:350)
- at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1021)
-Caused by: java.sql.BatchUpdateException: Batch entry 0 insert into RHQ_DRIFT_FILE (CTIME, DATA_SIZE, STATUS, DATA, HASH_ID) values ('1310583680392', '10485760', 'EMPTY', '1489397', '6486d7a1e0f8a97387e1f1f8780ea7dd1ab212a4b862bcefdfb0f1d1480f9996') was aborted. Call getNextException to see the cause.
- at org.postgresql.jdbc2.AbstractJdbc2Statement$BatchResultHandler.handleError(AbstractJdbc2Statement.java:2598)
- at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1836)
- at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:407)
- at org.postgresql.jdbc2.AbstractJdbc2Statement.executeBatch(AbstractJdbc2Statement.java:2737)
- at org.jboss.resource.adapter.jdbc.WrappedStatement.executeBatch(WrappedStatement.java:518)
- at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
- at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:247)
- ... 42 more
-testTraitQuery ...
-testTraitQuery: found 1 item(s)
- and it is MeasurementDataTrait[value=[Hello World], MeasurementData [MeasurementDataPK: timestamp=[Wed Jul 13 15:01:21 EDT 2011], scheduleId=[12011]]] and name Fake display name
-Created resource with id 13617
-Created resource with id 13618
-Took [5092]ms to create [2000] resources
-Took [853]ms to remove [2000] resources
-Destroying 1 processes
-Destroying process..
-Destroyed 1 processes
12 years, 10 months
[rhq] Branch 'AdminConsole_EAP_5_1' - modules/plugins
by ips
modules/plugins/jboss-as-5/src/main/resources/META-INF/rhq-plugin.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
New commits:
commit 12148f7a17ddea6575aaa18078e97cc976becf4f
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Wed Jul 27 14:27:19 2011 -0400
[BZ 710230] improve the description of the 'testConnection' datasource/connFactory operation so it makes it clear that the operation always returns SUCCESS even if the connection test failed (https://bugzilla.redhat.com/show_bug.cgi?id=710230)
diff --git a/modules/plugins/jboss-as-5/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/jboss-as-5/src/main/resources/META-INF/rhq-plugin.xml
index e32a549..5fd44aa 100644
--- a/modules/plugins/jboss-as-5/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/jboss-as-5/src/main/resources/META-INF/rhq-plugin.xml
@@ -37,7 +37,7 @@
</results>
</operation>
- <operation name="testConnection" displayName="Test Connection" description="Test if a connection can be obtained">
+ <operation name="testConnection" displayName="Test Connection" description="Test if a connection can be obtained - returns true if a connection was obtained, or false if not; NOTE: this operation will always return a status of Successful - the results of the operation must be inspected to see whether or not a connection was obtained">
<results>
<c:notes>Test if a connection can be obtained</c:notes>
<c:simple-property type="boolean" name="result" description="Was a connection obtained?"/>
12 years, 10 months
[rhq] Branch 'AdminConsole_EAP_5_1' - modules/core
by ips
modules/core/client-api/src/main/java/org/rhq/core/clientapi/descriptor/PluginTransformer.java | 27 +++++++++-
1 file changed, 25 insertions(+), 2 deletions(-)
New commits:
commit 3473f01414f4fb27194e230b22ee2068bd103d90
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Wed Jul 27 12:45:26 2011 -0400
[BZ 726145] fix so plugin container can handle plugin jars whose MANIFEST.MF is not the first entry in the jarfile (https://bugzilla.redhat.com/show_bug.cgi?id=726145)
diff --git a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/descriptor/PluginTransformer.java b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/descriptor/PluginTransformer.java
index ecaa80b..fbefc1d 100644
--- a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/descriptor/PluginTransformer.java
+++ b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/descriptor/PluginTransformer.java
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2010 Red Hat, Inc.
+ * Copyright (C) 2005-2011 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -22,6 +22,8 @@
*/
package org.rhq.core.clientapi.descriptor;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.rhq.core.domain.plugin.Plugin;
import org.rhq.core.clientapi.descriptor.plugin.PluginDescriptor;
import org.rhq.core.clientapi.descriptor.plugin.Help;
@@ -29,6 +31,8 @@ import org.rhq.core.util.MessageDigestGenerator;
import java.net.URL;
import java.io.IOException;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
import java.util.jar.JarInputStream;
import java.util.jar.Manifest;
import java.util.jar.Attributes;
@@ -38,6 +42,8 @@ import java.util.jar.Attributes;
*/
public class PluginTransformer {
+ private static final Log LOG = LogFactory.getLog(PluginTransformer.class);
+
/**
* Takes the given plugin descriptor and plugin JAR file URL and converts them into a
* {@link org.rhq.core.domain.plugin.Plugin} object. This method does not set the <code>content</code> property
@@ -112,8 +118,24 @@ public class PluginTransformer {
private String getVersionFromPluginJarManifest(URL pluginJarUrl) throws IOException {
JarInputStream jarInputStream = new JarInputStream(pluginJarUrl.openStream());
- jarInputStream.close();
Manifest manifest = jarInputStream.getManifest();
+ if (manifest == null) {
+ // BZ 682116 (ips, 03/25/11): The manifest file is not in the standard place as the 2nd entry of the JAR,
+ // but we want to be flexible and support JARs that have a manifest file somewhere else, so scan the entire
+ // JAR for one.
+ JarEntry jarEntry;
+ while((jarEntry = jarInputStream.getNextJarEntry()) != null) {
+ if (JarFile.MANIFEST_NAME.equalsIgnoreCase(jarEntry.getName())) {
+ manifest = new Manifest(jarInputStream);
+ break;
+ }
+ }
+ }
+ try {
+ jarInputStream.close();
+ } catch (IOException e) {
+ LOG.error("Failed to close plugin jar input stream for plugin jar [" + pluginJarUrl + "].", e);
+ }
if (manifest != null) {
Attributes attributes = manifest.getMainAttributes();
return attributes.getValue(Attributes.Name.IMPLEMENTATION_VERSION);
@@ -121,4 +143,5 @@ public class PluginTransformer {
return null;
}
}
+
}
12 years, 10 months
[rhq] Branch 'AdminConsole_EAP_5_1' - modules/plugins
by ips
modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/adapter/api/AbstractPropertySimpleAdapter.java | 38 +------
modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/util/ConversionUtils.java | 52 ----------
modules/plugins/jboss-as-5/src/main/resources/META-INF/rhq-plugin.xml | 3
3 files changed, 13 insertions(+), 80 deletions(-)
New commits:
commit 8b2258eef1140aacdddde1c5b30de919ed67df51
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Wed Jul 27 11:45:14 2011 -0400
[BZ 694660, EMBJOPR-350] fix issue where unset did not work for certain resource config props (https://bugzilla.redhat.com/show_bug.cgi?id=694660, https://issues.jboss.org/browse/EMBJOPR-350)
diff --git a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/adapter/api/AbstractPropertySimpleAdapter.java b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/adapter/api/AbstractPropertySimpleAdapter.java
index 866ab89..bfcccd0 100644
--- a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/adapter/api/AbstractPropertySimpleAdapter.java
+++ b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/adapter/api/AbstractPropertySimpleAdapter.java
@@ -1,6 +1,6 @@
/*
* Jopr Management Platform
- * Copyright (C) 2005-2009 Red Hat, Inc.
+ * Copyright (C) 2005-2011 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -50,34 +50,16 @@ public abstract class AbstractPropertySimpleAdapter implements PropertyAdapter<P
{
if (metaValue == null)
throw new IllegalArgumentException("MetaValue to be populated is null.");
- String value;
- if (propSimple == null || propSimple.getStringValue() == null)
- {
- // Value is null (i.e. prop is unset) - figure out what to use as a default value.
- String defaultValue = propDefSimple.getDefaultValue();
- if (defaultValue != null)
- {
- log.debug("Simple property '" + propDefSimple.getName()
- + "' has a null value - setting inner value of corresponding ManagedProperty's MetaValue to plugin-specified default ('"
- + defaultValue + "')...");
- value = defaultValue;
+ String value = (propSimple != null) ? propSimple.getStringValue() : null;
+ if (value == null && metaValue.getMetaType().isPrimitive()) {
+ // For primitive types, if we set the value to null, the Profile Service will set the value to 0, which
+ // is not good, so for such properties, we make sure to define a default value in the plugin descriptor, so
+ // we can explicitly set the value to that default, rather than null, here.
+ value = propDefSimple.getDefaultValue();
+ if (value == null) {
+ log.warn("Plugin error: Managed property [" + propDefSimple.getName()
+ + "] has a primitive type, but the corresponding RHQ property definition does not provide a default value.");
}
- else
- {
- if (metaValue.getMetaType().isPrimitive())
- // If it's a primitive, don't mess with the MetaValue - just let it keep whatever inner value it
- // currently has.
- return;
- // It's a non-primitive - set its value to null. In most cases, this should tell the managed resource
- // to use its internal default.
- log.debug("Simple property '" + propDefSimple.getName()
- + "' has a null value - setting inner value of corresponding ManagedProperty's MetaValue to null...");
- value = null;
- }
- }
- else
- {
- value = propSimple.getStringValue();
}
setInnerValue(value, metaValue, propDefSimple);
}
diff --git a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/util/ConversionUtils.java b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/util/ConversionUtils.java
index 0f2bee0..02fb7ca 100644
--- a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/util/ConversionUtils.java
+++ b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/util/ConversionUtils.java
@@ -1,6 +1,6 @@
/*
* Jopr Management Platform
-* Copyright (C) 2005-2009 Red Hat, Inc.
+* Copyright (C) 2005-2011 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -22,7 +22,6 @@
*/
package org.rhq.plugins.jbossas5.util;
-import java.io.Serializable;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
@@ -62,9 +61,7 @@ import org.jboss.managed.api.annotation.ViewUse;
import org.jboss.metatype.api.types.MapCompositeMetaType;
import org.jboss.metatype.api.types.MetaType;
import org.jboss.metatype.api.types.SimpleMetaType;
-import org.jboss.metatype.api.values.EnumValue;
import org.jboss.metatype.api.values.MetaValue;
-import org.jboss.metatype.api.values.SimpleValue;
/**
* Utility class to convert some basic Profile Service objects to JON objects, and some basic manipulation and data
@@ -84,8 +81,6 @@ public class ConversionUtils
private static final Map<String, KnownDeploymentTypes> DEPLOYMENT_TYPE_CACHE = new HashMap<String, KnownDeploymentTypes>();
private static final Map<String, Configuration> DEFAULT_PLUGIN_CONFIG_CACHE = new HashMap<String, Configuration>();
- protected static final String PLUGIN = "ProfileService";
-
public static ComponentType getComponentType(@NotNull ResourceType resourceType)
{
String resourceTypeName = resourceType.getName();
@@ -224,20 +219,6 @@ public class ConversionUtils
@NotNull ManagedProperty managedProperty,
@Nullable PropertySimple customProperty)
{
- if (property == null ||
- (property instanceof PropertySimple && ((PropertySimple)property).getStringValue() == null))
- {
- // The property is unset, which translates to "removed" in Profile Service lingo.
- // We will also set the ManagedProperty's MetaValue to a default value - this will be handled by the
- // conversion performed below by the property's adapter.
- managedProperty.setRemoved(true);
- }
- // If the ManagedProperty defines a default value, assume it's more definitive than any default value that may
- // have been defined in the plugin descriptor, and update the PropertyDefinition to use that as its default
- // value.
- MetaValue defaultValue = managedProperty.getDefaultValue();
- if (defaultValue != null)
- updateDefaultValueOnPropertyDefinition(propertyDefinition, defaultValue);
// See if there is a custom adapter defined for this property.
PropertyAdapter propertyAdapter = PropertyAdapterFactory.getCustomPropertyAdapter(customProperty);
MetaValue metaValue = managedProperty.getValue();
@@ -261,37 +242,6 @@ public class ConversionUtils
}
}
- private static void updateDefaultValueOnPropertyDefinition(PropertyDefinition propertyDefinition,
- @NotNull MetaValue defaultValue)
- {
- if (!(propertyDefinition instanceof PropertyDefinitionSimple))
- {
- LOG.debug("Cannot update default value on non-simple property definition " + propertyDefinition
- + "(default value is " + defaultValue + ").");
- return;
- }
- MetaType metaType = defaultValue.getMetaType();
- if (!metaType.isSimple() && !metaType.isEnum())
- {
- LOG.debug("Cannot update default value on " + propertyDefinition
- + ", because default value's type (" + metaType + ") is not simple or enum.");
- return;
- }
- PropertyDefinitionSimple propertyDefinitionSimple = (PropertyDefinitionSimple)propertyDefinition;
- if (metaType.isSimple())
- {
- SimpleValue defaultSimpleValue = (SimpleValue)defaultValue;
- Serializable value = defaultSimpleValue.getValue();
- propertyDefinitionSimple.setDefaultValue((value != null) ? value.toString() : null);
- }
- else
- { // defaultValueMetaType.isEnum()
- EnumValue defaultEnumValue = (EnumValue)defaultValue;
- Serializable value = defaultEnumValue.getValue();
- propertyDefinitionSimple.setDefaultValue((value != null) ? value.toString() : null);
- }
- }
-
public static MetaType convertPropertyDefinitionToMetaType(PropertyDefinition propDef)
{
MetaType memberMetaType;
diff --git a/modules/plugins/jboss-as-5/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/jboss-as-5/src/main/resources/META-INF/rhq-plugin.xml
index ea8ff2d..e32a549 100644
--- a/modules/plugins/jboss-as-5/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/jboss-as-5/src/main/resources/META-INF/rhq-plugin.xml
@@ -406,7 +406,8 @@
displayName="Query Timeout"
type="integer"
units="seconds"
- required="false">
+ required="false"
+ defaultValue="0">
<c:description>
Any configured query timeout in seconds. A value of 0 means no timeout. The default is 0.
</c:description>
12 years, 10 months
[rhq] Branch 'release-3.0.0' - modules/plugins
by fdrabek
modules/plugins/augeas/src/main/java/org/rhq/augeas/AugeasComponent.java | 39 ++++++++++
1 file changed, 39 insertions(+)
New commits:
commit b787f3937f7618bfc83aad8bbc4e4ed67eb97b3e
Author: Filip Drabek <fdrabek(a)dhcp-lab-136.englab.brq.redhat.com>
Date: Wed Jul 27 16:56:55 2011 +0200
initial import of AugeasComponent
diff --git a/modules/plugins/augeas/src/main/java/org/rhq/augeas/AugeasComponent.java b/modules/plugins/augeas/src/main/java/org/rhq/augeas/AugeasComponent.java
new file mode 100644
index 0000000..ff343af
--- /dev/null
+++ b/modules/plugins/augeas/src/main/java/org/rhq/augeas/AugeasComponent.java
@@ -0,0 +1,39 @@
+package org.rhq.augeas;
+
+import org.rhq.augeas.config.AugeasConfiguration;
+import org.rhq.augeas.tree.AugeasTree;
+import org.rhq.augeas.tree.AugeasTreeBuilder;
+
+public abstract class AugeasComponent {
+
+ AugeasProxy augeasProxy;
+ boolean isClosed = true;
+
+ public abstract AugeasConfiguration initConfiguration();
+
+ public abstract AugeasTreeBuilder initTreeBuilder();
+
+ protected void reloadAugeas() {
+ if (!isClosed)
+ close();
+
+ augeasProxy = new AugeasProxy(initConfiguration(), initTreeBuilder());
+ augeasProxy.load();
+ isClosed = false;
+ }
+
+ public AugeasTree getAugeasTree(String moduleName) {
+ reloadAugeas();
+ return augeasProxy.getAugeasTree(moduleName, true);
+ }
+
+ public void close() {
+ isClosed = true;
+ augeasProxy.close();
+ }
+
+ public AugeasConfiguration getConfiguration() {
+ return augeasProxy.getConfiguration();
+ }
+
+}
12 years, 10 months
[rhq] modules/enterprise
by mazz
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java | 6 ++++++
1 file changed, 6 insertions(+)
New commits:
commit 609a2aa1c541eb8f38b98c725d3e513c364653dc
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Wed Jul 27 10:03:45 2011 -0400
add peer-review warning
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java
index ea2e29d..b1d0bb1 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java
@@ -91,6 +91,12 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
/**
* A tabular view of set of data records from an {@link RPCDataSource}.
*
+ * WARNING! If you make _any_ changes to this class, no matter how seemingly
+ * trivial, you must get it peer reviewed. Send out your proposed changes
+ * to the dev mailing list and ask for comments. Any problems introduced to
+ * this class are magnified because it is used in so many UI views and problems
+ * are hard to detect due to the varies ways it is used.
+ *
* @author Greg Hinkle
* @author Ian Springer
*/
12 years, 10 months
[rhq] Branch 'as7plugin' - 9 commits - .classpath modules/core modules/enterprise modules/integration-tests modules/plugins
by Heiko W. Rupp
.classpath | 1
modules/core/domain/src/main/java/org/rhq/core/domain/configuration/Configuration.java | 20 +
modules/core/domain/src/test/java/org/rhq/core/domain/drift/DriftFileTest.java | 4
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/metadata/PluginConfigurationMetadataManagerBean.java | 10
modules/integration-tests/jboss-as-7-plugin-test/src/test/java/org/rhq/modules/integrationTests/jbossas7plugin/UploadAndDeployTest.java | 85 ++++
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/AbstractBaseDiscovery.java | 53 ++
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java | 46 +-
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseProcessDiscovery.java | 94 ++++-
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseServerComponent.java | 184 ++++++++++
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ConfigurationLoadDelegate.java | 6
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DomainComponent.java | 72 ---
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/HostControllerComponent.java | 64 +++
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/JmsComponent.java | 3
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ManagedASComponent.java | 70 +++
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ManagedASDiscovery.java | 9
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ServerGroupComponent.java | 5
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/StandaloneASComponent.java | 38 --
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Address.java | 19 +
modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml | 139 ++++++-
19 files changed, 755 insertions(+), 167 deletions(-)
New commits:
commit 23f8cf9f8417f0780b4019b885f9271288ecda05
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Tue Jul 26 22:29:16 2011 +0200
Add more properties for JBossWeb. Unfortunately they are read-only in AS7
Follow :read-resource output, as the resource description from AS7 is not up to date.
diff --git a/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
index d9f79d1..6a8698e 100644
--- a/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
@@ -614,6 +614,78 @@
<c:simple-property name="path" readOnly="true" default="subsystem=web"/>
</plugin-configuration>
+ <resource-configuration>
+ <c:simple-property name="default-virtual-server" required="false" type="string" readOnly="true" defaultValue="localhost"
+ description="The web container's default virtual server."/>
+ <c:simple-property name="native" required="false" type="boolean" readOnly="true" defaultValue="true"
+ description="Add the native initialization listener to the web container."/>
+ <c:map-property name="configuration" description="The common web container configuration." >
+ <c:map-property name="static-resources" description="Configuration for static resources" >
+ <c:simple-property name="listings" required="false" type="boolean" readOnly="true" defaultValue="false"
+ description="Enable folder listings."/>
+ <c:simple-property name="sendfile" required="false" type="integer" readOnly="true" defaultValue="49152"
+ description="Enable sendfile if possible, for files bigger than the specified byte size."/>
+ <c:simple-property name="read-only" required="false" type="boolean" readOnly="true" defaultValue="true"
+ description="Allow write HTTP methods (PUT, DELETE)."/>
+ <c:simple-property name="webdav" required="false" type="boolean" readOnly="true" defaultValue="false"
+ description="Enable WebDAV functionality."/>
+ <c:simple-property name="secret" required="false" type="string" readOnly="true" description="Secret for WebDAV locking operations."/>
+ <c:simple-property name="max-depth" required="false" type="integer" readOnly="true" defaultValue="3"
+ description="Maximum recursion for PROPFIND."/>
+ <c:simple-property name="disabled" required="false" type="boolean" readOnly="true" defaultValue="false"
+ description="Enable the JSP container."/>
+ </c:map-property>
+ <c:map-property name="jsp-configuration" description="JSP container configuration">
+ <c:simple-property name="development" required="false" type="boolean" readOnly="true" defaultValue="false"
+ description="Enable the development mode, which gives more information when an error occurs."/>
+ <c:simple-property name="file-encoding" required="false" type="string" readOnly="true" description="Force a file encoding."/>
+ <c:simple-property name="keep-generated" required="false" type="boolean" readOnly="true" defaultValue="true"
+ description="Keep the generated Servlets."/>
+ <c:simple-property name="trim-spaces" required="false" type="boolean" readOnly="true" defaultValue="true"
+ description="Trim some spaces from the generated Servlet."/>
+ <c:simple-property name="tag-pooling" required="false" type="boolean" readOnly="true" defaultValue="true"
+ description="Enable tag pooling."/>
+ <c:simple-property name="mapped-file" required="false" type="boolean" readOnly="true" defaultValue="true"
+ description="Map to the JSP source."/>
+ <c:simple-property name="check-interval" required="false" type="integer" readOnly="true" defaultValue="0"
+ description="Check interval for JSP updates using a background thread."/>
+ <c:simple-property name="modification-test-interval" required="false" type="integer" readOnly="true" defaultValue="4"
+ description="Minimum amount of time between two tests for updates, in seconds."/>
+ <c:simple-property name="recompile-on-fail" required="false" type="boolean" readOnly="true" defaultValue="false"
+ description="Retry failed JSP compilations on each request."/>
+ <c:simple-property name="smap" required="false" type="boolean" readOnly="true" defaultValue="false"
+ description="Enable SMAP."/>
+ <c:simple-property name="dump-smap" required="false" type="boolean" readOnly="true" defaultValue="false"
+ description="Write SMAP data to a file."/>
+ <c:simple-property name="generate-strings-as-char-arrays" required="false" type="boolean" readOnly="true"
+ defaultValue="false"
+ description="Generate String constants as char arrays."/>
+ <c:simple-property name="error-on-use-bean-invalid-class-attribute" required="false" type="boolean" readOnly="true" defaultValue="false"
+ description="Enable errors when using a bad class in useBean."/>
+ <c:simple-property name="scratch-dir" required="false" type="string" readOnly="true" description="Specify a different work directory."/>
+ <c:simple-property name="source-vm" required="false" type="string" readOnly="true" defaultValue="1.5"
+ description="Source VM level for compilation."/>
+ <c:simple-property name="target-vm" required="false" type="string" readOnly="true" defaultValue="1.5"
+ description="Target VM level for compilation."/>
+ <c:simple-property name="java-encoding" required="false" type="string" readOnly="true" defaultValue="UTF-8"
+ description="Specify the encoding used for Java sources."/>
+ <c:simple-property name="x-powered-by" required="false" type="boolean" readOnly="true" defaultValue="true"
+ description="Enable advertising the JSP engine in x-powered-by."/>
+ <c:simple-property name="display-source-fragment" required="false" type="boolean" readOnly="true" defaultValue="true"
+ description="When a runtime error occurs, attempts to display corresponding JSP source fragment."/>
+ </c:map-property>
+ <c:list-property name="mime-mapping" description="A mime-mapping definition." >
+ <c:map-property name="mime-mapping" >
+ <c:simple-property name="name" description="A MIME mapping name"/>
+ <c:simple-property name="value" description="A MIME mapping value"/>
+ </c:map-property>
+ </c:list-property>
+ <c:list-property name="welcome-file" description="A welcome file declaration." >
+ <c:simple-property name="welcome-file" />
+ </c:list-property>
+ </c:map-property>
+ </resource-configuration>
+
<service name="Connector"
discovery="SubsystemDiscovery"
class="BaseComponent"
commit 13e821f0b60a26e6a4ea55cd8bacd523968d90f6
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Wed Jul 27 09:18:58 2011 +0200
Get rid of the explicit version number and let maven do the magic.
diff --git a/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
index 0927693..d9f79d1 100644
--- a/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
@@ -48,7 +48,6 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="urn:xmlns:rhq-plugin"
xmlns:c="urn:xmlns:rhq-configuration"
- version="4.0.0-SNAPSHOT"
>
<!-- <depends plugin="JMX" useClasses="true"/> -->
commit 0eb50dd5314086d110af46d614e3f607c1c1aac3
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Wed Jul 27 11:18:39 2011 +0200
Log the property being null and don't pollute stdout.
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ConfigurationLoadDelegate.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ConfigurationLoadDelegate.java
index e978962..c999be6 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ConfigurationLoadDelegate.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ConfigurationLoadDelegate.java
@@ -269,8 +269,10 @@ public class ConfigurationLoadDelegate implements ConfigurationFacet {
if (property!=null)
propertyMap.put(property);
- else
- System.out.println("Property " + key + " was null");
+ else {
+ if (log.isDebugEnabled())
+ log.debug("Property " + key + " was null");
+ }
}
commit 43a1577fe5b8de22132fc2dbe3d2f58fb92a06d2
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Mon Jul 25 18:00:50 2011 +0200
Provide more connection properties for standalone servers as well as the version. Add start and restart operations for standalone servers.
Read the running instance name (i.e. standalone server name) from standalone.xml
Allow to start a domain/host controller.
Allow to shut down hosts in a domain.
Allow to shut down host controllers. Revert the ability to shutdown hosts - this needs to be done at HC level.
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/AbstractBaseDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/AbstractBaseDiscovery.java
index 63a4e45..c089b79 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/AbstractBaseDiscovery.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/AbstractBaseDiscovery.java
@@ -46,9 +46,15 @@ public abstract class AbstractBaseDiscovery<T extends ResourceComponent> impleme
protected Document hostXml;
protected final Log log = LogFactory.getLog(this.getClass());
-// private final Log log = LogFactory.getLog(AbstractBaseDiscovery.class);
- protected void readHostXml(ProcessInfo processInfo,boolean isDomainMode) {
+ /**
+ * Read the host.xml or standalone.xml file depending on isDomainMode. If isDomainMode is true,
+ * host.xml is read, otherwise standalone.xml.
+ * The xml file content is stored in the variable hostXml for future use.
+ * @param processInfo Process info to determine the base file location
+ * @param isDomainMode Indiates if host.xml should be read (true) or standalone.xml (false)
+ */
+ protected void readStandaloneOrHostXml(ProcessInfo processInfo, boolean isDomainMode) {
String hostXmlFile = getHostXmlFileLocation(processInfo,isDomainMode);
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
try {
@@ -61,7 +67,11 @@ public abstract class AbstractBaseDiscovery<T extends ResourceComponent> impleme
}
}
-
+ /**
+ * Determine the server home (=base) directory by parsing the passed command line
+ * @param commandLine command line arguments of the process
+ * @return The home dir if found or empty string otherwise
+ */
String getHomeDirFromCommandLine(String[] commandLine) {
for (String line: commandLine) {
if (line.startsWith(DJBOSS_SERVER_HOME_DIR))
@@ -70,6 +80,11 @@ public abstract class AbstractBaseDiscovery<T extends ResourceComponent> impleme
return "";
}
+ /**
+ * Determine the location of the boot log file of the server by parsing the command line
+ * @param commandLine command line arguments of the process
+ * @return The log file location or empty string otherwise
+ */
String getLogFileFromCommandLine(String[] commandLine) {
for (String line: commandLine) {
@@ -79,7 +94,14 @@ public abstract class AbstractBaseDiscovery<T extends ResourceComponent> impleme
return "";
}
+ /**
+ * Try to obtain the management IP and port from the already parsed host.xml or standalone.xml
+ * @return an Object containing host and port
+ * @see #readStandaloneOrHostXml(org.rhq.core.system.ProcessInfo, boolean) on how to obtain the parsed xml
+ */
protected HostPort getManagementPortFromHostXml() {
+ if (hostXml==null)
+ throw new IllegalArgumentException("hostXml is null. You need to call 'readStandaloneOrHostXml' first.");
Element host = hostXml.getDocumentElement();
NodeList interfaceParent = host.getElementsByTagName("management-interfaces");
if (interfaceParent ==null || interfaceParent.getLength()==0) {
@@ -112,7 +134,15 @@ public abstract class AbstractBaseDiscovery<T extends ResourceComponent> impleme
return new HostPort();
}
+ /**
+ * Try to obtain the management interface IP from the host/standalone.xml files
+ * @param nIf Interface to look for
+ * @return IP address to use
+ */
private String getInterface(String nIf) {
+ if (hostXml==null)
+ throw new IllegalArgumentException("hostXml is null. You need to call 'readStandaloneOrHostXml' first.");
+
Element host = hostXml.getDocumentElement();
NodeList interfaceParent = host.getElementsByTagName("interfaces");
if (interfaceParent ==null || interfaceParent.getLength()==0) {
@@ -155,12 +185,26 @@ public abstract class AbstractBaseDiscovery<T extends ResourceComponent> impleme
return null; // TODO: Customise this generated block
}
+ /**
+ * Try to determine the host name - that is the name of a standalone server or a
+ * host in domain mode by looking at the standalone/host.xml files
+ * @return server name
+ */
protected String findHostName() {
+ if (hostXml==null)
+ throw new IllegalArgumentException("hostXml is null. You need to call 'readStandaloneOrHostXml' first.");
+
String hostName = hostXml.getDocumentElement().getAttribute("name");
return hostName;
}
+ /**
+ * Try to obtain the domain controller's location from looking at host.xml
+ * @return host and port of the domain controller
+ */
protected HostPort getDomainControllerFromHostXml() {
+ if (hostXml==null)
+ throw new IllegalArgumentException("hostXml is null. You need to call 'readStandaloneOrHostXml' first.");
Element host = hostXml.getDocumentElement();
NodeList dcParent = host.getElementsByTagName("domain-controller");
@@ -211,6 +255,9 @@ public abstract class AbstractBaseDiscovery<T extends ResourceComponent> impleme
}
+ /**
+ * Helper class that holds information about the host,port tuple
+ */
protected static class HostPort {
String host;
int port;
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java
index 8851706..776e5ef 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java
@@ -79,7 +79,7 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
final Log log = LogFactory.getLog(this.getClass());
ResourceContext context;
- Configuration conf;
+ Configuration pluginConfiguration;
String myServerName;
ASConnection connection;
String path;
@@ -107,16 +107,16 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
*/
public void start(ResourceContext context) throws InvalidPluginConfigurationException, Exception {
this.context = context;
- conf = context.getPluginConfiguration();
+ pluginConfiguration = context.getPluginConfiguration();
String typeName = context.getResourceType().getName();
// TODO can we use parent's connection and only set this up for top level base component?
- host = conf.getSimpleValue("hostname", LOCALHOST);
- String portString = conf.getSimpleValue("port", DEFAULT_HTTP_MANAGEMENT_PORT);
+ host = pluginConfiguration.getSimpleValue("hostname", LOCALHOST);
+ String portString = pluginConfiguration.getSimpleValue("port", DEFAULT_HTTP_MANAGEMENT_PORT);
port = Integer.parseInt(portString);
connection = new ASConnection(host,port);
- path = conf.getSimpleValue("path", null);
+ path = pluginConfiguration.getSimpleValue("path", null);
key = context.getResourceKey();
myServerName = context.getResourceKey().substring(context.getResourceKey().lastIndexOf("/")+1);
@@ -445,16 +445,15 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
List<PROPERTY_VALUE> address = new ArrayList<PROPERTY_VALUE>();
if (what.equals("server-group")) {
- String groupName = parameters.getSimpleValue("name",null);
+ String groupName = parameters.getSimpleValue("name","");
String profile = parameters.getSimpleValue("profile","default");
address.add(new PROPERTY_VALUE("server-group",groupName));
operation = new Operation(op,address,"profile",profile);
} else if (what.equals("server")) {
-
if (context.getResourceType().getName().equals("JBossAS-Managed")) {
- String host = conf.getSimpleValue("domainHost","local");
+ String host = pluginConfiguration.getSimpleValue("domainHost","local");
address.add(new PROPERTY_VALUE("host",host));
address.add(new PROPERTY_VALUE("server-config",myServerName));
operation = new Operation(op,address);
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseProcessDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseProcessDiscovery.java
index 2f71edb..475fd62 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseProcessDiscovery.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseProcessDiscovery.java
@@ -18,8 +18,11 @@
*/
package org.rhq.modules.plugins.jbossas7;
+import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
+import java.io.FileReader;
+import java.io.IOException;
import java.io.InputStream;
import java.util.HashSet;
import java.util.List;
@@ -30,7 +33,6 @@ import javax.xml.parsers.DocumentBuilderFactory;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.mc4j.ems.connection.support.metadata.LocalVMTypeDescriptor;
import org.w3c.dom.Document;
import org.rhq.core.domain.configuration.Configuration;
@@ -43,8 +45,6 @@ import org.rhq.core.pluginapi.inventory.ProcessScanResult;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
import org.rhq.core.system.ProcessInfo;
-import org.rhq.plugins.jmx.JMXDiscoveryComponent;
-
/**
* Discovery class
@@ -53,9 +53,10 @@ public class BaseProcessDiscovery extends AbstractBaseDiscovery implements Resou
{
- static final String DJBOSS_SERVER_BASE_DIR = "-Djboss.server.base.dir=";
+ static final String DJBOSS_HOME_DIR = "-Djboss.home.dir=";
static final String DORG_JBOSS_BOOT_LOG_FILE = "-Dorg.jboss.boot.log.file=";
static final String DLOGGING_CONFIGURATION = "-Dlogging.configuration=";
+ static final String DASH_DASH_SERVER_CONFIG = "--server-config=";
private final Log log = LogFactory.getLog(this.getClass());
/**
@@ -77,11 +78,13 @@ public class BaseProcessDiscovery extends AbstractBaseDiscovery implements Resou
String serverName;
String psName = psr.getProcessScan().getName();
String description = discoveryContext.getResourceType().getDescription();
+ String version = null;
+ String startScript;
if (psName.equals("ProcessController")) {
serverNameFull = "ProcessController";
serverName = "ProcessController";
} else if (psName.equals("HostController")) {
- readHostXml(psr.getProcessInfo(),true);
+ readStandaloneOrHostXml(psr.getProcessInfo(), true);
HostPort hp = getDomainControllerFromHostXml();
if (hp.isLocal) {
serverName = "DomainController";
@@ -92,11 +95,20 @@ public class BaseProcessDiscovery extends AbstractBaseDiscovery implements Resou
serverName = "HostController";
serverNameFull = "HostController";
}
- config.put(new PropertySimple("homedir",getHomeDirFromCommandLine(psr.getProcessInfo().getCommandLine())));
- // TODO add the start script
+ String homeDir = getHomeDirFromCommandLine(psr.getProcessInfo().getCommandLine());
+ config.put(new PropertySimple("baseDir", homeDir));
+ version = homeDir.substring(homeDir.lastIndexOf("-")+1);
+ config.put(new PropertySimple("startScript","bin/domain.sh"));
+ String host = findHost(psr.getProcessInfo(),true);
+ config.put(new PropertySimple("domainHost",host));
+
+ fillUserPassFromFile(config,"domain",homeDir);
+
+ // TODO provide running config
- } else {
- serverNameFull = getBaseDirFromCommandLine(commandLine);
+ } else { // Standalone server
+ serverNameFull = getHomeDirFromCommandLine(commandLine);
+ readStandaloneOrHostXml(psr.getProcessInfo(), false);
if (serverNameFull==null || serverNameFull.isEmpty()) {
// Try to obtain the server name
// -Dorg.jboss.boot.log.file=domain/servers/server-one/log/boot.log
@@ -111,10 +123,19 @@ public class BaseProcessDiscovery extends AbstractBaseDiscovery implements Resou
config.put(new PropertySimple("domainHost",host));
}
- serverName = serverNameFull.substring(serverNameFull.lastIndexOf("/")+1);
+ config.put(new PropertySimple("baseDir",serverNameFull));
+ serverName = findHostName();
if (serverName.isEmpty())
serverName = serverNameFull;
+ version = serverName.substring(serverName.lastIndexOf("-")+1);
+
+ String serverConfig = getServerConfigFromCommandLine(commandLine);
+ config.put(new PropertySimple("config",serverConfig));
+ config.put(new PropertySimple("startScript","bin/standalone.sh"));
+
+ fillUserPassFromFile(config,"standalone", serverNameFull);
+
}
String logFile = getLogFileFromCommandLine(commandLine);
initLogEventSourcesConfigProp(logFile,config);
@@ -139,7 +160,7 @@ public class BaseProcessDiscovery extends AbstractBaseDiscovery implements Resou
discoveryContext.getResourceType(), // ResourceType
serverNameFull, // key TODO distinguish per domain?
serverName, // Name
- null, // TODO real version ?
+ version, // TODO get via API ?Á
description, // Description
config,
psr.getProcessInfo()
@@ -155,6 +176,48 @@ public class BaseProcessDiscovery extends AbstractBaseDiscovery implements Resou
}
+ private void fillUserPassFromFile(Configuration config, String mode, String baseDir) {
+
+ String configDir = baseDir + File.separator + mode + File.separator + "configuration";
+
+ File file = new File(configDir ,"mgmt-users.properties");
+ if (!file.exists() || !file.canRead()) {
+ if (log.isDebugEnabled())
+ log.debug("No console user properties file found at [" + file.getAbsolutePath() + "] or file is not readable");
+ return;
+ }
+ BufferedReader br=null;
+ try {
+ FileReader fileReader = new FileReader(file);
+ br = new BufferedReader(fileReader);
+ String line;
+ while ((line = br.readLine())!=null) {
+ if (line.startsWith("#"))
+ continue;
+ if (line.isEmpty())
+ continue;
+ if (!line.contains("="))
+ continue;
+ // found a candidate
+ String user = line.substring(0,line.indexOf("="));
+ String pass = line.substring(line.indexOf("=")+1);
+ config.put(new PropertySimple("user",user));
+ config.put(new PropertySimple("password",pass));
+
+ }
+ } catch (IOException e) {
+ e.printStackTrace(); // TODO: Customise this generated block
+ } finally {
+ if (br!=null)
+ try {
+ br.close();
+ } catch (IOException e) {
+ // empty
+ }
+ }
+
+ }
+
private String findHost(ProcessInfo processInfo,boolean isDomain) {
String hostXmlFile = getHostXmlFileLocation(processInfo, isDomain);
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
@@ -173,12 +236,13 @@ public class BaseProcessDiscovery extends AbstractBaseDiscovery implements Resou
return hostName;
}
- String getBaseDirFromCommandLine(String[] commandLine) {
+
+ String getServerConfigFromCommandLine(String[] commandLine) {
for (String line: commandLine) {
- if (line.startsWith(DJBOSS_SERVER_BASE_DIR))
- return line.substring(DJBOSS_SERVER_BASE_DIR.length());
+ if (line.startsWith(DASH_DASH_SERVER_CONFIG))
+ return line.substring(DASH_DASH_SERVER_CONFIG.length());
}
- return "";
+ return "standalone.xml";
}
//-Dorg.jboss.boot.log.file=/devel/jbas7/jboss-as/build/target/jboss-7.0.0.Alpha2/domain/log/server-manager/boot.log
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseServerComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseServerComponent.java
new file mode 100644
index 0000000..c8703a6
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseServerComponent.java
@@ -0,0 +1,184 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.modules.plugins.jbossas7;
+
+import java.io.File;
+import java.net.ConnectException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.pluginapi.operation.OperationResult;
+import org.rhq.core.pluginapi.util.ProcessExecutionUtility;
+import org.rhq.core.system.ProcessExecution;
+import org.rhq.core.system.ProcessExecutionResults;
+import org.rhq.modules.plugins.jbossas7.json.Result;
+
+/**
+ * Base component for functionality that is common to Standalone AS and HostControllers
+ * @author Heiko W. Rupp
+ */
+public class BaseServerComponent extends BaseComponent {
+
+ private static final String STANDALONE_XML = "standalone.xml";
+ private static final String SEPARATOR = "\n-----------------------\n";
+ final Log log = LogFactory.getLog(BaseServerComponent.class);
+
+ /**
+ * Restart the server by first executing a 'shutdown' operation via its API. Then call
+ * the #startServer method to start it again.
+ *
+ * @param parameters Parameters to pass to the (recursive) invocation of #invokeOperation
+ * @param mode
+ * @return State of execution
+ * @throws Exception If anything goes wrong
+ */
+ protected OperationResult restartServer(Configuration parameters, Mode mode) throws Exception {
+ OperationResult tmp = invokeOperation("shutdown",parameters);
+
+ if (tmp.getErrorMessage()!=null) {
+ tmp.setErrorMessage("Restart failed while failing to shut down: " + tmp.getErrorMessage());
+ return tmp;
+ }
+ Thread.sleep(500); // Wait 0.5s -- this is plenty
+ return startServer(mode);
+ }
+
+ /**
+ * Start the server by calling the start script listed in the plugin configuration. If a different
+ * config is given, this is passed via --server-config
+ * @return State of Execution.
+ * @param mode
+ */
+ protected OperationResult startServer(Mode mode) {
+ OperationResult operationResult = new OperationResult();
+ Configuration conf = context.getPluginConfiguration();
+ String startScript = conf.getSimpleValue("startScript", mode.getStartScript());
+ String baseDir = conf.getSimpleValue("baseDir","");
+ if (baseDir.isEmpty()) {
+ operationResult.setErrorMessage("No base directory provided");
+ return operationResult;
+ }
+ String script = baseDir + File.separator + startScript;
+ String config = conf.getSimpleValue("config", mode.getXmlFile());
+
+ ProcessExecution processExecution;
+ processExecution = ProcessExecutionUtility.createProcessExecution(new File(script));
+ if (!config.equals(mode.getXmlFile())) {
+ processExecution.getArguments().add(mode.getConfigArg());
+ processExecution.getArguments().add(config);
+ }
+ processExecution.setWorkingDirectory(baseDir);
+ processExecution.setCaptureOutput(true);
+ processExecution.setWaitForCompletion(2000L); // 2 seconds // TODO: Should we wait longer than two seconds?
+ processExecution.setKillOnTimeout(false);
+
+
+ long start = System.currentTimeMillis();
+ if (log.isDebugEnabled()) {
+ log.debug("About to execute the following process: [" + processExecution + "]");
+ }
+ ProcessExecutionResults results = context.getSystemInformation().executeProcess(processExecution);
+ logExecutionResults(results);
+ if (results.getError()!=null) {
+ operationResult.setErrorMessage(results.getError().getMessage());
+ } else {
+ operationResult.setSimpleResult("Success");
+ }
+
+ return operationResult;
+
+ }
+
+ private void logExecutionResults(ProcessExecutionResults results) {
+ // Always log the output at info level. On Unix we could switch depending on a exitCode being !=0, but ...
+ log.info("Exit code from process execution: " + results.getExitCode());
+ log.info("Output from process execution: " + SEPARATOR + results.getCapturedOutput() + SEPARATOR);
+ }
+
+ /**
+ * Do some post processing of the Result - especially the 'shutdown' operation needs a special
+ * treatment.
+ * @param name Name of the operation
+ * @param res Result of the operation vs. AS7
+ * @return OperationResult filled in from values of res
+ */
+ protected OperationResult postProcessResult(String name, Result res) {
+ OperationResult operationResult = new OperationResult();
+ if (name.equals("shutdown")) {
+ /*
+ * Shutdown needs a special treatment, because after sending the operation, if shutdown suceeds,
+ * the server connection is closed and we can't read from it. So if we get connection refused for
+ * reading, this is a good sign.
+ */
+ if (!res.isSuccess()) {
+ if (res.getThrowable()!=null && (res.getThrowable() instanceof ConnectException || res.getThrowable().getMessage().equals("Connection refused")))
+ operationResult.setSimpleResult("Success");
+ else
+ operationResult.setErrorMessage(res.getFailureDescription());
+ }
+ }
+ else {
+ if (res.isSuccess()) {
+ if (res.getResult()!=null)
+ operationResult.setSimpleResult(res.getResult().toString());
+ else
+ operationResult.setSimpleResult("-None provided by server-");
+ }
+ else
+ operationResult.setErrorMessage(res.getFailureDescription());
+ }
+ return operationResult;
+ }
+
+ enum Mode {
+ STANDALONE(STANDALONE_XML,"standalone","--server-config","bin/standalone.sh"),
+ DOMAIN("domain.xml","domain", "--domain-config","bin/domain.sh"),
+ HOST("host.xml","domain", "--host-config","bin/domain.sh");
+
+ private String xmlFile;
+ private String baseDir;
+ private String configArg;
+ private String startScript;
+
+ private Mode(String xmlFile, String baseDir, String configArg, String startScript) {
+ this.xmlFile = xmlFile;
+ this.baseDir = baseDir;
+ this.configArg = configArg;
+ this.startScript = startScript;
+ }
+
+ public String getXmlFile() {
+ return xmlFile;
+ }
+
+ public String getBaseDir() {
+ return baseDir;
+ }
+
+ public String getConfigArg() {
+ return configArg;
+ }
+
+ public String getStartScript() {
+ return startScript;
+ }
+ }
+}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DomainComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DomainComponent.java
deleted file mode 100644
index c25fe88..0000000
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DomainComponent.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2011 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.modules.plugins.jbossas7;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.codehaus.jackson.JsonNode;
-
-import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.domain.measurement.AvailabilityType;
-import org.rhq.core.pluginapi.operation.OperationFacet;
-import org.rhq.core.pluginapi.operation.OperationResult;
-import org.rhq.modules.plugins.jbossas7.json.Operation;
-import org.rhq.modules.plugins.jbossas7.json.PROPERTY_VALUE;
-import org.rhq.modules.plugins.jbossas7.json.Result;
-
-/**
- * Common stuff for the Domain
- * @author Heiko W. Rupp
- */
-@SuppressWarnings("unused")
-public class DomainComponent extends BaseComponent implements OperationFacet{
-
- @Override
- public AvailabilityType getAvailability() {
-
- if (context.getResourceType().getName().equals("JBossAS-Managed")) {
- List<PROPERTY_VALUE> address = new ArrayList<PROPERTY_VALUE>(2);
- String host = conf.getSimpleValue("domainHost","local");
- address.add(new PROPERTY_VALUE("host",host));
- address.add(new PROPERTY_VALUE("server-config",myServerName));
- Operation getStatus = new Operation("read-attribute",address,"name","status");
- Result result = null;
- try {
- result = connection.execute(getStatus);
- } catch (Exception e) {
- log.warn(e.getMessage());
- return AvailabilityType.DOWN;
- }
- if (!result.isSuccess())
- return AvailabilityType.DOWN;
-
- String msg = result.getResult().toString();
- if (msg.contains("STARTED"))
- return AvailabilityType.UP;
- else
- return AvailabilityType.DOWN;
- }
-
- return super.getAvailability(); // TODO: Customise this generated block
- }
-
-}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/HostControllerComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/HostControllerComponent.java
new file mode 100644
index 0000000..73eb0bb
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/HostControllerComponent.java
@@ -0,0 +1,64 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.modules.plugins.jbossas7;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.pluginapi.operation.OperationFacet;
+import org.rhq.core.pluginapi.operation.OperationResult;
+import org.rhq.modules.plugins.jbossas7.json.Operation;
+import org.rhq.modules.plugins.jbossas7.json.Result;
+
+/**
+ * Component class for host- and domain controller
+ * @author Heiko W. Rupp
+ */
+public class HostControllerComponent extends BaseServerComponent implements OperationFacet {
+
+ private final Log log = LogFactory.getLog(HostControllerComponent.class);
+
+ @Override
+ public OperationResult invokeOperation(String name,
+ Configuration parameters) throws InterruptedException, Exception {
+
+ if (name.equals("start")) {
+ return startServer(Mode.DOMAIN);
+ } else if (name.equals("restart")) {
+ return restartServer(parameters, Mode.DOMAIN);
+
+ } else if (name.equals("shutdown")) {
+ // This is a bit trickier, as it needs to be executed on the level on /host=xx
+ String domainHost = pluginConfiguration.getSimpleValue("domainHost","");
+ if (domainHost.isEmpty()) {
+ OperationResult result = new OperationResult();
+ result.setErrorMessage("No domain host found - can not continue");
+ return result;
+ }
+ Operation op = new Operation("shutdown","host",domainHost);
+ Result res = getASConnection().execute(op);
+
+ postProcessResult(name,res);
+ }
+
+ // Defer other stuff to the base component for now
+ return super.invokeOperation(name, parameters);
+ }
+}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/JmsComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/JmsComponent.java
index d0d3eee..951430c 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/JmsComponent.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/JmsComponent.java
@@ -32,7 +32,6 @@ import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
import org.rhq.core.domain.configuration.definition.PropertyDefinitionList;
import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple;
-import org.rhq.core.domain.configuration.definition.PropertySimpleType;
import org.rhq.core.domain.resource.CreateResourceStatus;
import org.rhq.core.pluginapi.inventory.CreateResourceReport;
import org.rhq.modules.plugins.jbossas7.json.ComplexResult;
@@ -43,7 +42,7 @@ import org.rhq.modules.plugins.jbossas7.json.PROPERTY_VALUE;
* Component class for the JMS subsystem
* @author Heiko W. Rupp
*/
-public class JmsComponent extends DomainComponent {
+public class JmsComponent extends BaseComponent {
private final Log log = LogFactory.getLog(JmsComponent.class);
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ManagedASComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ManagedASComponent.java
new file mode 100644
index 0000000..64ac2b6
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ManagedASComponent.java
@@ -0,0 +1,70 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.modules.plugins.jbossas7;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.rhq.core.domain.measurement.AvailabilityType;
+import org.rhq.modules.plugins.jbossas7.json.Operation;
+import org.rhq.modules.plugins.jbossas7.json.PROPERTY_VALUE;
+import org.rhq.modules.plugins.jbossas7.json.Result;
+
+/**
+ * Common stuff for the Domain
+ * @author Heiko W. Rupp
+ */
+@SuppressWarnings("unused")
+public class ManagedASComponent extends BaseComponent {
+
+ /**
+ * Get the availability of the managed AS server. We can't just check if
+ * a connection succeeds, as the check runs against the API/HostController
+ * and the managed server may still be down even if the connection succeeds.
+ * @return Availability of the managed AS instance.
+ */
+ @Override
+ public AvailabilityType getAvailability() {
+
+ if (context.getResourceType().getName().equals("JBossAS-Managed")) {
+ List<PROPERTY_VALUE> address = new ArrayList<PROPERTY_VALUE>(2);
+ String host = pluginConfiguration.getSimpleValue("domainHost","local");
+ address.add(new PROPERTY_VALUE("host",host));
+ address.add(new PROPERTY_VALUE("server-config",myServerName));
+ Operation getStatus = new Operation("read-attribute",address,"name","status");
+ Result result = null;
+ try {
+ result = connection.execute(getStatus);
+ } catch (Exception e) {
+ log.warn(e.getMessage());
+ return AvailabilityType.DOWN;
+ }
+ if (!result.isSuccess())
+ return AvailabilityType.DOWN;
+
+ String msg = result.getResult().toString();
+ if (msg.contains("STARTED"))
+ return AvailabilityType.UP;
+ else
+ return AvailabilityType.DOWN;
+ }
+
+ return super.getAvailability();
+ }
+}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ManagedASDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ManagedASDiscovery.java
index 3946dbe..fd1b65d 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ManagedASDiscovery.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ManagedASDiscovery.java
@@ -70,7 +70,7 @@ public class ManagedASDiscovery extends AbstractBaseDiscovery
// Now we have the host controller, lets get the host.xml file
// and obtain the servers from there.
ProcessInfo processInfo = psr.getProcessInfo();
- readHostXml(processInfo,true);
+ readStandaloneOrHostXml(processInfo, true);
String hostName = findHostName();
HostPort managementHostPort = getManagementPortFromHostXml();
@@ -105,13 +105,16 @@ public class ManagedASDiscovery extends AbstractBaseDiscovery
// TODO this fails for the downed servers.
// get from the domain or other place as soon as the domain provides it.
- initLogFile(scans, serverInfo.name, config, getHomeDirFromCommandLine(processInfo.getCommandLine()));
+ String homeDir = getHomeDirFromCommandLine(processInfo.getCommandLine());
+ initLogFile(scans, serverInfo.name, config, homeDir);
+
+ String version = homeDir.substring(homeDir.lastIndexOf("-")+1);
DiscoveredResourceDetails detail = new DiscoveredResourceDetails(
discoveryContext.getResourceType(), // ResourceType
hostName + "/" + serverInfo.name, // key
serverInfo.name, // Name
- null, // TODO real version - get from Domain as soon as it is provided
+ version, // TODO get from Domain as soon as it is provided
"Managed AS 7 instance", // Description
config,
null
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ServerGroupComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ServerGroupComponent.java
index 15cb5d3..ad1109b 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ServerGroupComponent.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ServerGroupComponent.java
@@ -23,7 +23,6 @@ import java.io.OutputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -38,12 +37,10 @@ import org.rhq.core.domain.content.transfer.DeployPackageStep;
import org.rhq.core.domain.content.transfer.DeployPackagesResponse;
import org.rhq.core.domain.content.transfer.RemovePackagesResponse;
import org.rhq.core.domain.content.transfer.ResourcePackageDetails;
-import org.rhq.core.domain.resource.CreateResourceStatus;
import org.rhq.core.pluginapi.content.ContentContext;
import org.rhq.core.pluginapi.content.ContentFacet;
import org.rhq.core.pluginapi.content.ContentServices;
import org.rhq.core.pluginapi.inventory.CreateChildResourceFacet;
-import org.rhq.core.pluginapi.inventory.CreateResourceReport;
import org.rhq.modules.plugins.jbossas7.json.CompositeOperation;
import org.rhq.modules.plugins.jbossas7.json.Operation;
import org.rhq.modules.plugins.jbossas7.json.PROPERTY_VALUE;
@@ -55,7 +52,7 @@ import org.rhq.modules.plugins.jbossas7.json.Result;
* @author Heiko W. Rupp
*/
@SuppressWarnings("unused")
-public class ServerGroupComponent extends DomainComponent implements ContentFacet, CreateChildResourceFacet {
+public class ServerGroupComponent extends ManagedASComponent implements ContentFacet, CreateChildResourceFacet {
private static final String SUCCESS = "success";
private static final String OUTCOME = "outcome";
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/StandaloneASComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/StandaloneASComponent.java
index 0281279..ebddf95 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/StandaloneASComponent.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/StandaloneASComponent.java
@@ -31,41 +31,25 @@ import org.rhq.modules.plugins.jbossas7.json.Result;
* Component class for standalone AS7 servers
* @author Heiko W. Rupp
*/
-public class StandaloneASComponent extends BaseComponent implements OperationFacet {
-
+public class StandaloneASComponent extends BaseServerComponent implements OperationFacet {
@Override
public OperationResult invokeOperation(String name,
Configuration parameters) throws Exception {
- // reload, shutdown
+ if (name.equals("start")) {
+ return startServer(Mode.STANDALONE);
+ } else if (name.equals("restart")) {
+ return restartServer(parameters, Mode.STANDALONE);
+
+ }
+
+ // reload, shutdown go to the remote server
Operation op = new Operation(name,new Address());
Result res = getASConnection().execute(op);
- OperationResult operationResult = new OperationResult();
- if (name.equals("shutdown")) {
- /*
- * Shutdown needs a special treatment, because after sending the operation, if shutdown suceeds,
- * the server connection is closed and we can't read from it. So if we get connection refused for
- * reading, this is a good sign.
- */
- if (!res.isSuccess()) {
- if (res.getThrowable() instanceof ConnectException || res.getThrowable().getMessage().equals("Connection refused"))
- operationResult.setSimpleResult("Success");
- else
- operationResult.setErrorMessage(res.getFailureDescription());
- }
- }
- else {
- if (res.isSuccess()) {
- if (res.getResult()!=null)
- operationResult.setSimpleResult(res.getResult().toString());
- else
- operationResult.setSimpleResult("-None provided by server-");
- }
- else
- operationResult.setErrorMessage(res.getFailureDescription());
- }
+ OperationResult operationResult = postProcessResult(name, res);
return operationResult;
}
+
}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Address.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Address.java
index ad91dac..d762485 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Address.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Address.java
@@ -51,6 +51,25 @@ public class Address {
path.addAll(other);
}
+ public Address(String path) {
+ this();
+ String[] components = path.split(",");
+ for (String component : components) {
+ String tmp = component.trim();
+
+ if (tmp.contains("=")) {
+ // strip / from the start of the key if it happens to be there
+ if (tmp.startsWith("/"))
+ tmp = tmp.substring(1);
+
+ String[] pair = tmp.split("=");
+ PROPERTY_VALUE valuePair = new PROPERTY_VALUE(pair[0], pair[1]);
+ this.path.add(valuePair);
+ }
+ }
+
+ }
+
public void add(String key, String value) {
path.add(new PROPERTY_VALUE(key,value));
}
diff --git a/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
index c0e364d..0927693 100644
--- a/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
@@ -58,6 +58,7 @@
~~ additional 'Personalities' for the kinds of servers (PM, SM, Standalone AS, Managed AS)
-->
+ <!-- TODO do we want to show the process controller at all? We have no benefit from it
<server name="ProcessController"
discovery="BaseProcessDiscovery"
class="BaseComponent"
@@ -68,27 +69,28 @@
<c:simple-property name="hostname" default="localhost" required="true"/>
<c:simple-property name="port" default="9990" type="integer" required="true"/>
- &logSources;
</plugin-configuration>
<process-scan name="ProcessController" query="process|basename|match=^java.*,arg|org.jboss.as.process-controller|match=.*"/>
- <operation name="dummyOperation">
- <!-- TODO supply parameters and return values -->
- </operation>
-
-
</server>
+ -->
<server name="HostController"
discovery="BaseProcessDiscovery"
- class="BaseComponent"
+ class="HostControllerComponent"
description="Domain controller (delegate) for this host"
>
<plugin-configuration>
- <c:simple-property name="hostname" default="localhost" required="true"/>
- <c:simple-property name="port" default="9990" type="integer" required="true"/>
+ <c:simple-property name="hostname" default="localhost" required="true" description="Host name of the domain API"/>
+ <c:simple-property name="port" default="9990" type="integer" required="true" description="Port of the domain API"/>
+ <c:simple-property name="user" type="string" description="Management user for a secured Host controller" required="false"/>
+ <c:simple-property name="password" type="password" description="Password for the management user" required="false"/>
+ <c:simple-property name="config" type="string" default="domain.xml" description="Running configuration" displayName="Configuration"/>
+ <c:simple-property name="baseDir" type="file" description="Base directory of the server installation" displayName="Base directory" readOnly="true" required="false"/>
+ <c:simple-property name="startScript" type="file" default="bin/domain.sh" description="Script used to start the server. If the path is not absolute, it is relative to the base directory"/>
+ <c:simple-property name="domainHost" type="string" readOnly="true" required="false" description="Host name within the AS7 domain"/>
&logSources;
</plugin-configuration>
@@ -96,8 +98,10 @@
<process-scan name="HostController" query="process|basename|match=^java.*,arg|org.jboss.as.host-controller|match=.*"/>
+<!-- Currently not provided by AS7
<operation name="domain:shutdown" displayName="Shutdown Domain" description="Shut this Host-/Domaincontroller down with all managed servers.">
</operation>
+-->
<operation name="server-group:add" displayName="Add ServerGroup" description="Add a server group to the Domain.">
<parameters>
@@ -146,6 +150,17 @@
</operation>
+ <operation name="start" description="Start this Host-/Domaincontroller" displayName="Start this host controller">
+ <results>
+ <c:simple-property name="operationResult" description="Outcome of the start operation"/>
+ </results>
+ </operation>
+ <operation name="shutdown" description="Stop this Host-/Domaincontroller" displayName="Shut down this host controller">
+ <results>
+ <c:simple-property name="operationResult" description="Outcome of the stop operation"/>
+ </results>
+ </operation>
+
<metric property="_internal:mgmtRequests" category="performance" dataType="measurement" defaultInterval="120000"
displayType="summary" measurementType="trendsup" description="Number of requests sent to the controller"
@@ -206,7 +221,7 @@
<resource-configuration>
<c:simple-property name="profile" description="The profile name" required="true"/>
<c:simple-property name="socket-binding-group" readOnly="false" required="true">
- <c:option-source target="resource" expression="type=SocketBindingGroup"/>
+ <c:option-source target="resource" expression="type=SocketBindingGroupDomain"/>
</c:simple-property>
<c:simple-property name="socket-binding-port-offset" required="false" defaultValue="0" type="integer"
description="The default offset to be added to the port values given by the socket binding group."/>
@@ -217,7 +232,7 @@
<server name="Host"
description="Host involved in this domain"
discovery="SubsystemDiscovery"
- class="DomainComponent"
+ class="BaseComponent"
>
<plugin-configuration>
<c:simple-property name="path" default="host" readOnly="true"/>
@@ -287,11 +302,17 @@
<server name="JBossAS7-Standalone"
discovery="BaseProcessDiscovery"
class="StandaloneASComponent"
+ description="Standalone AS7 server"
>
<plugin-configuration>
<c:simple-property name="hostname" default="localhost" required="true"/>
<c:simple-property name="port" default="9990" type="integer" required="true"/>
+ <c:simple-property name="user" type="string" description="Management user for a secured AS" required="false"/>
+ <c:simple-property name="password" type="password" description="Password for the management user" required="false"/>
+ <c:simple-property name="config" type="string" default="standalone.xml" description="Running configuration" displayName="Configuration"/>
+ <c:simple-property name="baseDir" type="file" description="Base directory of the server installation" displayName="Base directory" readOnly="true" required="false"/>
+ <c:simple-property name="startScript" type="file" default="bin/standalone.sh" description="Script used to start the server. If the path is not absolute, it is relative to the base directory"/>
<c:list-property name="system-properties">
<c:map-property name="system-property">
<c:simple-property name="key" readOnly="true"/>
@@ -303,7 +324,18 @@
<process-scan name="StandaloneAS" query="process|basename|match=^java.*,arg|org.jboss.as.standalone|match=.*"/>
- <operation name="reload" description="Make the server load the (changed) configuration." displayName="Reload">
+
+ <operation name="reload" description="Make the server re-load the (changed) configuration. To load a different startup config use 'restart'" displayName="Reload">
+ <results>
+ <c:simple-property name="operationResult"/>
+ </results>
+ </operation>
+ <operation name="start" description="Start the server by invoking its start script">
+ <results>
+ <c:simple-property name="operationResult"/>
+ </results>
+ </operation>
+ <operation name="restart" description="Restart the server by shutting it down and invoking its start script">
<results>
<c:simple-property name="operationResult"/>
</results>
@@ -353,14 +385,14 @@
<server name="JBossAS-Managed"
discovery="ManagedASDiscovery"
- class="DomainComponent"
+ class="ManagedASComponent"
>
<plugin-configuration>
<c:simple-property name="hostname" default="localhost" displayName="Management host" required="true"/>
<c:simple-property name="port" default="9990" type="integer" displayName="Management port" required="true"/>
<c:simple-property name="domainHost" readOnly="true" description="Hostname in the domain"/>
<c:simple-property name="group" readOnly="true" displayName="Server Group" description="Server Group this instance belongs to."/>
- <c:simple-property name="socket-binding-group" readOnly="true" displayName="Socket binding group" description="Socket bindngs to use"/>
+ <c:simple-property name="socket-binding-group" readOnly="true" displayName="Socket binding group" description="Socket bindings to use"/>
<c:simple-property name="socket-binding-port-offset" readOnly="true" displayName="Port Offset" type="integer" default="0" description="Offset to the base ports"/>
<c:simple-property name="path" readOnly="true" />
@@ -412,7 +444,7 @@
<server name="Messaging"
discovery="SubsystemDiscovery"
- class="DomainComponent"
+ class="BaseComponent"
description="The underlying HornetQ based messaging subsystem"
singleton="true"
>
@@ -1792,8 +1824,8 @@ working area for individual server instances</li></ul>"/>
<c:list-property name="includes" required="false">
<c:simple-property name="includes" displayName="Included bindings" description="Other bindings that are included in this one (only needed in Domain Mode)"/>
</c:list-property>
- <c:group name="children:socket.binding">
- <c:list-property name="socket-binding">
+ <c:group name="children:socket-binding:name" displayName="Individual socket bindings">
+ <c:list-property name="*">
<c:map-property name="binding">
<c:simple-property name="name" description="The name of the socket. Services which need to access the socket configuration information will find it using this name." readOnly="true"/>
<c:simple-property name="interface" description="Name of the interface to which the socket should be bound, or, for multicast sockets, the interface on which it should listen. This should be one of the declared interfaces."
commit 9933f0e155e2274864458e042614ae8216768f5e
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Mon Jul 25 17:25:23 2011 +0200
BZ 725417 - if the 'default' attribute is missing on a required property, throw a descriptive exception instead of a NPE.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/metadata/PluginConfigurationMetadataManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/metadata/PluginConfigurationMetadataManagerBean.java
index 9b2d1db..3963f9d 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/metadata/PluginConfigurationMetadataManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/metadata/PluginConfigurationMetadataManagerBean.java
@@ -106,8 +106,14 @@ public class PluginConfigurationMetadataManagerBean implements PluginConfigurati
for (PropertyDefinition propertyDef : updateReport.getNewPropertyDefinitions()) {
if (propertyDef.isRequired()) {
Property templateProperty = templateConfiguration.get(propertyDef.getName());
- pluginConfiguration.put(templateProperty.deepCopy(false));
- modified = true;
+ if (templateProperty==null) {
+ throw new IllegalArgumentException("The property [" + propertyDef.getName()
+ + "] marked as required in the configuration definition of [" + propertyDef.getConfigurationDefinition().getName()
+ + "] has no attribute 'default'");
+ } else {
+ pluginConfiguration.put(templateProperty.deepCopy(false));
+ modified = true;
+ }
}
}
commit 98365fa7de2d2859473dd0e3bbd68004b837ee57
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Mon Jul 25 07:54:06 2011 +0200
Extract the deploy-to-server-magic from createChild() and add tests to use this extracted code to deploy to domain and server-group.
diff --git a/modules/integration-tests/jboss-as-7-plugin-test/src/test/java/org/rhq/modules/integrationTests/jbossas7plugin/UploadAndDeployTest.java b/modules/integration-tests/jboss-as-7-plugin-test/src/test/java/org/rhq/modules/integrationTests/jbossas7plugin/UploadAndDeployTest.java
index 8581ada..2010640 100644
--- a/modules/integration-tests/jboss-as-7-plugin-test/src/test/java/org/rhq/modules/integrationTests/jbossas7plugin/UploadAndDeployTest.java
+++ b/modules/integration-tests/jboss-as-7-plugin-test/src/test/java/org/rhq/modules/integrationTests/jbossas7plugin/UploadAndDeployTest.java
@@ -26,7 +26,17 @@ import java.util.Map;
import org.codehaus.jackson.JsonNode;
import org.testng.annotations.Test;
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.content.PackageDetailsKey;
+import org.rhq.core.domain.content.transfer.ResourcePackageDetails;
+import org.rhq.core.domain.resource.CreateResourceStatus;
+import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.core.pluginapi.inventory.CreateResourceReport;
+import org.rhq.core.pluginapi.inventory.ResourceContext;
import org.rhq.modules.plugins.jbossas7.ASConnection;
+import org.rhq.modules.plugins.jbossas7.BaseComponent;
+import org.rhq.modules.plugins.jbossas7.json.Address;
import org.rhq.modules.plugins.jbossas7.json.CompositeOperation;
import org.rhq.modules.plugins.jbossas7.json.Operation;
import org.rhq.modules.plugins.jbossas7.json.PROPERTY_VALUE;
@@ -292,7 +302,7 @@ public class UploadAndDeployTest extends AbstractIntegrationTest {
/**
* Test uploading to domain only, but not to a server group
- * @throws Exception
+ * @throws Exception if anything goes wrong.
*/
@Test(timeOut = 60*1000L,enabled = isEnabled)
public void testUploadComposite2() throws Exception {
@@ -346,4 +356,77 @@ public class UploadAndDeployTest extends AbstractIntegrationTest {
}
+ /**
+ * Test the real API code for uploading - case 1: just upload to /deployment
+ * @throws Exception if anything goes wrong.
+ */
+ @Test
+ public void testUploadViaCreateChild1() throws Exception {
+
+ BaseComponent bc = new BaseComponent();
+ bc.setConnection(getASConnection());
+ bc.setPath("");
+ ResourceType rt = new ResourceType();
+ rt.setName("Deployment");
+ Resource resource = new Resource("deployment="+TEST_WAR,TEST_WAR,rt); // TODO resource key?
+ ResourceContext context = new ResourceContext(resource,null,null,null,null,null,null,null,null,null,null,null);
+ bc.start(context);
+
+ String bytes_value = uploadToAs(TEST_WAR);
+
+ ResourcePackageDetails details = new ResourcePackageDetails(new PackageDetailsKey(TEST_WAR,"1.0","deployment","all"));
+ CreateResourceReport report = new CreateResourceReport(TEST_WAR,rt,new Configuration(), new Configuration(),details);
+ try {
+ report = bc.runDeploymentMagicOnServer(report,TEST_WAR,TEST_WAR,bytes_value);
+ assert report != null;
+ assert report.getErrorMessage()==null: "Report contained an unexpected error: " + report.getErrorMessage();
+ assert report.getStatus()!=null : "Report did not contain a status";
+ assert report.getStatus()== CreateResourceStatus.SUCCESS : "Status was no success";
+ assert report.getResourceName().equals(TEST_WAR);
+ assert report.getResourceKey().equals("deployment=" + TEST_WAR);
+ } finally {
+ Remove r =new Remove("deployment",TEST_WAR);
+ getASConnection().execute(r);
+ }
+
+ }
+
+ /**
+ * Test the real API code for uploading - case 2: upload to /deployment and a server group
+ * @throws Exception if anything goes wrong.
+ */
+ @Test
+ public void testUploadViaCreateChild2() throws Exception {
+
+ BaseComponent bc = new BaseComponent();
+ bc.setConnection(getASConnection());
+ bc.setPath("server-group=main-server-group");
+ ResourceType rt = new ResourceType();
+ rt.setName("Deployment");
+ Resource resource = new Resource("server-group=main-server-group",TEST_WAR,rt);
+ ResourceContext context = new ResourceContext(resource,null,null,null,null,null,null,null,null,null,null,null);
+ bc.start(context);
+
+ String bytes_value = uploadToAs(TEST_WAR);
+
+ ResourcePackageDetails details = new ResourcePackageDetails(new PackageDetailsKey(TEST_WAR,"1.0","deployment","all"));
+ CreateResourceReport report = new CreateResourceReport(TEST_WAR,rt,new Configuration(), new Configuration(),details);
+ try {
+ report = bc.runDeploymentMagicOnServer(report,TEST_WAR,TEST_WAR,bytes_value);
+ assert report != null;
+ assert report.getErrorMessage()==null: "Report contained an unexpected error: " + report.getErrorMessage();
+ assert report.getStatus()!=null : "Report did not contain a status";
+ assert report.getStatus()== CreateResourceStatus.SUCCESS : "Status was no success";
+ assert report.getResourceName().equals(TEST_WAR);
+ assert report.getResourceKey().equals("server-group=main-server-group,deployment=" + TEST_WAR) : "Resource key was wrong";
+ } finally {
+ Address sgd = new Address("server-group","main-server-group");
+ sgd.add("deployment", TEST_WAR);
+ Remove r =new Remove(sgd);
+ getASConnection().execute(r);
+ r =new Remove("deployment",TEST_WAR);
+ getASConnection().execute(r);
+ }
+
+ }
}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java
index 83b221b..8851706 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java
@@ -331,18 +331,34 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
fileName=fileName.substring("C:\\fakepath\\".length());
}
- boolean toServerGroup = context.getResourceKey().contains("server-group=");
- log.info("Deploying [" + fileName + "] to domain only= " + !toServerGroup + " ...");
String tmpName = fileName; // TODO figure out the tmp-name biz with the AS guys
JsonNode resultNode = uploadResult.get("result");
String hash = resultNode.get("BYTES_VALUE").getTextValue();
+ return runDeploymentMagicOnServer(report, fileName, tmpName, hash);
+
+ }
+
+ /**
+ * Do the actual fumbling with the domain api to deploy the uploaded content
+ * @param report CreateResourceReport to report the result
+ * @param runtimeName File name to use as runtime name
+ * @param deploymentName Name of the deployment
+ * @param hash Hash of the content bytes
+ * @return the passed report with success or failure settings
+ */
+ public CreateResourceReport runDeploymentMagicOnServer(CreateResourceReport report, String runtimeName,
+ String deploymentName, String hash) {
+
+ boolean toServerGroup = context.getResourceKey().contains("server-group=");
+ log.info("Deploying [" + runtimeName + "] to domain only= " + !toServerGroup + " ...");
+
ASConnection connection = getASConnection();
- Operation step1 = new Operation("add","deployment",tmpName);
+ Operation step1 = new Operation("add","deployment",deploymentName);
// step1.addAdditionalProperty("hash", new PROPERTY_VALUE("BYTES_VALUE", hash));
List<Object> content = new ArrayList<Object>(1);
Map<String,Object> contentValues = new HashMap<String,Object>();
@@ -350,8 +366,8 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
content.add(contentValues);
step1.addAdditionalProperty("content",content);
- step1.addAdditionalProperty("name", tmpName);
- step1.addAdditionalProperty("runtime-name", fileName);
+ step1.addAdditionalProperty("name", deploymentName);
+ step1.addAdditionalProperty("runtime-name", runtimeName);
String resourceKey;
Result result ;
@@ -379,7 +395,7 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
List<PROPERTY_VALUE> serverGroupAddress = new ArrayList<PROPERTY_VALUE>();
serverGroupAddress.addAll(pathToAddress(context.getResourceKey()));
- serverGroupAddress.add(new PROPERTY_VALUE("deployment", tmpName));
+ serverGroupAddress.add(new PROPERTY_VALUE("deployment", deploymentName));
Operation step2 = new Operation("add",serverGroupAddress);
cop.addStep(step2);
@@ -403,13 +419,12 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
}
else {
report.setStatus(CreateResourceStatus.SUCCESS);
- report.setResourceName(fileName);
+ report.setResourceName(runtimeName);
report.setResourceKey(resourceKey);
log.info(" ... with success and key [" + resourceKey + "]" );
}
return report;
-
}
@Override
commit 707ed7b4a147918fcaa863e5fc2e4d0f64bed629
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Mon Jul 25 14:30:15 2011 +0200
Configuration.PropertiesProxy now delegates equals(), hashCode() and toString() to the configuration properties values as it should.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/Configuration.java b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/Configuration.java
index 5182b09..e8c0bc3 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/Configuration.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/Configuration.java
@@ -228,6 +228,26 @@ public class Configuration implements Serializable, Cloneable, AbstractPropertyM
public void clear() {
properties.clear();
}
+
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+
+ if (!(obj instanceof Collection)) {
+ return false;
+ }
+
+ return properties.values().equals(obj);
+ }
+
+ public int hashCode() {
+ return properties.values().hashCode();
+ }
+
+ public String toString() {
+ return properties.values().toString();
+ }
}
private transient PropertiesProxy propertiesProxy;
commit 6eedd25e13783a9fac64ee96f385a4a6ab8e0f87
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Jul 22 14:17:26 2011 -0400
tell eclipse that some source is now in the filtered sources location
diff --git a/.classpath b/.classpath
index c263ab4..d5bec34 100644
--- a/.classpath
+++ b/.classpath
@@ -154,6 +154,7 @@
<classpathentry kind="src" path="modules/enterprise/server/xml-schemas/target/generated-sources/xjc"/>
<classpathentry kind="src" path="modules/enterprise/server/jar/src/main/java"/>
<classpathentry kind="src" path="modules/enterprise/server/jar/src/test/java"/>
+ <classpathentry kind="src" path="modules/enterprise/server/jar/src/main/filtered-sources/java"/>
<classpathentry kind="src" path="modules/enterprise/server/jar/target/generated-sources/antlr3"/>
<classpathentry kind="src" path="modules/enterprise/binding/src/main/java"/>
<classpathentry kind="src" path="modules/enterprise/gui/coregui/src/main/java"/>
commit 327eca078a43e2a16dd7e17ade502c18661bfd86
Author: John Sanda <jsanda(a)redhat.com>
Date: Fri Jul 22 13:24:06 2011 -0400
Do not upload large amounts of data to the db for unit tests
We will however want to test uploading large and very large files in a
separate test suite.
diff --git a/modules/core/domain/src/test/java/org/rhq/core/domain/drift/DriftFileTest.java b/modules/core/domain/src/test/java/org/rhq/core/domain/drift/DriftFileTest.java
index b22ac84..05757a7 100644
--- a/modules/core/domain/src/test/java/org/rhq/core/domain/drift/DriftFileTest.java
+++ b/modules/core/domain/src/test/java/org/rhq/core/domain/drift/DriftFileTest.java
@@ -96,11 +96,11 @@ public class DriftFileTest extends AbstractEJB3Test {
// running and should be moved to an integration test suite.
@Test(groups = { "integration.ejb3", "driftFile" })
public void loadMultipleDriftFilesWithoutLoadingData() throws Exception {
- int numDriftFiles = 10;
+ int numDriftFiles = 3;
final List<String> driftFileHashIds = new ArrayList<String>();
for (int i = 0; i < numDriftFiles; ++i) {
- File dataFile = createDataFile("test_data.txt", 10, (char) ('a' + i));
+ File dataFile = createDataFile("test_data.txt", 1, (char) ('a' + i));
final DriftFileBits driftFile = new DriftFileBits();
driftFile.setDataSize(dataFile.length());
driftFile.setHashId(digestGen.calcDigestString(dataFile));
12 years, 10 months
[rhq] Branch 'drift' - modules/core
by John Sanda
modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftDetectionSchedule.java | 6 +
modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftManager.java | 42 ++++++++--
modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/ScheduleQueue.java | 6 -
modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/ScheduleQueueImpl.java | 24 +++--
modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/ResourceContainer.java | 12 ++
5 files changed, 72 insertions(+), 18 deletions(-)
New commits:
commit e14fb8a490ab8b2838612fcb6a5795427dfb93ad
Author: John Sanda <jsanda(a)redhat.com>
Date: Tue Jul 26 21:22:19 2011 -0400
Persist drift detection schedule across agent restarts
This commit add functionality for persisting drift detection schedules
across restarts. When the agent is shutting down and the inventory is
persisted to disk, the schedules are now written out to disk along with
the rest of the inventory.
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftDetectionSchedule.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftDetectionSchedule.java
index fe42744..ab5bac3 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftDetectionSchedule.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftDetectionSchedule.java
@@ -1,8 +1,12 @@
package org.rhq.core.pc.drift;
+import java.io.Serializable;
+
import org.rhq.core.domain.drift.DriftConfiguration;
-public class DriftDetectionSchedule implements Comparable<DriftDetectionSchedule> {
+public class DriftDetectionSchedule implements Comparable<DriftDetectionSchedule>, Serializable {
+
+ private static final long serialVersionUID = 1L;
private int resourceId;
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftManager.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftManager.java
index f499697..879ceca 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftManager.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftManager.java
@@ -67,11 +67,36 @@ public class DriftManager extends AgentService implements DriftAgentService, Dri
driftDetector.setChangeSetManager(changeSetMgr);
driftDetector.setDriftClient(this);
+ InventoryManager inventoryMgr = PluginContainer.getInstance().getInventoryManager();
+ initSchedules(inventoryMgr.getPlatform(), inventoryMgr);
+
driftThreadPool = new ScheduledThreadPoolExecutor(5);
// TODO Make the drift detection rate configurable
driftThreadPool.scheduleAtFixedRate(driftDetector, 30, 60, TimeUnit.SECONDS);
}
+ private void initSchedules(Resource r, InventoryManager inventoryMgr) {
+ if (r.getId() == 0) {
+ log.debug("Will not reschedule drift detection schedules for " + r + ". It is not sync'ed yet.");
+ return;
+ }
+
+ ResourceContainer container = inventoryMgr.getResourceContainer(r.getId());
+ if (container == null) {
+ log.debug("No resource container found for " + r + ". Unable to reschedule drift detection schedules.");
+ return;
+ }
+
+ log.debug("Rescheduling drift detection schedules for " + r);
+ for (DriftDetectionSchedule schedule : container.getDriftSchedules()) {
+ schedulesQueue.addSchedule(schedule);
+ }
+
+ for (Resource child : r.getChildResources()) {
+ initSchedules(child, inventoryMgr);
+ }
+ }
+
@Override
public void shutdown() {
driftThreadPool.shutdown();
@@ -164,8 +189,8 @@ public class DriftManager extends AgentService implements DriftAgentService, Dri
}
@Override
- public boolean update(int resourceId, DriftConfiguration config) {
- return false;
+ public DriftDetectionSchedule update(int resourceId, DriftConfiguration config) {
+ return schedule;
}
@Override
@@ -208,9 +233,16 @@ public class DriftManager extends AgentService implements DriftAgentService, Dri
@Override
public void updateDriftDetection(int resourceId, DriftConfiguration driftConfiguration) {
- boolean updated = schedulesQueue.update(resourceId, driftConfiguration);
- if (!updated) {
- schedulesQueue.addSchedule(new DriftDetectionSchedule(resourceId, driftConfiguration));
+ DriftDetectionSchedule updatedSchedule = schedulesQueue.update(resourceId, driftConfiguration);
+ if (updatedSchedule == null) {
+ updatedSchedule = new DriftDetectionSchedule(resourceId, driftConfiguration);
+ schedulesQueue.addSchedule(updatedSchedule);
+ }
+
+ InventoryManager inventoryMgr = PluginContainer.getInstance().getInventoryManager();
+ ResourceContainer container = inventoryMgr.getResourceContainer(resourceId);
+ if (container != null) {
+ container.getDriftSchedules().add(updatedSchedule);
}
}
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/ScheduleQueue.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/ScheduleQueue.java
index ca7edc5..374e27e 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/ScheduleQueue.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/ScheduleQueue.java
@@ -38,7 +38,7 @@ public interface ScheduleQueue {
* Adds a schedule to the queue for processing by the drift detector
*
* @param schedule A {@link DriftDetectionSchedule} object
- * @return true if the schedule is added, falsed otherwise
+ * @return true if the schedule is added, false otherwise
*/
boolean addSchedule(DriftDetectionSchedule schedule);
@@ -52,9 +52,9 @@ public interface ScheduleQueue {
*
* @param resourceId The resource id
* @param config A {@link DriftConfiguration} belonging the resource with the specified id
- * @return true if the schedule is updated, false otherwise.
+ * @return A copy of the updated schedule or null if no update was performed
*/
- boolean update(int resourceId, DriftConfiguration config);
+ DriftDetectionSchedule update(int resourceId, DriftConfiguration config);
/**
* Removes the schedule identified by the resource id and the drift configuration. More
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/ScheduleQueueImpl.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/ScheduleQueueImpl.java
index 499ad91..b4a2f00 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/ScheduleQueueImpl.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/ScheduleQueueImpl.java
@@ -112,20 +112,26 @@ public class ScheduleQueueImpl implements ScheduleQueue {
}
@Override
- public boolean update(int resourceId, DriftConfiguration config) {
+ public DriftDetectionSchedule update(int resourceId, DriftConfiguration config) {
try {
lock.writeLock().lock();
if (isActiveSchedule(resourceId, config)) {
update(activeSchedule, config);
- } else {
- DriftDetectionSchedule schedule = remove(resourceId, config);
- if (schedule == null) {
- return false;
- }
- update(schedule, config);
- queue.offer(schedule);
+ return activeSchedule.copy();
+ }
+
+ DriftDetectionSchedule schedule = remove(resourceId, config);
+ if (schedule == null) {
+ return null;
}
- return true;
+
+ update(schedule, config);
+
+ if (queue.offer(schedule)) {
+ return schedule.copy();
+ }
+
+ return null;
} finally {
lock.writeLock().unlock();
}
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/ResourceContainer.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/ResourceContainer.java
index ab8d30e..fcf1aea 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/ResourceContainer.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/ResourceContainer.java
@@ -52,6 +52,7 @@ import org.rhq.core.domain.measurement.Availability;
import org.rhq.core.domain.measurement.AvailabilityType;
import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.pc.drift.DriftDetectionSchedule;
import org.rhq.core.pc.util.FacetLockType;
import org.rhq.core.pc.util.LoggingThreadFactory;
import org.rhq.core.pluginapi.inventory.ResourceComponent;
@@ -88,6 +89,7 @@ public class ResourceContainer implements Serializable {
private SynchronizationState synchronizationState = SynchronizationState.NEW;
private Set<MeasurementScheduleRequest> measurementSchedule = new HashSet<MeasurementScheduleRequest>();
private Set<ResourcePackageDetails> installedPackages = new HashSet<ResourcePackageDetails>();
+ private Set<DriftDetectionSchedule> driftSchedules = new HashSet<DriftDetectionSchedule>();
// transient fields
private transient ResourceComponent resourceComponent;
@@ -242,6 +244,16 @@ public class ResourceContainer implements Serializable {
}
}
+ public Set<DriftDetectionSchedule> getDriftSchedules() {
+ synchronized (this) {
+ return driftSchedules;
+ }
+ }
+
+ public void setDriftSchedules(Set<DriftDetectionSchedule> schedules) {
+ driftSchedules = schedules;
+ }
+
public ResourceComponentState getResourceComponentState() {
synchronized (this) {
return this.resourceComponentState;
12 years, 10 months
[rhq] Branch 'release-3.0.0' - modules/plugins
by fdrabek
modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheDirectoryComponent.java | 126 +-
modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheDirectoryDiscoveryComponent.java | 77 -
modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheIfModuleComponent.java | 168 +--
modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheIfModuleDirectoryComponent.java | 68 -
modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheIfModuleDirectoryDiscoveryComponent.java | 62 -
modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheIfModuleDiscoveryComponent.java | 62 -
modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerComponent.java | 447 +++++-----
modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceComponent.java | 389 ++++----
modules/plugins/augeas/src/main/java/org/rhq/augeas/AugeasProxy.java | 64 +
modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationComponent.java | 202 ++--
modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/helper/AugeasRawConfigHelper.java | 28
modules/plugins/augeas/src/main/java/org/rhq/rhqtransform/AugeasRHQComponent.java | 22
modules/plugins/cron/src/main/java/org/rhq/plugins/cron/CronComponent.java | 78 +
modules/plugins/hosts/src/main/java/org/rhq/plugins/hosts/HostsComponent.java | 4
modules/plugins/samba/src/main/java/org/rhq/plugins/samba/SambaShareComponent.java | 21
modules/plugins/samba/src/main/java/org/rhq/plugins/samba/SambaShareDiscoveryComponent.java | 54 -
16 files changed, 1064 insertions(+), 808 deletions(-)
New commits:
commit 4cfd2eb0b6f12bb9e4cd77862a0aa0e2292580e2
Author: Filip Drabek <fdrabek(a)dhcp-lab-136.englab.brq.redhat.com>
Date: Wed Jul 27 01:04:54 2011 +0200
BZ-721152 avoiding memory leaks in plugins which uses augeas.
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheDirectoryComponent.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheDirectoryComponent.java
index 0c3f447..fb4a357 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheDirectoryComponent.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheDirectoryComponent.java
@@ -23,17 +23,13 @@
package org.rhq.plugins.apache;
-import java.util.ArrayList;
-import java.util.List;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.rhq.augeas.AugeasComponent;
import org.rhq.augeas.node.AugeasNode;
import org.rhq.augeas.tree.AugeasTree;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.ConfigurationUpdateStatus;
-import org.rhq.core.domain.configuration.Property;
-import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
import org.rhq.core.domain.measurement.AvailabilityType;
import org.rhq.core.pluginapi.configuration.ConfigurationFacet;
@@ -46,23 +42,24 @@ import org.rhq.plugins.apache.mapping.ApacheAugeasMapping;
import org.rhq.plugins.apache.util.AugeasNodeSearch;
/**
- * Component for configuring the <Directory> and underlying directives inside
- * Apache configuration.
+ * Component for configuring the <Directory> and underlying directives
+ * inside Apache configuration.
*
* @author Lukas Krejci
*/
-public class ApacheDirectoryComponent implements ResourceComponent<ApacheVirtualHostServiceComponent>, ConfigurationFacet, DeleteResourceFacet {
-
- private final Log log = LogFactory.getLog(this.getClass());
+public class ApacheDirectoryComponent implements ResourceComponent<ApacheVirtualHostServiceComponent>,
+ ConfigurationFacet, DeleteResourceFacet {
+
+ private final Log log = LogFactory.getLog(this.getClass());
public static final String REGEXP_PROP = "regexp";
public static final String DIRECTORY_DIRECTIVE = "<Directory";
-
+
private ResourceContext<ApacheVirtualHostServiceComponent> resourceContext;
-
- public void start(ResourceContext<ApacheVirtualHostServiceComponent> context) throws InvalidPluginConfigurationException, Exception {
- resourceContext = context;
- }
-
+
+ public void start(ResourceContext<ApacheVirtualHostServiceComponent> context)
+ throws InvalidPluginConfigurationException, Exception {
+ resourceContext = context;
+ }
public void stop() {
}
@@ -73,20 +70,30 @@ public class ApacheDirectoryComponent implements ResourceComponent<ApacheVirtual
public Configuration loadResourceConfiguration() throws Exception {
ApacheVirtualHostServiceComponent parentVirtualHost = resourceContext.getParentResourceComponent();
- AugeasTree tree = parentVirtualHost.getServerConfigurationTree();
- ConfigurationDefinition resourceConfigDef = resourceContext.getResourceType().getResourceConfigurationDefinition();
-
- AugeasNode virtualHostNode = parentVirtualHost.getNode(tree);
- ApacheAugeasMapping mapping = new ApacheAugeasMapping(tree);
- return mapping.updateConfiguration(getNode(virtualHostNode), resourceConfigDef);
+
+ AugeasComponent comp = null;
+ try {
+ comp = getAugeas();
+ AugeasTree tree = comp.getAugeasTree(ApacheServerComponent.AUGEAS_HTTP_MODULE_NAME);
+ ConfigurationDefinition resourceConfigDef = resourceContext.getResourceType()
+ .getResourceConfigurationDefinition();
+
+ AugeasNode virtualHostNode = parentVirtualHost.getNode(tree);
+ ApacheAugeasMapping mapping = new ApacheAugeasMapping(tree);
+ return mapping.updateConfiguration(getNode(virtualHostNode), resourceConfigDef);
+ } finally {
+ if (comp != null)
+ comp.close();
+ }
}
public void updateResourceConfiguration(ConfigurationUpdateReport report) {
- ApacheVirtualHostServiceComponent parentVirtualHost = resourceContext.getParentResourceComponent();
+ AugeasComponent comp = null;
AugeasTree tree = null;
try {
- tree = parentVirtualHost.getServerConfigurationTree();
+ comp = getAugeas();
+ tree = comp.getAugeasTree(ApacheServerComponent.AUGEAS_HTTP_MODULE_NAME);
ConfigurationDefinition resourceConfigDef = resourceContext.getResourceType()
.getResourceConfigurationDefinition();
ApacheAugeasMapping mapping = new ApacheAugeasMapping(tree);
@@ -96,7 +103,7 @@ public class ApacheDirectoryComponent implements ResourceComponent<ApacheVirtual
report.setStatus(ConfigurationUpdateStatus.SUCCESS);
log.info("Apache configuration was updated");
-
+
resourceContext.getParentResourceComponent().finishConfigurationUpdate(report);
} catch (Exception e) {
if (tree != null)
@@ -104,27 +111,37 @@ public class ApacheDirectoryComponent implements ResourceComponent<ApacheVirtual
else
log.error("Augeas failed to save configuration", e);
report.setStatus(ConfigurationUpdateStatus.FAILURE);
+ } finally {
+ if (comp != null)
+ comp.close();
}
- }
-
+ }
public void deleteResource() throws Exception {
ApacheVirtualHostServiceComponent parentVirtualHost = resourceContext.getParentResourceComponent();
- AugeasTree tree = parentVirtualHost.getServerConfigurationTree();
- AugeasNode virtualHostNode = parentVirtualHost.getNode(tree);
-
- AugeasNode myNode = getNode(virtualHostNode);
-
- if (myNode != null) {
- tree.removeNode(myNode, true);
- tree.save();
-
- ApacheVirtualHostServiceComponent parentVhost = resourceContext.getParentResourceComponent();
-
- parentVhost.deleteEmptyFile(tree, myNode);
- parentVhost.conditionalRestart();
- } else {
- log.info("Could find the configuration corresponding to the directory " + resourceContext.getResourceKey() + ". Ignoring.");
+ AugeasComponent comp = getAugeas();
+
+ try {
+ AugeasTree tree = comp.getAugeasTree(ApacheServerComponent.AUGEAS_HTTP_MODULE_NAME);
+ AugeasNode virtualHostNode = parentVirtualHost.getNode(tree);
+
+ AugeasNode myNode = getNode(virtualHostNode);
+
+ if (myNode != null) {
+ tree.removeNode(myNode, true);
+ tree.save();
+
+ ApacheVirtualHostServiceComponent parentVhost = resourceContext.getParentResourceComponent();
+
+ parentVhost.deleteEmptyFile(tree, myNode);
+ parentVhost.conditionalRestart();
+ } else {
+ log.info("Could find the configuration corresponding to the directory "
+ + resourceContext.getResourceKey() + ". Ignoring.");
+ }
+ } finally {
+ if (comp != null)
+ comp.close();
}
}
@@ -132,35 +149,36 @@ public class ApacheDirectoryComponent implements ResourceComponent<ApacheVirtual
* Gets the node from under given node corresponding to the Directory this
* component is managing.
*
- * @param virtualHost the node of the parent virtualHost (or root node of the augeas tree)
+ * @param virtualHost
+ * the node of the parent virtualHost (or root node of the augeas
+ * tree)
* @return
*/
public AugeasNode getNode(AugeasNode virtualHost) {
AugeasNode directory = AugeasNodeSearch.findNodeById(virtualHost, resourceContext.getResourceKey());
-
+
return directory;
}
-
- public AugeasNode getNode(){
+
+ public AugeasNode getNode(AugeasTree tree) {
ApacheVirtualHostServiceComponent virtHost = resourceContext.getParentResourceComponent();
- AugeasTree tree = virtHost.getServerConfigurationTree();
AugeasNode virtHostNode = resourceContext.getParentResourceComponent().getNode(tree);
return getNode(virtHostNode);
}
-
- public AugeasTree getServerConfigurationTree(){
- return resourceContext.getParentResourceComponent().getServerConfigurationTree();
+
+ public AugeasComponent getAugeas() {
+ return resourceContext.getParentResourceComponent().getAugeas();
}
-
+
/**
* @see ApacheServerComponent#finishConfigurationUpdate(ConfigurationUpdateReport)
*/
public void finishConfigurationUpdate(ConfigurationUpdateReport report) {
resourceContext.getParentResourceComponent().finishConfigurationUpdate(report);
}
-
- public boolean isAugeasEnabled(){
+
+ public boolean isAugeasEnabled() {
ApacheVirtualHostServiceComponent parent = resourceContext.getParentResourceComponent();
- return parent.isAugeasEnabled();
+ return parent.isAugeasEnabled();
}
}
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheDirectoryDiscoveryComponent.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheDirectoryDiscoveryComponent.java
index c407f34..56dea4b 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheDirectoryDiscoveryComponent.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheDirectoryDiscoveryComponent.java
@@ -29,6 +29,7 @@ import java.util.Set;
import net.augeas.AugeasException;
+import org.rhq.augeas.AugeasComponent;
import org.rhq.augeas.node.AugeasNode;
import org.rhq.augeas.tree.AugeasTree;
import org.rhq.core.domain.configuration.Configuration;
@@ -52,8 +53,8 @@ public class ApacheDirectoryDiscoveryComponent implements ResourceDiscoveryCompo
* @see org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent#discoverResources(org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext)
*/
public static final String DIRECTORY_DIRECTIVE = "<Directory";
- public static final String [] PARENT_DIRECTIVES = {"<IfModule"};
-
+ public static final String[] PARENT_DIRECTIVES = { "<IfModule" };
+
public Set<DiscoveredResourceDetails> discoverResources(
ResourceDiscoveryContext<ApacheVirtualHostServiceComponent> context)
throws InvalidPluginConfigurationException, Exception {
@@ -63,47 +64,55 @@ public class ApacheDirectoryDiscoveryComponent implements ResourceDiscoveryCompo
if (!context.getParentResourceComponent().isAugeasEnabled())
return discoveredResources;
-
+ AugeasComponent comp;
AugeasTree tree = null;
-
+
try {
- tree = context.getParentResourceComponent().getServerConfigurationTree();
+ comp = context.getParentResourceComponent().getAugeas();
+ tree = comp.getAugeasTree(ApacheServerComponent.AUGEAS_HTTP_MODULE_NAME);
} catch (AugeasException e) {
//we depend on Augeas to do anything useful with directories.
//give up, if Augeas isn't there.
return discoveredResources;
}
- AugeasNode parentNode = context.getParentResourceComponent().getNode(tree);
- List<AugeasNode> directories = AugeasNodeSearch.searchNode(PARENT_DIRECTIVES, DIRECTORY_DIRECTIVE, parentNode);
-
- ResourceType resourceType = context.getResourceType();
-
- for (AugeasNode node : directories) {
- Configuration pluginConfiguration = new Configuration();
-
- String ifmoduleParams = AugeasNodeSearch.getNodeKey(node, parentNode);
- List<AugeasNode> params = node.getChildByLabel("param");
-
- String directoryParam;
- boolean isRegexp;
-
- if (params.size() > 1) {
- directoryParam = params.get(1).getValue();
- isRegexp = true;
- } else {
- directoryParam = params.get(0).getValue();
- isRegexp = false;
+ try {
+ AugeasNode parentNode = context.getParentResourceComponent().getNode(tree);
+ List<AugeasNode> directories = AugeasNodeSearch.searchNode(PARENT_DIRECTIVES, DIRECTORY_DIRECTIVE,
+ parentNode);
+
+ ResourceType resourceType = context.getResourceType();
+
+ for (AugeasNode node : directories) {
+ Configuration pluginConfiguration = new Configuration();
+
+ String ifmoduleParams = AugeasNodeSearch.getNodeKey(node, parentNode);
+ List<AugeasNode> params = node.getChildByLabel("param");
+
+ String directoryParam;
+ boolean isRegexp;
+
+ if (params.size() > 1) {
+ directoryParam = params.get(1).getValue();
+ isRegexp = true;
+ } else {
+ directoryParam = params.get(0).getValue();
+ isRegexp = false;
+ }
+
+ pluginConfiguration.put(new PropertySimple(ApacheDirectoryComponent.REGEXP_PROP, isRegexp));
+
+ String resourceKey = ifmoduleParams;
+ String resourceName = AugeasNodeValueUtil.unescape(directoryParam);
+
+ discoveredResources.add(new DiscoveredResourceDetails(resourceType, resourceKey, resourceName, null,
+ null, pluginConfiguration, null));
}
-
- pluginConfiguration.put(new PropertySimple(ApacheDirectoryComponent.REGEXP_PROP, isRegexp));
-
- String resourceKey = ifmoduleParams;
- String resourceName = AugeasNodeValueUtil.unescape(directoryParam);
-
- discoveredResources.add(new DiscoveredResourceDetails(resourceType, resourceKey, resourceName, null, null,
- pluginConfiguration, null));
+ return discoveredResources;
+
+ } finally {
+ if (comp != null)
+ comp.close();
}
- return discoveredResources;
}
}
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheIfModuleComponent.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheIfModuleComponent.java
index b046f17..91d5d5a 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheIfModuleComponent.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheIfModuleComponent.java
@@ -27,6 +27,7 @@ import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.rhq.augeas.AugeasComponent;
import org.rhq.augeas.node.AugeasNode;
import org.rhq.augeas.tree.AugeasTree;
import org.rhq.core.domain.configuration.Configuration;
@@ -47,53 +48,61 @@ import org.rhq.plugins.apache.augeas.mappingImpl.MappingPositionToConfiguration;
import org.rhq.plugins.apache.mapping.ApacheAugeasMapping;
import org.rhq.plugins.apache.util.AugeasNodeSearch;
-
-public class ApacheIfModuleComponent implements ResourceComponent<ApacheVirtualHostServiceComponent>, ConfigurationFacet, DeleteResourceFacet {
+public class ApacheIfModuleComponent implements ResourceComponent<ApacheVirtualHostServiceComponent>,
+ ConfigurationFacet, DeleteResourceFacet {
private AugeasTree tree;
private ResourceContext<ApacheVirtualHostServiceComponent> context;
- private ApacheVirtualHostServiceComponent parentComponent;
+ private ApacheVirtualHostServiceComponent parentComponent;
private final Log log = LogFactory.getLog(this.getClass());
- private static final String IFMODULE_DIRECTIVE_NAME="<IfModule";
-
+ private static final String IFMODULE_DIRECTIVE_NAME = "<IfModule";
+
public void start(ResourceContext<ApacheVirtualHostServiceComponent> context)
throws InvalidPluginConfigurationException, Exception {
-
- this.context = context;
- parentComponent = context.getParentResourceComponent();
+
+ this.context = context;
+ parentComponent = context.getParentResourceComponent();
}
- public void stop(){
+ public void stop() {
}
public AvailabilityType getAvailability() {
- return parentComponent.getAvailability();
+ return parentComponent.getAvailability();
}
- public Configuration loadResourceConfiguration() throws Exception {
- AugeasTree tree = parentComponent.getServerConfigurationTree();
- ConfigurationDefinition resourceConfigDef = context.getResourceType().getResourceConfigurationDefinition();
-
- AugeasNode virtualHostNode = parentComponent.getNode(tree);
- ApacheAugeasMapping mapping = new ApacheAugeasMapping(tree);
- return mapping.updateConfiguration(getNode(virtualHostNode), resourceConfigDef);
+ public Configuration loadResourceConfiguration() throws Exception {
+ AugeasComponent comp = null;
+ try {
+ comp = parentComponent.getAugeas();
+ AugeasTree tree = comp.getAugeasTree(ApacheServerComponent.AUGEAS_HTTP_MODULE_NAME);
+ ConfigurationDefinition resourceConfigDef = context.getResourceType().getResourceConfigurationDefinition();
+
+ AugeasNode virtualHostNode = parentComponent.getNode(tree);
+ ApacheAugeasMapping mapping = new ApacheAugeasMapping(tree);
+ return mapping.updateConfiguration(getNode(virtualHostNode), resourceConfigDef);
+ } finally {
+ if (comp != null)
+ comp.close();
+ }
}
public void updateResourceConfiguration(ConfigurationUpdateReport report) {
+ AugeasComponent comp = null;
AugeasTree tree = null;
try {
- tree = parentComponent.getServerConfigurationTree();
- ConfigurationDefinition resourceConfigDef = context.getResourceType()
- .getResourceConfigurationDefinition();
+ comp = parentComponent.getAugeas();
+ tree = comp.getAugeasTree(ApacheServerComponent.AUGEAS_HTTP_MODULE_NAME);
+ ConfigurationDefinition resourceConfigDef = context.getResourceType().getResourceConfigurationDefinition();
ApacheAugeasMapping mapping = new ApacheAugeasMapping(tree);
-
+
AugeasNode directoryNode = getNode(parentComponent.getNode(tree));
mapping.updateAugeas(directoryNode, report.getConfiguration(), resourceConfigDef);
tree.save();
report.setStatus(ConfigurationUpdateStatus.SUCCESS);
log.info("Apache configuration was updated");
-
+
context.getParentResourceComponent().finishConfigurationUpdate(report);
} catch (Exception e) {
if (tree != null)
@@ -101,73 +110,74 @@ public class ApacheIfModuleComponent implements ResourceComponent<ApacheVirtualH
else
log.error("Augeas failed to save configuration", e);
report.setStatus(ConfigurationUpdateStatus.FAILURE);
+ } finally {
+ if (comp != null)
+ comp.close();
}
- }
+ }
+
public void deleteResource() throws Exception {
-
+
}
-
+
private AugeasNode getNode(AugeasNode virtualHost) {
AugeasNode directory = AugeasNodeSearch.findNodeById(virtualHost, context.getResourceKey());
return directory;
- }
-
- private void prepareNode(AugeasNode node,AugeasNode parentNode,AugeasTree tree,Configuration configuration){
- List<String> params = AugeasNodeSearch.getParams(node, parentNode);
-
- PropertyList list = (PropertyList)configuration.get(MappingPositionToConfiguration.LIST_PROPERTY_NAME);
- List<String> newParams = new ArrayList<String>();
- //get new list of params
- for (Property prop : list.getList()){
- if (prop instanceof PropertyMap)
- {
- PropertyMap propMap = (PropertyMap) prop;
- PropertySimple value = (PropertySimple) propMap.get(MappingPositionToConfiguration.SIMPLE_PROPERTY_NAME);
- newParams.add(value.getStringValue());
- }
- }
-
- int i = 0;
- int position = 0;
- AugeasNode tempNode = parentNode;
- boolean updated = true;
-
- while (updated){
- updated = false;
- List<AugeasNode> nodes = tempNode.getChildByLabel(IFMODULE_DIRECTIVE_NAME);
- for (AugeasNode nd : nodes){
- List<AugeasNode> paramNodes = nd.getChildByLabel("param");
- if (paramNodes.size()>0)
- {
- String value = paramNodes.get(0).getValue();
- if (value.equals(newParams.get(position)))
- {
- position = position + 1;
- tempNode = nd;
- updated = true;
- break;
- }
- }
- }
+ }
+
+ private void prepareNode(AugeasNode node, AugeasNode parentNode, AugeasTree tree, Configuration configuration) {
+ List<String> params = AugeasNodeSearch.getParams(node, parentNode);
+
+ PropertyList list = (PropertyList) configuration.get(MappingPositionToConfiguration.LIST_PROPERTY_NAME);
+ List<String> newParams = new ArrayList<String>();
+ //get new list of params
+ for (Property prop : list.getList()) {
+ if (prop instanceof PropertyMap) {
+ PropertyMap propMap = (PropertyMap) prop;
+ PropertySimple value = (PropertySimple) propMap
+ .get(MappingPositionToConfiguration.SIMPLE_PROPERTY_NAME);
+ newParams.add(value.getStringValue());
+ }
+ }
+
+ int i = 0;
+ int position = 0;
+ AugeasNode tempNode = parentNode;
+ boolean updated = true;
+
+ while (updated) {
+ updated = false;
+ List<AugeasNode> nodes = tempNode.getChildByLabel(IFMODULE_DIRECTIVE_NAME);
+ for (AugeasNode nd : nodes) {
+ List<AugeasNode> paramNodes = nd.getChildByLabel("param");
+ if (paramNodes.size() > 0) {
+ String value = paramNodes.get(0).getValue();
+ if (value.equals(newParams.get(position))) {
+ position = position + 1;
+ tempNode = nd;
+ updated = true;
+ break;
+ }
+ }
}
-
- for(i=position;i<newParams.size();i++){
- int size = tempNode.getChildByLabel(IFMODULE_DIRECTIVE_NAME).size()+1;
- tempNode = tree.createNode(tempNode, IFMODULE_DIRECTIVE_NAME, null, size);
- tree.createNode(tempNode, "param", newParams.get(i), 1);
- }
+ }
+
+ for (i = position; i < newParams.size(); i++) {
+ int size = tempNode.getChildByLabel(IFMODULE_DIRECTIVE_NAME).size() + 1;
+ tempNode = tree.createNode(tempNode, IFMODULE_DIRECTIVE_NAME, null, size);
+ tree.createNode(tempNode, "param", newParams.get(i), 1);
+ }
}
-
- public void copy(AugeasNode a, AugeasNode b){
- for (AugeasNode nd : a.getChildNodes()){
+
+ public void copy(AugeasNode a, AugeasNode b) {
+ for (AugeasNode nd : a.getChildNodes()) {
AugeasNode tempNode = tree.createNode(b, nd.getLabel(), nd.getValue(), nd.getSeq());
- copy(nd,tempNode);
+ copy(nd, tempNode);
}
}
-
-
- public boolean isAugeasEnabled(){
- return parentComponent.isAugeasEnabled();
+
+ public boolean isAugeasEnabled() {
+ return parentComponent.isAugeasEnabled();
}
-
+
}
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheIfModuleDirectoryComponent.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheIfModuleDirectoryComponent.java
index acb2572..77eb1a4 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheIfModuleDirectoryComponent.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheIfModuleDirectoryComponent.java
@@ -24,6 +24,7 @@ package org.rhq.plugins.apache;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.rhq.augeas.AugeasComponent;
import org.rhq.augeas.node.AugeasNode;
import org.rhq.augeas.tree.AugeasTree;
import org.rhq.core.domain.configuration.Configuration;
@@ -38,51 +39,60 @@ import org.rhq.core.pluginapi.inventory.ResourceContext;
import org.rhq.plugins.apache.mapping.ApacheAugeasMapping;
import org.rhq.plugins.apache.util.AugeasNodeSearch;
-public class ApacheIfModuleDirectoryComponent implements ResourceComponent<ApacheDirectoryComponent>, ConfigurationFacet {
+public class ApacheIfModuleDirectoryComponent implements ResourceComponent<ApacheDirectoryComponent>,
+ ConfigurationFacet {
private ResourceContext<ApacheDirectoryComponent> context;
- private ApacheDirectoryComponent parentComponent;
+ private ApacheDirectoryComponent parentComponent;
private final Log log = LogFactory.getLog(this.getClass());
- private static final String IFMODULE_DIRECTIVE_NAME="<IfModule";
-
- public void start(ResourceContext<ApacheDirectoryComponent> context)
- throws InvalidPluginConfigurationException, Exception {
-
- this.context = context;
- parentComponent = context.getParentResourceComponent();
+ private static final String IFMODULE_DIRECTIVE_NAME = "<IfModule";
+ public void start(ResourceContext<ApacheDirectoryComponent> context) throws InvalidPluginConfigurationException,
+ Exception {
+
+ this.context = context;
+ parentComponent = context.getParentResourceComponent();
}
public void stop() {
}
public AvailabilityType getAvailability() {
- return parentComponent.getAvailability();
+ return parentComponent.getAvailability();
}
- public Configuration loadResourceConfiguration() throws Exception {
+ public Configuration loadResourceConfiguration() throws Exception {
ConfigurationDefinition resourceConfigDef = context.getResourceType().getResourceConfigurationDefinition();
-
- AugeasNode directoryNode = parentComponent.getNode();
- AugeasTree tree = parentComponent.getServerConfigurationTree();
- ApacheAugeasMapping mapping = new ApacheAugeasMapping(tree);
- return mapping.updateConfiguration(getNode(directoryNode), resourceConfigDef);
+ AugeasComponent comp = null;
+ AugeasTree tree = null;
+ try {
+ comp = parentComponent.getAugeas();
+ tree = comp.getAugeasTree(ApacheServerComponent.AUGEAS_HTTP_MODULE_NAME);
+ AugeasNode directoryNode = parentComponent.getNode(tree);
+
+ ApacheAugeasMapping mapping = new ApacheAugeasMapping(tree);
+ return mapping.updateConfiguration(getNode(directoryNode), resourceConfigDef);
+ } finally {
+ if (comp != null)
+ comp.close();
+ }
}
public void updateResourceConfiguration(ConfigurationUpdateReport report) {
+ AugeasComponent comp = null;
AugeasTree tree = null;
try {
- tree = parentComponent.getServerConfigurationTree();
- ConfigurationDefinition resourceConfigDef = context.getResourceType()
- .getResourceConfigurationDefinition();
+ comp = parentComponent.getAugeas();
+ tree = comp.getAugeasTree(ApacheServerComponent.AUGEAS_HTTP_MODULE_NAME);
+ ConfigurationDefinition resourceConfigDef = context.getResourceType().getResourceConfigurationDefinition();
ApacheAugeasMapping mapping = new ApacheAugeasMapping(tree);
- AugeasNode directoryNode = getNode(parentComponent.getNode());
+ AugeasNode directoryNode = getNode(parentComponent.getNode(tree));
mapping.updateAugeas(directoryNode, report.getConfiguration(), resourceConfigDef);
tree.save();
report.setStatus(ConfigurationUpdateStatus.SUCCESS);
log.info("Apache configuration was updated");
-
+
context.getParentResourceComponent().finishConfigurationUpdate(report);
} catch (Exception e) {
if (tree != null)
@@ -90,16 +100,18 @@ public class ApacheIfModuleDirectoryComponent implements ResourceComponent<Apach
else
log.error("Augeas failed to save configuration", e);
report.setStatus(ConfigurationUpdateStatus.FAILURE);
+ } finally {
+ if (comp != null)
+ comp.close();
}
- }
-
+ }
+
private AugeasNode getNode(AugeasNode virtualHost) {
AugeasNode directory = AugeasNodeSearch.findNodeById(virtualHost, context.getResourceKey());
return directory;
- }
-
- public boolean isAugeasEnabled(){
- return parentComponent.isAugeasEnabled();
}
-}
+ public boolean isAugeasEnabled() {
+ return parentComponent.isAugeasEnabled();
+ }
+}
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheIfModuleDirectoryDiscoveryComponent.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheIfModuleDirectoryDiscoveryComponent.java
index 3d17f71..2952035 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheIfModuleDirectoryDiscoveryComponent.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheIfModuleDirectoryDiscoveryComponent.java
@@ -26,6 +26,7 @@ import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
+import org.rhq.augeas.AugeasComponent;
import org.rhq.augeas.node.AugeasNode;
import org.rhq.augeas.tree.AugeasTree;
import org.rhq.core.domain.resource.ResourceType;
@@ -36,39 +37,46 @@ import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
import org.rhq.plugins.apache.util.AugeasNodeSearch;
public class ApacheIfModuleDirectoryDiscoveryComponent implements ResourceDiscoveryComponent<ApacheDirectoryComponent> {
-
- private static final String [] parentRes = {"<IfModule"};
+
+ private static final String[] parentRes = { "<IfModule" };
private static final String IFMODULE_NODE_NAME = "<IfModule";
private AugeasTree tree;
private AugeasNode parentNode;
-
- public Set<DiscoveredResourceDetails> discoverResources(
- ResourceDiscoveryContext<ApacheDirectoryComponent> context)
+
+ public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<ApacheDirectoryComponent> context)
throws InvalidPluginConfigurationException, Exception {
-
- ApacheDirectoryComponent directory = context.getParentResourceComponent();
- Set<DiscoveredResourceDetails> discoveredResources = new LinkedHashSet<DiscoveredResourceDetails>();
-
- if (!directory.isAugeasEnabled())
- return discoveredResources;
-
- parentNode = directory.getNode();
-
- List<AugeasNode> ifModuleNodes = AugeasNodeSearch.searchNode(parentRes, IFMODULE_NODE_NAME, parentNode);
-
- ResourceType resourceType = context.getResourceType();
+ ApacheDirectoryComponent directory = context.getParentResourceComponent();
+ Set<DiscoveredResourceDetails> discoveredResources = new LinkedHashSet<DiscoveredResourceDetails>();
+
+ if (!directory.isAugeasEnabled())
+ return discoveredResources;
+
+ AugeasComponent comp = null;
+ AugeasTree tree = null;
+ try {
+ comp = directory.getAugeas();
+ tree = comp.getAugeasTree(ApacheServerComponent.AUGEAS_HTTP_MODULE_NAME);
+
+ parentNode = directory.getNode(tree);
+
+ List<AugeasNode> ifModuleNodes = AugeasNodeSearch.searchNode(parentRes, IFMODULE_NODE_NAME, parentNode);
+
+ ResourceType resourceType = context.getResourceType();
+
+ for (AugeasNode node : ifModuleNodes) {
- for (AugeasNode node : ifModuleNodes) {
-
-
- String resourceKey = AugeasNodeSearch.getNodeKey(node,parentNode);
- String [] paramArray = resourceKey.split("\\|");
- String resourceName = paramArray[1];
+ String resourceKey = AugeasNodeSearch.getNodeKey(node, parentNode);
+ String[] paramArray = resourceKey.split("\\|");
+ String resourceName = paramArray[1];
- discoveredResources.add(new DiscoveredResourceDetails(resourceType, resourceKey, resourceName, null, null,
- null, null));
+ discoveredResources.add(new DiscoveredResourceDetails(resourceType, resourceKey, resourceName, null,
+ null, null, null));
+ }
+ return discoveredResources;
+ } finally {
+ if (comp != null)
+ comp.close();
}
- return discoveredResources;
- }
+ }
}
\ No newline at end of file
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheIfModuleDiscoveryComponent.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheIfModuleDiscoveryComponent.java
index 708c198..0662e04 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheIfModuleDiscoveryComponent.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheIfModuleDiscoveryComponent.java
@@ -26,6 +26,7 @@ import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
+import org.rhq.augeas.AugeasComponent;
import org.rhq.augeas.node.AugeasNode;
import org.rhq.augeas.tree.AugeasTree;
import org.rhq.core.domain.resource.ResourceType;
@@ -35,41 +36,48 @@ import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
import org.rhq.plugins.apache.util.AugeasNodeSearch;
-public class ApacheIfModuleDiscoveryComponent implements ResourceDiscoveryComponent<ApacheVirtualHostServiceComponent> {
+public class ApacheIfModuleDiscoveryComponent implements ResourceDiscoveryComponent<ApacheVirtualHostServiceComponent> {
- private static final String [] parentRes = {"<IfModule"};
+ private static final String[] parentRes = { "<IfModule" };
private static final String IFMODULE_NODE_NAME = "<IfModule";
private AugeasTree tree;
private AugeasNode parentNode;
-
+
public Set<DiscoveredResourceDetails> discoverResources(
ResourceDiscoveryContext<ApacheVirtualHostServiceComponent> context)
throws InvalidPluginConfigurationException, Exception {
-
- Set<DiscoveredResourceDetails> discoveredResources = new LinkedHashSet<DiscoveredResourceDetails>();
- ApacheVirtualHostServiceComponent virtualHost = context.getParentResourceComponent();
-
- if (!virtualHost.isAugeasEnabled()){
- return discoveredResources;
- }
-
- tree = virtualHost.getServerConfigurationTree();
- parentNode = virtualHost.getNode(tree);
-
- List<AugeasNode> ifModuleNodes = AugeasNodeSearch.searchNode(parentRes, IFMODULE_NODE_NAME, parentNode);
-
-
- ResourceType resourceType = context.getResourceType();
- for (AugeasNode node : ifModuleNodes) {
-
- String resourceKey = AugeasNodeSearch.getNodeKey(node,parentNode);
- String [] paramArray = resourceKey.split("\\|");
- String resourceName = paramArray[1];
+ Set<DiscoveredResourceDetails> discoveredResources = new LinkedHashSet<DiscoveredResourceDetails>();
+ ApacheVirtualHostServiceComponent virtualHost = context.getParentResourceComponent();
+
+ if (!virtualHost.isAugeasEnabled()) {
+ return discoveredResources;
+ }
+ AugeasComponent comp = null;
+ AugeasTree tree = null;
+ try {
+ comp = virtualHost.getAugeas();
+ tree = comp.getAugeasTree(ApacheServerComponent.AUGEAS_HTTP_MODULE_NAME);
+
+ parentNode = virtualHost.getNode(tree);
- discoveredResources.add(new DiscoveredResourceDetails(resourceType, resourceKey, resourceName, null, null,
- null, null));
+ List<AugeasNode> ifModuleNodes = AugeasNodeSearch.searchNode(parentRes, IFMODULE_NODE_NAME, parentNode);
+
+ ResourceType resourceType = context.getResourceType();
+
+ for (AugeasNode node : ifModuleNodes) {
+
+ String resourceKey = AugeasNodeSearch.getNodeKey(node, parentNode);
+ String[] paramArray = resourceKey.split("\\|");
+ String resourceName = paramArray[1];
+
+ discoveredResources.add(new DiscoveredResourceDetails(resourceType, resourceKey, resourceName, null,
+ null, null, null));
+ }
+ return discoveredResources;
+ } finally {
+ if (comp != null)
+ comp.close();
}
- return discoveredResources;
- }
+ }
}
\ No newline at end of file
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerComponent.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerComponent.java
index b320028..3c8758b 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerComponent.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerComponent.java
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
+ * Copyright (C) 2005-2011 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -36,11 +36,13 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-
-import org.rhq.augeas.AugeasProxy;
+import org.rhq.augeas.AugeasComponent;
+import org.rhq.augeas.config.AugeasConfiguration;
import org.rhq.augeas.config.AugeasModuleConfig;
import org.rhq.augeas.node.AugeasNode;
import org.rhq.augeas.tree.AugeasTree;
+import org.rhq.augeas.tree.AugeasTreeBuilder;
+import org.rhq.augeas.tree.AugeasTreeException;
import org.rhq.augeas.util.Glob;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.ConfigurationUpdateStatus;
@@ -61,6 +63,7 @@ import org.rhq.core.pluginapi.event.log.LogFileEventPoller;
import org.rhq.core.pluginapi.inventory.CreateChildResourceFacet;
import org.rhq.core.pluginapi.inventory.CreateResourceReport;
import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
+import org.rhq.core.pluginapi.inventory.ResourceComponent;
import org.rhq.core.pluginapi.inventory.ResourceContext;
import org.rhq.core.pluginapi.measurement.MeasurementFacet;
import org.rhq.core.pluginapi.operation.OperationFacet;
@@ -93,8 +96,8 @@ import org.rhq.rhqtransform.AugeasRHQComponent;
* @author Ian Springer
* @author Lukas Krejci
*/
-public class ApacheServerComponent implements AugeasRHQComponent<PlatformComponent>, MeasurementFacet, OperationFacet,
- ConfigurationFacet, CreateChildResourceFacet {
+public class ApacheServerComponent implements AugeasRHQComponent, ResourceComponent<PlatformComponent>,
+ MeasurementFacet, OperationFacet, ConfigurationFacet, CreateChildResourceFacet {
public static final String CONFIGURATION_NOT_SUPPORTED_ERROR_MESSAGE = "Configuration is supported only for Apache version 2 and up using Augeas. You either have an old version of Apache or Augeas is not installed.";
@@ -105,6 +108,7 @@ public class ApacheServerComponent implements AugeasRHQComponent<PlatformCompone
public static final String PLUGIN_CONFIG_PROP_CONTROL_SCRIPT_PATH = "controlScriptPath";
public static final String PLUGIN_CONFIG_PROP_URL = "url";
public static final String PLUGIN_CONFIG_PROP_HTTPD_CONF = "configFile";
+ public static final String AUGEAS_HTTP_MODULE_NAME = "Httpd";
public static final String PLUGIN_CONFIG_PROP_SNMP_AGENT_HOST = "snmpAgentHost";
public static final String PLUGIN_CONFIG_PROP_SNMP_AGENT_PORT = "snmpAgentPort";
@@ -116,12 +120,12 @@ public class ApacheServerComponent implements AugeasRHQComponent<PlatformCompone
public static final String PLUGIN_CONFIG_PROP_ERROR_LOG_INCLUDES_PATTERN = "errorLogIncludesPattern";
public static final String PLUGIN_CONFIG_PROP_VHOST_FILES_MASK = "vhostFilesMask";
public static final String PLUGIN_CONFIG_PROP_VHOST_CREATION_POLICY = "vhostCreationPolicy";
-
+
public static final String PLUGIN_CONFIG_PROP_RESTART_AFTER_CONFIG_UPDATE = "restartAfterConfigurationUpdate";
-
+
public static final String PLUGIN_CONFIG_VHOST_IN_SINGLE_FILE_PROP_VALUE = "single-file";
public static final String PLUGIN_CONFIG_VHOST_PER_FILE_PROP_VALUE = "vhost-per-file";
-
+
public static final String AUXILIARY_INDEX_PROP = "_index";
public static final String SERVER_BUILT_TRAIT = "serverBuilt";
@@ -137,14 +141,14 @@ public class ApacheServerComponent implements AugeasRHQComponent<PlatformCompone
private static final String[] CONTROL_SCRIPT_PATHS = { "bin/apachectl", "sbin/apachectl", "bin/apachectl2",
"sbin/apachectl2" };
-
+
private ResourceContext<PlatformComponent> resourceContext;
private EventContext eventContext;
private SNMPClient snmpClient;
private URL url;
private ApacheBinaryInfo binaryInfo;
private long availPingTime = -1;
-
+
/**
* Delegate instance for handling all calls to invoke operations on this component.
*/
@@ -161,14 +165,13 @@ public class ApacheServerComponent implements AugeasRHQComponent<PlatformCompone
SNMPSession snmpSession = getSNMPSession();
if (!snmpSession.ping()) {
- log
- .warn("Failed to connect to SNMP agent at "
- + snmpSession
- + "\n"
- + ". Make sure\n1) the managed Apache server has been instrumented with the JON SNMP module,\n"
- + "2) the Apache server is running, and\n"
- + "3) the SNMP agent host, port, and community are set correctly in this resource's connection properties.\n"
- + "The agent will not be able to record metrics from apache httpd without SNMP");
+ log.warn("Failed to connect to SNMP agent at "
+ + snmpSession
+ + "\n"
+ + ". Make sure\n1) the managed Apache server has been instrumented with the JON SNMP module,\n"
+ + "2) the Apache server is running, and\n"
+ + "3) the SNMP agent host, port, and community are set correctly in this resource's connection properties.\n"
+ + "The agent will not be able to record metrics from apache httpd without SNMP");
} else {
configured = true;
}
@@ -179,11 +182,10 @@ public class ApacheServerComponent implements AugeasRHQComponent<PlatformCompone
try {
this.url = new URL(url);
if (this.url.getPort() == 0) {
- log
- .error("The 'url' connection property is invalid - 0 is not a valid port; please change the value to the "
- + "port the \"main\" Apache server is listening on. NOTE: If the 'url' property was set this way "
- + "after autodiscovery, you most likely did not include the port in the ServerName directive for "
- + "the \"main\" Apache server in httpd.conf.");
+ log.error("The 'url' connection property is invalid - 0 is not a valid port; please change the value to the "
+ + "port the \"main\" Apache server is listening on. NOTE: If the 'url' property was set this way "
+ + "after autodiscovery, you most likely did not include the port in the ServerName directive for "
+ + "the \"main\" Apache server in httpd.conf.");
} else {
configured = true;
}
@@ -200,15 +202,15 @@ public class ApacheServerComponent implements AugeasRHQComponent<PlatformCompone
File executablePath = getExecutablePath();
try {
- this.binaryInfo = ApacheBinaryInfo.getInfo(executablePath.getPath(), this.resourceContext
- .getSystemInformation());
+ this.binaryInfo = ApacheBinaryInfo.getInfo(executablePath.getPath(),
+ this.resourceContext.getSystemInformation());
} catch (Exception e) {
throw new InvalidPluginConfigurationException("'" + executablePath
+ "' is not a valid Apache executable (" + e + ").");
}
- this.operationsDelegate = new ApacheServerOperationsDelegate(this, pluginConfig, this.resourceContext
- .getSystemInformation());
+ this.operationsDelegate = new ApacheServerOperationsDelegate(this, pluginConfig,
+ this.resourceContext.getSystemInformation());
startEventPollers();
} catch (Exception e) {
@@ -300,31 +302,41 @@ public class ApacheServerComponent implements AugeasRHQComponent<PlatformCompone
}
public Configuration loadResourceConfiguration() throws Exception {
+
if (!isAugeasEnabled())
throw new RuntimeException(CONFIGURATION_NOT_SUPPORTED_ERROR_MESSAGE);
+ AugeasComponent comp = null;
try {
+ comp = getAugeas();
ConfigurationDefinition resourceConfigDef = resourceContext.getResourceType()
.getResourceConfigurationDefinition();
- AugeasTree tree = getAugeasTree();
+ AugeasTree tree = comp.getAugeasTree(AUGEAS_HTTP_MODULE_NAME);
ApacheAugeasMapping mapping = new ApacheAugeasMapping(tree);
return mapping.updateConfiguration(tree.getRootNode(), resourceConfigDef);
} catch (Exception e) {
log.error("Failed to load Apache configuration.", e);
throw e;
+ } finally {
+ if (comp != null)
+ comp.close();
}
}
public void updateResourceConfiguration(ConfigurationUpdateReport report) {
- if (!isAugeasEnabled()){
+ if (!isAugeasEnabled()) {
report.setStatus(ConfigurationUpdateStatus.FAILURE);
return;
}
+
+ AugeasComponent comp = null;
+
Configuration originalConfig = report.getConfiguration().deepCopy(true);
AugeasTree tree = null;
try {
- tree = getAugeasTree();
+ comp = getAugeas();
+ tree = comp.getAugeasTree(AUGEAS_HTTP_MODULE_NAME);
ConfigurationDefinition resourceConfigDef = resourceContext.getResourceType()
.getResourceConfigurationDefinition();
ApacheAugeasMapping mapping = new ApacheAugeasMapping(tree);
@@ -334,183 +346,199 @@ public class ApacheServerComponent implements AugeasRHQComponent<PlatformCompone
log.info("Apache configuration was updated");
report.setStatus(ConfigurationUpdateStatus.SUCCESS);
-
+
finishConfigurationUpdate(report);
} catch (Exception e) {
if (tree != null) {
log.error("Augeas failed to save configuration " + tree.summarizeAugeasError());
e = new AugeasException("Failed to save configuration: " + tree.summarizeAugeasError() + " ", e);
- }
- else
+ } else
log.error("Augeas failed to save configuration", e);
report.setStatus(ConfigurationUpdateStatus.FAILURE);
report.setErrorMessageFromThrowable(e);
if (!originalConfig.equals(report.getConfiguration())) {
log.error("Configuration has changed");
- }
- else {
+ } else {
log.error("Configuratio has not changed");
}
+ } finally {
+ if (comp != null)
+ comp.close();
}
- }
-
- public AugeasProxy getAugeasProxy() throws AugeasException {
- File tempDir = resourceContext.getDataDirectory();
- if (!tempDir.exists())
- throw new RuntimeException("Loading of lens failed");
- AugeasConfigurationApache config = new AugeasConfigurationApache(tempDir.getAbsolutePath(),resourceContext.getPluginConfiguration());
- AugeasTreeBuilderApache builder = new AugeasTreeBuilderApache();
- AugeasProxy augeasProxy = new AugeasProxy(config, builder);
- augeasProxy.load();
- return augeasProxy;
- }
-
- public AugeasTree getAugeasTree() throws AugeasException {
- AugeasProxy proxy = getAugeasProxy();
- String module = ((AugeasConfigurationApache)proxy.getConfiguration()).getAugeasModuleName();
-
- return proxy.getAugeasTree(module, true);
- }
-
+ }
+
+ public AugeasComponent getAugeas() throws AugeasTreeException {
+ return new AugeasComponent() {
+
+ public AugeasConfiguration initConfiguration() {
+ File tempDir = resourceContext.getDataDirectory();
+ if (!tempDir.exists())
+ throw new RuntimeException("Loading of lens failed");
+ AugeasConfigurationApache config = new AugeasConfigurationApache(tempDir.getAbsolutePath(),
+ resourceContext.getPluginConfiguration());
+ return config;
+ }
+
+ public AugeasTreeBuilder initTreeBuilder() {
+ AugeasTreeBuilderApache builder = new AugeasTreeBuilderApache();
+ return builder;
+ }
+
+ };
+ }
+
public CreateResourceReport createResource(CreateResourceReport report) {
- if (!isAugeasEnabled()){
+ if (!isAugeasEnabled()) {
report.setStatus(CreateResourceStatus.FAILURE);
report.setErrorMessage("Resources can be created only when augeas is enabled.");
return report;
}
if (ApacheVirtualHostServiceComponent.RESOURCE_TYPE_NAME.equals(report.getResourceType().getName())) {
Configuration vhostResourceConfig = report.getResourceConfiguration();
- ConfigurationDefinition vhostResourceConfigDef = report.getResourceType().getResourceConfigurationDefinition();
+ ConfigurationDefinition vhostResourceConfigDef = report.getResourceType()
+ .getResourceConfigurationDefinition();
Configuration vhostPluginConfig = report.getPluginConfiguration();
-
+
String vhostDef = report.getUserSpecifiedResourceName();
- String serverName = vhostResourceConfig.getSimpleValue(ApacheVirtualHostServiceComponent.SERVER_NAME_CONFIG_PROP, null);
-
+ String serverName = vhostResourceConfig.getSimpleValue(
+ ApacheVirtualHostServiceComponent.SERVER_NAME_CONFIG_PROP, null);
+
//determine the resource key
String resourceKey = vhostDef;
if (serverName != null) {
resourceKey = serverName + "|" + resourceKey;
}
-
- //determine the resource name
- AugeasProxy proxy = getAugeasProxy();
- AugeasTree tree = getAugeasTree();
+
String[] vhostDefs = vhostDef.split(" ");
- HttpdAddressUtility.Address addr;
- try{
+ HttpdAddressUtility.Address addr;
+ try {
ApacheDirectiveTree parserTree = new ApacheDirectiveTree();
- ApacheParser parser = new ApacheParserImpl(parserTree,getServerRoot().getAbsolutePath());
-
+ ApacheParser parser = new ApacheParserImpl(parserTree, getServerRoot().getAbsolutePath());
+
ApacheConfigReader.buildTree(getHttpdConfFile().getAbsolutePath(), parser);
-
+
Pattern virtualHostPattern = Pattern.compile(".+:([\\d]+|\\*)");
Matcher matcher = virtualHostPattern.matcher(vhostDefs[0]);
if (!matcher.matches())
- throw new Exception("Wrong format of virtual host resource name. The right format is Address:Port.");
-
+ throw new Exception("Wrong format of virtual host resource name. The right format is Address:Port.");
+
addr = getAddressUtility().getVirtualHostSampleAddress(parserTree, vhostDefs[0], serverName, false);
} catch (Exception e) {
- report.setStatus(CreateResourceStatus.FAILURE);
- report.setErrorMessage("Wrong format of virtual host resource name.");
- report.setException(e);
- return report;
- }
-
+ report.setStatus(CreateResourceStatus.FAILURE);
+ report.setErrorMessage("Wrong format of virtual host resource name.");
+ report.setException(e);
+ return report;
+ }
+
String resourceName;
if (serverName != null) {
resourceName = addr.host + ":" + addr.port;
} else {
resourceName = resourceKey;
}
-
+
report.setResourceKey(resourceKey);
report.setResourceName(resourceName);
- //fill in the plugin config
- String url = "http://" + addr.host + ":" + addr.port + "/";
- vhostPluginConfig.put(new PropertySimple(ApacheVirtualHostServiceComponent.URL_CONFIG_PROP, url));
-
- //determine the sequence number of the new vhost
- List<AugeasNode> existingVhosts = tree.matchRelative(tree.getRootNode(), "<VirtualHost");
- int seq = existingVhosts.size() + 1;
-
- Configuration pluginConfig = resourceContext.getPluginConfiguration();
- String creationType = pluginConfig.getSimpleValue(PLUGIN_CONFIG_PROP_VHOST_CREATION_POLICY,
- PLUGIN_CONFIG_VHOST_PER_FILE_PROP_VALUE);
-
- AugeasNode vhost = null;
- String vhostFile = proxy.getConfiguration().getModules().get(0).getConfigFiles().get(0);
-
- if (PLUGIN_CONFIG_VHOST_IN_SINGLE_FILE_PROP_VALUE.equals(creationType)) {
- vhost = tree.createNode(tree.getRootNode(), "<VirtualHost", null, seq);
- } else if (PLUGIN_CONFIG_VHOST_PER_FILE_PROP_VALUE.equals(creationType)) {
- String mask = pluginConfig.getSimpleValue(PLUGIN_CONFIG_PROP_VHOST_FILES_MASK, null);
- if (mask == null) {
- report.setErrorMessage("No virtual host file mask configured.");
- } else {
- vhostFile = getNewVhostFileName(addr, mask);
- File vhostFileFile = new File(vhostFile);
-
- //we're creating a new file here, so we must ensure that Augeas does have this file
- //on its load path, otherwise it will refuse to create it.
- AugeasConfigurationApache config = (AugeasConfigurationApache) proxy.getConfiguration();
- AugeasModuleConfig moduleConfig = config.getModuleByName(config.getAugeasModuleName());
- boolean willPersist = false;
- for(String glob : moduleConfig.getIncludedGlobs()) {
- if (Glob.matches(getServerRoot(), glob, vhostFileFile)) {
- willPersist = true;
- break;
+ AugeasComponent comp = null;
+ //determine the resource name
+
+ AugeasTree tree;
+ try {
+ comp = getAugeas();
+ tree = comp.getAugeasTree(AUGEAS_HTTP_MODULE_NAME);
+ //fill in the plugin config
+ String url = "http://" + addr.host + ":" + addr.port + "/";
+ vhostPluginConfig.put(new PropertySimple(ApacheVirtualHostServiceComponent.URL_CONFIG_PROP, url));
+
+ //determine the sequence number of the new vhost
+ List<AugeasNode> existingVhosts = tree.matchRelative(tree.getRootNode(), "<VirtualHost");
+ int seq = existingVhosts.size() + 1;
+
+ Configuration pluginConfig = resourceContext.getPluginConfiguration();
+ String creationType = pluginConfig.getSimpleValue(PLUGIN_CONFIG_PROP_VHOST_CREATION_POLICY,
+ PLUGIN_CONFIG_VHOST_PER_FILE_PROP_VALUE);
+
+ AugeasNode vhost = null;
+
+ String vhostFile = comp.getConfiguration().getModules().get(0).getConfigFiles().get(0);
+
+ if (PLUGIN_CONFIG_VHOST_IN_SINGLE_FILE_PROP_VALUE.equals(creationType)) {
+ vhost = tree.createNode(tree.getRootNode(), "<VirtualHost", null, seq);
+ } else if (PLUGIN_CONFIG_VHOST_PER_FILE_PROP_VALUE.equals(creationType)) {
+ String mask = pluginConfig.getSimpleValue(PLUGIN_CONFIG_PROP_VHOST_FILES_MASK, null);
+ if (mask == null) {
+ report.setErrorMessage("No virtual host file mask configured.");
+ } else {
+ vhostFile = getNewVhostFileName(addr, mask);
+ File vhostFileFile = new File(vhostFile);
+
+ //we're creating a new file here, so we must ensure that Augeas does have this file
+ //on its load path, otherwise it will refuse to create it.
+ AugeasConfigurationApache config = (AugeasConfigurationApache) comp.getConfiguration();
+ AugeasModuleConfig moduleConfig = config.getModuleByName(config.getAugeasModuleName());
+ boolean willPersist = false;
+ for (String glob : moduleConfig.getIncludedGlobs()) {
+ if (Glob.matches(getServerRoot(), glob, vhostFileFile)) {
+ willPersist = true;
+ break;
+ }
}
- }
-
- if (!willPersist) {
- //the file wouldn't be loaded by augeas
- moduleConfig.addIncludedGlob(vhostFile);
- }
-
- try {
- vhostFileFile.createNewFile();
- } catch (IOException e) {
- log.error("Failed to create a new vhost file: " + vhostFile, e);
- }
-
- proxy.load();
- tree = proxy.getAugeasTree(moduleConfig.getModuletName(), true);
-
- vhost = tree.createNode(AugeasTree.AUGEAS_DATA_PATH + vhostFile + "/<VirtualHost");
- ((ApacheAugeasNode)vhost).setParentNode(tree.getRootNode());
-
- if (!willPersist) {
- //this also means that there was no include
- //that would load the file, so we have to
- //add the include directive to the main conf.
- List<AugeasNode> includes = tree.matchRelative(tree.getRootNode(), "Include");
- AugeasNode include = tree.createNode(tree.getRootNode(), "Include", null, includes.size() + 1);
- tree.createNode(include, "param", vhostFile, 0);
+
+ if (!willPersist) {
+ //the file wouldn't be loaded by augeas
+ moduleConfig.addIncludedGlob(vhostFile);
+ //this also means that there was no include
+ //that would load the file, so we have to
+ //add the include directive to the main conf.
+ List<AugeasNode> includes = tree.matchRelative(tree.getRootNode(), "Include");
+ AugeasNode include = tree.createNode(tree.getRootNode(), "Include", null,
+ includes.size() + 1);
+ tree.createNode(include, "param", vhostFile, 0);
+ tree.save();
+ }
+
+ try {
+ vhostFileFile.createNewFile();
+ } catch (IOException e) {
+ log.error("Failed to create a new vhost file: " + vhostFile, e);
+ }
+
+ comp.close();
+ comp = getAugeas();
+ tree = comp.getAugeasTree(moduleConfig.getModuletName());
+
+ vhost = tree.createNode(AugeasTree.AUGEAS_DATA_PATH + vhostFile + "/<VirtualHost");
+ ((ApacheAugeasNode) vhost).setParentNode(tree.getRootNode());
+
}
}
- }
-
- if (vhost == null) {
- report.setStatus(CreateResourceStatus.FAILURE);
- } else {
- try {
- for(int i = 0; i < vhostDefs.length; ++i) {
- tree.createNode(vhost, "param", vhostDefs[i], i + 1);
- }
- ApacheAugeasMapping mapping = new ApacheAugeasMapping(tree);
- mapping.updateAugeas(vhost, vhostResourceConfig, vhostResourceConfigDef);
-
- tree.save();
- report.setStatus(CreateResourceStatus.SUCCESS);
-
- finishChildResourceCreate(report);
- } catch (Exception e) {
+
+ if (vhost == null) {
report.setStatus(CreateResourceStatus.FAILURE);
- report.setException(e);
+ } else {
+ try {
+ for (int i = 0; i < vhostDefs.length; ++i) {
+ tree.createNode(vhost, "param", vhostDefs[i], i + 1);
+ }
+ ApacheAugeasMapping mapping = new ApacheAugeasMapping(tree);
+ mapping.updateAugeas(vhost, vhostResourceConfig, vhostResourceConfigDef);
+
+ tree.save();
+ report.setStatus(CreateResourceStatus.SUCCESS);
+
+ finishChildResourceCreate(report);
+ } catch (Exception e) {
+ report.setStatus(CreateResourceStatus.FAILURE);
+ report.setException(e);
+ }
}
+ } finally {
+ if (comp != null)
+ comp.close();
}
}
+
return report;
}
@@ -569,14 +597,14 @@ public class ApacheServerComponent implements AugeasRHQComponent<PlatformCompone
if (executablePath != null) {
executableFile = resolvePathRelativeToServerRoot(executablePath);
} else {
- String serverRoot=null;
-
- ApacheDirectiveTree tree = loadParser();
- List<ApacheDirective> directives = tree.search("/ServerRoot");
- if (!directives.isEmpty())
- if (!directives.get(0).getValues().isEmpty())
- serverRoot = directives.get(0).getValues().get(0);
-
+ String serverRoot = null;
+
+ ApacheDirectiveTree tree = loadParser();
+ List<ApacheDirective> directives = tree.search("/ServerRoot");
+ if (!directives.isEmpty())
+ if (!directives.get(0).getValues().isEmpty())
+ serverRoot = directives.get(0).getValues().get(0);
+
SystemInfo systemInfo = this.resourceContext.getSystemInformation();
if (systemInfo.getOperatingSystemType() != OperatingSystemType.WINDOWS) // UNIX
{
@@ -600,10 +628,11 @@ public class ApacheServerComponent implements AugeasRHQComponent<PlatformCompone
/**
* @return The url the server is pinged for availability or null if the url is not set.
*/
- public @Nullable String getServerUrl() {
+ public @Nullable
+ String getServerUrl() {
return resourceContext.getPluginConfiguration().getSimpleValue(PLUGIN_CONFIG_PROP_URL, null);
}
-
+
/**
* Returns the httpd.conf file
* @return A File object that represents the httpd.conf file or null in case of error
@@ -656,19 +685,20 @@ public class ApacheServerComponent implements AugeasRHQComponent<PlatformCompone
}
}
}
-
+
//only try harder on the control script path on OSes with UNIX file system layout
- if (!found && resourceContext.getSystemInformation().getOperatingSystemType() != OperatingSystemType.WINDOWS) {
+ if (!found
+ && resourceContext.getSystemInformation().getOperatingSystemType() != OperatingSystemType.WINDOWS) {
String executablePath = pluginConfig.getSimpleValue(PLUGIN_CONFIG_PROP_EXECUTABLE_PATH, null);
if (executablePath != null) {
// this is now something like /usr/sbin/httpd .. trim off the last 2 parts
int i = executablePath.lastIndexOf(File.separatorChar);
-
+
if (i >= 0) {
executablePath = executablePath.substring(0, i);
i = executablePath.lastIndexOf(File.separatorChar);
}
-
+
if (i >= 0) {
executablePath = executablePath.substring(0, i);
for (String path : CONTROL_SCRIPT_PATHS) {
@@ -678,10 +708,10 @@ public class ApacheServerComponent implements AugeasRHQComponent<PlatformCompone
break;
}
}
- }
+ }
}
}
-
+
if (!found) {
controlScriptFile = getExecutablePath(); // fall back to the httpd binary
}
@@ -692,11 +722,11 @@ public class ApacheServerComponent implements AugeasRHQComponent<PlatformCompone
@NotNull
public ConfigurationTimestamp getConfigurationTimestamp() {
- AugeasConfigurationApache config = new AugeasConfigurationApache(resourceContext.getTemporaryDirectory().getAbsolutePath(),
- resourceContext.getPluginConfiguration());
+ AugeasConfigurationApache config = new AugeasConfigurationApache(resourceContext.getTemporaryDirectory()
+ .getAbsolutePath(), resourceContext.getPluginConfiguration());
return new ConfigurationTimestamp(config.getAllConfigurationFiles());
}
-
+
/**
* This method is supposed to be called from {@link #updateResourceConfiguration(ConfigurationUpdateReport)}
* of this resource and any child resources.
@@ -713,7 +743,7 @@ public class ApacheServerComponent implements AugeasRHQComponent<PlatformCompone
report.setErrorMessageFromThrowable(e);
}
}
-
+
/**
* This method is akin to {@link #finishConfigurationUpdate(ConfigurationUpdateReport)} but should
* be used in the {@link #createResource(CreateResourceReport)} method.
@@ -728,7 +758,7 @@ public class ApacheServerComponent implements AugeasRHQComponent<PlatformCompone
report.setException(e);
}
}
-
+
/**
* Conditionally restarts the server based on the settings in the plugin configuration of the server.
*
@@ -741,7 +771,7 @@ public class ApacheServerComponent implements AugeasRHQComponent<PlatformCompone
operationsDelegate.invokeOperation("graceful_restart", new Configuration());
}
}
-
+
/**
* This method checks whether the supplied node that has been deleted from the tree didn't leave
* the file it was contained in empty.
@@ -752,12 +782,12 @@ public class ApacheServerComponent implements AugeasRHQComponent<PlatformCompone
public void deleteEmptyFile(AugeasTree tree, AugeasNode deletedNode) {
File file = tree.getFile(deletedNode);
List<AugeasNode> fileContents = tree.match(file.getAbsolutePath() + AugeasTree.PATH_SEPARATOR + "*");
-
+
if (fileContents.size() == 0) {
file.delete();
}
}
-
+
// TODO: Move this method to a helper class.
static void addSnmpMetricValueToReport(MeasurementReport report, MeasurementScheduleRequest schedule,
SNMPValue snmpValue, boolean valueIsTimestamp) throws SNMPException {
@@ -862,13 +892,13 @@ public class ApacheServerComponent implements AugeasRHQComponent<PlatformCompone
String version = resourceContext.getVersion();
return HttpdAddressUtility.get(version);
}
-
+
private String getNewVhostFileName(HttpdAddressUtility.Address address, String mask) {
String filename = address.host + "_" + address.port;
String fullPath = mask.replace("*", filename);
-
+
File file = getFileRelativeToServerRoot(fullPath);
-
+
int i = 1;
while (file.exists()) {
filename = address.host + "_" + address.port + "-" + (i++);
@@ -877,50 +907,59 @@ public class ApacheServerComponent implements AugeasRHQComponent<PlatformCompone
}
return file.getAbsolutePath();
}
-
+
private File getFileRelativeToServerRoot(String path) {
File f = new File(path);
if (f.isAbsolute()) {
return f;
} else {
return new File(getServerRoot(), path);
- }
+ }
}
-
- public ApacheDirectiveTree loadParser(){
+
+ public ApacheDirectiveTree loadParser() {
ApacheDirectiveTree tree = new ApacheDirectiveTree();
- ApacheParser parser = new ApacheParserImpl(tree,getServerRoot().getAbsolutePath());
+ ApacheParser parser = new ApacheParserImpl(tree, getServerRoot().getAbsolutePath());
ApacheConfigReader.buildTree(getHttpdConfFile().getAbsolutePath(), parser);
- return tree;
+ return tree;
}
-
+
public boolean isAugeasEnabled() {
-
+
Configuration pluginConfig = this.resourceContext.getPluginConfiguration();
PropertySimple prop = pluginConfig.getSimple(AUGEAS_ENABLED);
- if (prop == null || prop.getStringValue() == null)
- {
+ if (prop == null || prop.getStringValue() == null) {
return false;
- }
-
+ }
+
String val = prop.getStringValue();
-
- if (val.equals("yes")){
- try {
- Augeas ag = new Augeas();
- }catch(Exception e){
+
+ if (val.equals("yes")) {
+ Augeas ag = null;
+ try {
+ ag = new Augeas();
+ } catch (Exception e) {
log.error("Augeas is enabled in configuration but was not found on the system.");
- throw new RuntimeException(CONFIGURATION_NOT_SUPPORTED_ERROR_MESSAGE);
+ throw new RuntimeException(CONFIGURATION_NOT_SUPPORTED_ERROR_MESSAGE);
+ } finally {
+ if (ag != null) {
+ try {
+ ag.close();
+ } catch (Exception e) {
+ }
+ ag = null;
+ }
}
String version = resourceContext.getVersion();
-
+
if (!version.startsWith("2.")) {
log.error(CONFIGURATION_NOT_SUPPORTED_ERROR_MESSAGE);
throw new RuntimeException(CONFIGURATION_NOT_SUPPORTED_ERROR_MESSAGE);
}
return true;
- }else{
- return false;
+ } else {
+ return false;
}
}
+
}
\ No newline at end of file
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceComponent.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceComponent.java
index c894fa9..e9c155f 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceComponent.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceComponent.java
@@ -34,6 +34,7 @@ import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.rhq.augeas.AugeasComponent;
import org.rhq.augeas.node.AugeasNode;
import org.rhq.augeas.tree.AugeasTree;
import org.rhq.core.domain.configuration.Configuration;
@@ -84,7 +85,7 @@ public class ApacheVirtualHostServiceComponent implements ResourceComponent<Apac
public static final String RESPONSE_TIME_URL_TRANSFORMS_CONFIG_PROP = ResponseTimeConfiguration.RESPONSE_TIME_URL_TRANSFORMS_CONFIG_PROP;
public static final String SERVER_NAME_CONFIG_PROP = "ServerName";
-
+
private static final String RESPONSE_TIME_METRIC = "ResponseTime";
/** Multiply by 1/1000 to convert logged response times, which are in microseconds, to milliseconds. */
private static final double RESPONSE_TIME_LOG_TIME_MULTIPLIER = 0.001;
@@ -97,7 +98,7 @@ public class ApacheVirtualHostServiceComponent implements ResourceComponent<Apac
private int snmpWwwServiceIndex = -1;
public static final String RESOURCE_TYPE_NAME = "Apache Virtual Host";
-
+
public void start(ResourceContext<ApacheServerComponent> resourceContext) throws Exception {
this.resourceContext = resourceContext;
Configuration pluginConfig = this.resourceContext.getPluginConfiguration();
@@ -117,7 +118,7 @@ public class ApacheVirtualHostServiceComponent implements ResourceComponent<Apac
+ "') is not a valid URL.");
}
}
-
+
ResponseTimeConfiguration responseTimeConfig = new ResponseTimeConfiguration(pluginConfig);
File logFile = responseTimeConfig.getLogFile();
if (logFile != null) {
@@ -139,20 +140,29 @@ public class ApacheVirtualHostServiceComponent implements ResourceComponent<Apac
public Configuration loadResourceConfiguration() throws Exception {
ApacheServerComponent parent = resourceContext.getParentResourceComponent();
if (!parent.isAugeasEnabled())
- throw new Exception(ApacheServerComponent.CONFIGURATION_NOT_SUPPORTED_ERROR_MESSAGE);
-
- AugeasTree tree = getServerConfigurationTree();
- ConfigurationDefinition resourceConfigDef = resourceContext.getResourceType()
- .getResourceConfigurationDefinition();
-
- ApacheAugeasMapping mapping = new ApacheAugeasMapping(tree);
- return mapping.updateConfiguration(getNode(tree), resourceConfigDef);
+ throw new Exception(ApacheServerComponent.CONFIGURATION_NOT_SUPPORTED_ERROR_MESSAGE);
+
+ AugeasComponent comp = null;
+ try {
+ comp = getAugeas();
+ AugeasTree tree = comp.getAugeasTree(ApacheServerComponent.AUGEAS_HTTP_MODULE_NAME);
+ ConfigurationDefinition resourceConfigDef = resourceContext.getResourceType()
+ .getResourceConfigurationDefinition();
+
+ ApacheAugeasMapping mapping = new ApacheAugeasMapping(tree);
+ return mapping.updateConfiguration(getNode(tree), resourceConfigDef);
+ } finally {
+ if (comp != null)
+ comp.close();
+ }
}
public void updateResourceConfiguration(ConfigurationUpdateReport report) {
+ AugeasComponent comp = null;
AugeasTree tree = null;
try {
- tree = getServerConfigurationTree();
+ comp = getAugeas();
+ tree = comp.getAugeasTree(ApacheServerComponent.AUGEAS_HTTP_MODULE_NAME);
ConfigurationDefinition resourceConfigDef = resourceContext.getResourceType()
.getResourceConfigurationDefinition();
ApacheAugeasMapping mapping = new ApacheAugeasMapping(tree);
@@ -162,7 +172,7 @@ public class ApacheVirtualHostServiceComponent implements ResourceComponent<Apac
report.setStatus(ConfigurationUpdateStatus.SUCCESS);
log.info("Apache configuration was updated");
-
+
finishConfigurationUpdate(report);
} catch (Exception e) {
if (tree != null)
@@ -170,31 +180,40 @@ public class ApacheVirtualHostServiceComponent implements ResourceComponent<Apac
else
log.error("Augeas failed to save configuration", e);
report.setStatus(ConfigurationUpdateStatus.FAILURE);
+ } finally {
+ if (comp != null)
+ comp.close();
}
}
public void deleteResource() throws Exception {
ApacheServerComponent parent = resourceContext.getParentResourceComponent();
if (!parent.isAugeasEnabled())
- throw new Exception(ApacheServerComponent.CONFIGURATION_NOT_SUPPORTED_ERROR_MESSAGE);
-
+ throw new Exception(ApacheServerComponent.CONFIGURATION_NOT_SUPPORTED_ERROR_MESSAGE);
+
if (MAIN_SERVER_RESOURCE_KEY.equals(resourceContext.getResourceKey())) {
- throw new IllegalArgumentException("Cannot delete the virtual host representing the main server configuration.");
+ throw new IllegalArgumentException(
+ "Cannot delete the virtual host representing the main server configuration.");
}
-
- AugeasTree tree = getServerConfigurationTree();
-
+
+ AugeasComponent comp = null;
+
try {
- AugeasNode myNode = getNode(getServerConfigurationTree());
-
+ comp = getAugeas();
+ AugeasTree tree = comp.getAugeasTree(ApacheServerComponent.AUGEAS_HTTP_MODULE_NAME);
+ AugeasNode myNode = getNode(tree);
+
tree.removeNode(myNode, true);
tree.save();
-
+
deleteEmptyFile(tree, myNode);
conditionalRestart();
} catch (IllegalStateException e) {
//this means we couldn't find the augeas node for this vhost.
//that error can be safely ignored in this situation.
+ } finally {
+ if (comp != null)
+ comp.close();
}
}
@@ -245,82 +264,106 @@ public class ApacheVirtualHostServiceComponent implements ResourceComponent<Apac
}
public CreateResourceReport createResource(CreateResourceReport report) {
- if (!isAugeasEnabled()){
+ if (!isAugeasEnabled()) {
report.setStatus(CreateResourceStatus.FAILURE);
report.setErrorMessage("Resources can be created only when augeas is enabled.");
return report;
}
ResourceType resourceType = report.getResourceType();
-
- if (resourceType.equals(getDirectoryResourceType())) {
- Configuration resourceConfiguration = report.getResourceConfiguration();
- Configuration pluginConfiguration = report.getPluginConfiguration();
-
- String directoryName = report.getUserSpecifiedResourceName();
-
- //fill in the plugin configuration
-
- //get the directive index
- AugeasTree tree = getServerConfigurationTree();
- AugeasNode myNode = getNode(tree);
- List<AugeasNode> directories = myNode.getChildByLabel("<Directory");
- int seq = 1;
- /*
- * myNode will be parent node of the new Directory node.
- * We need to create a new node for directory node which will contain child nodes.
- * To create a node we can call method from AugeasTree which will create a node. In this method is
- * parameter sequence, if we will leave this parameter empty and there will be more nodes with
- * the same label, new node will be created but the method createNode will return node with index 0 resp 1.
- * If that will happen we can not update the node anymore because we are updating wrong node.
- * To avoid this situation we need to know what is the last sequence nr. of virtual host's child (directory) nodes.
- * We can not just count child nodes with the same label because some of the child nodes
- * could be stored in another file. So that in httpd configurationstructure they are child nodes of virtual host,
- * but in augeas configuration structure they can be child nodes of node Include[];.
- */
-
- for (AugeasNode n : directories) {
- String param = n.getFullPath();
- int end = param.lastIndexOf(File.separatorChar);
- if (end != -1)
- if (myNode.getFullPath().equals(param.substring(0,end)))
- seq++;
+ AugeasComponent comp = null;
+ try {
+ comp = getAugeas();
+ if (resourceType.equals(getDirectoryResourceType())) {
+ Configuration resourceConfiguration = report.getResourceConfiguration();
+ Configuration pluginConfiguration = report.getPluginConfiguration();
+
+ String directoryName = report.getUserSpecifiedResourceName();
+
+ //fill in the plugin configuration
+
+ //get the directive index
+ AugeasTree tree = comp.getAugeasTree(ApacheServerComponent.AUGEAS_HTTP_MODULE_NAME);
+ AugeasNode myNode = getNode(tree);
+ List<AugeasNode> directories = myNode.getChildByLabel("<Directory");
+ int seq = 1;
+ /*
+ * myNode will be parent node of the new Directory node.
+ * We need to create a new node for directory node which will contain child nodes.
+ * To create a node we can call method from AugeasTree which will create a node. In this method is
+ * parameter sequence, if we will leave this parameter empty and there will be more nodes with
+ * the same label, new node will be created but the method createNode will return node with index 0 resp 1.
+ * If that will happen we can not update the node anymore because we are updating wrong node.
+ * To avoid this situation we need to know what is the last sequence nr. of virtual host's child (directory) nodes.
+ * We can not just count child nodes with the same label because some of the child nodes
+ * could be stored in another file. So that in httpd configurationstructure they are child nodes of virtual host,
+ * but in augeas configuration structure they can be child nodes of node Include[];.
+ */
+
+ for (AugeasNode n : directories) {
+ String param = n.getFullPath();
+ int end = param.lastIndexOf(File.separatorChar);
+ if (end != -1)
+ if (myNode.getFullPath().equals(param.substring(0, end)))
+ seq++;
}
-
- //pluginConfiguration.put(new PropertySimple(ApacheDirectoryComponent.DIRECTIVE_INDEX_PROP, seq));
- //we don't support this yet... need to figure out how...
- pluginConfiguration.put(new PropertySimple(ApacheDirectoryComponent.REGEXP_PROP, false));
- String dirNameToSet = AugeasNodeValueUtil.escape(directoryName);
-
- //now actually create the data in augeas
- try {
- ApacheAugeasMapping mapping = new ApacheAugeasMapping(tree);
- AugeasNode directoryNode = tree.createNode(myNode, "<Directory", null, seq);
- tree.createNode(directoryNode, "param", dirNameToSet, 0);
- mapping.updateAugeas(directoryNode, resourceConfiguration, resourceType.getResourceConfigurationDefinition());
- tree.save();
-
-
- tree = getServerConfigurationTree();
- String key = AugeasNodeSearch.getNodeKey(myNode, directoryNode);
- report.setResourceKey(key);
- report.setResourceName(directoryName);
-
- report.setStatus(CreateResourceStatus.SUCCESS);
-
- resourceContext.getParentResourceComponent().finishChildResourceCreate(report);
- } catch (Exception e) {
- report.setException(e);
+
+ //pluginConfiguration.put(new PropertySimple(ApacheDirectoryComponent.DIRECTIVE_INDEX_PROP, seq));
+ //we don't support this yet... need to figure out how...
+ pluginConfiguration.put(new PropertySimple(ApacheDirectoryComponent.REGEXP_PROP, false));
+ String dirNameToSet = AugeasNodeValueUtil.escape(directoryName);
+
+ //now actually create the data in augeas
+ try {
+ ApacheAugeasMapping mapping = new ApacheAugeasMapping(tree);
+ AugeasNode directoryNode = tree.createNode(myNode, "<Directory", null, seq);
+ String myNodeKey = AugeasNodeSearch.getNodeKey(myNode, tree.getRootNode());
+ tree.createNode(directoryNode, "param", dirNameToSet, 0);
+ mapping.updateAugeas(directoryNode, resourceConfiguration,
+ resourceType.getResourceConfigurationDefinition());
+
+ tree.save();
+ comp.close();
+ tree = comp.getAugeasTree(ApacheServerComponent.AUGEAS_HTTP_MODULE_NAME);
+
+ AugeasNode parentNode;
+ if (myNodeKey.equals("")) {
+ parentNode = tree.getRootNode();
+ } else
+ parentNode = AugeasNodeSearch.findNodeById(tree.getRootNode(), myNodeKey);
+
+ List<AugeasNode> nodes = parentNode.getChildByLabel("<Directory");
+ if (nodes.size() < seq) {
+ report.setStatus(CreateResourceStatus.FAILURE);
+ report.setErrorMessage("Could not create directory node.");
+ }
+
+ AugeasNode nd = nodes.get(seq - 1);
+ String key = AugeasNodeSearch.getNodeKey(nd, parentNode);
+
+ report.setResourceKey(key);
+ report.setResourceName(directoryName);
+
+ report.setStatus(CreateResourceStatus.SUCCESS);
+
+ resourceContext.getParentResourceComponent().finishChildResourceCreate(report);
+ } catch (Exception e) {
+ log.error("Could not create httpd virtual host child resource.", e);
+ report.setException(e);
+ report.setStatus(CreateResourceStatus.FAILURE);
+ }
+ } else {
+ report.setErrorMessage("Unable to create resources of type " + resourceType.getName());
report.setStatus(CreateResourceStatus.FAILURE);
}
- } else {
- report.setErrorMessage("Unable to create resources of type " + resourceType.getName());
- report.setStatus(CreateResourceStatus.FAILURE);
+ } finally {
+ if (comp != null)
+ comp.close();
}
return report;
}
-
- public AugeasTree getServerConfigurationTree() {
- return resourceContext.getParentResourceComponent().getAugeasTree();
+
+ public AugeasComponent getAugeas() {
+ return resourceContext.getParentResourceComponent().getAugeas();
}
/**
@@ -348,54 +391,54 @@ public class ApacheVirtualHostServiceComponent implements ResourceComponent<Apac
List<AugeasNode> virtualHosts = new ArrayList<AugeasNode>();
boolean updated = false;
-//BZ 612189 - uncomment this algo once the resource upgrade is in place
-// for (AugeasNode node : nodes) {
-// updated = false;
-// List<AugeasNode> serverNameNodes = tree.matchRelative(node, "ServerName/param");
-// String tempServerName = null;
-//
-// if (!(serverNameNodes.isEmpty())) {
-// tempServerName = serverNameNodes.get(0).getValue();
-// }
-// if (tempServerName == null & serverName == null)
-// updated = true;
-// if (tempServerName != null & serverName != null)
-// if (tempServerName.equals(serverName)){
-// updated = true;
-// }
-//
-//
-// if (updated){
-// updated = false;
-// List<AugeasNode> params = node.getChildByLabel("param");
-// for (AugeasNode nd : params) {
-// updated = false;
-// for (String adr : addrs) {
-// if (adr.equals(nd.getValue()))
-// updated = true;
-// }
-// if (!updated)
-// break;
-// }
-//
-// if (updated)
-// virtualHosts.add(node);
-// }
-// }
-
+ //BZ 612189 - uncomment this algo once the resource upgrade is in place
+ // for (AugeasNode node : nodes) {
+ // updated = false;
+ // List<AugeasNode> serverNameNodes = tree.matchRelative(node, "ServerName/param");
+ // String tempServerName = null;
+ //
+ // if (!(serverNameNodes.isEmpty())) {
+ // tempServerName = serverNameNodes.get(0).getValue();
+ // }
+ // if (tempServerName == null & serverName == null)
+ // updated = true;
+ // if (tempServerName != null & serverName != null)
+ // if (tempServerName.equals(serverName)){
+ // updated = true;
+ // }
+ //
+ //
+ // if (updated){
+ // updated = false;
+ // List<AugeasNode> params = node.getChildByLabel("param");
+ // for (AugeasNode nd : params) {
+ // updated = false;
+ // for (String adr : addrs) {
+ // if (adr.equals(nd.getValue()))
+ // updated = true;
+ // }
+ // if (!updated)
+ // break;
+ // }
+ //
+ // if (updated)
+ // virtualHosts.add(node);
+ // }
+ // }
+
//BZ 612189 - remove this once resource upgrade is in place
- HttpdAddressUtility.Address resourceKeyAddress = HttpdAddressUtility.Address.parse(resourceKey);
-
+ HttpdAddressUtility.Address resourceKeyAddress = HttpdAddressUtility.Address.parse(resourceKey);
+
AugeasNode bestNode = null;
int bestMatch = 0;
- for(AugeasNode node : nodes) {
+ for (AugeasNode node : nodes) {
List<AugeasNode> vhostAddressNodes = node.getChildByLabel("param");
-
+
List<HttpdAddressUtility.Address> vhostAddresses = new ArrayList<HttpdAddressUtility.Address>();
for (AugeasNode vhostAddressNode : vhostAddressNodes) {
vhostAddresses.add(HttpdAddressUtility.Address.parse(vhostAddressNode.getValue()));
}
-
+
int matchRate = matchRate(vhostAddresses, resourceKeyAddress);
if (bestMatch < matchRate) {
bestNode = node;
@@ -405,24 +448,24 @@ public class ApacheVirtualHostServiceComponent implements ResourceComponent<Apac
if (bestNode != null) {
return bestNode;
}
-
+
//BZ 612189 - remove this once we have resource upgrade
//ok, one final attempt... the legacy resource key format for the MainServer is just a host:port as with the rest of the vhosts, let's try that
try {
String serverUrl = resourceContext.getParentResourceComponent().getServerUrl();
URI serverUri = new URI(serverUrl);
String expectedResourceKey = serverUri.getHost() + ":" + serverUri.getPort();
-
+
HttpdAddressUtility.Address expectedAddress = HttpdAddressUtility.Address.parse(expectedResourceKey);
HttpdAddressUtility.Address actualAddress = HttpdAddressUtility.Address.parse(resourceKey);
-
+
if (matchRate(Collections.singletonList(expectedAddress), actualAddress) > 0) {
return tree.getRootNode();
}
} catch (URISyntaxException e) {
log.warn("Failed to parse the server URL when trying to match the vhost with the main server.", e);
}
-
+
throw new IllegalStateException("Could not find virtual host configuration in augeas for virtual host: "
+ resourceKey);
}
@@ -433,7 +476,7 @@ public class ApacheVirtualHostServiceComponent implements ResourceComponent<Apac
public void finishConfigurationUpdate(ConfigurationUpdateReport report) {
resourceContext.getParentResourceComponent().finishConfigurationUpdate(report);
}
-
+
/**
* @see ApacheServerComponent#conditionalRestart()
*
@@ -442,11 +485,11 @@ public class ApacheVirtualHostServiceComponent implements ResourceComponent<Apac
public void conditionalRestart() throws Exception {
resourceContext.getParentResourceComponent().conditionalRestart();
}
-
+
public void deleteEmptyFile(AugeasTree tree, AugeasNode deletedNode) {
resourceContext.getParentResourceComponent().deleteEmptyFile(tree, deletedNode);
}
-
+
private void collectSnmpMetric(MeasurementReport report, int primaryIndex, SNMPSession snmpSession,
MeasurementScheduleRequest schedule) throws SNMPException {
SNMPValue snmpValue = null;
@@ -508,7 +551,8 @@ public class ApacheVirtualHostServiceComponent implements ResourceComponent<Apac
return oid;
}
- public static int getMatchingWwwServiceIndex(ApacheServerComponent parent, String resourceKey, List<SNMPValue> names, List<SNMPValue> ports) {
+ public static int getMatchingWwwServiceIndex(ApacheServerComponent parent, String resourceKey,
+ List<SNMPValue> names, List<SNMPValue> ports) {
int ret = -1;
Iterator<SNMPValue> namesIterator = names.iterator();
Iterator<SNMPValue> portsIterator = ports.iterator();
@@ -523,21 +567,22 @@ public class ApacheVirtualHostServiceComponent implements ResourceComponent<Apac
}
vhostAddressStrings = resourceKey.substring(pipeIdx + 1).split(" ");
- ApacheDirectiveTree tree = parent.loadParser();
-
+ ApacheDirectiveTree tree = parent.loadParser();
+
//convert the vhost addresses into fully qualified ip/port addresses
List<HttpdAddressUtility.Address> vhostAddresses = new ArrayList<HttpdAddressUtility.Address>(
vhostAddressStrings.length);
if (vhostAddressStrings.length == 1 && MAIN_SERVER_RESOURCE_KEY.equals(vhostAddressStrings[0])) {
- HttpdAddressUtility.Address serverAddr = parent.getAddressUtility().getMainServerSampleAddress(tree, null, 0);
+ HttpdAddressUtility.Address serverAddr = parent.getAddressUtility().getMainServerSampleAddress(tree, null,
+ 0);
if (serverAddr != null) {
vhostAddresses.add(serverAddr);
}
} else {
for (int i = 0; i < vhostAddressStrings.length; ++i) {
- HttpdAddressUtility.Address vhostAddr = parent.getAddressUtility().getVirtualHostSampleAddress(tree, vhostAddressStrings[i],
- vhostServerName, true);
+ HttpdAddressUtility.Address vhostAddr = parent.getAddressUtility().getVirtualHostSampleAddress(tree,
+ vhostAddressStrings[i], vhostServerName, true);
if (vhostAddr != null) {
vhostAddresses.add(vhostAddr);
} else {
@@ -559,7 +604,7 @@ public class ApacheVirtualHostServiceComponent implements ResourceComponent<Apac
//and possibly multiple IP addresses.
SNMPValue bestMatch = null;
int bestMatchRate = 0;
-
+
while (namesIterator.hasNext()) {
SNMPValue nameValue = namesIterator.next();
SNMPValue portValue = portsIterator.next();
@@ -568,36 +613,38 @@ public class ApacheVirtualHostServiceComponent implements ResourceComponent<Apac
String fullPort = portValue.toString();
int snmpPort = Integer.parseInt(fullPort.substring(fullPort.lastIndexOf(".") + 1));
-
+
HttpdAddressUtility.Address snmpAddress = new HttpdAddressUtility.Address(snmpHost, snmpPort);
-
+
int matchRate = matchRate(vhostAddresses, snmpAddress);
if (matchRate > bestMatchRate) {
bestMatch = nameValue;
bestMatchRate = matchRate;
}
}
-
+
if (bestMatch != null) {
String nameOID = bestMatch.getOID();
ret = Integer.parseInt(nameOID.substring(nameOID.lastIndexOf(".") + 1));
} else {
- log.warn("Unable to match the Virtual Host [" + resourceKey + "] with any of the SNMP advertised vhosts: " + names + ". It won't be possible to monitor the Virtual Host.");
+ log.warn("Unable to match the Virtual Host [" + resourceKey + "] with any of the SNMP advertised vhosts: "
+ + names + ". It won't be possible to monitor the Virtual Host.");
}
return ret;
}
-
+
/**
* @return the index of the virtual host that identifies it in SNMP
* @throws Exception on SNMP error
*/
private int getWwwServiceIndex() throws Exception {
- ConfigurationTimestamp currentTimestamp = resourceContext.getParentResourceComponent().getConfigurationTimestamp();
+ ConfigurationTimestamp currentTimestamp = resourceContext.getParentResourceComponent()
+ .getConfigurationTimestamp();
if (!lastConfigurationTimeStamp.equals(currentTimestamp)) {
snmpWwwServiceIndex = -1;
//don't go through this configuration again even if we fail further below.. we'd fail again.
lastConfigurationTimeStamp = currentTimestamp;
-
+
//configuration has changed. re-read the service index of this virtual host
//we have to scan the SNMP to find the entry corresponding to this vhost.
@@ -608,54 +655,56 @@ public class ApacheVirtualHostServiceComponent implements ResourceComponent<Apac
names = snmpSession.getColumn(SNMPConstants.COLUMN_VHOST_NAME);
ports = snmpSession.getColumn(SNMPConstants.COLUMN_VHOST_PORT);
-
- snmpWwwServiceIndex = getMatchingWwwServiceIndex(resourceContext.getParentResourceComponent(), resourceContext.getResourceKey(), names, ports);
+
+ snmpWwwServiceIndex = getMatchingWwwServiceIndex(resourceContext.getParentResourceComponent(),
+ resourceContext.getResourceKey(), names, ports);
}
return snmpWwwServiceIndex;
}
private static int matchRate(List<HttpdAddressUtility.Address> addresses, HttpdAddressUtility.Address addressToCheck) {
- for(HttpdAddressUtility.Address a : addresses) {
+ for (HttpdAddressUtility.Address a : addresses) {
if (HttpdAddressUtility.isAddressConforming(addressToCheck, a.host, a.port, true)) {
return 3;
}
}
-
+
//try to get the IP of the address to check
InetAddress[] ipAddresses;
try {
ipAddresses = InetAddress.getAllByName(addressToCheck.host);
- for(InetAddress ip : ipAddresses) {
- HttpdAddressUtility.Address newCheck = new HttpdAddressUtility.Address(ip.getHostAddress(), addressToCheck.port);
-
- for(HttpdAddressUtility.Address a : addresses) {
+ for (InetAddress ip : ipAddresses) {
+ HttpdAddressUtility.Address newCheck = new HttpdAddressUtility.Address(ip.getHostAddress(),
+ addressToCheck.port);
+
+ for (HttpdAddressUtility.Address a : addresses) {
if (HttpdAddressUtility.isAddressConforming(newCheck, a.host, a.port, true)) {
return 2;
}
}
- }
+ }
} catch (UnknownHostException e) {
log.debug("Unknown host encountered in the httpd configuration: " + addressToCheck.host);
return 0;
}
-
+
//this stupid 80 = 0 rule is to conform with snmp module
//the problem is that snmp module represents both 80 and * port defs as 0,
//so whatever we do, we might mismatch the vhost. But there's no working around that
//but to modify the snmp module itself.
-
+
int addressPort = addressToCheck.port;
if (addressPort == 80) {
addressPort = 0;
}
-
+
//ok, try the hardest...
- for(HttpdAddressUtility.Address listAddress: addresses) {
+ for (HttpdAddressUtility.Address listAddress : addresses) {
int listPort = listAddress.port;
if (listPort == 80) {
listPort = 0;
}
-
+
InetAddress[] listAddresses;
try {
listAddresses = InetAddress.getAllByName(listAddress.host);
@@ -663,7 +712,7 @@ public class ApacheVirtualHostServiceComponent implements ResourceComponent<Apac
log.debug("Unknown host encountered in the httpd configuration: " + listAddress.host);
return 0;
}
-
+
for (InetAddress listInetAddr : listAddresses) {
for (InetAddress ip : ipAddresses) {
if (ip.equals(listInetAddr) && addressPort == listPort) {
@@ -672,20 +721,20 @@ public class ApacheVirtualHostServiceComponent implements ResourceComponent<Apac
}
}
}
-
+
return 0;
}
-
+
private ResourceType getDirectoryResourceType() {
return resourceContext.getResourceType().getChildResourceTypes().iterator().next();
}
-
- public ApacheDirectiveTree loadParser() throws Exception{
+
+ public ApacheDirectiveTree loadParser() throws Exception {
return resourceContext.getParentResourceComponent().loadParser();
}
-
- public boolean isAugeasEnabled(){
+
+ public boolean isAugeasEnabled() {
ApacheServerComponent parent = resourceContext.getParentResourceComponent();
- return parent.isAugeasEnabled();
+ return parent.isAugeasEnabled();
}
}
\ No newline at end of file
diff --git a/modules/plugins/augeas/src/main/java/org/rhq/augeas/AugeasProxy.java b/modules/plugins/augeas/src/main/java/org/rhq/augeas/AugeasProxy.java
index 262bf95..ff6a1a4 100644
--- a/modules/plugins/augeas/src/main/java/org/rhq/augeas/AugeasProxy.java
+++ b/modules/plugins/augeas/src/main/java/org/rhq/augeas/AugeasProxy.java
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2009 Red Hat, Inc.
+ * Copyright (C) 2005-2011 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -23,7 +23,6 @@
package org.rhq.augeas;
import java.io.File;
-import java.net.URL;
import java.util.ArrayList;
import java.util.List;
@@ -38,7 +37,6 @@ import org.rhq.augeas.tree.AugeasTree;
import org.rhq.augeas.tree.AugeasTreeBuilder;
import org.rhq.augeas.tree.AugeasTreeException;
import org.rhq.augeas.tree.impl.DefaultAugeasTreeBuilder;
-import org.rhq.plugins.augeas.AugeasPluginLifecycleListener;
/**
* This is the main entry point for interfacing with Augeas.
@@ -53,13 +51,13 @@ import org.rhq.plugins.augeas.AugeasPluginLifecycleListener;
*
*/
public class AugeasProxy {
-
- private final Log log = LogFactory.getLog(this.getClass());
+
+ private final Log log = LogFactory.getLog(this.getClass());
private AugeasConfiguration config;
private Augeas augeas;
private List<String> modules;
private AugeasTreeBuilder augeasTreeBuilder;
-
+
/**
* Instantiates new proxy with supplied configuration and
* {@link DefaultAugeasTreeBuilder} as the tree builder.
@@ -99,13 +97,20 @@ public class AugeasProxy {
public void load() throws AugeasTreeException {
try {
config.loadFiles();
+ if (augeas != null) {
+ try {
+ augeas.close();
+ } catch (Exception e) {
+ }
+ augeas = null;
+ }
augeas = new Augeas(config.getRootPath(), config.getLoadPath(), config.getMode());
-
+
for (AugeasModuleConfig module : config.getModules()) {
-
+
modules.add(module.getModuletName());
augeas.set("/augeas/load/" + module.getModuletName() + "/lens", module.getLensPath());
-
+
int idx = 1;
for (String incl : module.getConfigFiles()) {
augeas.set("/augeas/load/" + module.getModuletName() + "/incl[" + (idx++) + "]", incl);
@@ -113,13 +118,25 @@ public class AugeasProxy {
}
augeas.load();
} catch (NoClassDefFoundError e) {
+ if (augeas != null) {
+ try {
+ augeas.close();
+ } catch (Exception e2) {
+ }
+ augeas = null;
+ }
throw new AugeasException("Failed to initialize Augeas. It is probably not installed.", e);
} catch (Exception e) {
+ if (augeas != null) {
+ try {
+ augeas.close();
+ } catch (Exception e2) {
+ }
+ augeas = null;
+ }
throw new AugeasException(e);
}
}
-
-
/**
* Produces the Augeas tree by loading it from augeas (if {@link #load()} wasn't called already)
@@ -178,4 +195,29 @@ public class AugeasProxy {
public Augeas getAugeas() {
return augeas;
}
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#finalize()
+ */
+ @Override
+ protected void finalize() throws Throwable {
+ if (augeas != null) {
+ try {
+ augeas.close();
+ } catch (Exception e) {
+ }
+ augeas = null;
+ }
+ super.finalize();
+ }
+
+ public void close() {
+ if (augeas != null) {
+ try {
+ augeas.close();
+ } catch (Exception e) {
+ }
+ augeas = null;
+ }
+ }
}
diff --git a/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationComponent.java b/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationComponent.java
index 2f500b6..91cde41 100644
--- a/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationComponent.java
+++ b/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/AugeasConfigurationComponent.java
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2009 Red Hat, Inc.
+ * Copyright (C) 2005-2011 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -35,7 +35,6 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-
import org.rhq.augeas.util.Glob;
import org.rhq.core.domain.configuration.AbstractPropertyMap;
import org.rhq.core.domain.configuration.Configuration;
@@ -130,41 +129,45 @@ public class AugeasConfigurationComponent<T extends ResourceComponent> implement
public Configuration loadResourceConfiguration() throws Exception {
abortIfAugeasNotAvailable();
- // Load the config file from disk and build a tree representation of it.
- loadConfigurationFiles(this.augeas);
+ //augeas was initialized in abortIfAugeasNotAvailable();
+ try {
+ ConfigurationDefinition resourceConfigDef = this.resourceContext.getResourceType()
+ .getResourceConfigurationDefinition();
+ Configuration resourceConfig = new Configuration();
+ resourceConfig.setNotes("Loaded from Augeas at " + new Date());
- ConfigurationDefinition resourceConfigDef = this.resourceContext.getResourceType()
- .getResourceConfigurationDefinition();
- Configuration resourceConfig = new Configuration();
- resourceConfig.setNotes("Loaded from Augeas at " + new Date());
+ Collection<PropertyDefinition> propDefs = resourceConfigDef.getPropertyDefinitions().values();
- Collection<PropertyDefinition> propDefs = resourceConfigDef.getPropertyDefinitions().values();
+ for (PropertyDefinition propDef : propDefs) {
+ loadProperty(propDef, resourceConfig, this.augeas, this.resourceConfigRootNode);
+ }
- for (PropertyDefinition propDef : propDefs) {
- loadProperty(propDef, resourceConfig, this.augeas, this.resourceConfigRootNode);
+ // This will add error messages to any PropertySimples with invalid values, so they can be displayed by the GUI.
+ validateResourceConfiguration(new ConfigurationUpdateReport(resourceConfig));
+ return resourceConfig;
+ } finally {
+ close();
}
-
- // This will add error messages to any PropertySimples with invalid values, so they can be displayed by the GUI.
- validateResourceConfiguration(new ConfigurationUpdateReport(resourceConfig));
- return resourceConfig;
}
protected void updateStructuredConfiguration(Configuration config) throws Exception {
abortIfAugeasNotAvailable();
- // Load the config files from disk and build a tree representation of them in memory.
- loadConfigurationFiles(this.augeas);
+ //augeas was initialized in abortIfAugeasNotAvailable
+ try {
+ ConfigurationDefinition resourceConfigDef = this.resourceContext.getResourceType()
+ .getResourceConfigurationDefinition();
- ConfigurationDefinition resourceConfigDef = this.resourceContext.getResourceType()
- .getResourceConfigurationDefinition();
+ Collection<PropertyDefinition> propDefs = resourceConfigDef.getPropertyDefinitions().values();
+ for (PropertyDefinition propDef : propDefs) {
+ setNode(propDef, config, this.augeas, this.resourceConfigRootNode);
+ }
- Collection<PropertyDefinition> propDefs = resourceConfigDef.getPropertyDefinitions().values();
- for (PropertyDefinition propDef : propDefs) {
- setNode(propDef, config, this.augeas, this.resourceConfigRootNode);
+ // Write the updated tree out to the config file.
+ saveConfigurationFiles();
+ } finally {
+ close();
}
-
- // Write the updated tree out to the config file.
- saveConfigurationFiles();
}
public void updateResourceConfiguration(ConfigurationUpdateReport report) {
@@ -182,23 +185,25 @@ public class AugeasConfigurationComponent<T extends ResourceComponent> implement
return;
}
- // Load the config files from disk and build a tree representation of them in memory.
- loadConfigurationFiles(this.augeas);
-
- ConfigurationDefinition resourceConfigDef = this.resourceContext.getResourceType()
- .getResourceConfigurationDefinition();
- Configuration resourceConfig = report.getConfiguration();
+ //augeas was initialized in abortIfAugeasNotAvailable();
+ try {
+ ConfigurationDefinition resourceConfigDef = this.resourceContext.getResourceType()
+ .getResourceConfigurationDefinition();
+ Configuration resourceConfig = report.getConfiguration();
- Collection<PropertyDefinition> propDefs = resourceConfigDef.getPropertyDefinitions().values();
- for (PropertyDefinition propDef : propDefs) {
- setNode(propDef, resourceConfig, this.augeas, this.resourceConfigRootNode);
- }
+ Collection<PropertyDefinition> propDefs = resourceConfigDef.getPropertyDefinitions().values();
+ for (PropertyDefinition propDef : propDefs) {
+ setNode(propDef, resourceConfig, this.augeas, this.resourceConfigRootNode);
+ }
- // Write the updated tree out to the config file.
- saveConfigurationFiles();
+ // Write the updated tree out to the config file.
+ saveConfigurationFiles();
- // If we got this far, we've succeeded in our mission.
- report.setStatus(ConfigurationUpdateStatus.SUCCESS);
+ // If we got this far, we've succeeded in our mission.
+ report.setStatus(ConfigurationUpdateStatus.SUCCESS);
+ } finally {
+ close();
+ }
}
public CreateResourceReport createResource(CreateResourceReport report) {
@@ -206,37 +211,47 @@ public class AugeasConfigurationComponent<T extends ResourceComponent> implement
ConfigurationDefinition resourceConfigDef = report.getResourceType().getResourceConfigurationDefinition();
// First insert the root node corresponding to the new child Resource.
- String rootPath = getChildResourceConfigurationRootPath(report.getResourceType(), report
- .getResourceConfiguration());
- AugeasNode rootNode = new AugeasNode(rootPath);
- if (this.augeas.exists(rootNode.getPath())) {
- report.setStatus(CreateResourceStatus.FAILURE);
- report.setErrorMessage("An Augeas node already exists with path " + rootPath);
- return report;
- }
- String rootLabel = getChildResourceConfigurationRootLabel(report.getResourceType(), report
- .getResourceConfiguration());
- this.augeas.set(rootNode.getPath(), rootLabel);
-
- // Then set all its child nodes.
- Collection<PropertyDefinition> propDefs = resourceConfigDef.getPropertyDefinitions().values();
- for (PropertyDefinition propDef : propDefs) {
- setNode(propDef, resourceConfig, this.augeas, rootNode);
- }
+ String rootPath = getChildResourceConfigurationRootPath(report.getResourceType(),
+ report.getResourceConfiguration());
+ initAugeas();
+ try {
+ AugeasNode rootNode = new AugeasNode(rootPath);
+ if (this.augeas.exists(rootNode.getPath())) {
+ report.setStatus(CreateResourceStatus.FAILURE);
+ report.setErrorMessage("An Augeas node already exists with path " + rootPath);
+ return report;
+ }
+ String rootLabel = getChildResourceConfigurationRootLabel(report.getResourceType(),
+ report.getResourceConfiguration());
+ this.augeas.set(rootNode.getPath(), rootLabel);
+
+ // Then set all its child nodes.
+ Collection<PropertyDefinition> propDefs = resourceConfigDef.getPropertyDefinitions().values();
+ for (PropertyDefinition propDef : propDefs) {
+ setNode(propDef, resourceConfig, this.augeas, rootNode);
+ }
- // Write the updated tree out to the config file.
- saveConfigurationFiles();
+ // Write the updated tree out to the config file.
+ saveConfigurationFiles();
- // If we got this far, we've succeeded in our mission.
- report.setStatus(CreateResourceStatus.SUCCESS);
- return report;
+ // If we got this far, we've succeeded in our mission.
+ report.setStatus(CreateResourceStatus.SUCCESS);
+ return report;
+ } finally {
+ close();
+ }
}
public void deleteResource() throws Exception {
String rootPath = getResourceConfigurationRootPath();
- Augeas augeas = getAugeas();
- augeas.remove(rootPath);
- augeas.save();
+ initAugeas();
+ try {
+ Augeas augeas = getAugeas();
+ augeas.remove(rootPath);
+ augeas.save();
+ } finally {
+ close();
+ }
}
/**
@@ -318,6 +333,8 @@ public class AugeasConfigurationComponent<T extends ResourceComponent> implement
}
public Augeas getAugeas() {
+ if (this.augeas == null)
+ initAugeas();
return this.augeas;
}
@@ -339,13 +356,18 @@ public class AugeasConfigurationComponent<T extends ResourceComponent> implement
}
protected Augeas createAugeas() {
- Augeas augeas;
+ Augeas augeas = null;
try {
augeas = new Augeas(this.augeasRootPath, AUGEAS_LOAD_PATH, Augeas.NO_MODL_AUTOLOAD);
setupAugeasModules(augeas);
- loadConfigurationFiles(augeas);
} catch (RuntimeException e) {
- augeas = null;
+ if (augeas != null) {
+ try {
+ augeas.close();
+ } catch (Exception e2) {
+ }
+ augeas = null;
+ }
log.error("Failed to initialize Augeas Java API.", e);
}
return augeas;
@@ -619,14 +641,6 @@ public class AugeasConfigurationComponent<T extends ResourceComponent> implement
return mapKeyNames.getSimpleValue(listName, null);
}
- private void loadConfigurationFiles(Augeas augeas) {
- try {
- augeas.load();
- } catch (AugeasException e) {
- throw new RuntimeException(summarizeAugeasError(augeas), e);
- }
- }
-
private void saveConfigurationFiles() {
// TODO: Backup original file.
try {
@@ -676,8 +690,8 @@ public class AugeasConfigurationComponent<T extends ResourceComponent> implement
List<String> nodePaths = augeas.match(errorNode.getPath() + "/*");
for (String path : nodePaths) {
String error = augeas.get(path);
- summary.append("File \"").append(path.substring(metadataNodePrefix.length(), path.length())).append(
- "\":\n").append(error).append("\n");
+ summary.append("File \"").append(path.substring(metadataNodePrefix.length(), path.length()))
+ .append("\":\n").append(error).append("\n");
}
}
@@ -685,7 +699,15 @@ public class AugeasConfigurationComponent<T extends ResourceComponent> implement
}
protected void initAugeas() {
+ if (this.augeas != null) {
+ try {
+ this.augeas.close();
+ } catch (Exception e) {
+ }
+ this.augeas = null;
+ }
this.augeas = createAugeas();
+ this.augeas.load();
String resourceConfigRootPath = getResourceConfigurationRootPath();
if (resourceConfigRootPath.indexOf(AugeasNode.SEPARATOR_CHAR) != 0) {
// root path is relative - make it absolute
@@ -695,6 +717,7 @@ public class AugeasConfigurationComponent<T extends ResourceComponent> implement
this.resourceConfigRootNode = new AugeasNode(resourceConfigRootPath);
}
log.debug("Resource Config Root Node = \"" + this.resourceConfigRootNode + "\"");
+
}
private void abortIfAugeasNotAvailable() throws Exception {
@@ -718,4 +741,29 @@ public class AugeasConfigurationComponent<T extends ResourceComponent> implement
}
}
}
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#finalize()
+ */
+ @Override
+ protected void finalize() throws Throwable {
+ if (this.augeas != null) {
+ try {
+ this.augeas.close();
+ } catch (Exception e) {
+ }
+ this.augeas = null;
+ }
+ super.finalize();
+ }
+
+ public void close() {
+ if (this.augeas != null) {
+ try {
+ this.augeas.close();
+ } catch (Exception e) {
+ }
+ this.augeas = null;
+ }
+ }
}
diff --git a/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/helper/AugeasRawConfigHelper.java b/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/helper/AugeasRawConfigHelper.java
index 4d42e0d..d2003ca 100644
--- a/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/helper/AugeasRawConfigHelper.java
+++ b/modules/plugins/augeas/src/main/java/org/rhq/plugins/augeas/helper/AugeasRawConfigHelper.java
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2009 Red Hat, Inc.
+ * Copyright (C) 2005-2011 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -122,13 +122,25 @@ public class AugeasRawConfigHelper {
}
private Augeas createAugeas(String lens, String contents) throws Exception {
- Augeas aug = new Augeas(rootPath, loadPath, Augeas.NO_MODL_AUTOLOAD);
- File fl = File.createTempFile("_rhq", null);
- //write the 'to' file to disk
- FileUtils.writeStringToFile(fl, contents);
- aug.set(transformPrefix + "/lens", lens);
- aug.set(transformPrefix + "/incl", fl.getAbsolutePath());
- aug.load();
+ Augeas aug = null;
+ try {
+ aug = new Augeas(rootPath, loadPath, Augeas.NO_MODL_AUTOLOAD);
+ File fl = File.createTempFile("_rhq", null);
+ //write the 'to' file to disk
+ FileUtils.writeStringToFile(fl, contents);
+ aug.set(transformPrefix + "/lens", lens);
+ aug.set(transformPrefix + "/incl", fl.getAbsolutePath());
+ aug.load();
+ } catch (Exception e) {
+ if (aug != null) {
+ try {
+ aug.close();
+ } catch (Exception e2) {
+ }
+ aug = null;
+ }
+ throw e;
+ }
return aug;
}
diff --git a/modules/plugins/augeas/src/main/java/org/rhq/rhqtransform/AugeasRHQComponent.java b/modules/plugins/augeas/src/main/java/org/rhq/rhqtransform/AugeasRHQComponent.java
index 7660de2..05e7bc4 100644
--- a/modules/plugins/augeas/src/main/java/org/rhq/rhqtransform/AugeasRHQComponent.java
+++ b/modules/plugins/augeas/src/main/java/org/rhq/rhqtransform/AugeasRHQComponent.java
@@ -23,11 +23,8 @@
package org.rhq.rhqtransform;
-import org.rhq.augeas.AugeasProxy;
-import org.rhq.augeas.tree.AugeasTree;
+import org.rhq.augeas.AugeasComponent;
import org.rhq.augeas.tree.AugeasTreeException;
-import org.rhq.core.pluginapi.inventory.ResourceComponent;
-
/**
* An interface the RHQ resource components can implement to provide access
@@ -36,20 +33,7 @@ import org.rhq.core.pluginapi.inventory.ResourceComponent;
* @author Filip Drabek
*
*/
-public interface AugeasRHQComponent<T extends ResourceComponent> extends ResourceComponent<T> {
-
- /**
- * @return the augeas tree for the component
- * @throws AugeasTreeException
- */
- public AugeasTree getAugeasTree() throws AugeasTreeException;
+public interface AugeasRHQComponent {
- /**
- * Provides access to the Augeas proxy configured in the way this component needs
- * so that users are able to perform non-trivial operations on it.
- *
- * @return
- * @throws AugeasTreeException
- */
- public AugeasProxy getAugeasProxy() throws AugeasTreeException;
+ public AugeasComponent getAugeas() throws AugeasTreeException;
}
diff --git a/modules/plugins/cron/src/main/java/org/rhq/plugins/cron/CronComponent.java b/modules/plugins/cron/src/main/java/org/rhq/plugins/cron/CronComponent.java
index ae22c2f..cfc1799 100644
--- a/modules/plugins/cron/src/main/java/org/rhq/plugins/cron/CronComponent.java
+++ b/modules/plugins/cron/src/main/java/org/rhq/plugins/cron/CronComponent.java
@@ -25,6 +25,7 @@ import java.util.List;
import net.augeas.Augeas;
import net.augeas.AugeasException;
+import org.rhq.augeas.util.GlobFilter;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.ConfigurationUpdateStatus;
import org.rhq.core.domain.configuration.Property;
@@ -41,7 +42,6 @@ import org.rhq.core.pluginapi.inventory.CreateResourceReport;
import org.rhq.plugins.augeas.AugeasConfigurationComponent;
import org.rhq.plugins.augeas.AugeasConfigurationDiscoveryComponent;
import org.rhq.plugins.augeas.helper.AugeasNode;
-import org.rhq.augeas.util.GlobFilter;
import org.rhq.plugins.platform.PlatformComponent;
/**
@@ -53,7 +53,7 @@ import org.rhq.plugins.platform.PlatformComponent;
public class CronComponent extends AugeasConfigurationComponent<PlatformComponent> implements CreateChildResourceFacet {
private static final String HOURLY_JOBS_PROP = "hourlyJobs";
- private static final String HOURLY_JOBS_NODE = "entry[time/minute != \"*\" and time/hour = \"*\" and time/dayofmonth = \"*\" and time/month = \"*\" and time/dayofweek = \"*\"]";
+ private static final String HOURLY_JOBS_NODE = "entry[time/minute != \"*\" and time/hour = \"*\" and time/dayofmonth = \"*\" and time/month = \"*\" and time/dayofweek = \"*\"]";
private static final String DAILY_JOBS_PROP = "dailyJobs";
private static final String DAILY_JOBS_NODE = "entry[time/minute != \"*\" and time/hour != \"*\" and time/dayofmonth = \"*\" and time/month = \"*\" and time/dayofweek = \"*\"]";
private static final String WEEKLY_JOBS_PROP = "weeklyJobs";
@@ -67,7 +67,7 @@ public class CronComponent extends AugeasConfigurationComponent<PlatformComponen
private static final String AUGEAS_FILES_PREFIX = "/files";
private static final int AUGEAS_FILES_PREFIX_LENGTH = AUGEAS_FILES_PREFIX.length();
private static final String CRONTAB_RESOURCE_TYPE_NAME = "Cron Tab";
-
+
@Override
protected String getResourceConfigurationRootPath() {
return "/files/"; //the trailing slash is intentional so that we can get the
@@ -77,7 +77,8 @@ public class CronComponent extends AugeasConfigurationComponent<PlatformComponen
public CreateResourceReport createResource(CreateResourceReport report) {
if (CRONTAB_RESOURCE_TYPE_NAME.equals(report.getResourceType().getName())) {
try {
- String resourceKey = createCrontab(report.getUserSpecifiedResourceName(), report.getResourceType().getResourceConfigurationDefinition(), report.getResourceConfiguration());
+ String resourceKey = createCrontab(report.getUserSpecifiedResourceName(), report.getResourceType()
+ .getResourceConfigurationDefinition(), report.getResourceConfiguration());
report.setResourceName(resourceKey);
report.setResourceKey(resourceKey);
report.setStatus(CreateResourceStatus.SUCCESS);
@@ -130,7 +131,7 @@ public class CronComponent extends AugeasConfigurationComponent<PlatformComponen
private String getEntryCrontabPath(AugeasNode crontabNode) {
//the node's path is /files/blah/blah/entry/..
//we want the /blah/blah part
- return crontabNode.getParent().getParent().getPath().substring(AUGEAS_FILES_PREFIX_LENGTH);
+ return crontabNode.getParent().getParent().getPath().substring(AUGEAS_FILES_PREFIX_LENGTH);
}
/**
@@ -139,65 +140,71 @@ public class CronComponent extends AugeasConfigurationComponent<PlatformComponen
* @param resourceConfiguration
* @return the resource key of the crontab
*/
- private String createCrontab(String resourceName, ConfigurationDefinition configurationDefinition, Configuration resourceConfiguration) {
+ private String createCrontab(String resourceName, ConfigurationDefinition configurationDefinition,
+ Configuration resourceConfiguration) {
File crontabFile = new File(resourceName);
-
+
try {
if (!crontabFile.createNewFile()) {
- throw new RuntimeException("File " + resourceName + " already exists. Creating the crontab would overwrite it.");
+ throw new RuntimeException("File " + resourceName
+ + " already exists. Creating the crontab would overwrite it.");
}
} catch (IOException e) {
throw new RuntimeException("Failed to create the crontab file named: " + resourceName);
}
-
+
//check that the crontab's name passes the glob filters
Configuration pluginConfiguration = getResourceContext().getPluginConfiguration();
-
- List<String> includeGlobs = AugeasConfigurationDiscoveryComponent.getGlobList(pluginConfiguration.getSimple(AugeasConfigurationComponent.INCLUDE_GLOBS_PROP));
- List<String> excludeGlobs = AugeasConfigurationDiscoveryComponent.getGlobList(pluginConfiguration.getSimple(AugeasConfigurationComponent.EXCLUDE_GLOBS_PROP));
+
+ List<String> includeGlobs = AugeasConfigurationDiscoveryComponent.getGlobList(pluginConfiguration
+ .getSimple(AugeasConfigurationComponent.INCLUDE_GLOBS_PROP));
+ List<String> excludeGlobs = AugeasConfigurationDiscoveryComponent.getGlobList(pluginConfiguration
+ .getSimple(AugeasConfigurationComponent.EXCLUDE_GLOBS_PROP));
boolean isIncluded = false;
-
- for(String include : includeGlobs) {
+
+ for (String include : includeGlobs) {
if (new GlobFilter(include).accept(crontabFile)) {
isIncluded = true;
break;
}
}
-
- String errorText = "Given Cron tab file name would be created outside of mapped filters. See the Cron resource connection properties for the inclusion and exclusion filters set up.";
+
+ String errorText = "Given Cron tab file name would be created outside of mapped filters. See the Cron resource connection properties for the inclusion and exclusion filters set up.";
if (!isIncluded) {
throw new IllegalArgumentException(errorText);
}
-
- for(String exclude : excludeGlobs) {
+
+ for (String exclude : excludeGlobs) {
if (new GlobFilter(exclude).accept(crontabFile)) {
throw new IllegalArgumentException(errorText);
}
}
-
+
updateCrontab(resourceName, configurationDefinition, resourceConfiguration);
-
+
return resourceName;
}
-
- protected void updateCrontab(String crontabPath, ConfigurationDefinition crontabConfigurationDefinition, Configuration crontabConfiguration) {
- Augeas augeas = getAugeas();
+
+ protected void updateCrontab(String crontabPath, ConfigurationDefinition crontabConfigurationDefinition,
+ Configuration crontabConfiguration) {
+ Augeas augeas = null;
try {
- augeas.load();
-
+ augeas = getAugeas();
+
File crontabFile = new File(crontabPath);
String basePath = AUGEAS_FILES_PREFIX + crontabFile.getAbsolutePath();
AugeasNode baseNode = new AugeasNode(basePath);
-
+
PropertyList entries = crontabConfiguration.getList(CronTabComponent.ENTRIES_PROP);
- PropertyDefinitionList entriesDef = crontabConfigurationDefinition.getPropertyDefinitionList(CronTabComponent.ENTRIES_PROP);
+ PropertyDefinitionList entriesDef = crontabConfigurationDefinition
+ .getPropertyDefinitionList(CronTabComponent.ENTRIES_PROP);
setNodeFromPropertyList(entriesDef, entries, augeas, baseNode);
-
+
PropertyList settings = crontabConfiguration.getList(CronTabComponent.ENVIRONMENT_SETTINGS_PROP);
if (settings != null) {
- for(Property p : settings.getList()) {
- PropertyMap setting = (PropertyMap)p;
+ for (Property p : settings.getList()) {
+ PropertyMap setting = (PropertyMap) p;
String name = setting.getSimpleValue(CronTabComponent.NAME_PROP, null);
String value = setting.getSimpleValue(CronTabComponent.VALUE_PROP, "");
if (name != null) {
@@ -206,10 +213,15 @@ public class CronComponent extends AugeasConfigurationComponent<PlatformComponen
}
}
}
-
+
augeas.save();
} catch (AugeasException e) {
- throw new RuntimeException(summarizeAugeasError(augeas), e);
+ if (augeas != null)
+ throw new RuntimeException(summarizeAugeasError(augeas), e);
+ else
+ throw new RuntimeException(e);
+ } finally {
+ close();
}
- }
+ }
}
diff --git a/modules/plugins/hosts/src/main/java/org/rhq/plugins/hosts/HostsComponent.java b/modules/plugins/hosts/src/main/java/org/rhq/plugins/hosts/HostsComponent.java
index dd29e6e..3f59718 100644
--- a/modules/plugins/hosts/src/main/java/org/rhq/plugins/hosts/HostsComponent.java
+++ b/modules/plugins/hosts/src/main/java/org/rhq/plugins/hosts/HostsComponent.java
@@ -78,7 +78,7 @@ public class HostsComponent extends AugeasConfigurationComponent {
@Override
public Configuration loadResourceConfiguration() throws Exception {
Configuration resourceConfig;
- if (getAugeas() != null) {
+ if (isAugeasAvailable()) {
resourceConfig = super.loadResourceConfiguration();
} else {
resourceConfig = new NonAugeasHostsConfigurationDelegate(this).loadResourceConfiguration();
@@ -90,7 +90,7 @@ public class HostsComponent extends AugeasConfigurationComponent {
@Override
public void updateResourceConfiguration(ConfigurationUpdateReport report) {
- if (getAugeas() != null) {
+ if (isAugeasAvailable()) {
super.updateResourceConfiguration(report);
} else {
if (!validateResourceConfiguration(report)) {
diff --git a/modules/plugins/samba/src/main/java/org/rhq/plugins/samba/SambaShareComponent.java b/modules/plugins/samba/src/main/java/org/rhq/plugins/samba/SambaShareComponent.java
index c123e86..7524a93 100644
--- a/modules/plugins/samba/src/main/java/org/rhq/plugins/samba/SambaShareComponent.java
+++ b/modules/plugins/samba/src/main/java/org/rhq/plugins/samba/SambaShareComponent.java
@@ -18,19 +18,18 @@ GNU General Public License for more details.
*/
package org.rhq.plugins.samba;
+import java.util.List;
+
import net.augeas.Augeas;
+
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.measurement.AvailabilityType;
-import org.rhq.core.domain.resource.CreateResourceHistory;
import org.rhq.core.pluginapi.configuration.ConfigurationUpdateReport;
import org.rhq.core.pluginapi.inventory.ResourceContext;
-import org.rhq.core.pluginapi.inventory.CreateResourceReport;
import org.rhq.plugins.augeas.AugeasConfigurationComponent;
import org.rhq.plugins.augeas.helper.AugeasNode;
-import java.util.List;
-
/**
* TODO
*/
@@ -52,7 +51,7 @@ public class SambaShareComponent extends AugeasConfigurationComponent<SambaServe
String targetPath = "/files/etc/samba/smb.conf/target[.='" + targetName + "']";
AugeasNode targetNode = new AugeasNode(targetPath);
Augeas augeas = getAugeas();
- augeas.load();
+
List<String> matches = augeas.match(targetNode.getPath());
return matches.get(0);
}
@@ -62,7 +61,7 @@ public class SambaShareComponent extends AugeasConfigurationComponent<SambaServe
}
public AvailabilityType getAvailability() {
- return super.getAvailability();
+ return super.getAvailability();
}
public Configuration loadResourceConfiguration() throws Exception {
@@ -78,7 +77,15 @@ public class SambaShareComponent extends AugeasConfigurationComponent<SambaServe
}
public void deleteResource() throws Exception {
- super.deleteResource();
+ initAugeas();
+ String rootPath = getResourceConfigurationRootPath();
+ try {
+ Augeas augeas = getAugeas();
+ augeas.remove(rootPath);
+ augeas.save();
+ } finally {
+ close();
+ }
}
}
diff --git a/modules/plugins/samba/src/main/java/org/rhq/plugins/samba/SambaShareDiscoveryComponent.java b/modules/plugins/samba/src/main/java/org/rhq/plugins/samba/SambaShareDiscoveryComponent.java
index 5fc3b4f..34809b7 100644
--- a/modules/plugins/samba/src/main/java/org/rhq/plugins/samba/SambaShareDiscoveryComponent.java
+++ b/modules/plugins/samba/src/main/java/org/rhq/plugins/samba/SambaShareDiscoveryComponent.java
@@ -18,49 +18,47 @@
*/
package org.rhq.plugins.samba;
-import java.util.Set;
-import java.util.List;
import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
import net.augeas.Augeas;
-import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
-import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
-import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
-import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
+import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
public class SambaShareDiscoveryComponent implements ResourceDiscoveryComponent<SambaServerComponent> {
-
- public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<SambaServerComponent> discoveryContext)
- throws InvalidPluginConfigurationException, Exception {
+ public Set<DiscoveredResourceDetails> discoverResources(
+ ResourceDiscoveryContext<SambaServerComponent> discoveryContext) throws InvalidPluginConfigurationException,
+ Exception {
Set<DiscoveredResourceDetails> details = new HashSet<DiscoveredResourceDetails>();
SambaServerComponent serverComponent = discoveryContext.getParentResourceComponent();
- Augeas augeas = serverComponent.getAugeas();
- augeas.load();
+ Augeas augeas = null;
+ try {
+ augeas = serverComponent.getAugeas();
+
+ List<String> matches = augeas.match("/files/etc/samba/smb.conf/target[. != 'global']");
+ for (String match : matches) {
+ String name = augeas.get(match);
+ Configuration pluginConfig = discoveryContext.getDefaultPluginConfiguration();
+ pluginConfig.put(new PropertySimple("targetName", name));
+ DiscoveredResourceDetails detail = new DiscoveredResourceDetails(discoveryContext.getResourceType(),
+ name, name + " share", null, "Samba Share [" + name + "]", pluginConfig, null);
+ details.add(detail);
+ }
- List<String> matches = augeas.match("/files/etc/samba/smb.conf/target[. != 'global']");
- for (String match : matches) {
- String name = augeas.get(match);
- Configuration pluginConfig = discoveryContext.getDefaultPluginConfiguration();
- pluginConfig.put(new PropertySimple("targetName", name));
- DiscoveredResourceDetails detail = new DiscoveredResourceDetails(
- discoveryContext.getResourceType(),
- name,
- name + " share",
- null,
- "Samba Share [" + name + "]",
- pluginConfig,
- null
- );
- details.add(detail);
+ return details;
+ } finally {
+ if (serverComponent != null)
+ serverComponent.close();
}
-
- return details;
}
}
12 years, 10 months
[rhq] Branch 'drift' - modules/enterprise
by mazz
modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/drift/ChangeSet_16.png |binary
modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/drift/ChangeSet_16_open.png |binary
2 files changed
New commits:
commit 1359b2b4bb7743395916b0a8fab21cff1bc214cf
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Tue Jul 26 18:31:39 2011 -0400
tweek folder icons for drift
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/drift/ChangeSet_16.png b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/drift/ChangeSet_16.png
index fdda214..e728bc8 100644
Binary files a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/drift/ChangeSet_16.png and b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/drift/ChangeSet_16.png differ
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/drift/ChangeSet_16_open.png b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/drift/ChangeSet_16_open.png
index 358cf61..1ca204f 100644
Binary files a/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/drift/ChangeSet_16_open.png and b/modules/enterprise/gui/coregui/src/main/webapp/images/subsystems/drift/ChangeSet_16_open.png differ
12 years, 10 months