modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerComponent.java | 113 ++++------ modules/plugins/jboss-as-5/src/main/resources/META-INF/rhq-plugin.xml | 2 2 files changed, 54 insertions(+), 61 deletions(-)
New commits: commit 968f756a62a0931ee7e1addd6c9041864a8db336 Merge: abc1adc... 5055dca... Author: Ian Springer ian.springer@redhat.com Date: Wed Jun 30 18:44:06 2010 -0400
Merge branch 'release-3.0.0' of ssh://git.fedorahosted.org/git/rhq/rhq into release-3.0.0
commit abc1adc013a10a6b6d3a380be91ec12457c66524 Author: Ian Springer ian.springer@redhat.com Date: Wed Jun 30 18:42:59 2010 -0400
fix so "Partition Name" trait returns a non-null value for an EAP 5.0.x server running "production" config (https://bugzilla.redhat.com/show_bug.cgi?id=594520)
diff --git a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerComponent.java b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerComponent.java index e21153e..6b5dfa4 100644 --- a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerComponent.java +++ b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerComponent.java @@ -28,7 +28,6 @@ import java.io.Serializable; import java.net.URI; import java.net.URISyntaxException; import java.util.ArrayList; -import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -44,13 +43,10 @@ import org.jboss.deployers.spi.management.ManagementView; import org.jboss.deployers.spi.management.deploy.ProgressEvent; import org.jboss.deployers.spi.management.deploy.ProgressListener; import org.jboss.managed.api.ComponentType; -import org.jboss.managed.api.DeploymentTemplateInfo; import org.jboss.managed.api.ManagedComponent; -import org.jboss.managed.api.ManagedProperty; import org.jboss.metatype.api.values.SimpleValue; import org.jboss.on.common.jbossas.JBPMWorkflowManager; import org.jboss.on.common.jbossas.JBossASPaths; -import org.jboss.profileservice.spi.NoSuchDeploymentException;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -60,11 +56,7 @@ import org.mc4j.ems.connection.support.metadata.InternalVMTypeDescriptor; import org.rhq.core.domain.content.transfer.DeployPackagesResponse; import org.rhq.core.domain.content.transfer.RemovePackagesResponse; import org.rhq.core.domain.configuration.Configuration; -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.configuration.definition.ConfigurationTemplate; -import org.rhq.core.domain.configuration.definition.PropertyDefinition; import org.rhq.core.domain.content.PackageType; import org.rhq.core.domain.content.transfer.DeployPackageStep; import org.rhq.core.domain.content.transfer.ResourcePackageDetails; @@ -74,9 +66,6 @@ import org.rhq.core.domain.measurement.MeasurementDataNumeric; import org.rhq.core.domain.measurement.MeasurementDataTrait; import org.rhq.core.domain.measurement.MeasurementReport; import org.rhq.core.domain.measurement.MeasurementScheduleRequest; -import org.rhq.core.domain.resource.CreateResourceStatus; -import org.rhq.core.domain.resource.ResourceCreationDataType; -import org.rhq.core.domain.resource.ResourceType; import org.rhq.core.pluginapi.availability.AvailabilityCollectorRunnable; import org.rhq.core.pluginapi.availability.AvailabilityFacet; import org.rhq.core.pluginapi.configuration.ConfigurationFacet; @@ -93,23 +82,15 @@ import org.rhq.core.pluginapi.inventory.ResourceContext; import org.rhq.core.pluginapi.measurement.MeasurementFacet; import org.rhq.core.pluginapi.operation.OperationFacet; import org.rhq.core.pluginapi.operation.OperationResult; -import org.rhq.plugins.jbossas5.adapter.api.PropertyAdapter; -import org.rhq.plugins.jbossas5.adapter.api.PropertyAdapterFactory; import org.rhq.plugins.jbossas5.connection.LocalProfileServiceConnectionProvider; import org.rhq.plugins.jbossas5.connection.ProfileServiceConnection; import org.rhq.plugins.jbossas5.connection.ProfileServiceConnectionProvider; import org.rhq.plugins.jbossas5.connection.RemoteProfileServiceConnectionProvider; -import org.rhq.plugins.jbossas5.deploy.Deployer; -import org.rhq.plugins.jbossas5.deploy.LocalDeployer; -import org.rhq.plugins.jbossas5.deploy.RemoteDeployer; import org.rhq.plugins.jbossas5.helper.CreateChildResourceFacetDelegate; import org.rhq.plugins.jbossas5.helper.JBossAS5ConnectionTypeDescriptor; import org.rhq.plugins.jbossas5.helper.JmxConnectionHelper; import org.rhq.plugins.jbossas5.helper.InPluginControlActionFacade; -import org.rhq.plugins.jbossas5.util.ConversionUtils; -import org.rhq.plugins.jbossas5.util.DebugUtils; import org.rhq.plugins.jbossas5.util.ManagedComponentUtils; -import org.rhq.plugins.jbossas5.util.ResourceComponentUtils;
import com.jboss.jbossnetwork.product.jbpm.handlers.ControlActionFacade;
@@ -125,13 +106,16 @@ public class ApplicationServerComponent implements ResourceComponent, ProfileSer
private static final Pattern METRIC_NAME_PATTERN = Pattern.compile("(.*)\|(.*)\|(.*)\|(.*)");
- public static final Map<String, String> NEW_PROPERTY_NAMES = new HashMap<String, String>(); + private static final Map<String, String> ALTERNATE_METRIC_NAMES = new HashMap<String, String>(); static { - NEW_PROPERTY_NAMES.put("transactionCount", "numberOfTransactions"); - NEW_PROPERTY_NAMES.put("commitCount", "numberOfCommittedTransactions"); - NEW_PROPERTY_NAMES.put("rollbackCount", "numberOfApplicationRollbacks"); + ALTERNATE_METRIC_NAMES.put("MCBean|JTA|*|transactionCount", "MCBean|JTA|*|numberOfTransactions"); + ALTERNATE_METRIC_NAMES.put("MCBean|JTA|*|commitCount", "MCBean|JTA|*|numberOfCommittedTransactions"); + ALTERNATE_METRIC_NAMES.put("MCBean|JTA|*|rollbackCount", "MCBean|JTA|*|numberOfApplicationRollbacks"); + ALTERNATE_METRIC_NAMES.put("MCBean|ServerConfig|*|partitionName", "MCBean|HAPartition|*|partitionName"); }
+ private static final Map<String, String> VERIFIED_METRIC_NAMES = new HashMap<String, String>(); + private final Log log = LogFactory.getLog(this.getClass());
private ResourceContext resourceContext; @@ -244,59 +228,44 @@ public class ApplicationServerComponent implements ResourceComponent, ProfileSer public void getValues(MeasurementReport report, Set<MeasurementScheduleRequest> requests) { ManagementView managementView = getConnection().getManagementView(); for (MeasurementScheduleRequest request : requests) { - String metricName = request.getName(); + String requestName = request.getName(); + String verifiedMetricName = VERIFIED_METRIC_NAMES.get(requestName); + String metricName = (verifiedMetricName != null) ? verifiedMetricName : requestName; try { - // All other metric names are expected to have the following syntax: - // "<componentType>|<componentSubType>|<componentName>|<propertyName>" - Matcher matcher = METRIC_NAME_PATTERN.matcher(metricName); - if (!matcher.matches()) { - log.error("Metric name '" + metricName + "' does not match pattern '" + METRIC_NAME_PATTERN + "'."); - continue; - } - String componentCategory = matcher.group(1); - String componentSubType = matcher.group(2); - String componentName = matcher.group(3); - String propertyName = matcher.group(4); - ComponentType componentType = new ComponentType(componentCategory, componentSubType); - ManagedComponent component; - if (componentName.equals("*")) { - component = ManagedComponentUtils.getSingletonManagedComponent(managementView, componentType); - } else { - component = ManagedComponentUtils.getManagedComponent(managementView, componentType, componentName); - } - Serializable value = null; boolean foundProperty = false; try { - value = ManagedComponentUtils.getSimplePropertyValue(component, propertyName); + value = getMetric(managementView, metricName); foundProperty = true; } catch (ManagedComponentUtils.PropertyNotFoundException e) { - if (NEW_PROPERTY_NAMES.containsKey(propertyName)) { - String newPropertyName = NEW_PROPERTY_NAMES.get(propertyName); + // ignore + } + + if (value == null) { + metricName = ALTERNATE_METRIC_NAMES.get(metricName); + if (metricName != null) { try { - value = ManagedComponentUtils.getSimplePropertyValue(component, newPropertyName); + value = getMetric(managementView, metricName); foundProperty = true; - } catch (ManagedComponentUtils.PropertyNotFoundException e1) { + } catch (ManagedComponentUtils.PropertyNotFoundException e) { // ignore } } }
if (!foundProperty) { - if (NEW_PROPERTY_NAMES.containsKey(propertyName)) { - List<String> propertyNames = new ArrayList<String>(2); - propertyNames.add(propertyName); - propertyNames.add(NEW_PROPERTY_NAMES.get(propertyName)); - log.error("Property with one of the following names was not found for ManagedComponent [" - + component + "]: " + propertyNames); - } else { - log.error("Property '" + propertyName + "' was not found for ManagedComponent [" - + component + "]."); + List<String> propertyNames = new ArrayList<String>(2); + propertyNames.add(requestName); + if (ALTERNATE_METRIC_NAMES.containsKey(requestName)) { + propertyNames.add(ALTERNATE_METRIC_NAMES.get(requestName)); } - continue; + throw new IllegalStateException("A property was not found with any of the following names: " + + propertyNames); }
- if (value == null) { + if (value != null) { + VERIFIED_METRIC_NAMES.put(requestName, metricName); + } else { log.debug("Null value returned for metric '" + metricName + "'."); continue; } @@ -308,7 +277,7 @@ public class ApplicationServerComponent implements ResourceComponent, ProfileSer report.addData(new MeasurementDataTrait(request, value.toString())); } } catch (RuntimeException e) { - log.error("Failed to obtain metric '" + metricName + "'.", e); + log.error("Failed to obtain metric '" + requestName + "'.", e); } } } @@ -550,4 +519,28 @@ public class ApplicationServerComponent implements ResourceComponent, ProfileSer } return configPath; } + + private static Serializable getMetric(ManagementView managementView, String metricName) + throws ManagedComponentUtils.PropertyNotFoundException { + // All metric names are expected to have the following syntax: + // "<componentType>|<componentSubType>|<componentName>|<propertyName>" + Matcher matcher = METRIC_NAME_PATTERN.matcher(metricName); + if (!matcher.matches()) { + throw new IllegalStateException("Metric name '" + metricName + "' does not match pattern '" + + METRIC_NAME_PATTERN + "'."); + } + String componentCategory = matcher.group(1); + String componentSubType = matcher.group(2); + String componentName = matcher.group(3); + String propertyName = matcher.group(4); + ComponentType componentType = new ComponentType(componentCategory, componentSubType); + ManagedComponent component; + if (componentName.equals("*")) { + component = ManagedComponentUtils.getSingletonManagedComponent(managementView, componentType); + } else { + component = ManagedComponentUtils.getManagedComponent(managementView, componentType, componentName); + } + + return ManagedComponentUtils.getSimplePropertyValue(component, propertyName); + } } 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 b470905..ea8ff2d 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 @@ -1084,7 +1084,7 @@ <results><c:simple-property name="operationResult" description="Outcome of restarting the server."/></results> </operation>
- <metric displayName="Partition Name" property="MCBean|ServerConfig|*|partitionName" + <metric displayName="Cluster Partition Name" property="MCBean|ServerConfig|*|partitionName" dataType="trait" displayType="summary" description="the name of the cluster partition this server belongs to"/>
rhq-commits@lists.fedorahosted.org