modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java
| 26 +-
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementScheduleManagerBean.java
| 11 +
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceFactoryManagerRemote.java
| 58 -----
modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/deploy/ManagedComponentDeployer.java
| 105 +++++-----
modules/plugins/jboss-as-5/src/main/resources/META-INF/rhq-plugin.xml
| 2
5 files changed, 87 insertions(+), 115 deletions(-)
New commits:
commit 78ce51980e1fbb6ece062825c813722b46e4952c
Merge: fbc31a7 ec88d4b
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Mon Aug 1 08:42:38 2011 +0200
Merge branch 'master' into code-smell
commit ec88d4be0152d195ef769de97f43cdd289d77aeb
Merge: b38642e c4a82bc
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Mon Aug 1 08:41:55 2011 +0200
Merge branch 'code-smell' into master
commit fbc31a7aae1ffc7949789473bfe7a72c5777d862
Merge: b38642e c4a82bc
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Mon Aug 1 08:38:51 2011 +0200
Merge branch 'master' into code-smell
commit c4a82bca1620900e3bb2c7353ca5425a1ee4b354
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Fri Jul 29 17:20:11 2011 -0400
[BZ-726508 - Can't create alert condition on certain metrics]
Since metric def names may not be unique, they are duplicated
for the 'Per Minute' version of certain metrics, don't use them
for the value map keys in alert def drop downs.
- Also, some of these metric name lists are long, sort the
menu entries.
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java
index 2fd9400..44875d8 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NewConditionEditor.java
@@ -24,9 +24,11 @@
package org.rhq.enterprise.gui.coregui.client.alert.definitions;
import java.util.ArrayList;
+import java.util.Comparator;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.Set;
+import java.util.TreeSet;
import com.smartgwt.client.types.Alignment;
import com.smartgwt.client.widgets.form.DynamicForm;
@@ -572,7 +574,7 @@ public class NewConditionEditor extends LocatableDynamicForm {
LinkedHashMap<String, String> traitsMap = new LinkedHashMap<String,
String>();
for (MeasurementDefinition def : this.resourceType.getMetricDefinitions()) {
if (def.getDataType() == DataType.TRAIT) {
- traitsMap.put(def.getName(), def.getDisplayName());
+ traitsMap.put(String.valueOf(def.getId()), def.getDisplayName());
}
}
@@ -703,10 +705,21 @@ public class NewConditionEditor extends LocatableDynamicForm {
private SelectItem buildMetricDropDownMenu(String itemName, boolean dynamicOnly,
FormItemIfFunction ifFunc) {
LinkedHashMap<String, String> metricsMap = new LinkedHashMap<String,
String>();
- for (MeasurementDefinition def : this.resourceType.getMetricDefinitions()) {
+ TreeSet<MeasurementDefinition> sortedDefs = new
TreeSet<MeasurementDefinition>(
+ new Comparator<MeasurementDefinition>() {
+
+ @Override
+ public int compare(MeasurementDefinition o1, MeasurementDefinition o2) {
+ return o1.getDisplayName().compareTo(o2.getDisplayName());
+ }
+ });
+ sortedDefs.addAll(this.resourceType.getMetricDefinitions());
+
+ for (MeasurementDefinition def : sortedDefs) {
if (def.getDataType() == DataType.MEASUREMENT) {
if (!dynamicOnly || def.getNumericType() == NumericType.DYNAMIC) {
- metricsMap.put(def.getName(), def.getDisplayName());
+ // use id as opposed to name for key, the name is not unique when
per-minute metric is also used
+ metricsMap.put(String.valueOf(def.getId()), def.getDisplayName());
}
}
}
@@ -726,7 +739,7 @@ public class NewConditionEditor extends LocatableDynamicForm {
LinkedHashMap<String, String> metricsMap = new LinkedHashMap<String,
String>();
for (MeasurementDefinition def : this.resourceType.getMetricDefinitions()) {
if (def.getDataType() == DataType.CALLTIME) {
- metricsMap.put(def.getName(), def.getDisplayName());
+ metricsMap.put(String.valueOf(def.getId()), def.getDisplayName());
}
}
@@ -790,9 +803,10 @@ public class NewConditionEditor extends LocatableDynamicForm {
return help;
}
- private MeasurementDefinition getMeasurementDefinition(String metricName) {
+ private MeasurementDefinition getMeasurementDefinition(String metricId) {
+ int id = Integer.valueOf(metricId).intValue();
for (MeasurementDefinition def : this.resourceType.getMetricDefinitions()) {
- if (metricName.equals(def.getName())) {
+ if (id == def.getId()) {
return def;
}
}
commit e431028f07369d98a0ffc72c883a8be1c4ab39f6
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Fri Jul 29 15:03:54 2011 -0400
[BZ 710230] improve description of testConnection operation on
datasources/connFactories (
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 21161fe..bbe70ea 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?"/>
commit e4e340d418889e7a8972c421fe002a84ff2aa187
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Fri Jul 29 13:28:33 2011 -0400
[BZ-726714 - Metric template creation generates NPE (null pointer exception)]
Fix a problem when trying to apply a metric template to a resource in a
"hidden" state like UNINVENTORIED.
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementScheduleManagerBean.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementScheduleManagerBean.java
index 98110ac..03cd4bb 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementScheduleManagerBean.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementScheduleManagerBean.java
@@ -498,6 +498,17 @@ public class MeasurementScheduleManagerBean implements
MeasurementScheduleManage
for (Integer resourceId : reqMap.keySet()) {
Agent agent =
agentManager.getAgentByResourceId(subjectManager.getOverlord(), resourceId);
+ // Ignore resources that are not actually associated with an agent.
For example,
+ // those with an UNINVENTORIED status.
+ if (null == agent) {
+ if (log.isDebugEnabled()) {
+ log.debug("Ignoring measurement schedule change for
non-agent-related resource ["
+ + resourceId + "]. It is probably waiting to be
uninventoried.");
+ }
+
+ continue;
+ }
+
Set<ResourceMeasurementScheduleRequest> agentUpdate =
agentUpdates.get(agent);
if (agentUpdate == null) {
agentUpdate = new
HashSet<ResourceMeasurementScheduleRequest>();
commit 397cb79ad080285aadb93a9257318d4c1ee2c9b6
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Fri Jul 29 12:51:50 2011 -0400
some general cleanup/refactoring + improved error handling
diff --git
a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/deploy/ManagedComponentDeployer.java
b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/deploy/ManagedComponentDeployer.java
index 6314d3a..4315155 100644
---
a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/deploy/ManagedComponentDeployer.java
+++
b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/deploy/ManagedComponentDeployer.java
@@ -16,7 +16,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-
package org.rhq.plugins.jbossas5.deploy;
import java.io.File;
@@ -60,14 +59,10 @@ public class ManagedComponentDeployer implements Deployer {
private static final ProfileKey FARM_PROFILE_KEY = new ProfileKey("farm");
private static final ProfileKey APPLICATIONS_PROFILE_KEY = new
ProfileKey("applications");
- public static final String DEPLOYMENT_NAME_PROPERTY = "deploymentName";
private PackageDownloader downloader;
private ProfileServiceConnection profileServiceConnection;
- /**
- * @param downloader
- */
public ManagedComponentDeployer(ProfileServiceConnection profileServiceConnection,
PackageDownloader downloader) {
this.downloader = downloader;
this.profileServiceConnection = profileServiceConnection;
@@ -120,9 +115,9 @@ public class ManagedComponentDeployer implements Deployer {
deploymentManager.loadProfile(FARM_PROFILE_KEY);
}
- String[] deployedArchives;
+ String[] deploymentNames;
try {
- deployedArchives = DeploymentUtils.deployArchive(deploymentManager,
archiveFile, deployExploded);
+ deploymentNames = DeploymentUtils.deployArchive(deploymentManager,
archiveFile, deployExploded);
} finally {
// Make sure to switch back to the 'applications' profile if we
switched to the 'farm' profile above.
if (deployFarmed) {
@@ -130,62 +125,72 @@ public class ManagedComponentDeployer implements Deployer {
}
}
- //if deployed exploded, we need to store the sha of source package for
correct versioning
+ if (deploymentNames == null || deploymentNames.length != 1) {
+ throw new RuntimeException("deploy operation returned invalid
result: " + deploymentNames);
+ }
+
+ // e.g.: vfszip:/C:/opt/jboss-6.0.0.Final/server/default/deploy/foo.war
+ String deploymentName = deploymentNames[0];
+
+ // If deployed exploded, we need to store the SHA of source package in
META-INF/MANIFEST.MF for correct
+ // versioning.
if (deployExploded) {
- for (String archive : deployedArchives) {
-
- String shaString = new
MessageDigestGenerator(MessageDigestGenerator.SHA_256)
- .getDigestString(archiveFile);
-
- URI deployePackageURI = URI.create(archive);
- // e.g.: foo.war
- String path = deployePackageURI.getPath();
- File location = new File(path);
- //We've located the deployed
- if ((location != null) && (location.isDirectory())) {
- File manifestFile = new File(location,
"META-INF/MANIFEST.MF");
- Manifest manifest;
- if (manifestFile.exists()) {
- FileInputStream inputStream = new
FileInputStream(manifestFile);
- manifest = new Manifest(inputStream);
- inputStream.close();
- } else {
- File metaInf = new File(location, "META-INF");
- if (!metaInf.exists())
- if (!metaInf.mkdir())
- throw new Exception("Could not create directory
" + location + "META-INF.");
-
- manifestFile = new File(metaInf, "MANIFEST.MF");
- manifest = new Manifest();
- }
- Attributes attribs = manifest.getMainAttributes();
- attribs.putValue("RHQ-Sha256", shaString);
- FileOutputStream outputStream = new
FileOutputStream(manifestFile);
- manifest.write(outputStream);
- outputStream.close();
+ MessageDigestGenerator sha256Generator = new
MessageDigestGenerator(MessageDigestGenerator.SHA_256);
+ String shaString = sha256Generator.calcDigestString(archiveFile);
+ URI deploymentURI = URI.create(deploymentName);
+ // e.g.: /C:/opt/jboss-6.0.0.Final/server/default/deploy/foo.war
+ String deploymentPath = deploymentURI.getPath();
+ File deploymentFile = new File(deploymentPath);
+ if (deploymentFile.isDirectory()) {
+ File manifestFile = new File(deploymentFile,
"META-INF/MANIFEST.MF");
+ Manifest manifest;
+ if (manifestFile.exists()) {
+ FileInputStream inputStream = new FileInputStream(manifestFile);
+ manifest = new Manifest(inputStream);
+ inputStream.close();
+ } else {
+ File metaInf = new File(deploymentFile, "META-INF");
+ if (!metaInf.exists())
+ if (!metaInf.mkdir())
+ throw new Exception("Could not create directory
" + deploymentFile + "META-INF.");
+
+ manifestFile = new File(metaInf, "MANIFEST.MF");
+ manifest = new Manifest();
}
+ Attributes attribs = manifest.getMainAttributes();
+ attribs.putValue("RHQ-Sha256", shaString);
+ FileOutputStream outputStream = new FileOutputStream(manifestFile);
+ manifest.write(outputStream);
+ outputStream.close();
+ } else {
+ LOG.error("Exploded deployment '" + deploymentFile
+ + "' does not exist or is not a directory - unable
to add RHQ versioning metadata to META-INF/MANIFEST.MF.");
}
}
+ // Reload the management view to pickup the ManagedDeployment for the app we
just deployed.
ManagementView managementView =
this.profileServiceConnection.getManagementView();
managementView.load();
- for (String deployedArchive : deployedArchives) {
- ManagedDeployment managedDeployment;
- try {
- managedDeployment = managementView.getDeployment(deployedArchive);
- } catch (NoSuchDeploymentException e) {
- LOG.error("Failed to find managed deployment '" +
deployedArchive + "' after deploying '"
- + archiveName + "'.");
- continue;
- }
+
+ ManagedDeployment managedDeployment = null;
+ try {
+ managedDeployment = managementView.getDeployment(deploymentName);
+ } catch (NoSuchDeploymentException e) {
+ LOG.error("Failed to find managed deployment '" +
deploymentName + "' after deploying '"
+ + archiveName + "', so cannot start the
application.");
+ createResourceReport.setStatus(CreateResourceStatus.INVALID_ARTIFACT);
+ createResourceReport.setErrorMessage("Unable to start application
'" + deploymentName
+ + "' after deploying it, since lookup of the associated
ManagedDeployment failed.");
+ }
+ if (managedDeployment != null) {
DeploymentState state = managedDeployment.getDeploymentState();
if (state != DeploymentState.STARTED) {
// The app failed to start - do not consider this a FAILURE, since it
was at least deployed
// successfully. However, set the status to INVALID_ARTIFACT and set
an error message, so
// the user is informed of the condition.
createResourceReport.setStatus(CreateResourceStatus.INVALID_ARTIFACT);
- createResourceReport.setErrorMessage("Failed to start
application '" + deployedArchive + "' after deploying it.");
- break;
+ createResourceReport.setErrorMessage("Failed to start
application '" + deploymentName
+ + "' after deploying it.");
}
}
commit ff1fc54e0d3c744c5a66172d375eb44dca31e631
Author: Simeon Pinder <simeonpinder(a)gmail.com>
Date: Fri Jul 29 09:03:56 2011 -0400
BZ:726502,717526: removing deprecated content from the remote interface as duplicate
but deprecated names causes non-unique message signatures which creates invalid wsdl.
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceFactoryManagerRemote.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceFactoryManagerRemote.java
index 0883859..d92883f 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceFactoryManagerRemote.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceFactoryManagerRemote.java
@@ -47,64 +47,6 @@ import org.rhq.enterprise.server.system.ServerVersion;
public interface ResourceFactoryManagerRemote {
/**
- * @Deprecated
- *
- * Use new signature with timeout parameter:
- * @{link {@link #createPackageBackedResource(Subject, int, int, String,
Configuration, String, String, Integer, Configuration, byte[], Integer)}
- */
- @WebMethod
- CreateResourceHistory createResource( //
- @WebParam(name = "subject") Subject subject, //
- @WebParam(name = "parentResourceId") int parentResourceId, //
- @WebParam(name = "resourceTypeId") int resourceTypeId, //
- @WebParam(name = "resourceName") String resourceName, //
- @WebParam(name = "pluginConfiguration") Configuration
pluginConfiguration, //
- @WebParam(name = "resourceConfiguration") Configuration
resourceConfiguration);
-
- /**
- * @Deprecated
- *
- * Use new signature with timeout parameter:
- * @{link {@link #createPackageBackedResource(Subject, int, int, String,
Configuration, String, String, Integer, Configuration, byte[], Integer)}
- */
- @WebMethod
- CreateResourceHistory createPackageBackedResource(//
- @WebParam(name = "subject") Subject subject, //
- @WebParam(name = "parentResourceId") int parentResourceId, //
- @WebParam(name = "newResourceTypeId") int newResourceTypeId, //
- @WebParam(name = "newResourceName") String newResourceName, //
- @WebParam(name = "pluginConfiguration")//
- @XmlJavaTypeAdapter(value = ConfigurationAdapter.class)//
- Configuration pluginConfiguration, //
- @WebParam(name = "packageName") String packageName, //
- @WebParam(name = "packageVersion") String packageVersion, //
- @WebParam(name = "architectureId") Integer architectureId, //
- @WebParam(name = "deploymentTimeConfiguration")//
- @XmlJavaTypeAdapter(value = ConfigurationAdapter.class)//
- Configuration deploymentTimeConfiguration, //
- @WebParam(name = "packageBits") byte[] packageBits);
-
- /**
- * @Deprecated
- *
- * Use new signature with timeout parameter:
- * @{link {@link #createPackageBackedResourceViaPackageVersion(Subject, int, int,
String, Configuration, Configuration, int, Integer)
- */
- @WebMethod
- public CreateResourceHistory createPackageBackedResourceViaPackageVersion(//
- @WebParam(name = "subject") Subject subject, //
- @WebParam(name = "parentResourceId") int parentResourceId, //
- @WebParam(name = "newResourceTypeId") int newResourceTypeId, //
- @WebParam(name = "newResourceName") String newResourceName, //
- @WebParam(name = "pluginConfiguration")//
- @XmlJavaTypeAdapter(value = ConfigurationAdapter.class)//
- Configuration pluginConfiguration, //
- @WebParam(name = "deploymentTimeConfiguration")//
- @XmlJavaTypeAdapter(value = ConfigurationAdapter.class)//
- Configuration deploymentTimeConfiguration, //
- @WebParam(name = "packageVersionId") int packageVersionId);
-
- /**
* Creates a new physical resource. The resource will be created as a child of the
specified parent. In other words,
* the resource component of the indicated parent will be used to create the new
resource. This call should only be
* made for resource types that are defined with a create/delete policy of {@link
CreateDeletePolicy#BOTH} or