[rhq] Branch 'nonplatform-bundles-644328' - 5 commits - modules/core modules/plugins pom.xml
by mazz
modules/core/plugin-container/src/main/java/org/rhq/core/pc/upgrade/ResourceUpgradeDelegate.java | 113 +++++++---
modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceDiscoveryComponent.java | 6
modules/plugins/apache/src/main/java/org/rhq/plugins/apache/util/VirtualHostLegacyResourceKeyUtil.java | 48 ++--
modules/plugins/apache/src/main/resources/META-INF/rhq-plugin.xml | 10
pom.xml | 2
5 files changed, 118 insertions(+), 61 deletions(-)
New commits:
commit a75d63257ea4c4212e66c6a18f1c69286a75e895
Merge: 2ec2511 b166bce
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Jun 16 14:32:56 2011 -0400
Merge commit 'origin/master' into nonplatform-bundles-644328
commit b166bce2bb8319661e3f169edc73f7644bc89600
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Thu Jun 16 19:32:38 2011 +0200
Improving the apache vhost upgrade process. Now we can successfully upgrade resoures from RHQ 1.x even if RHQ 3 would get them wrong.
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceDiscoveryComponent.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceDiscoveryComponent.java
index d6a36fb..28f68da 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceDiscoveryComponent.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceDiscoveryComponent.java
@@ -191,7 +191,7 @@ public class ApacheVirtualHostServiceDiscoveryComponent implements ResourceDisco
//yay, we can use the snmpService index to determine which vhost we're dealing with
if (snmpServiceIndex == 1) {
//k, looks the vhost was representing the main server. Let's do a cross-check.
- List<String> legacyResourceKeys = legacyResourceKeyUtil.getLegacyMainServerResourceKeys();
+ Set<String> legacyResourceKeys = legacyResourceKeyUtil.getLegacyMainServerResourceKeys();
if (legacyResourceKeys.contains(resourceKey)) {
newResourceKey = ApacheVirtualHostServiceComponent.MAIN_SERVER_RESOURCE_KEY;
} else {
@@ -214,7 +214,7 @@ public class ApacheVirtualHostServiceDiscoveryComponent implements ResourceDisco
//right, let's do a cross-check before we actually create the resource key so
//that we catch user-generated errors.
- List<String> legacyResourceKeys = legacyResourceKeyUtil.getLegacyVirtualHostResourceKeys(vhost);
+ Set<String> legacyResourceKeys = legacyResourceKeyUtil.getLegacyVirtualHostResourceKeys(vhost);
if (legacyResourceKeys.contains(resourceKey)) {
newResourceKey = createResourceKey(vhost.serverName, vhost.hosts);
} else {
@@ -240,7 +240,7 @@ public class ApacheVirtualHostServiceDiscoveryComponent implements ResourceDisco
Map<String, Set<VHostSpec>> possibleMatchesPerRK = new HashMap<String, Set<VHostSpec>>();
for (VHostSpec vhost : vhosts) {
- List<String> legacyResourceKeys = legacyResourceKeyUtil.getLegacyVirtualHostResourceKeys(vhost);
+ Set<String> legacyResourceKeys = legacyResourceKeyUtil.getLegacyVirtualHostResourceKeys(vhost);
for(String legacyRK : legacyResourceKeys) {
addPossibleRKMatch(legacyRK, vhost, possibleMatchesPerRK);
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/util/VirtualHostLegacyResourceKeyUtil.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/util/VirtualHostLegacyResourceKeyUtil.java
index 6c8436e..c1f98aa 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/util/VirtualHostLegacyResourceKeyUtil.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/util/VirtualHostLegacyResourceKeyUtil.java
@@ -25,7 +25,9 @@ import java.net.URISyntaxException;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.HashSet;
import java.util.List;
+import java.util.Set;
import org.rhq.plugins.apache.ApacheServerComponent;
import org.rhq.plugins.apache.ApacheVirtualHostServiceComponent;
@@ -64,15 +66,11 @@ public class VirtualHostLegacyResourceKeyUtil {
* This uses the algoritms used in the RHQ 3 codebase and returns both the resource key
* that would be generated wihout SNMP support and with it.
* <p>
- * The returned list contains either 1 or 2 elements. The first element is always the resource
- * key as it would be generated without SNMP support. The second element is the resource key as
- * it would be derived from the SNMP record. If the legacy algorithm wouldn't be able to
- * deduce the resource key from SNMP (which could happen), the second element wouldn't be present
- * in the resulting list.
- * .
+ * The returned set also contains the resource key as it would be found by RHQ 1.x
+ *
* @return possible resource keys of the main server.
*/
- public List<String> getLegacyMainServerResourceKeys() {
+ public Set<String> getLegacyMainServerResourceKeys() {
String mainServerUrl = serverComponent.getServerUrl();
String key = null;
@@ -94,29 +92,32 @@ public class VirtualHostLegacyResourceKeyUtil {
key = ApacheVirtualHostServiceComponent.MAIN_SERVER_RESOURCE_KEY;
}
+ Set<String> ret = new HashSet<String>();
+
+ ret.add(key);
+
String snmpKey = getSNMPResourceKey(key);
- String[] ret = new String[snmpKey == null ? 1 : 2];
-
- ret[0] = key;
if (snmpKey != null) {
- ret[1] = snmpKey;
+ ret.add(snmpKey);
}
+
+ ret.add(addressUtility.getHttpdInternalMainServerAddressRepresentation(runtimeConfig).toString(false, false));
- return Arrays.asList(ret);
+ return ret;
}
/**
* Returns a list of possible resource keys that the RHQ 3 code could generate for the specified
* vhost.
* <p>
- * As with {@link #getLegacyMainServerResourceKeys()} the resulting list will contain either 1 or
- * 2 elements depending on the ability of the legacy algorithm to deduce the resource key from SNMP.
+ * As with {@link #getLegacyMainServerResourceKeys()} the resulting set will contain all the various
+ * resource keys that could have been found by past versions of the plugin.
*
* @param vhost
* @return the possible vhosts
*/
- public List<String> getLegacyVirtualHostResourceKeys(VHostSpec vhost) {
+ public Set<String> getLegacyVirtualHostResourceKeys(VHostSpec vhost) {
String host = vhost.hosts.get(0);
HttpdAddressUtility.Address hostAddr = HttpdAddressUtility.Address.parse(host);
if (vhost.serverName != null) {
@@ -133,16 +134,19 @@ public class VirtualHostLegacyResourceKeyUtil {
String key = hostAddr.host + ":" + hostAddr.port;
- String snmpKey = getSNMPResourceKey(key);
-
- String[] ret = new String[snmpKey == null ? 1 : 2];
- ret[0] = key;
+ Set<String> ret = new HashSet<String>();
+
+ ret.add(key);
+ String snmpKey = getSNMPResourceKey(key);
if (snmpKey != null) {
- ret[1] = snmpKey;
+ ret.add(snmpKey);
}
-
- return Arrays.asList(ret);
+
+ String snmpKeyFromRhq1 = addressUtility.getHttpdInternalVirtualHostAddressRepresentation(runtimeConfig, vhost.hosts.get(0), vhost.serverName).toString(false, false);
+ ret.add(snmpKeyFromRhq1);
+
+ return ret;
}
private String getSNMPResourceKey(String nonSnmpResourceKey) {
commit c6ebdb696373e10dcfa7ed28eed0e7547efaa615
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Thu Jun 16 19:31:13 2011 +0200
BZ 711135 - define defaults to all required properties in the apache plugin configuration so that upgrade of the plugin on the server succeeds.
diff --git a/modules/plugins/apache/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/apache/src/main/resources/META-INF/rhq-plugin.xml
index f3cf33f..ad08a22 100644
--- a/modules/plugins/apache/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/apache/src/main/resources/META-INF/rhq-plugin.xml
@@ -84,7 +84,7 @@
</c:list-property>
'>
<!ENTITY DocumentRoot '
- <c:simple-property name="DocumentRoot">
+ <c:simple-property name="DocumentRoot" default="THIS IS AUTO-DISCOVERED">
<c:description>
This directive sets the directory from which httpd will serve files. Unless matched by a directive like Alias, the server appends the path from the requested URL to the document root to make the path to the document.
If the directory-path is not absolute then it is assumed to be relative to the ServerRoot.
@@ -264,14 +264,14 @@
activationPolicy: immediate
-->
<c:simple-property name="serverRoot" required="true"
- description="the absolute path of the Apache server root directory"/>
+ description="the absolute path of the Apache server root directory" default="THIS SHOULD BE AUTO-DISCOVERED"/>
<c:simple-property name="executablePath" required="false"
description="the path to the Apache executable - if the path is not absolute, it will be resolved relative to the server root directory; if unset, default value is 'bin/httpd' on UNIX or 'bin\Apache.exe' on Windows"/>
<c:simple-property name="controlScriptPath" required="false"
description="the path to the Apache control script - if the path is not absolute, it will be resolved relative to the server root directory; if unset, default will be 'bin/apachectl' on UNIX or the Apache executable on Windows"/>
<!-- TODO need to add a comment about the file location on Win* -->
<c:simple-property name="configFile" required="true" readOnly="true"
- description="the path to the httpd.conf file - if the path is not absolute, it will be resolved relative to the server root directory; if unset, default will be 'conf/httpd.conf' on UNIX"/>
+ description="the path to the httpd.conf file - if the path is not absolute, it will be resolved relative to the server root directory; if unset, default will be 'conf/httpd.conf' on UNIX" default="THIS SHOULD BE AUTO-DISCOVERED"/>
<c:simple-property name="url" displayName="URL" required="false"
description="The http or https URL that will be used to check availability for this Apache
server; if not set, availablity will be determined based on whether plugin can connect
@@ -320,7 +320,7 @@
</c:property-options>
</c:simple-property>
- <c:simple-property name="vhostFilesMask" displayName="Path To Contain Virtual Hosts Files">
+ <c:simple-property name="vhostFilesMask" displayName="Path To Contain Virtual Hosts Files" default="conf.d/*.conf">
<c:description>
If the new virtual hosts should be created in standalone files, this mask determines where
to create those files. The '*' in the path is replaced by the name of the virtual host.
@@ -718,7 +718,7 @@
<service name="Directory" class="ApacheDirectoryComponent" discovery="ApacheDirectoryDiscoveryComponent" createDeletePolicy="both">
<plugin-configuration>
- <c:simple-property name="directiveIndex" readOnly="true" required="true" type="integer"/>
+ <c:simple-property name="directiveIndex" readOnly="true" required="true" type="integer" default="-1"/>
<c:simple-property name="regexp" displayName="Regular Expression" type="boolean" default="false" readOnly="true"
description="Does the name of this directory denote a regular expression?"/>
</plugin-configuration>
commit ab97d23a233552d206f198f71bcdd711618a7bb0
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Thu Jun 16 19:26:15 2011 +0200
BZ 712429 - giving out more useful error message in case of resource key conflict during the resource upgrade.
The error message now contains the details of the resources given resource conflicts with so that the user can easily locate them.
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/upgrade/ResourceUpgradeDelegate.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/upgrade/ResourceUpgradeDelegate.java
index cee582e..915c8e0 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/upgrade/ResourceUpgradeDelegate.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/upgrade/ResourceUpgradeDelegate.java
@@ -19,6 +19,7 @@
package org.rhq.core.pc.upgrade;
+import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
@@ -59,7 +60,7 @@ public class ResourceUpgradeDelegate {
private boolean enabled = true;
private Set<ResourceUpgradeRequest> requests = new HashSet<ResourceUpgradeRequest>();
- private Set<ResourceUpgradeRequest> originalResourceData = new HashSet<ResourceUpgradeRequest>();
+ private Set<ResourceUpgradeRequest> originalResourceData = new HashSet<ResourceUpgradeRequest>();
private InventoryManager inventoryManager;
private Set<Resource> failedResources = new HashSet<Resource>();
private Map<Resource, Set<ResourceType>> failedResourceTypesPerParent = new HashMap<Resource, Set<ResourceType>>();
@@ -154,19 +155,21 @@ public class ResourceUpgradeDelegate {
if ((upgradeErrors = checkUpgradeValid(resource, request)) != null) {
//the resource is in its upgraded state but it's going to get reverted back to the original state
//in the code below. Let's use the original resource for the error message so that we don't confuse
- //the user.
- for(ResourceUpgradeRequest orig : originalResourceData) {
- if (orig.equals(request)) {
- orig.updateResource(resource);
- break;
- }
+ //the user.
+ ResourceUpgradeRequest orig = findOriginal(request);
+
+ //orig should never be null, but let's be paranoid
+ if (orig != null) {
+ orig.updateResource(resource);
}
- String errorString = "Upgrading the resource [" + resource + "] using these updates [" + request
- + "] would render the inventory invalid because of the following reasons: " + upgradeErrors;
+
+ String errorString = "Upgrading the resource [" + resource + "] using these updates ["
+ + request + "] would render the inventory invalid because of the following reasons: "
+ + upgradeErrors;
//now switch the resource back to the upgraded state for the rest of the code below again
request.updateResource(resource);
-
+
log.error(errorString);
IllegalStateException ex = new IllegalStateException(errorString);
@@ -176,7 +179,7 @@ public class ResourceUpgradeDelegate {
//to the server and locally roll back to the previous state.
request.setErrorProperties(ex);
request.clearUpgradeData();
-
+
if (request.getUpgradeErrorMessage() != null) {
rememberFailure(resource);
inventoryManager.deactivateResource(resource);
@@ -185,7 +188,7 @@ public class ResourceUpgradeDelegate {
}
}
}
-
+
//now before we talk to server and sync up the upgraded data,
//reset the resources to their original values so that any changes
//the server makes to the upgrade data are applied to the "vanilla" state
@@ -197,12 +200,12 @@ public class ResourceUpgradeDelegate {
request.updateResource(resource);
}
}
-
+
//merge the resources with the data as received from the server
//(this can differ from what the upgrade "wants" because the server is
//free to disallow some changes, e.g. resource name change)
inventoryManager.mergeResourcesFromUpgrade(requests);
-
+
//and now restart all the "touched" resources with the true intended
//data
for (ResourceUpgradeRequest request : requests) {
@@ -235,16 +238,17 @@ public class ResourceUpgradeDelegate {
ResourceComponent<T> parentResourceComponent = resourceContainer.getResourceContext()
.getParentResourceComponent();
-
+
Resource parentResource = resourceContainer.getResource().getParentResource();
ResourceContainer parentResourceContainer = (parentResource != null) ? inventoryManager
.getResourceContainer(resourceContainer.getResource().getParentResource()) : null;
- ResourceContext<?> parentResourceContext = parentResourceContainer == null ? null : parentResourceContainer.getResourceContext();
-
+ ResourceContext<?> parentResourceContext = parentResourceContainer == null ? null : parentResourceContainer
+ .getResourceContext();
+
Resource resource = resourceContainer.getResource();
-
+
ResourceDiscoveryComponent<ResourceComponent<T>> discoveryComponent = PluginContainer.getInstance()
.getPluginComponentFactory().getDiscoveryComponent(resource.getResourceType(), parentResourceContainer);
@@ -281,41 +285,80 @@ public class ResourceUpgradeDelegate {
rememberFailure(resource);
return false;
}
-
+
//alright, everything went fine with the upgrade. Let's update the data of the resource
//right now so that it starts up as if it was already upgraded. This is to ensure that
//its children will use a parent component that behaves like the upgraded one.
//We are going to roll back the upgraded data if the upgrade fails to sync with the server
//later on.
-
+
//remember the original values
ResourceUpgradeRequest original = new ResourceUpgradeRequest(resource.getId());
original.fillInFromResource(resource);
originalResourceData.add(original);
-
+
//update the resource
request.updateResource(resource);
-
+
return true;
}
private String checkUpgradeValid(Resource resource, ResourceUpgradeReport upgradeReport) {
StringBuilder s = new StringBuilder();
- if (!checkResourceKeyUniqueAmongSiblings(resource, upgradeReport)) {
- s.append("\nAnother inventoried sibling resource of the same type already has the proposed resource key or would have it after the upgrade.");
+ Set<Resource> duplicitSiblings = findDuplicitSiblingResources(resource, upgradeReport);
+ if (!duplicitSiblings.isEmpty()) {
+ s.append("After the upgrade, the following resources would have the same resource key which is illegal. This is an issue of either the old or the new version of the plugin '"
+ + resource.getResourceType().getPlugin()
+ + "'. Please consult the documentation of the plugin to see what are the recommended steps to resolve this situation:\n");
+
+ //ok, this is a little tricky
+ //this method is called when the inventory is in the state as it would look after a
+ //successful upgrade.
+ //but just now, we found out that the upgrade won't succeed because we found some
+ //conflicting resources. These resources won't be upgraded but right now, we see
+ //them as if they were.
+ //For each resource, we therefore need to find the corresponding "original" and report
+ //that instead of how the resource looks like right now.
+ for (Resource r : duplicitSiblings) {
+ ResourceUpgradeRequest fakeRequest = new ResourceUpgradeRequest(r.getId());
+ fakeRequest.fillInFromResource(r);
+
+ ResourceUpgradeRequest orig = findOriginal(fakeRequest);
+
+ //we might not find the original, because this resource might not need an upgrade.
+ //in that case, the reporting will be accurate because upgrade didn't touch the resource.
+ if (orig != null) {
+ orig.updateResource(r);
+ }
+
+ //now we have the resource as it looked before the upgrade kicked in (which is in this
+ //case also what it will look like after the upgrade finishes, because we're failing it).
+ s.append(r).append(",\n");
+
+ //and revert the resource back to what it looked like (i.e. back to the upgraded state so
+ //that we don't introduce side-effects in this method).
+ if (orig != null) {
+ fakeRequest.updateResource(r);
+ }
+ }
+
+ //remove the trailing ",\n"
+ s.replace(s.length() - 2, s.length(), "");
}
return s.length() > 0 ? s.toString() : null;
}
- private boolean checkResourceKeyUniqueAmongSiblings(Resource resource, ResourceUpgradeReport upgradeReport) {
+ private Set<Resource> findDuplicitSiblingResources(Resource resource, ResourceUpgradeReport upgradeReport) {
Resource parent = resource.getParentResource();
if (parent == null) {
//there is only a single platform resource on an agent
- return true;
+ return Collections.emptySet();
}
+ Set<Resource> ret = new HashSet<Resource>();
+
for (Resource sibling : parent.getChildResources()) {
//we'd have a resource key conflict if there was a resource
//of the same type under the same parent that would have the same
@@ -325,18 +368,18 @@ public class ResourceUpgradeDelegate {
&& !sibling.getUuid().equals(resource.getUuid())) {
if (sibling.getResourceKey().equals(upgradeReport.getNewResourceKey())) {
- return false;
+ ret.add(sibling);
}
}
}
- return true;
+ return ret;
}
-
+
private void rememberFailure(Resource resource) {
failedResources.add(resource);
Resource parentResource = resource.getParentResource();
-
+
Set<ResourceType> failedResourceTypesInParent = failedResourceTypesPerParent.get(parentResource);
if (failedResourceTypesInParent == null) {
failedResourceTypesInParent = new HashSet<ResourceType>();
@@ -345,4 +388,14 @@ public class ResourceUpgradeDelegate {
failedResourceTypesInParent.add(resource.getResourceType());
}
+
+ private ResourceUpgradeRequest findOriginal(ResourceUpgradeRequest request) {
+ for(ResourceUpgradeRequest original : originalResourceData) {
+ if (original.equals(request)) {
+ return original;
+ }
+ }
+
+ return null;
+ }
}
commit 969095fc111bff5690a3102f506eedb0beaced98
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Thu Jun 16 11:25:27 2011 -0400
downgrade JNA from 3.2.5 to 3.2.3, since 3.2.3 is the latest version available
in the central repo
diff --git a/pom.xml b/pom.xml
index b7f249e..c47cd49 100644
--- a/pom.xml
+++ b/pom.xml
@@ -94,7 +94,7 @@
<sigar.version>1.6.5.132</sigar.version>
<sigar.zip.version>1.6.5</sigar.zip.version>
<quartz.version>1.6.5</quartz.version>
- <jna.version>3.2.5</jna.version>
+ <jna.version>3.2.3</jna.version>
<twitter4j.version>2.1.2</twitter4j.version>
<commons-codec.version>1.4</commons-codec.version>
<testng.version>5.13.1</testng.version>
12 years, 11 months
[rhq] 3 commits - modules/core modules/plugins
by lkrejci
modules/core/plugin-container/src/main/java/org/rhq/core/pc/upgrade/ResourceUpgradeDelegate.java | 113 +++++++---
modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceDiscoveryComponent.java | 6
modules/plugins/apache/src/main/java/org/rhq/plugins/apache/util/VirtualHostLegacyResourceKeyUtil.java | 48 ++--
modules/plugins/apache/src/main/resources/META-INF/rhq-plugin.xml | 10
4 files changed, 117 insertions(+), 60 deletions(-)
New commits:
commit b166bce2bb8319661e3f169edc73f7644bc89600
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Thu Jun 16 19:32:38 2011 +0200
Improving the apache vhost upgrade process. Now we can successfully upgrade resoures from RHQ 1.x even if RHQ 3 would get them wrong.
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceDiscoveryComponent.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceDiscoveryComponent.java
index d6a36fb..28f68da 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceDiscoveryComponent.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceDiscoveryComponent.java
@@ -191,7 +191,7 @@ public class ApacheVirtualHostServiceDiscoveryComponent implements ResourceDisco
//yay, we can use the snmpService index to determine which vhost we're dealing with
if (snmpServiceIndex == 1) {
//k, looks the vhost was representing the main server. Let's do a cross-check.
- List<String> legacyResourceKeys = legacyResourceKeyUtil.getLegacyMainServerResourceKeys();
+ Set<String> legacyResourceKeys = legacyResourceKeyUtil.getLegacyMainServerResourceKeys();
if (legacyResourceKeys.contains(resourceKey)) {
newResourceKey = ApacheVirtualHostServiceComponent.MAIN_SERVER_RESOURCE_KEY;
} else {
@@ -214,7 +214,7 @@ public class ApacheVirtualHostServiceDiscoveryComponent implements ResourceDisco
//right, let's do a cross-check before we actually create the resource key so
//that we catch user-generated errors.
- List<String> legacyResourceKeys = legacyResourceKeyUtil.getLegacyVirtualHostResourceKeys(vhost);
+ Set<String> legacyResourceKeys = legacyResourceKeyUtil.getLegacyVirtualHostResourceKeys(vhost);
if (legacyResourceKeys.contains(resourceKey)) {
newResourceKey = createResourceKey(vhost.serverName, vhost.hosts);
} else {
@@ -240,7 +240,7 @@ public class ApacheVirtualHostServiceDiscoveryComponent implements ResourceDisco
Map<String, Set<VHostSpec>> possibleMatchesPerRK = new HashMap<String, Set<VHostSpec>>();
for (VHostSpec vhost : vhosts) {
- List<String> legacyResourceKeys = legacyResourceKeyUtil.getLegacyVirtualHostResourceKeys(vhost);
+ Set<String> legacyResourceKeys = legacyResourceKeyUtil.getLegacyVirtualHostResourceKeys(vhost);
for(String legacyRK : legacyResourceKeys) {
addPossibleRKMatch(legacyRK, vhost, possibleMatchesPerRK);
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/util/VirtualHostLegacyResourceKeyUtil.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/util/VirtualHostLegacyResourceKeyUtil.java
index 6c8436e..c1f98aa 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/util/VirtualHostLegacyResourceKeyUtil.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/util/VirtualHostLegacyResourceKeyUtil.java
@@ -25,7 +25,9 @@ import java.net.URISyntaxException;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.HashSet;
import java.util.List;
+import java.util.Set;
import org.rhq.plugins.apache.ApacheServerComponent;
import org.rhq.plugins.apache.ApacheVirtualHostServiceComponent;
@@ -64,15 +66,11 @@ public class VirtualHostLegacyResourceKeyUtil {
* This uses the algoritms used in the RHQ 3 codebase and returns both the resource key
* that would be generated wihout SNMP support and with it.
* <p>
- * The returned list contains either 1 or 2 elements. The first element is always the resource
- * key as it would be generated without SNMP support. The second element is the resource key as
- * it would be derived from the SNMP record. If the legacy algorithm wouldn't be able to
- * deduce the resource key from SNMP (which could happen), the second element wouldn't be present
- * in the resulting list.
- * .
+ * The returned set also contains the resource key as it would be found by RHQ 1.x
+ *
* @return possible resource keys of the main server.
*/
- public List<String> getLegacyMainServerResourceKeys() {
+ public Set<String> getLegacyMainServerResourceKeys() {
String mainServerUrl = serverComponent.getServerUrl();
String key = null;
@@ -94,29 +92,32 @@ public class VirtualHostLegacyResourceKeyUtil {
key = ApacheVirtualHostServiceComponent.MAIN_SERVER_RESOURCE_KEY;
}
+ Set<String> ret = new HashSet<String>();
+
+ ret.add(key);
+
String snmpKey = getSNMPResourceKey(key);
- String[] ret = new String[snmpKey == null ? 1 : 2];
-
- ret[0] = key;
if (snmpKey != null) {
- ret[1] = snmpKey;
+ ret.add(snmpKey);
}
+
+ ret.add(addressUtility.getHttpdInternalMainServerAddressRepresentation(runtimeConfig).toString(false, false));
- return Arrays.asList(ret);
+ return ret;
}
/**
* Returns a list of possible resource keys that the RHQ 3 code could generate for the specified
* vhost.
* <p>
- * As with {@link #getLegacyMainServerResourceKeys()} the resulting list will contain either 1 or
- * 2 elements depending on the ability of the legacy algorithm to deduce the resource key from SNMP.
+ * As with {@link #getLegacyMainServerResourceKeys()} the resulting set will contain all the various
+ * resource keys that could have been found by past versions of the plugin.
*
* @param vhost
* @return the possible vhosts
*/
- public List<String> getLegacyVirtualHostResourceKeys(VHostSpec vhost) {
+ public Set<String> getLegacyVirtualHostResourceKeys(VHostSpec vhost) {
String host = vhost.hosts.get(0);
HttpdAddressUtility.Address hostAddr = HttpdAddressUtility.Address.parse(host);
if (vhost.serverName != null) {
@@ -133,16 +134,19 @@ public class VirtualHostLegacyResourceKeyUtil {
String key = hostAddr.host + ":" + hostAddr.port;
- String snmpKey = getSNMPResourceKey(key);
-
- String[] ret = new String[snmpKey == null ? 1 : 2];
- ret[0] = key;
+ Set<String> ret = new HashSet<String>();
+
+ ret.add(key);
+ String snmpKey = getSNMPResourceKey(key);
if (snmpKey != null) {
- ret[1] = snmpKey;
+ ret.add(snmpKey);
}
-
- return Arrays.asList(ret);
+
+ String snmpKeyFromRhq1 = addressUtility.getHttpdInternalVirtualHostAddressRepresentation(runtimeConfig, vhost.hosts.get(0), vhost.serverName).toString(false, false);
+ ret.add(snmpKeyFromRhq1);
+
+ return ret;
}
private String getSNMPResourceKey(String nonSnmpResourceKey) {
commit c6ebdb696373e10dcfa7ed28eed0e7547efaa615
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Thu Jun 16 19:31:13 2011 +0200
BZ 711135 - define defaults to all required properties in the apache plugin configuration so that upgrade of the plugin on the server succeeds.
diff --git a/modules/plugins/apache/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/apache/src/main/resources/META-INF/rhq-plugin.xml
index f3cf33f..ad08a22 100644
--- a/modules/plugins/apache/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/apache/src/main/resources/META-INF/rhq-plugin.xml
@@ -84,7 +84,7 @@
</c:list-property>
'>
<!ENTITY DocumentRoot '
- <c:simple-property name="DocumentRoot">
+ <c:simple-property name="DocumentRoot" default="THIS IS AUTO-DISCOVERED">
<c:description>
This directive sets the directory from which httpd will serve files. Unless matched by a directive like Alias, the server appends the path from the requested URL to the document root to make the path to the document.
If the directory-path is not absolute then it is assumed to be relative to the ServerRoot.
@@ -264,14 +264,14 @@
activationPolicy: immediate
-->
<c:simple-property name="serverRoot" required="true"
- description="the absolute path of the Apache server root directory"/>
+ description="the absolute path of the Apache server root directory" default="THIS SHOULD BE AUTO-DISCOVERED"/>
<c:simple-property name="executablePath" required="false"
description="the path to the Apache executable - if the path is not absolute, it will be resolved relative to the server root directory; if unset, default value is 'bin/httpd' on UNIX or 'bin\Apache.exe' on Windows"/>
<c:simple-property name="controlScriptPath" required="false"
description="the path to the Apache control script - if the path is not absolute, it will be resolved relative to the server root directory; if unset, default will be 'bin/apachectl' on UNIX or the Apache executable on Windows"/>
<!-- TODO need to add a comment about the file location on Win* -->
<c:simple-property name="configFile" required="true" readOnly="true"
- description="the path to the httpd.conf file - if the path is not absolute, it will be resolved relative to the server root directory; if unset, default will be 'conf/httpd.conf' on UNIX"/>
+ description="the path to the httpd.conf file - if the path is not absolute, it will be resolved relative to the server root directory; if unset, default will be 'conf/httpd.conf' on UNIX" default="THIS SHOULD BE AUTO-DISCOVERED"/>
<c:simple-property name="url" displayName="URL" required="false"
description="The http or https URL that will be used to check availability for this Apache
server; if not set, availablity will be determined based on whether plugin can connect
@@ -320,7 +320,7 @@
</c:property-options>
</c:simple-property>
- <c:simple-property name="vhostFilesMask" displayName="Path To Contain Virtual Hosts Files">
+ <c:simple-property name="vhostFilesMask" displayName="Path To Contain Virtual Hosts Files" default="conf.d/*.conf">
<c:description>
If the new virtual hosts should be created in standalone files, this mask determines where
to create those files. The '*' in the path is replaced by the name of the virtual host.
@@ -718,7 +718,7 @@
<service name="Directory" class="ApacheDirectoryComponent" discovery="ApacheDirectoryDiscoveryComponent" createDeletePolicy="both">
<plugin-configuration>
- <c:simple-property name="directiveIndex" readOnly="true" required="true" type="integer"/>
+ <c:simple-property name="directiveIndex" readOnly="true" required="true" type="integer" default="-1"/>
<c:simple-property name="regexp" displayName="Regular Expression" type="boolean" default="false" readOnly="true"
description="Does the name of this directory denote a regular expression?"/>
</plugin-configuration>
commit ab97d23a233552d206f198f71bcdd711618a7bb0
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Thu Jun 16 19:26:15 2011 +0200
BZ 712429 - giving out more useful error message in case of resource key conflict during the resource upgrade.
The error message now contains the details of the resources given resource conflicts with so that the user can easily locate them.
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/upgrade/ResourceUpgradeDelegate.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/upgrade/ResourceUpgradeDelegate.java
index cee582e..915c8e0 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/upgrade/ResourceUpgradeDelegate.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/upgrade/ResourceUpgradeDelegate.java
@@ -19,6 +19,7 @@
package org.rhq.core.pc.upgrade;
+import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
@@ -59,7 +60,7 @@ public class ResourceUpgradeDelegate {
private boolean enabled = true;
private Set<ResourceUpgradeRequest> requests = new HashSet<ResourceUpgradeRequest>();
- private Set<ResourceUpgradeRequest> originalResourceData = new HashSet<ResourceUpgradeRequest>();
+ private Set<ResourceUpgradeRequest> originalResourceData = new HashSet<ResourceUpgradeRequest>();
private InventoryManager inventoryManager;
private Set<Resource> failedResources = new HashSet<Resource>();
private Map<Resource, Set<ResourceType>> failedResourceTypesPerParent = new HashMap<Resource, Set<ResourceType>>();
@@ -154,19 +155,21 @@ public class ResourceUpgradeDelegate {
if ((upgradeErrors = checkUpgradeValid(resource, request)) != null) {
//the resource is in its upgraded state but it's going to get reverted back to the original state
//in the code below. Let's use the original resource for the error message so that we don't confuse
- //the user.
- for(ResourceUpgradeRequest orig : originalResourceData) {
- if (orig.equals(request)) {
- orig.updateResource(resource);
- break;
- }
+ //the user.
+ ResourceUpgradeRequest orig = findOriginal(request);
+
+ //orig should never be null, but let's be paranoid
+ if (orig != null) {
+ orig.updateResource(resource);
}
- String errorString = "Upgrading the resource [" + resource + "] using these updates [" + request
- + "] would render the inventory invalid because of the following reasons: " + upgradeErrors;
+
+ String errorString = "Upgrading the resource [" + resource + "] using these updates ["
+ + request + "] would render the inventory invalid because of the following reasons: "
+ + upgradeErrors;
//now switch the resource back to the upgraded state for the rest of the code below again
request.updateResource(resource);
-
+
log.error(errorString);
IllegalStateException ex = new IllegalStateException(errorString);
@@ -176,7 +179,7 @@ public class ResourceUpgradeDelegate {
//to the server and locally roll back to the previous state.
request.setErrorProperties(ex);
request.clearUpgradeData();
-
+
if (request.getUpgradeErrorMessage() != null) {
rememberFailure(resource);
inventoryManager.deactivateResource(resource);
@@ -185,7 +188,7 @@ public class ResourceUpgradeDelegate {
}
}
}
-
+
//now before we talk to server and sync up the upgraded data,
//reset the resources to their original values so that any changes
//the server makes to the upgrade data are applied to the "vanilla" state
@@ -197,12 +200,12 @@ public class ResourceUpgradeDelegate {
request.updateResource(resource);
}
}
-
+
//merge the resources with the data as received from the server
//(this can differ from what the upgrade "wants" because the server is
//free to disallow some changes, e.g. resource name change)
inventoryManager.mergeResourcesFromUpgrade(requests);
-
+
//and now restart all the "touched" resources with the true intended
//data
for (ResourceUpgradeRequest request : requests) {
@@ -235,16 +238,17 @@ public class ResourceUpgradeDelegate {
ResourceComponent<T> parentResourceComponent = resourceContainer.getResourceContext()
.getParentResourceComponent();
-
+
Resource parentResource = resourceContainer.getResource().getParentResource();
ResourceContainer parentResourceContainer = (parentResource != null) ? inventoryManager
.getResourceContainer(resourceContainer.getResource().getParentResource()) : null;
- ResourceContext<?> parentResourceContext = parentResourceContainer == null ? null : parentResourceContainer.getResourceContext();
-
+ ResourceContext<?> parentResourceContext = parentResourceContainer == null ? null : parentResourceContainer
+ .getResourceContext();
+
Resource resource = resourceContainer.getResource();
-
+
ResourceDiscoveryComponent<ResourceComponent<T>> discoveryComponent = PluginContainer.getInstance()
.getPluginComponentFactory().getDiscoveryComponent(resource.getResourceType(), parentResourceContainer);
@@ -281,41 +285,80 @@ public class ResourceUpgradeDelegate {
rememberFailure(resource);
return false;
}
-
+
//alright, everything went fine with the upgrade. Let's update the data of the resource
//right now so that it starts up as if it was already upgraded. This is to ensure that
//its children will use a parent component that behaves like the upgraded one.
//We are going to roll back the upgraded data if the upgrade fails to sync with the server
//later on.
-
+
//remember the original values
ResourceUpgradeRequest original = new ResourceUpgradeRequest(resource.getId());
original.fillInFromResource(resource);
originalResourceData.add(original);
-
+
//update the resource
request.updateResource(resource);
-
+
return true;
}
private String checkUpgradeValid(Resource resource, ResourceUpgradeReport upgradeReport) {
StringBuilder s = new StringBuilder();
- if (!checkResourceKeyUniqueAmongSiblings(resource, upgradeReport)) {
- s.append("\nAnother inventoried sibling resource of the same type already has the proposed resource key or would have it after the upgrade.");
+ Set<Resource> duplicitSiblings = findDuplicitSiblingResources(resource, upgradeReport);
+ if (!duplicitSiblings.isEmpty()) {
+ s.append("After the upgrade, the following resources would have the same resource key which is illegal. This is an issue of either the old or the new version of the plugin '"
+ + resource.getResourceType().getPlugin()
+ + "'. Please consult the documentation of the plugin to see what are the recommended steps to resolve this situation:\n");
+
+ //ok, this is a little tricky
+ //this method is called when the inventory is in the state as it would look after a
+ //successful upgrade.
+ //but just now, we found out that the upgrade won't succeed because we found some
+ //conflicting resources. These resources won't be upgraded but right now, we see
+ //them as if they were.
+ //For each resource, we therefore need to find the corresponding "original" and report
+ //that instead of how the resource looks like right now.
+ for (Resource r : duplicitSiblings) {
+ ResourceUpgradeRequest fakeRequest = new ResourceUpgradeRequest(r.getId());
+ fakeRequest.fillInFromResource(r);
+
+ ResourceUpgradeRequest orig = findOriginal(fakeRequest);
+
+ //we might not find the original, because this resource might not need an upgrade.
+ //in that case, the reporting will be accurate because upgrade didn't touch the resource.
+ if (orig != null) {
+ orig.updateResource(r);
+ }
+
+ //now we have the resource as it looked before the upgrade kicked in (which is in this
+ //case also what it will look like after the upgrade finishes, because we're failing it).
+ s.append(r).append(",\n");
+
+ //and revert the resource back to what it looked like (i.e. back to the upgraded state so
+ //that we don't introduce side-effects in this method).
+ if (orig != null) {
+ fakeRequest.updateResource(r);
+ }
+ }
+
+ //remove the trailing ",\n"
+ s.replace(s.length() - 2, s.length(), "");
}
return s.length() > 0 ? s.toString() : null;
}
- private boolean checkResourceKeyUniqueAmongSiblings(Resource resource, ResourceUpgradeReport upgradeReport) {
+ private Set<Resource> findDuplicitSiblingResources(Resource resource, ResourceUpgradeReport upgradeReport) {
Resource parent = resource.getParentResource();
if (parent == null) {
//there is only a single platform resource on an agent
- return true;
+ return Collections.emptySet();
}
+ Set<Resource> ret = new HashSet<Resource>();
+
for (Resource sibling : parent.getChildResources()) {
//we'd have a resource key conflict if there was a resource
//of the same type under the same parent that would have the same
@@ -325,18 +368,18 @@ public class ResourceUpgradeDelegate {
&& !sibling.getUuid().equals(resource.getUuid())) {
if (sibling.getResourceKey().equals(upgradeReport.getNewResourceKey())) {
- return false;
+ ret.add(sibling);
}
}
}
- return true;
+ return ret;
}
-
+
private void rememberFailure(Resource resource) {
failedResources.add(resource);
Resource parentResource = resource.getParentResource();
-
+
Set<ResourceType> failedResourceTypesInParent = failedResourceTypesPerParent.get(parentResource);
if (failedResourceTypesInParent == null) {
failedResourceTypesInParent = new HashSet<ResourceType>();
@@ -345,4 +388,14 @@ public class ResourceUpgradeDelegate {
failedResourceTypesInParent.add(resource.getResourceType());
}
+
+ private ResourceUpgradeRequest findOriginal(ResourceUpgradeRequest request) {
+ for(ResourceUpgradeRequest original : originalResourceData) {
+ if (original.equals(request)) {
+ return original;
+ }
+ }
+
+ return null;
+ }
}
12 years, 11 months
[rhq] Branch 'nonplatform-bundles-644328' - modules/enterprise
by mazz
modules/enterprise/gui/coregui/src/main/webapp/images/global/help.png |binary
modules/enterprise/gui/coregui/src/main/webapp/images/global/help_Disabled.png |binary
2 files changed
New commits:
commit 2ec2511ba508c96a2389f40ea13a121774cdeebd
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Jun 16 13:32:34 2011 -0400
BZ 644328 - not really related to this BZ but the help icons need to show
a "?" not a "i". For some reason, our built in skin's icon has a "i" in the icon.
I found the smartgwt ? icon and used that.
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/global/help.png b/modules/enterprise/gui/coregui/src/main/webapp/images/global/help.png
index 12cd1ae..25ce508 100644
Binary files a/modules/enterprise/gui/coregui/src/main/webapp/images/global/help.png and b/modules/enterprise/gui/coregui/src/main/webapp/images/global/help.png differ
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/global/help_Disabled.png b/modules/enterprise/gui/coregui/src/main/webapp/images/global/help_Disabled.png
index 4fc784a..ff2fd21 100644
Binary files a/modules/enterprise/gui/coregui/src/main/webapp/images/global/help_Disabled.png and b/modules/enterprise/gui/coregui/src/main/webapp/images/global/help_Disabled.png differ
12 years, 11 months
[rhq] Branch 'drift' - modules/core
by John Sanda
modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/ChangeSetManagerImplTest.java | 33 ++++++++--
1 file changed, 27 insertions(+), 6 deletions(-)
New commits:
commit 86df6f39fa6e82b35d460c2474294c4e14e840cb
Author: John Sanda <jsanda(a)redhat.com>
Date: Thu Jun 16 13:26:58 2011 -0400
Refactoring test code into more self-documenting assert method
diff --git a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/ChangeSetManagerImplTest.java b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/ChangeSetManagerImplTest.java
index 21e44de..f839eb2 100644
--- a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/ChangeSetManagerImplTest.java
+++ b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/ChangeSetManagerImplTest.java
@@ -62,12 +62,7 @@ public class ChangeSetManagerImplTest {
ChangeSetReader reader = changeSetMgr.getChangeSetReader(resourceId, drfitConfig);
assertNotNull(reader, "Expected to get a change set reader when change set exists");
-
- DirectoryEntry dirEntry = reader.readDirectoryEntry();
- assertNotNull(dirEntry, "Expected reader to return a directory entry. Was the correct change set located?");
-
- assertEquals(dirEntry.getDirectory(), "server/conf", "The directory entry path is wrong");
- assertEquals(dirEntry.getNumberOfFiles(), 1, "The number of files for the directory entry is wrong");
+ assertReaderOpenedOnChangeSet(reader, asList("server/conf", "1"));
}
DriftConfiguration driftConfiguration(String name, String basedir) {
@@ -78,4 +73,30 @@ public class ChangeSetManagerImplTest {
return new DriftConfiguration(config);
}
+ /**
+ * Verifies that a {@link ChangeSetReader} has been opened on the expected change set.
+ * This method first verifies that the reader is not null. It then reads the first
+ * {@link DirectoryEntry} from the reader and verifies that the directory and
+ * numberOfFiles properties match the expected values specified in dirEntry.
+ * <p/>
+ * This method does not rigorously check the entire contents of the change set file
+ * because that {@link ChangeSetReader} tests; rather, it aims to inspect just enough
+ * info to verify that the reader is opened on the correct change set.
+ *
+ * @param reader The ChangeSetReader returned from the ChangeSetManager under test
+ * @param dirEntry A list of strings representing the first line of a directory entry.
+ * The list should consist of two elements. The first being the directory path and the
+ * second being the number of files in the entry.
+ * @throws Exception
+ */
+ void assertReaderOpenedOnChangeSet(ChangeSetReader reader, List<String> dirEntry) throws Exception {
+ assertNotNull(reader, "The " + ChangeSetReader.class.getSimpleName() + " should not be null.");
+
+ DirectoryEntry actual = reader.readDirectoryEntry();
+ assertNotNull(actual, "Expected to find a directory entry");
+ assertEquals(actual.getDirectory(), dirEntry.get(0), "The directory entry path is wrong");
+ assertEquals(Integer.toString(actual.getNumberOfFiles()), dirEntry.get(1),
+ "The number of files for the directory entry is wrong");
+ }
+
}
12 years, 11 months
[rhq] Branch 'nonplatform-bundles-644328' - 4 commits - modules/core modules/enterprise
by mazz
modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java | 6 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ImageManager.java | 7 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/GetDestinationStep.java | 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/FormUtility.java | 4
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties | 3
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties | 7 +
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties | 7 +
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties | 7 +
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties | 3
modules/enterprise/gui/coregui/src/main/webapp/images/global/help.png |binary
modules/enterprise/gui/coregui/src/main/webapp/images/global/help_Disabled.png |binary
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/alert/test/AlertManagerBeanTest.java | 44 +++++----
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/discovery/DiscoveryBossBeanTest.java | 21 +++-
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/inventory/InventoryManagerBeanTest.java | 25 +++--
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/MetadataBeanTest.java | 46 +++-------
15 files changed, 108 insertions(+), 76 deletions(-)
New commits:
commit 83d78504eac6fd1afdab1e2eab1ab598cbd2f336
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Jun 16 13:24:23 2011 -0400
BZ 644328 - add context help to some fields in the bundle deploy wizard
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ImageManager.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ImageManager.java
index 8be3976..4c8fbfa 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ImageManager.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ImageManager.java
@@ -25,6 +25,13 @@ public class ImageManager {
public static final String IMAGES_DIR = "images/";
+ /**
+ * Returns a generic "help" icon. This will also have a peer "disabled" help icon.
+ */
+ public static String getHelpIcon() {
+ return "global/help.png";
+ }
+
public static String getLoadingIcon() {
return "ajax-loader.gif";
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/GetDestinationStep.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/GetDestinationStep.java
index 8d7acfd..21a6a64 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/GetDestinationStep.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/GetDestinationStep.java
@@ -42,6 +42,7 @@ import org.rhq.enterprise.gui.coregui.client.bundle.deploy.selection.SingleCompa
import org.rhq.enterprise.gui.coregui.client.components.wizard.AbstractWizardStep;
import org.rhq.enterprise.gui.coregui.client.gwt.BundleGWTServiceAsync;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.util.FormUtility;
import org.rhq.enterprise.gui.coregui.client.util.message.Message;
import org.rhq.enterprise.gui.coregui.client.util.message.Message.Severity;
import org.rhq.enterprise.gui.coregui.client.util.selenium.Locatable;
@@ -91,6 +92,7 @@ public class GetDestinationStep extends AbstractWizardStep {
dest.setName(value.toString());
}
});
+ FormUtility.addContextualHelp(nameTextItem, MSG.view_bundle_deployWizard_getDest_name_help());
final TextAreaItem descriptionTextAreaItem = new TextAreaItem("description", MSG
.view_bundle_deployWizard_getDest_desc());
@@ -118,6 +120,7 @@ public class GetDestinationStep extends AbstractWizardStep {
dest.setDeployDir(value.toString());
}
});
+ FormUtility.addContextualHelp(deployDirTextItem, MSG.view_bundle_deployWizard_getDest_deployDir_help());
final RadioGroupItem destBaseDirItem = new RadioGroupItem("destBaseDir", MSG
.view_bundle_deployWizard_getDest_destBaseDirName());
@@ -198,6 +201,7 @@ public class GetDestinationStep extends AbstractWizardStep {
}
}
});
+ FormUtility.addContextualHelp(this.selector, MSG.view_bundle_deployWizard_getDest_group_help());
this.valForm.setItems(nameTextItem, descriptionTextAreaItem, this.selector, destBaseDirItem,
deployDirTextItem);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/FormUtility.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/FormUtility.java
index 1097bf1..c510c4b 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/FormUtility.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/FormUtility.java
@@ -25,6 +25,8 @@ import com.smartgwt.client.widgets.form.fields.FormItemIcon;
import com.smartgwt.client.widgets.form.fields.events.IconClickEvent;
import com.smartgwt.client.widgets.form.fields.events.IconClickHandler;
+import org.rhq.enterprise.gui.coregui.client.ImageManager;
+
/**
* A collection of utility methods for working with SmartGWT {@link DynamicForm}s.
*
@@ -50,7 +52,7 @@ public class FormUtility {
public static void addContextualHelp(FormItem item, final String helpText) {
final FormItemIcon helpIcon = new FormItemIcon();
- helpIcon.setSrc("[SKIN]/actions/help.png");
+ helpIcon.setSrc(ImageManager.getHelpIcon());
item.setIcons(helpIcon);
item.addIconClickHandler(new IconClickHandler() {
public void onIconClick(IconClickEvent event) {
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
index a66fbd1..ddd0d3e 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
@@ -918,9 +918,12 @@ view_bundle_deployWizard_getConfigSkip = No configuration needed for this bundle
view_bundle_deployWizard_getConfigStep = Set Deployment Configuration
view_bundle_deployWizard_getDestStep = New Destination
view_bundle_deployWizard_getDest_deployDir = Deployment Directory
+view_bundle_deployWizard_getDest_deployDir_help = The directory where the bundle will be deployed. This directory will be the same for all deployments on all resources but it is relative to the destination base directory location. This means that the absolute directory may have a different path on the different target resources depending on where the base location is on all the different target resources.
view_bundle_deployWizard_getDest_desc = Destination Description
view_bundle_deployWizard_getDest_destBaseDirName = Base Location
+view_bundle_deployWizard_getDest_group_help = The group whose members will be the destination targets for all bundle deployments. Only compatible groups that contain resources that support bundle deployments are selectable.
view_bundle_deployWizard_getDest_name = Destination Name
+view_bundle_deployWizard_getDest_name_help = The name of the destination, which will identify a particular group of resources and the destination directory on those resources for a particular bundle.
view_bundle_deployWizard_getInfoStep = Provide Deployment Information
view_bundle_deployWizard_getInfo_clean = Clean Deployment? (wipe deploy directory on destination platform)
view_bundle_deployWizard_getInfo_deploymentDesc = Deployment Description
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties
index ff33d5d..8edfee2 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties
@@ -781,9 +781,12 @@ view_bundle_deployWizard_getConfigSkip = No configuration needed for this bundle
view_bundle_deployWizard_getConfigStep = Set Deployment Configuration~
view_bundle_deployWizard_getDestStep = New Destination~
##view_bundle_deployWizard_getDest_deployDir = Deployment Directory
-view_bundle_deployWizard_getDest_desc = Destination Description~
+##view_bundle_deployWizard_getDest_deployDir_help = The directory where the bundle will be deployed. This directory will be the same for all deployments on all resources but it is relative to the destination base directory location. This means that the absolute directory may have a different path on the different target resources depending on where the base location is on all the different target resources.
+##view_bundle_deployWizard_getDest_desc = Destination Description
##view_bundle_deployWizard_getDest_destBaseDirName = Base Location
-view_bundle_deployWizard_getDest_name = Destination Name~
+##view_bundle_deployWizard_getDest_group_help = The group whose members will be the destination targets for all bundle deployments. Only compatible groups that contain resources that support bundle deployments are selectable.
+##view_bundle_deployWizard_getDest_name = Destination Name
+##view_bundle_deployWizard_getDest_name_help = The name of the destination, which will identify a particular group of resources and the destination directory on those resources for a particular bundle.
view_bundle_deployWizard_getInfoStep = Provide Deployment Information~
view_bundle_deployWizard_getInfo_clean = Clean Deployment? (wipe deploy directory on destination platform)~
view_bundle_deployWizard_getInfo_deploymentDesc = Deployment Description~
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties
index b20b7c0..b9fc4a3 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties
@@ -919,9 +919,12 @@ view_bundle_deployWizard_getConfigSkip = No configuration needed for this bundle
view_bundle_deployWizard_getConfigStep = Set Deployment Configuration
view_bundle_deployWizard_getDestStep = New Destination
##view_bundle_deployWizard_getDest_deployDir = Deployment Directory
-view_bundle_deployWizard_getDest_desc = Destination Description
+##view_bundle_deployWizard_getDest_deployDir_help = The directory where the bundle will be deployed. This directory will be the same for all deployments on all resources but it is relative to the destination base directory location. This means that the absolute directory may have a different path on the different target resources depending on where the base location is on all the different target resources.
+##view_bundle_deployWizard_getDest_desc = Destination Description
##view_bundle_deployWizard_getDest_destBaseDirName = Base Location
-view_bundle_deployWizard_getDest_name = Destination Name
+##view_bundle_deployWizard_getDest_group_help = The group whose members will be the destination targets for all bundle deployments. Only compatible groups that contain resources that support bundle deployments are selectable.
+##view_bundle_deployWizard_getDest_name = Destination Name
+##view_bundle_deployWizard_getDest_name_help = The name of the destination, which will identify a particular group of resources and the destination directory on those resources for a particular bundle.
view_bundle_deployWizard_getInfoStep = Provide Deployment Information
view_bundle_deployWizard_getInfo_clean = Clean Deployment? (wipe deploy directory on destination platform)
view_bundle_deployWizard_getInfo_deploymentDesc = Deployment Description
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties
index 68e9552..1a2ae2f 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties
@@ -936,9 +936,12 @@ view_bundle_deployWizard_getConfigSkip = No configuration needed for this bundle
view_bundle_deployWizard_getConfigStep = Set Deployment Configuration~
view_bundle_deployWizard_getDestStep = New Destination~
##view_bundle_deployWizard_getDest_deployDir = Deployment Directory
-view_bundle_deployWizard_getDest_desc = Destination Description~
+##view_bundle_deployWizard_getDest_deployDir_help = The directory where the bundle will be deployed. This directory will be the same for all deployments on all resources but it is relative to the destination base directory location. This means that the absolute directory may have a different path on the different target resources depending on where the base location is on all the different target resources.
+##view_bundle_deployWizard_getDest_desc = Destination Description
##view_bundle_deployWizard_getDest_destBaseDirName = Base Location
-view_bundle_deployWizard_getDest_name = Destination Name~
+##view_bundle_deployWizard_getDest_group_help = The group whose members will be the destination targets for all bundle deployments. Only compatible groups that contain resources that support bundle deployments are selectable.
+##view_bundle_deployWizard_getDest_name = Destination Name
+##view_bundle_deployWizard_getDest_name_help = The name of the destination, which will identify a particular group of resources and the destination directory on those resources for a particular bundle.
view_bundle_deployWizard_getInfoStep = Provide Deployment Information~
view_bundle_deployWizard_getInfo_clean = Clean Deployment? (wipe deploy directory on destination platform)~
view_bundle_deployWizard_getInfo_deploymentDesc = Deployment Description~
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties
index cde574b..0b9d91a 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties
@@ -918,9 +918,12 @@ view_bundle_deployWizard_getConfigSkip = No configuration needed for this bundle
view_bundle_deployWizard_getConfigStep = Set Deployment Configuration
view_bundle_deployWizard_getDestStep = \u65B0\u5EFA\u76EE\u7684\u5730
##view_bundle_deployWizard_getDest_deployDir = Deployment Directory
+##view_bundle_deployWizard_getDest_deployDir_help = The directory where the bundle will be deployed. This directory will be the same for all deployments on all resources but it is relative to the destination base directory location. This means that the absolute directory may have a different path on the different target resources depending on where the base location is on all the different target resources.
view_bundle_deployWizard_getDest_desc = \u76EE\u7684\u5730\u63CF\u8FF0
##view_bundle_deployWizard_getDest_destBaseDirName = Base Location
+##view_bundle_deployWizard_getDest_group_help = The group whose members will be the destination targets for all bundle deployments. Only compatible groups that contain resources that support bundle deployments are selectable.
view_bundle_deployWizard_getDest_name = \u76EE\u7684\u5730\u540D
+##view_bundle_deployWizard_getDest_name_help = The name of the destination, which will identify a particular group of resources and the destination directory on those resources for a particular bundle.
view_bundle_deployWizard_getInfoStep = \u63D0\u4F9B\u53D1\u5E03\u4FE1\u606F
view_bundle_deployWizard_getInfo_clean = Clean Deployment? (wipe deploy directory on destination platform)
view_bundle_deployWizard_getInfo_deploymentDesc = \u53D1\u5E03\u63CF\u8FF0
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/global/help.png b/modules/enterprise/gui/coregui/src/main/webapp/images/global/help.png
new file mode 100644
index 0000000..12cd1ae
Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/global/help.png differ
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/global/help_Disabled.png b/modules/enterprise/gui/coregui/src/main/webapp/images/global/help_Disabled.png
new file mode 100644
index 0000000..4fc784a
Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/global/help_Disabled.png differ
commit 3431d0db3475816a887511505904576b588367c3
Merge: 5a2ef20 47a5ff6
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Jun 16 09:57:06 2011 -0400
Merge commit 'origin/master' into nonplatform-bundles-644328
commit 47a5ff64c25c0f4d8648ed8101152d17863abe4d
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Tue Jun 7 18:40:22 2011 +0200
BZ 711484 - catching all the exceptions that can happen during resource activation
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java
index d29cd56..dc58717 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java
@@ -2746,8 +2746,10 @@ public class InventoryManager extends AgentService implements ContainerService,
for (Resource child : resource.getChildResources()) {
activateAndUpgradeResourceRecursively(child, doUpgrade);
}
- } catch (PluginContainerException e) {
- log.error("Exception thrown while activating [" + resource + "].", e);
+ } catch (InvalidPluginConfigurationException e) {
+ log.debug("Failed to activate resource [" + resource + "] due to invalid plugin configuration.", e);
+ } catch (Throwable t) {
+ log.error("Exception thrown while activating [" + resource + "].", t);
}
}
}
commit 5905b70b72eea224790d1254d973ba6dadf6b30e
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Wed Jun 15 15:08:37 2011 -0500
Close all db connections used by dbunit when no longer needed.
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/alert/test/AlertManagerBeanTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/alert/test/AlertManagerBeanTest.java
index 83eb204..41b902c 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/alert/test/AlertManagerBeanTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/alert/test/AlertManagerBeanTest.java
@@ -18,10 +18,8 @@
*/
package org.rhq.enterprise.server.alert.test;
+import java.sql.Connection;
import java.util.List;
-import java.util.Random;
-
-import javax.persistence.EntityManager;
import org.dbunit.database.DatabaseConnection;
import org.dbunit.database.IDatabaseConnection;
@@ -30,27 +28,15 @@ import org.dbunit.dataset.xml.FlatXmlDataSet;
import org.dbunit.dataset.xml.FlatXmlProducer;
import org.dbunit.operation.DatabaseOperation;
import org.testng.annotations.AfterClass;
-import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import org.xml.sax.InputSource;
-import org.rhq.core.domain.alert.Alert;
-import org.rhq.core.domain.alert.AlertCondition;
-import org.rhq.core.domain.alert.AlertConditionCategory;
import org.rhq.core.domain.alert.AlertConditionLog;
-import org.rhq.core.domain.alert.AlertDampening;
-import org.rhq.core.domain.alert.AlertDefinition;
-import org.rhq.core.domain.alert.AlertPriority;
-import org.rhq.core.domain.alert.BooleanExpression;
import org.rhq.core.domain.alert.notification.AlertNotificationLog;
-import org.rhq.core.domain.alert.notification.ResultState;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.common.EntityContext;
-import org.rhq.core.domain.resource.Agent;
import org.rhq.core.domain.resource.Resource;
-import org.rhq.core.domain.resource.ResourceCategory;
-import org.rhq.core.domain.resource.ResourceType;
import org.rhq.enterprise.server.alert.AlertManagerLocal;
import org.rhq.enterprise.server.test.AbstractEJB3Test;
import org.rhq.enterprise.server.util.LookupUtil;
@@ -64,14 +50,22 @@ public class AlertManagerBeanTest extends AbstractEJB3Test {
private Subject superuser;
private Resource newResource;
-
@BeforeMethod
public void beforeMethod() throws Exception {
alertManager = LookupUtil.getAlertManager();
superuser = LookupUtil.getSubjectManager().getOverlord();
- IDatabaseConnection connection = new DatabaseConnection(getConnection());
- DatabaseOperation.CLEAN_INSERT.execute(connection, getDataSet());
+ Connection connection = null;
+
+ try {
+ connection = getConnection();
+ IDatabaseConnection dbUnitConnection = new DatabaseConnection(connection);
+ DatabaseOperation.CLEAN_INSERT.execute(dbUnitConnection, getDataSet());
+ } finally {
+ if (connection != null) {
+ connection.close();
+ }
+ }
newResource = getEntityManager().find(Resource.class, 1);
}
@@ -79,8 +73,17 @@ public class AlertManagerBeanTest extends AbstractEJB3Test {
@AfterClass
public void cleanupDB() throws Exception {
if ("true".equals(System.getProperty("clean.db"))) {
- IDatabaseConnection connection = new DatabaseConnection(getConnection());
- DatabaseOperation.DELETE_ALL.execute(connection, getDataSet());
+ Connection connection = null;
+
+ try {
+ connection = getConnection();
+ IDatabaseConnection dbUnitConnection = new DatabaseConnection(connection);
+ DatabaseOperation.DELETE_ALL.execute(dbUnitConnection, getDataSet());
+ } finally {
+ if (connection != null) {
+ connection.close();
+ }
+ }
}
}
@@ -121,5 +124,4 @@ public class AlertManagerBeanTest extends AbstractEJB3Test {
assert 2 == alertManager.deleteAlerts(0L, System.currentTimeMillis() + 600000L); // go out into the future to make sure we get our alert
}
-
}
\ No newline at end of file
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/discovery/DiscoveryBossBeanTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/discovery/DiscoveryBossBeanTest.java
index 46005c3..082bd6b 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/discovery/DiscoveryBossBeanTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/discovery/DiscoveryBossBeanTest.java
@@ -22,11 +22,11 @@ import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
+import java.sql.Connection;
import java.util.Random;
import javax.management.MBeanServer;
import javax.management.MBeanServerFactory;
-import javax.persistence.EntityManager;
import org.dbunit.database.DatabaseConfig;
import org.dbunit.database.DatabaseConnection;
@@ -43,6 +43,7 @@ import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
+import org.xml.sax.InputSource;
import org.jboss.mx.util.MBeanServerLocator;
@@ -50,14 +51,11 @@ import org.rhq.core.clientapi.server.discovery.InventoryReport;
import org.rhq.core.domain.discovery.ResourceSyncInfo;
import org.rhq.core.domain.resource.Agent;
import org.rhq.core.domain.resource.Resource;
-import org.rhq.core.domain.resource.ResourceCategory;
import org.rhq.core.domain.resource.ResourceType;
import org.rhq.enterprise.server.core.comm.ServerCommunicationsService;
import org.rhq.enterprise.server.core.comm.ServerCommunicationsServiceMBean;
-import org.rhq.enterprise.server.discovery.DiscoveryBossLocal;
import org.rhq.enterprise.server.test.AbstractEJB3Test;
import org.rhq.enterprise.server.util.LookupUtil;
-import org.xml.sax.InputSource;
public class DiscoveryBossBeanTest extends AbstractEJB3Test {
private DiscoveryBossLocal discoveryBoss;
@@ -176,9 +174,18 @@ public class DiscoveryBossBeanTest extends AbstractEJB3Test {
}
public void initDB() throws Exception {
- IDatabaseConnection conn = new DatabaseConnection(getConnection());
- setDbType(conn);
- DatabaseOperation.CLEAN_INSERT.execute(conn, getDataSet());
+ Connection connection = null;
+
+ try {
+ connection = getConnection();
+ IDatabaseConnection dbUnitConnection = new DatabaseConnection(connection);
+ setDbType(dbUnitConnection);
+ DatabaseOperation.CLEAN_INSERT.execute(dbUnitConnection, getDataSet());
+ } finally {
+ if (connection != null) {
+ connection.close();
+ }
+ }
}
void setDbType(IDatabaseConnection connection) throws Exception {
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/inventory/InventoryManagerBeanTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/inventory/InventoryManagerBeanTest.java
index acb6963..6aa8c4d 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/inventory/InventoryManagerBeanTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/inventory/InventoryManagerBeanTest.java
@@ -1,5 +1,8 @@
package org.rhq.enterprise.server.inventory;
+import static java.util.Arrays.asList;
+
+import java.sql.Connection;
import java.util.ArrayList;
import java.util.List;
@@ -24,8 +27,6 @@ import org.rhq.core.domain.resource.ResourceType;
import org.rhq.enterprise.server.test.AbstractEJB3Test;
import org.rhq.enterprise.server.util.LookupUtil;
-import static java.util.Arrays.asList;
-
public class InventoryManagerBeanTest extends AbstractEJB3Test {
@BeforeClass
@@ -34,10 +35,7 @@ public class InventoryManagerBeanTest extends AbstractEJB3Test {
getTransactionManager().begin();
List<Integer> resourceTypeIds = asList(1, 2, 3, 4, 5);
-// List<ResourceType> resourceTypes = asList(
-// getEntityManager().find(ResourceType.class, 1),
-// getEntityManager().find(ResourceType.class, 4));
-
+
InventoryManagerLocal inventoryMgr = LookupUtil.getInventoryManager();
inventoryMgr.markTypesDeleted(resourceTypeIds);
getTransactionManager().commit();
@@ -117,9 +115,18 @@ public class InventoryManagerBeanTest extends AbstractEJB3Test {
}
public void initDB() throws Exception {
- IDatabaseConnection conn = new DatabaseConnection(getConnection());
- setDbType(conn);
- DatabaseOperation.CLEAN_INSERT.execute(conn, getDataSet());
+ Connection connection = null;
+
+ try {
+ connection = getConnection();
+ IDatabaseConnection conn = new DatabaseConnection(connection);
+ setDbType(conn);
+ DatabaseOperation.CLEAN_INSERT.execute(conn, getDataSet());
+ } finally {
+ if (connection != null) {
+ connection.close();
+ }
+ }
}
void setDbType(IDatabaseConnection connection) throws Exception {
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/MetadataBeanTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/MetadataBeanTest.java
index 8eebdb9..7182555 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/MetadataBeanTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/MetadataBeanTest.java
@@ -1,7 +1,10 @@
package org.rhq.enterprise.server.resource.metadata;
+import static org.rhq.core.clientapi.shared.PluginDescriptorUtil.loadPluginDescriptor;
+
import java.io.File;
import java.net.URL;
+import java.sql.Connection;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
@@ -36,9 +39,6 @@ import org.rhq.enterprise.server.resource.ResourceTypeManagerLocal;
import org.rhq.enterprise.server.test.AbstractEJB3Test;
import org.rhq.enterprise.server.util.LookupUtil;
-import static org.rhq.core.clientapi.shared.PluginDescriptorUtil.toPluginDescriptor;
-import static org.rhq.core.clientapi.shared.PluginDescriptorUtil.loadPluginDescriptor;
-
public class MetadataBeanTest extends AbstractEJB3Test {
private static List<String> plugins = new ArrayList<String>();
@@ -70,9 +70,18 @@ public class MetadataBeanTest extends AbstractEJB3Test {
}
protected void setupDB() throws Exception {
- DatabaseConnection dbunitConnection = new DatabaseConnection(getConnection());
- setDbType(dbunitConnection);
- DatabaseOperation.CLEAN_INSERT.execute(dbunitConnection, getDataSet());
+ Connection connection = null;
+
+ try {
+ connection = getConnection();
+ DatabaseConnection dbunitConnection = new DatabaseConnection(connection);
+ setDbType(dbunitConnection);
+ DatabaseOperation.CLEAN_INSERT.execute(dbunitConnection, getDataSet());
+ } finally {
+ if (connection != null) {
+ connection.close();
+ }
+ }
}
private void setDbType(IDatabaseConnection connection) throws Exception {
@@ -106,7 +115,6 @@ public class MetadataBeanTest extends AbstractEJB3Test {
}
protected void createPlugin(String pluginFileName, String version, String descriptorFileName) throws Exception {
-// URL descriptorURL = getClass().getResource(descriptorFileName);
URL descriptorURL = getDescriptorURL(descriptorFileName);
PluginDescriptor pluginDescriptor = loadPluginDescriptor(descriptorURL);
String pluginFilePath = getCurrentWorkingDir() + "/" + pluginFileName + ".jar";
@@ -132,25 +140,6 @@ public class MetadataBeanTest extends AbstractEJB3Test {
String dir = getClass().getSimpleName();
return getClass().getResource(dir + "/" + descriptor);
}
-
-// protected void createPlugin(String pluginFileName, String version, String descriptor) throws Exception {
-// PluginDescriptor pluginDescriptor = toPluginDescriptor(descriptor);
-// String pluginFilePath = getCurrentWorkingDir() + "/" + pluginFileName + ".jar";
-// File pluginFile = new File(pluginFilePath);
-//
-// Plugin plugin = new Plugin(pluginDescriptor.getName(), pluginFilePath);
-// plugin.setDisplayName(pluginDescriptor.getName());
-// plugin.setEnabled(true);
-// plugin.setDescription(pluginDescriptor.getDescription());
-// plugin.setAmpsVersion(getAmpsVersion(pluginDescriptor));
-// plugin.setVersion(pluginDescriptor.getVersion());
-// plugin.setMD5(MessageDigestGenerator.getDigestString(pluginFile));
-//
-// SubjectManagerLocal subjectMgr = LookupUtil.getSubjectManager();
-// PluginManagerLocal pluginMgr = LookupUtil.getPluginManager();
-//
-// pluginMgr.registerPlugin(subjectMgr.getOverlord(), plugin, pluginDescriptor, null, true);
-// }
private String getPluginWorkDir() throws Exception {
return getCurrentWorkingDir() + "/work";
@@ -212,13 +201,11 @@ public class MetadataBeanTest extends AbstractEJB3Test {
errors = "Failed to find the following " + propertyName + "(s) for type " + resourceTypeName +
": " + missing;
}
-
+
if (unexpected.size() > 0) {
errors += "\nFailed to find the following " + propertyName + "(s) for type " + resourceTypeName +
": " + unexpected;
}
-
-
}
private boolean contains(ResourceType type, String propertyName, String expected) throws Exception {
@@ -231,5 +218,4 @@ public class MetadataBeanTest extends AbstractEJB3Test {
}
return false;
}
-
}
12 years, 11 months
[rhq] Branch 'release-3.0.1' - 3 commits - modules/core
by snegrea
modules/core/dbutils/pom.xml | 35 ++++++++++++++++++++---------------
1 file changed, 20 insertions(+), 15 deletions(-)
New commits:
commit 1686eb5e036d2648297886deb4586ba793f37a29
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Thu Jun 16 11:29:50 2011 -0500
Fixing the formating for inline pom code.
diff --git a/modules/core/dbutils/pom.xml b/modules/core/dbutils/pom.xml
index 2dc5804..4f71c07 100644
--- a/modules/core/dbutils/pom.xml
+++ b/modules/core/dbutils/pom.xml
@@ -98,8 +98,8 @@
database = project.properties['rhq.dev.ds.db-name']
server = project.properties['rhq.dev.ds.server-name'] ?: '127.0.0.1'
rhqUser = project.properties['rhq.dev.ds.user-name'] ?: 'rhqadmin'
- }
- else {
+ }
+ else {
database = project.properties['rhq.test.ds.db-name']
server = project.properties['rhq.test.ds.server-name'] ?: '127.0.0.1'
rhqUser = project.properties['rhq.test.ds.user-name'] ?: 'rhqadmin'
commit 385eb481404314340e6b4b06b1041dc60918947f
Author: John Sanda <jsanda(a)redhat.com>
Date: Wed May 25 16:21:30 2011 -0400
Refactoring logic in dbreset script for use with upgrade db
The database name comes from settings.xml for hudson builds. If you want
to develop/test against a database on which you have run dbupgrade, then
you can run maven with -Dupgrade.db and it will use the rhqupgrade
database.
diff --git a/modules/core/dbutils/pom.xml b/modules/core/dbutils/pom.xml
index 6111642..2dc5804 100644
--- a/modules/core/dbutils/pom.xml
+++ b/modules/core/dbutils/pom.xml
@@ -99,21 +99,19 @@
server = project.properties['rhq.dev.ds.server-name'] ?: '127.0.0.1'
rhqUser = project.properties['rhq.dev.ds.user-name'] ?: 'rhqadmin'
}
- // This is a bit of a temporary hack to work around
- // https://cvs.codehaus.org/browse/GMAVEN-46 which results in
- // groovy scripts not being able to get the correct values of
- // build properties that are overridden on the command line.
- // This is being done in support of the hudson job which is
- // trying to use a database named rhqupgrade.
- else if (project.properties['upgrade.db']) {
- database = 'rhqupgrade'
- }
else {
database = project.properties['rhq.test.ds.db-name']
server = project.properties['rhq.test.ds.server-name'] ?: '127.0.0.1'
rhqUser = project.properties['rhq.test.ds.user-name'] ?: 'rhqadmin'
}
+ // The upgrade.db property should be set for local builds when you
+ // need to test upgrade changes. Hudson builds will specify the
+ // database to use in settings.xml
+ if (project.properties['upgrade.db']) {
+ database = 'rhqupgrade'
+ }
+
adminUsername = project.properties['rhq.db.admin.username'] ?: 'postgres'
adminPassword = project.properties['rhq.db.admin.password'] ?: 'postgres'
project.properties.dbsetup = 'true'
commit 0542930fda0ea7d788d2a28be3d92d112478fc1a
Author: John Sanda <jsanda(a)redhat.com>
Date: Wed Apr 20 14:47:37 2011 -0400
Further parameterizeing dbreset script
Parameterizing the script to make it usable with databases running on machines
other than localhost.
diff --git a/modules/core/dbutils/pom.xml b/modules/core/dbutils/pom.xml
index 48b6346..6111642 100644
--- a/modules/core/dbutils/pom.xml
+++ b/modules/core/dbutils/pom.xml
@@ -96,30 +96,37 @@
db = project.properties.db
if (db == 'dev') {
database = project.properties['rhq.dev.ds.db-name']
- }
+ server = project.properties['rhq.dev.ds.server-name'] ?: '127.0.0.1'
+ rhqUser = project.properties['rhq.dev.ds.user-name'] ?: 'rhqadmin'
+ }
// This is a bit of a temporary hack to work around
// https://cvs.codehaus.org/browse/GMAVEN-46 which results in
// groovy scripts not being able to get the correct values of
// build properties that are overridden on the command line.
// This is being done in support of the hudson job which is
// trying to use a database named rhqupgrade.
- else if (project.properties['upgrade.db']) {
- database = 'rhqupgrade'
- }
- else {
+ else if (project.properties['upgrade.db']) {
+ database = 'rhqupgrade'
+ }
+ else {
database = project.properties['rhq.test.ds.db-name']
+ server = project.properties['rhq.test.ds.server-name'] ?: '127.0.0.1'
+ rhqUser = project.properties['rhq.test.ds.user-name'] ?: 'rhqadmin'
}
+
+ adminUsername = project.properties['rhq.db.admin.username'] ?: 'postgres'
+ adminPassword = project.properties['rhq.db.admin.password'] ?: 'postgres'
project.properties.dbsetup = 'true'
sql = Sql.newInstance(
- "jdbc:postgresql://127.0.0.1:5432/postgres",
- "postgres",
- "postgres",
+ "jdbc:postgresql://${server}:5432/postgres",
+ adminUsername,
+ adminPassword,
"org.postgresql.Driver")
sql.execute("drop database if exists ${Sql.expand(database)};")
log.info("dropped database $database")
- sql.execute("create database ${Sql.expand(database)} with owner rhqadmin;")
+ sql.execute("create database ${Sql.expand(database)} with owner ${Sql.expand(rhqUser)};")
log.info("created database $database")
</source>
</configuration>
12 years, 11 months
[rhq] Branch 'drift' - modules/core
by John Sanda
modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/ChangeSetManager.java | 7
modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/ChangeSetManagerImpl.java | 63 +++++++
modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftDetector.java | 2
modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/ChangeSetManagerImplTest.java | 81 ++++++++++
4 files changed, 152 insertions(+), 1 deletion(-)
New commits:
commit c416f6e8413b33320ec075bc20b06f93ad8281a7
Author: John Sanda <jsanda(a)redhat.com>
Date: Thu Jun 16 12:04:29 2011 -0400
Initial commit for ChangeSetManagerImpl and ChangeSetManagerImplTest
ChangeSetManager is responsible for managing changeset files on disk.
This includes providing readers and writers for change sets and moving
copyin files into a change set.
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/ChangeSetManager.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/ChangeSetManager.java
index fd946b3..9ac3cc2 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/ChangeSetManager.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/ChangeSetManager.java
@@ -1,5 +1,8 @@
package org.rhq.core.pc.drift;
+import java.io.File;
+import java.io.IOException;
+
import org.rhq.common.drift.ChangeSetReader;
import org.rhq.common.drift.ChangeSetWriter;
import org.rhq.core.domain.drift.DriftConfiguration;
@@ -18,8 +21,10 @@ public interface ChangeSetManager {
* and driftConfiguration. Returns null if no change set has previously been generated.
* @see ChangeSetReader
*/
- ChangeSetReader getChangeSetReader(int resourceId, DriftConfiguration driftConfiguration);
+ ChangeSetReader getChangeSetReader(int resourceId, DriftConfiguration driftConfiguration) throws IOException;
ChangeSetWriter getChangeSetWriter(int resourceId, DriftConfiguration driftConfiguration);
+ void addFileToChangeSet(int resourceId, DriftConfiguration driftConfiguration, File file);
+
}
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/ChangeSetManagerImpl.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/ChangeSetManagerImpl.java
new file mode 100644
index 0000000..2470611
--- /dev/null
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/ChangeSetManagerImpl.java
@@ -0,0 +1,63 @@
+package org.rhq.core.pc.drift;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.apache.commons.io.FilenameUtils;
+
+import org.rhq.common.drift.ChangeSetReader;
+import org.rhq.common.drift.ChangeSetReaderImpl;
+import org.rhq.common.drift.ChangeSetWriter;
+import org.rhq.core.domain.drift.DriftConfiguration;
+
+import static java.io.File.separator;
+
+public class ChangeSetManagerImpl implements ChangeSetManager {
+
+ private File changeSetsDir;
+
+ public ChangeSetManagerImpl(File changeSetsDir) {
+ this.changeSetsDir = changeSetsDir;
+ }
+
+ @Override
+ public ChangeSetReader getChangeSetReader(int resourceId, DriftConfiguration driftConfiguration)
+ throws IOException {
+ File changeSetDir = findChangeSetDir(resourceId, driftConfiguration);
+ File changeSetFile = new File(changeSetDir, "changeset.txt");
+
+ if (!changeSetFile.exists()) {
+ return null;
+ }
+
+ return new ChangeSetReaderImpl(changeSetFile);
+ }
+
+ @Override
+ public ChangeSetWriter getChangeSetWriter(int resourceId, DriftConfiguration driftConfiguration) {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public void addFileToChangeSet(int resourceId, DriftConfiguration driftConfiguration, File file) {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ private File findChangeSetDir(int resourceId, DriftConfiguration driftConfiguration) {
+ File resourceDir = new File(changeSetsDir, Integer.toString(resourceId));
+ if (!resourceDir.exists()) {
+ return null;
+ }
+
+ return new File(resourceDir, driftConfiguration.getName());
+
+ }
+
+ private String relativePath(File basedir, File file) {
+ if (basedir.equals(file)) {
+ return basedir.getPath();
+ }
+ return FilenameUtils.getName(basedir.getAbsolutePath()) + separator +
+ file.getAbsolutePath().substring(basedir.getAbsolutePath().length() + 1);
+ }
+}
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftDetector.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftDetector.java
index 6302f04..6812dbd 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftDetector.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftDetector.java
@@ -92,6 +92,8 @@ public class DriftDetector implements Runnable {
protected void handleDirectoryEnd(File directory, int depth, Collection results) throws IOException {
DirectoryEntry dirEntry = stack.pop();
writer.writeDirectoryEntry(dirEntry);
+
+
}
@Override
diff --git a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/ChangeSetManagerImplTest.java b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/ChangeSetManagerImplTest.java
new file mode 100644
index 0000000..21e44de
--- /dev/null
+++ b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/ChangeSetManagerImplTest.java
@@ -0,0 +1,81 @@
+package org.rhq.core.pc.drift;
+
+import java.io.File;
+import java.util.Arrays;
+import java.util.List;
+
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import org.rhq.common.drift.ChangeSetReader;
+import org.rhq.common.drift.DirectoryEntry;
+import org.rhq.common.drift.FileEntry;
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.drift.DriftConfiguration;
+
+import static java.util.Arrays.asList;
+import static org.apache.commons.io.FileUtils.writeLines;
+import static org.testng.Assert.*;
+import static org.apache.commons.io.FileUtils.deleteDirectory;
+
+public class ChangeSetManagerImplTest {
+
+ File changeSetsDir;
+
+ @BeforeClass
+ public void resetChangeSetsDir() throws Exception {
+ File dataDir = new File("target", getClass().getSimpleName());
+ deleteDirectory(dataDir);
+
+ changeSetsDir = new File(dataDir, "changesets");
+ assertTrue(changeSetsDir.mkdirs(), "Failed to create " + changeSetsDir.getAbsolutePath());
+ changeSetsDir = new File(dataDir, "changesets");
+ }
+
+ @Test
+ public void returnNullReaderWhenNoChangeSetExists() throws Exception {
+ int resourceId = -1;
+ ChangeSetManager changeSetMgr = new ChangeSetManagerImpl(changeSetsDir);
+ ChangeSetReader reader = changeSetMgr.getChangeSetReader(resourceId, driftConfiguration("test", "server"));
+
+ assertNull(reader, "Expect null for the reader when no change set exists for the drift configuration.");
+ }
+
+ @Test
+ public void returnReaderForRequestedChangeSet() throws Exception {
+ int resourceId = 1;
+ DriftConfiguration drfitConfig = driftConfiguration("test-1", "server");
+
+ File resourceDir = new File(changeSetsDir, Integer.toString(resourceId));
+ File changeSetDir = new File(resourceDir, "test-1");
+
+ assertTrue(changeSetDir.mkdirs(), "Failed to create change set directory: " + changeSetDir.getAbsolutePath());
+
+ List<String> changeSet = asList(
+ "server/conf 1",
+ "8f26ac3d 0 myconf.conf A"
+ );
+ writeLines(new File(changeSetDir, "changeset.txt"), changeSet);
+
+ ChangeSetManager changeSetMgr = new ChangeSetManagerImpl(changeSetsDir);
+ ChangeSetReader reader = changeSetMgr.getChangeSetReader(resourceId, drfitConfig);
+
+ assertNotNull(reader, "Expected to get a change set reader when change set exists");
+
+ DirectoryEntry dirEntry = reader.readDirectoryEntry();
+ assertNotNull(dirEntry, "Expected reader to return a directory entry. Was the correct change set located?");
+
+ assertEquals(dirEntry.getDirectory(), "server/conf", "The directory entry path is wrong");
+ assertEquals(dirEntry.getNumberOfFiles(), 1, "The number of files for the directory entry is wrong");
+ }
+
+ DriftConfiguration driftConfiguration(String name, String basedir) {
+ Configuration config = new Configuration();
+ config.put(new PropertySimple("name", name));
+ config.put(new PropertySimple("basedir", basedir));
+
+ return new DriftConfiguration(config);
+ }
+
+}
12 years, 11 months
[rhq] Branch 'drift' - modules/common modules/core modules/enterprise
by Jay Shaughnessy
modules/common/drift/src/main/java/org/rhq/common/drift/ChangeSetReaderImpl.java | 25 +-
modules/common/drift/src/main/java/org/rhq/common/drift/DriftChangeSetEntry.java | 92 --------
modules/common/drift/src/main/java/org/rhq/common/drift/DriftChangeSetParser.java | 27 --
modules/core/client-api/src/main/java/org/rhq/core/clientapi/server/drift/DriftServerService.java | 19 +
modules/core/util/src/main/java/org/rhq/core/util/file/FileUtil.java | 11
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerBean.java | 113 +++++-----
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/drift/DriftManagerBeanTest.java | 29 +-
modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/drift/changeset-1.txt | 2
modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/drift/changeset-1.zip |binary
modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/drift/changeset-2.txt | 2
modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/drift/changeset-2.zip |binary
11 files changed, 133 insertions(+), 187 deletions(-)
New commits:
commit ba58976670826d539576585c38836f75e0fdcdf1
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Thu Jun 16 11:25:38 2011 -0400
-tweak ChangeSetReaderImpl to use regex to allow for directort paths with spaces
-- also now return null when there are no more directories (maybe use Iterator here at some point)
- deleted unnecessary classes DriftChangeSetParser and DriftChangeSetEntry
- Added simple FileUtil for replacing backslashes with forward slashes
- DriftManagerBean now expecting/processing real Zip ChangeSets and
using ChangeSetReaderImpl
- Updated tests to use real changeset zips
diff --git a/modules/common/drift/src/main/java/org/rhq/common/drift/ChangeSetReaderImpl.java b/modules/common/drift/src/main/java/org/rhq/common/drift/ChangeSetReaderImpl.java
index e9595ab..7e557a2 100644
--- a/modules/common/drift/src/main/java/org/rhq/common/drift/ChangeSetReaderImpl.java
+++ b/modules/common/drift/src/main/java/org/rhq/common/drift/ChangeSetReaderImpl.java
@@ -1,15 +1,20 @@
package org.rhq.common.drift;
+import static java.lang.Integer.parseInt;
+
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.Reader;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
-import static java.lang.Integer.parseInt;
+import org.apache.commons.logging.LogFactory;
public class ChangeSetReaderImpl implements ChangeSetReader {
+ private Pattern DIRECTORY_PATTERN = Pattern.compile("^\\s*(.*?)\\s+(\\d+)\\s*$");
private BufferedReader reader;
private File metaDataFile;
@@ -19,15 +24,25 @@ public class ChangeSetReaderImpl implements ChangeSetReader {
reader = new BufferedReader(new FileReader(this.metaDataFile));
}
- ChangeSetReaderImpl(Reader metaDataFile) throws Exception {
+ public ChangeSetReaderImpl(Reader metaDataFile) throws Exception {
reader = new BufferedReader(metaDataFile);
}
@Override
public DirectoryEntry readDirectoryEntry() throws IOException {
- String[] fields = reader.readLine().split(" ");
- DirectoryEntry dirEntry = new DirectoryEntry(fields[0]);
- int numFiles = parseInt(fields[1]);
+ String line = reader.readLine();
+ if (null == line) {
+ return null;
+ }
+
+ Matcher m = DIRECTORY_PATTERN.matcher(line);
+ if (!m.matches() || 2 != m.groupCount()) {
+ LogFactory.getLog(ChangeSetReaderImpl.class).error("Unexpected directory line, returning null on: " + line);
+ return null;
+ }
+
+ DirectoryEntry dirEntry = new DirectoryEntry(m.group(1));
+ int numFiles = parseInt(m.group(2));
for (int i = 0; i < numFiles; ++i) {
String[] cols = reader.readLine().split(" ");
diff --git a/modules/common/drift/src/main/java/org/rhq/common/drift/DriftChangeSetEntry.java b/modules/common/drift/src/main/java/org/rhq/common/drift/DriftChangeSetEntry.java
deleted file mode 100644
index 6fb29ac..0000000
--- a/modules/common/drift/src/main/java/org/rhq/common/drift/DriftChangeSetEntry.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2009 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.common.drift;
-
-import org.rhq.core.domain.drift.DriftCategory;
-
-/**
- * @author Jay Shaughnessy
- * @author John Sanda
- */
-public class DriftChangeSetEntry {
-
- private String path;
- private Integer size = 0;
- private DriftCategory category;
- // required for FILE_CHANGED and FILE_REMOVED, null for FILE_ADDED
- private String oldSha256;
- // required for FILE_CHANGED and FILE_ADDED, null for FILE_REMOVED
- private String newSha256;
-
- public DriftChangeSetEntry(Integer size, String path, DriftCategory category, String oldSha256, String newSha256) {
- super();
- this.size = size;
- this.path = path;
- this.category = category;
- this.oldSha256 = oldSha256;
- this.newSha256 = newSha256;
- }
-
- public String getPath() {
- return path;
- }
-
- public void setPath(String path) {
- this.path = path;
- }
-
- public Integer getSize() {
- return size;
- }
-
- public void setSize(Integer size) {
- this.size = size;
- }
-
- public DriftCategory getCategory() {
- return category;
- }
-
- public void setCategory(DriftCategory category) {
- this.category = category;
- }
-
- public String getOldSha256() {
- return oldSha256;
- }
-
- public void setOldSha256(String oldSha256) {
- this.oldSha256 = oldSha256;
- }
-
- public String getNewSha256() {
- return newSha256;
- }
-
- public void setNewSha256(String newSha256) {
- this.newSha256 = newSha256;
- }
-
- @Override
- public String toString() {
- return "DriftChangeSetEntry [category=" + category + ", newSha256=" + newSha256 + ", oldSha256=" + oldSha256
- + ", path=" + path + "]";
- }
-
-}
diff --git a/modules/common/drift/src/main/java/org/rhq/common/drift/DriftChangeSetParser.java b/modules/common/drift/src/main/java/org/rhq/common/drift/DriftChangeSetParser.java
deleted file mode 100644
index a0f2903..0000000
--- a/modules/common/drift/src/main/java/org/rhq/common/drift/DriftChangeSetParser.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2009 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.common.drift;
-
-/**
- * @author Jay Shaughnessy
- * @author John Sanda
- */
-public class DriftChangeSetParser {
-
-}
diff --git a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/server/drift/DriftServerService.java b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/server/drift/DriftServerService.java
index af7e9f7..f1314a3 100644
--- a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/server/drift/DriftServerService.java
+++ b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/server/drift/DriftServerService.java
@@ -23,15 +23,34 @@ import java.io.InputStream;
import org.rhq.core.communications.command.annotation.Asynchronous;
+/**
+ * @author Jay Shaughnessy
+ * @author John Sanda
+ */
public interface DriftServerService {
// note that this guaranteed delivery is weak because most likely the stream will be dead if it
// doesn't work the first time.
+ /**
+ * The ChangeSet file is of the format described in ChangeSetReader.
+ *
+ * @param resourceId
+ * @param zipSize
+ * @param zipStream A RemoteStream
+ */
@Asynchronous(guaranteedDelivery = true)
void sendChangesetZip(int resourceId, long zipSize, InputStream zipStream);
// note that this guaranteed delivery is weak because most likely the stream will be dead if it
// doesn't work the first time.
+ /**
+ * The name of each zip entry should be the sha256. The filenames and paths are not relevant as this
+ * is only a store of content and the content is identified ony by the sha.
+ *
+ * @param resourceId
+ * @param zipSize
+ * @param zipStream A RemoteStream
+ */
@Asynchronous(guaranteedDelivery = true)
void sendFilesZip(int resourceId, long zipSize, InputStream zipStream);
}
diff --git a/modules/core/util/src/main/java/org/rhq/core/util/file/FileUtil.java b/modules/core/util/src/main/java/org/rhq/core/util/file/FileUtil.java
index 04d0537..d40f822 100644
--- a/modules/core/util/src/main/java/org/rhq/core/util/file/FileUtil.java
+++ b/modules/core/util/src/main/java/org/rhq/core/util/file/FileUtil.java
@@ -308,4 +308,15 @@ public class FileUtil {
}
return driveLetter;
}
+
+ /**
+ * Ensure that the path uses only forward slash
+ * Like java.io.File(String,String) but just
+ * @param dir
+ * @param fileName
+ * @return
+ */
+ public static String useForwardSlash(String path) {
+ return path.replace('\\', '/');
+ }
}
\ No newline at end of file
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerBean.java
index 5c63224..e2c9fac 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerBean.java
@@ -20,9 +20,12 @@
package org.rhq.enterprise.server.drift;
import java.io.BufferedInputStream;
+import java.io.BufferedReader;
import java.io.File;
import java.io.InputStream;
+import java.io.InputStreamReader;
import java.util.ArrayList;
+import java.util.Iterator;
import java.util.List;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
@@ -44,18 +47,21 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.Hibernate;
-import org.rhq.common.drift.DriftChangeSetEntry;
+import org.rhq.common.drift.ChangeSetReader;
+import org.rhq.common.drift.ChangeSetReaderImpl;
+import org.rhq.common.drift.DirectoryEntry;
+import org.rhq.common.drift.FileEntry;
import org.rhq.core.clientapi.agent.drift.DriftAgentService;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.criteria.DriftChangeSetCriteria;
import org.rhq.core.domain.drift.Drift;
-import org.rhq.core.domain.drift.DriftCategory;
import org.rhq.core.domain.drift.DriftChangeSet;
import org.rhq.core.domain.drift.DriftFile;
import org.rhq.core.domain.drift.DriftFileStatus;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.util.PageList;
import org.rhq.core.util.ZipUtil;
+import org.rhq.core.util.file.FileUtil;
import org.rhq.enterprise.server.RHQConstants;
import org.rhq.enterprise.server.agentclient.AgentClient;
import org.rhq.enterprise.server.auth.SubjectManagerLocal;
@@ -111,8 +117,7 @@ public class DriftManagerBean implements DriftManagerLocal {
}
@Override
- public void storeChangeSet(int resourceId, File changeSetZip) throws Exception {
- DriftChangeSet driftChangeSet = null;
+ public void storeChangeSet(final int resourceId, File changeSetZip) throws Exception {
Resource resource = entityManager.find(Resource.class, resourceId);
if (null == resource) {
throw new IllegalArgumentException("Resource not found: " + resourceId);
@@ -122,56 +127,69 @@ public class DriftManagerBean implements DriftManagerLocal {
DriftChangeSetCriteria c = new DriftChangeSetCriteria();
c.addFilterResourceId(resourceId);
List<DriftChangeSet> changeSets = findDriftChangeSetsByCriteria(subjectManager.getOverlord(), c);
- boolean isInitialChangeSet = changeSets.isEmpty();
- int version = changeSets.size();
- List<DriftFile> emptyDriftFiles = new ArrayList<DriftFile>();
+ final boolean isInitialChangeSet = changeSets.isEmpty();
+ final int version = changeSets.size();
// store the new change set info (not the actual blob)
- driftChangeSet = new DriftChangeSet(resource, version);
+ final DriftChangeSet driftChangeSet = new DriftChangeSet(resource, version);
//driftChangeSet.setData(Hibernate.createBlob(new BufferedInputStream(new FileInputStream(changeSetZip))));
entityManager.persist(driftChangeSet);
- // TODO whole thing will change to use the parser utility when it's available, just use a dummy entry for now
- List<DriftChangeSetEntry> entries = new ArrayList<DriftChangeSetEntry>();
- if (0 == version) {
- entries.add(new DriftChangeSetEntry(0, "/foo/bar", DriftCategory.FILE_ADDED, null, String
- .valueOf(version)));
- } else {
- entries.add(new DriftChangeSetEntry(0, "/foo/bar", DriftCategory.FILE_CHANGED, String
- .valueOf(version - 1), String.valueOf(version)));
- }
-
- for (DriftChangeSetEntry entry : entries) {
- DriftFile oldDriftFile = getDriftFile(entry.getOldSha256(), emptyDriftFiles);
- DriftFile newDriftFile = getDriftFile(entry.getNewSha256(), emptyDriftFiles);
-
- // We don't generate Drift occurrences off of the initial change set. It is used only
- // to give us a starting point and to tell us what files we need to pull down.
- if (!isInitialChangeSet) {
- Drift drift = new Drift(driftChangeSet, entry.getPath(), entry.getCategory(), oldDriftFile,
- newDriftFile);
- entityManager.persist(drift);
- }
- }
-
- // send a message to the agent requesting the empty DriftFile content
- if (!emptyDriftFiles.isEmpty()) {
-
- AgentClient agentClient = agentManager.getAgentClient(subjectManager.getOverlord(), resourceId);
- DriftAgentService service = agentClient.getDriftAgentService();
- if (service.requestDriftFiles(emptyDriftFiles)) {
-
- for (DriftFile driftFile : emptyDriftFiles) {
- driftFile.setStatus(DriftFileStatus.REQUESTED);
+ ZipUtil.walkZipFile(changeSetZip, new ChangeSetFileVisitor() {
+
+ @Override
+ public boolean visit(ZipEntry zipEntry, ZipInputStream stream) throws Exception {
+ List<DriftFile> emptyDriftFiles = new ArrayList<DriftFile>();
+
+ try {
+ ChangeSetReader reader = new ChangeSetReaderImpl(new BufferedReader(new InputStreamReader(
+ stream)));
+
+ for (DirectoryEntry dir = reader.readDirectoryEntry(); null != dir; dir = reader
+ .readDirectoryEntry()) {
+
+ for (Iterator<FileEntry> i = dir.iterator(); i.hasNext();) {
+ FileEntry entry = i.next();
+ DriftFile oldDriftFile = getDriftFile(entry.getOldSHA(), emptyDriftFiles);
+ DriftFile newDriftFile = getDriftFile(entry.getNewSHA(), emptyDriftFiles);
+
+ // We don't generate Drift occurrences off of the initial change set. It is used only
+ // to give us a starting point and to tell us what files we need to pull down.
+ if (!isInitialChangeSet) {
+ // use a canonical path with only forward slashing to ensure consistent paths across reports
+ String path = new File(dir.getDirectory(), entry.getFile()).getPath();
+ path = FileUtil.useForwardSlash(path);
+ Drift drift = new Drift(driftChangeSet, path, entry.getType(), oldDriftFile,
+ newDriftFile);
+ entityManager.persist(drift);
+ }
+ }
+ }
+ // send a message to the agent requesting the empty DriftFile content
+ if (!emptyDriftFiles.isEmpty()) {
+
+ AgentClient agentClient = agentManager.getAgentClient(subjectManager.getOverlord(),
+ resourceId);
+ DriftAgentService service = agentClient.getDriftAgentService();
+ if (service.requestDriftFiles(emptyDriftFiles)) {
+
+ for (DriftFile driftFile : emptyDriftFiles) {
+ driftFile.setStatus(DriftFileStatus.REQUESTED);
+ }
+ }
+ }
+ } catch (Exception e) {
+ String msg = "Failed to store drift changeset: " + driftChangeSet;
+ log.error(msg, e);
+ return false;
}
- }
- }
+ return true;
+ }
+ });
} catch (Exception e) {
String msg = "Failed to store drift changeset for ";
- if (null != driftChangeSet) {
- msg += driftChangeSet;
- } else if (null != resource) {
+ if (null != resource) {
msg += resource;
} else {
msg += ("resourceId " + resourceId);
@@ -183,10 +201,13 @@ public class DriftManagerBean implements DriftManagerLocal {
}
}
+ private abstract class ChangeSetFileVisitor implements ZipUtil.ZipEntryVisitor {
+ }
+
private DriftFile getDriftFile(String sha256, List<DriftFile> emptyDriftFiles) {
DriftFile result = null;
- if (null == sha256) {
+ if (null == sha256 || "0".equals(sha256)) {
return result;
}
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/drift/DriftManagerBeanTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/drift/DriftManagerBeanTest.java
index 89beaa7..8e94b25 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/drift/DriftManagerBeanTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/drift/DriftManagerBeanTest.java
@@ -105,7 +105,9 @@ public class DriftManagerBeanTest extends AbstractEJB3Test {
@Test(enabled = ENABLE_TESTS)
public void testStoreChangeSet() throws Exception {
// the initial changeset should not create any drift, just should request a drift file "0"
- driftManager.storeChangeSet(newResource.getId(), File.createTempFile("drift-cs-1", ".test"));
+ File changeset1 = new File("./src/test/resources/org/rhq/enterprise/server/drift/changeset-1.zip");
+ assertTrue(changeset1.exists());
+ driftManager.storeChangeSet(newResource.getId(), changeset1);
DriftChangeSetCriteria c = new DriftChangeSetCriteria();
c.addFilterResourceId(newResource.getId());
@@ -116,12 +118,14 @@ public class DriftManagerBeanTest extends AbstractEJB3Test {
assertEquals(0, changeSet.getVersion());
assertEquals(0, changeSet.getDrifts().size());
- DriftFile driftFile = driftManager.getDriftFile(overlord, "0");
+ DriftFile driftFile = driftManager.getDriftFile(overlord, "aaaaa");
assertNotNull(driftFile);
assertEquals(DriftFileStatus.REQUESTED, driftFile.getStatus());
// the second change set should report drift
- driftManager.storeChangeSet(newResource.getId(), File.createTempFile("drift-cs-2", ".test"));
+ File changeset2 = new File("./src/test/resources/org/rhq/enterprise/server/drift/changeset-2.zip");
+ assertTrue(changeset2.exists());
+ driftManager.storeChangeSet(newResource.getId(), changeset2);
c.addSortVersion(PageOrdering.ASC);
changeSets = driftManager.findDriftChangeSetsByCriteria(overlord, c);
assertEquals(2, changeSets.size());
@@ -132,11 +136,12 @@ public class DriftManagerBeanTest extends AbstractEJB3Test {
assertEquals(1, changeSet.getVersion());
assertEquals(1, changeSet.getDrifts().size());
Drift drift = changeSet.getDrifts().iterator().next();
- assertEquals("0", drift.getOldDriftFile().getSha256());
- assertEquals("1", drift.getNewDriftFile().getSha256());
+ assertEquals("test/dir/filename.ext", drift.getPath());
+ assertEquals("aaaaa", drift.getOldDriftFile().getSha256());
+ assertEquals("bbbbb", drift.getNewDriftFile().getSha256());
assertEquals(DriftCategory.FILE_CHANGED, drift.getCategory());
- driftFile = driftManager.getDriftFile(overlord, "1");
+ driftFile = driftManager.getDriftFile(overlord, "bbbbb");
assertNotNull(driftFile);
assertEquals(DriftFileStatus.REQUESTED, driftFile.getStatus());
}
@@ -210,17 +215,7 @@ public class DriftManagerBeanTest extends AbstractEJB3Test {
try {
ResourceManagerLocal resourceManager = LookupUtil.getResourceManager();
- // first, get entity for group removal
- //getTransactionManager().begin();
- //em = getEntityManager();
-
- //Resource res = em.find(Resource.class, resource.getId());
-
- //getTransactionManager().commit();
- //em.close();
- //em = null;
-
- // then invoke bulk delete on the resource to remove any dependencies not defined in the hibernate entity model
+ // invoke bulk delete on the resource to remove any dependencies not defined in the hibernate entity model
// perform in-band and out-of-band work in quick succession
List<Integer> deletedIds = resourceManager.uninventoryResource(overlord, resource.getId());
for (Integer deletedResourceId : deletedIds) {
diff --git a/modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/drift/changeset-1.txt b/modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/drift/changeset-1.txt
new file mode 100644
index 0000000..9aca9f8
--- /dev/null
+++ b/modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/drift/changeset-1.txt
@@ -0,0 +1,2 @@
+test/dir 1
+aaaaa 0 filename.ext A
diff --git a/modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/drift/changeset-1.zip b/modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/drift/changeset-1.zip
new file mode 100644
index 0000000..81ead4d
Binary files /dev/null and b/modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/drift/changeset-1.zip differ
diff --git a/modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/drift/changeset-2.txt b/modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/drift/changeset-2.txt
new file mode 100644
index 0000000..6eeefc9
--- /dev/null
+++ b/modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/drift/changeset-2.txt
@@ -0,0 +1,2 @@
+test\dir 1
+bbbbb aaaaa filename.ext C
diff --git a/modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/drift/changeset-2.zip b/modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/drift/changeset-2.zip
new file mode 100644
index 0000000..a6c60eb
Binary files /dev/null and b/modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/drift/changeset-2.zip differ
12 years, 11 months
[rhq] pom.xml
by ips
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
New commits:
commit 969095fc111bff5690a3102f506eedb0beaced98
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Thu Jun 16 11:25:27 2011 -0400
downgrade JNA from 3.2.5 to 3.2.3, since 3.2.3 is the latest version available
in the central repo
diff --git a/pom.xml b/pom.xml
index b7f249e..c47cd49 100644
--- a/pom.xml
+++ b/pom.xml
@@ -94,7 +94,7 @@
<sigar.version>1.6.5.132</sigar.version>
<sigar.zip.version>1.6.5</sigar.zip.version>
<quartz.version>1.6.5</quartz.version>
- <jna.version>3.2.5</jna.version>
+ <jna.version>3.2.3</jna.version>
<twitter4j.version>2.1.2</twitter4j.version>
<commons-codec.version>1.4</commons-codec.version>
<testng.version>5.13.1</testng.version>
12 years, 11 months
[rhq] Branch 'nonplatform-bundles-644328' - modules/core modules/enterprise modules/plugins
by mazz
modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/PluginMetadataParser.java | 4 -
modules/core/client-api/src/main/resources/rhq-plugin.xsd | 15 +++-
modules/core/domain/src/main/java/org/rhq/core/domain/bundle/ResourceTypeBundleConfiguration.java | 35 ++++++++--
modules/core/plugin-container/src/test/java/org/rhq/core/pc/bundle/BundleManagerTest.java | 8 +-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/GetDestinationStep.java | 25 +++----
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/bundle/BundleManagerBeanTest.java | 2
modules/plugins/jboss-as/src/main/resources/META-INF/rhq-plugin.xml | 4 -
modules/plugins/platform/src/main/resources/META-INF/rhq-plugin.xml | 2
8 files changed, 64 insertions(+), 31 deletions(-)
New commits:
commit 5a2ef20fb74acbf56c3ea303852c90e440e5e910
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Jun 16 09:56:42 2011 -0400
BZ 644328 - add description attribute to the bundle-target schema stuff so
we can add help test to the deploy wizard. change the Base Location drop down
menu to a radio button group.
diff --git a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/PluginMetadataParser.java b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/PluginMetadataParser.java
index c75111b..2d6ba8b 100644
--- a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/PluginMetadataParser.java
+++ b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/PluginMetadataParser.java
@@ -542,7 +542,9 @@ public class PluginMetadataParser {
String name = destBaseDir.getName();
String valueContext = destBaseDir.getValueContext();
String valueName = destBaseDir.getValueName();
- bundleConfiguration.addBundleDestinationBaseDirectory(name, valueContext, valueName);
+ String description = destBaseDir.getDescription();
+ bundleConfiguration.addBundleDestinationBaseDirectory(name, valueContext, valueName,
+ description);
}
resourceType.setResourceTypeBundleConfiguration(bundleConfiguration);
}
diff --git a/modules/core/client-api/src/main/resources/rhq-plugin.xsd b/modules/core/client-api/src/main/resources/rhq-plugin.xsd
index c06b949..dc4a572 100644
--- a/modules/core/client-api/src/main/resources/rhq-plugin.xsd
+++ b/modules/core/client-api/src/main/resources/rhq-plugin.xsd
@@ -530,10 +530,17 @@
</xs:sequence>
<xs:attribute name="name" type="xs:string" use="required">
<xs:annotation>
- <xs:documentation>
- The name given to identify this particular destination base directory.
- </xs:documentation>
- </xs:annotation>
+ <xs:documentation>
+ The name given to identify this particular destination base directory.
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute name="description" type="xs:string" use="optional">
+ <xs:annotation>
+ <xs:documentation>
+ An explanation to the user to describe what this destination location is.
+ </xs:documentation>
+ </xs:annotation>
</xs:attribute>
</xs:complexType>
</xs:element>
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/ResourceTypeBundleConfiguration.java b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/ResourceTypeBundleConfiguration.java
index 4ab5755..415383c 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/ResourceTypeBundleConfiguration.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/ResourceTypeBundleConfiguration.java
@@ -36,7 +36,7 @@ import org.rhq.core.domain.configuration.PropertySimple;
* the bundle destination base directory definitions (the base locations where bundles can be deployed for resources that
* are of the given type). Rather than expect users of this object to know the internal properties stored in the config, this
* object has strongly-typed methods to extract the properties into more easily consumable POJOs, such as
- * {@link #getBundleDestinationBaseDirectory()} and {@link #addBundleDestinationBaseDirectory(String, String)}.
+ * {@link #getBundleDestinationBaseDirectory()} and {@link #addBundleDestinationBaseDirectory(String, String, String, String)}.
*
* @author John Mazzitelli
*/
@@ -48,6 +48,7 @@ public class ResourceTypeBundleConfiguration implements Serializable {
private static final String BUNDLE_DEST_BASE_DIR_NAME_NAME = "name";
private static final String BUNDLE_DEST_BASE_DIR_VALUE_CONTEXT_NAME = "valueContext";
private static final String BUNDLE_DEST_BASE_DIR_VALUE_NAME_NAME = "valueName";
+ private static final String BUNDLE_DEST_BASE_DIR_DESCRIPTION_NAME = "description";
// this is the actual bundle configuration - see ResourceType.bundleConfiguration
private Configuration bundleConfiguration;
@@ -102,7 +103,9 @@ public class ResourceTypeBundleConfiguration implements Serializable {
String name = map.getSimpleValue(BUNDLE_DEST_BASE_DIR_NAME_NAME, null);
String valueContext = map.getSimpleValue(BUNDLE_DEST_BASE_DIR_VALUE_CONTEXT_NAME, null);
String valueName = map.getSimpleValue(BUNDLE_DEST_BASE_DIR_VALUE_NAME_NAME, null);
- BundleDestinationBaseDirectory bdbd = new BundleDestinationBaseDirectory(name, valueContext, valueName);
+ String description = map.getSimpleValue(BUNDLE_DEST_BASE_DIR_DESCRIPTION_NAME, null);
+ BundleDestinationBaseDirectory bdbd = new BundleDestinationBaseDirectory(name, valueContext, valueName,
+ description);
retVal.add(bdbd);
}
@@ -118,14 +121,16 @@ public class ResourceTypeBundleConfiguration implements Serializable {
* in {@link BundleDestinationBaseDirectory.Context}
* @param valueName the name of the property found in the given context where the value
* of the base directory is
+ * @param description optional explanation for what this destination location is
*/
- public void addBundleDestinationBaseDirectory(String name, String valueContext, String valueName) {
+ public void addBundleDestinationBaseDirectory(String name, String valueContext, String valueName, String description) {
if (this.bundleConfiguration == null) {
throw new NullPointerException("bundleConfiguration == null");
}
// we create this just to make sure the context and value are valid. An exception will be thrown if they are not.
- BundleDestinationBaseDirectory destBaseDir = new BundleDestinationBaseDirectory(name, valueContext, valueName);
+ BundleDestinationBaseDirectory destBaseDir = new BundleDestinationBaseDirectory(name, valueContext, valueName,
+ description);
PropertyList propertyList = this.bundleConfiguration.getList(BUNDLE_DEST_BASE_DIR_LIST_NAME);
if (propertyList == null) {
@@ -138,10 +143,18 @@ public class ResourceTypeBundleConfiguration implements Serializable {
.getValueContext().name());
PropertySimple valueNameProp = new PropertySimple(BUNDLE_DEST_BASE_DIR_VALUE_NAME_NAME, destBaseDir
.getValueName());
+
PropertyMap map = new PropertyMap(BUNDLE_DEST_BASE_DIR_LIST_ITEM_NAME);
map.put(nameProp);
map.put(valueContextProp);
map.put(valueNameProp);
+
+ if (destBaseDir.getDescription() != null) {
+ PropertySimple descriptionProp = new PropertySimple(BUNDLE_DEST_BASE_DIR_DESCRIPTION_NAME, destBaseDir
+ .getDescription());
+ map.put(descriptionProp);
+ }
+
propertyList.add(map);
return;
}
@@ -200,14 +213,16 @@ public class ResourceTypeBundleConfiguration implements Serializable {
private final String name;
private final Context valueContext;
private final String valueName;
+ private final String description;
- public BundleDestinationBaseDirectory(String name, String valueContext, String valueName) {
+ public BundleDestinationBaseDirectory(String name, String valueContext, String valueName, String description) {
if (name == null) {
throw new NullPointerException("name == null");
}
this.name = name;
this.valueContext = Context.valueOf(valueContext); // will throw an exception if its not valid, which is what we want
this.valueName = valueName;
+ this.description = description;
}
/**
@@ -233,11 +248,19 @@ public class ResourceTypeBundleConfiguration implements Serializable {
return valueName;
}
+ /**
+ * @return an explanation for what this directory location is
+ */
+ public String getDescription() {
+ return description;
+ }
+
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("BundleDestinationBaseDirectory [name=").append(name).append(", valueContext=").append(
- valueContext).append(", valueName=").append(valueName).append("]");
+ valueContext).append(", valueName=").append(valueName).append(", description=").append(description)
+ .append("]");
return builder.toString();
}
diff --git a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/bundle/BundleManagerTest.java b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/bundle/BundleManagerTest.java
index 9942cb3..c69331c 100644
--- a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/bundle/BundleManagerTest.java
+++ b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/bundle/BundleManagerTest.java
@@ -401,22 +401,22 @@ public class BundleManagerTest {
// measurement trait value, or strictly on the root file system (using no resource specific value)
ResourceTypeBundleConfiguration rtbc = new ResourceTypeBundleConfiguration(new Configuration());
rtbc.addBundleDestinationBaseDirectory(BUNDLE_CONFIG_NAME_FS, Context.fileSystem.name(),
- BUNDLE_CONFIG_CONTEXT_VALUE_FS);
+ BUNDLE_CONFIG_CONTEXT_VALUE_FS, null);
serverTypeFS.setResourceTypeBundleConfiguration(rtbc);
rtbc = new ResourceTypeBundleConfiguration(new Configuration());
rtbc.addBundleDestinationBaseDirectory(BUNDLE_CONFIG_NAME_PC, Context.pluginConfiguration.name(),
- BUNDLE_CONFIG_CONTEXT_VALUE_PC);
+ BUNDLE_CONFIG_CONTEXT_VALUE_PC, null);
serverTypePC.setResourceTypeBundleConfiguration(rtbc);
rtbc = new ResourceTypeBundleConfiguration(new Configuration());
rtbc.addBundleDestinationBaseDirectory(BUNDLE_CONFIG_NAME_RC, Context.resourceConfiguration.name(),
- BUNDLE_CONFIG_CONTEXT_VALUE_RC);
+ BUNDLE_CONFIG_CONTEXT_VALUE_RC, null);
serverTypeRC.setResourceTypeBundleConfiguration(rtbc);
rtbc = new ResourceTypeBundleConfiguration(new Configuration());
rtbc.addBundleDestinationBaseDirectory(BUNDLE_CONFIG_NAME_MT, Context.measurementTrait.name(),
- BUNDLE_CONFIG_CONTEXT_VALUE_MT);
+ BUNDLE_CONFIG_CONTEXT_VALUE_MT, null);
serverTypeMT.setResourceTypeBundleConfiguration(rtbc);
// each different resource needs to specify where exactly it wants the bundles deployed
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/GetDestinationStep.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/GetDestinationStep.java
index cdba5cb..8d7acfd 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/GetDestinationStep.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/GetDestinationStep.java
@@ -18,14 +18,14 @@
*/
package org.rhq.enterprise.gui.coregui.client.bundle.deploy;
-import java.util.Arrays;
+import java.util.LinkedHashMap;
import java.util.Set;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.form.DynamicForm;
import com.smartgwt.client.widgets.form.fields.CanvasItem;
-import com.smartgwt.client.widgets.form.fields.SelectItem;
+import com.smartgwt.client.widgets.form.fields.RadioGroupItem;
import com.smartgwt.client.widgets.form.fields.TextAreaItem;
import com.smartgwt.client.widgets.form.fields.TextItem;
import com.smartgwt.client.widgets.form.fields.events.ChangedEvent;
@@ -119,12 +119,10 @@ public class GetDestinationStep extends AbstractWizardStep {
}
});
- final SelectItem destBaseDirItem = new SelectItem("destBaseDir", MSG
+ final RadioGroupItem destBaseDirItem = new RadioGroupItem("destBaseDir", MSG
.view_bundle_deployWizard_getDest_destBaseDirName());
destBaseDirItem.setWidth(300);
destBaseDirItem.setRequired(true);
- destBaseDirItem.setAllowEmptyValue(false);
- destBaseDirItem.setMultiple(false);
destBaseDirItem.setDisabled(true);
destBaseDirItem.addChangedHandler(new ChangedHandler() {
public void onChanged(ChangedEvent event) {
@@ -166,20 +164,23 @@ public class GetDestinationStep extends AbstractWizardStep {
new AsyncCallback<ResourceTypeBundleConfiguration>() {
public void onSuccess(ResourceTypeBundleConfiguration result) {
// populate the base location drop down with all the possible dest base directories
- String[] menuItems = null;
+ LinkedHashMap<String, String> menuItems = null;
if (result != null) {
Set<BundleDestinationBaseDirectory> baseDirs;
baseDirs = result.getBundleDestinationBaseDirectories();
if (baseDirs != null && baseDirs.size() > 0) {
- menuItems = new String[baseDirs.size()];
- int i = 0;
+ String defaultSelectedItem = null;
+ menuItems = new LinkedHashMap<String, String>(baseDirs.size());
for (BundleDestinationBaseDirectory baseDir : baseDirs) {
- menuItems[i++] = baseDir.getName();
+ menuItems.put(baseDir.getName(), "<b>" + baseDir.getName() + "</b>: "
+ + baseDir.getDescription());
+ if (defaultSelectedItem == null) {
+ defaultSelectedItem = baseDir.getName();
+ }
}
- Arrays.sort(menuItems); // just so they are ordered in the drop down list
destBaseDirItem.setValueMap(menuItems);
- destBaseDirItem.setValue(menuItems[0]);
- dest.setDestinationBaseDirectoryName(menuItems[0]);
+ destBaseDirItem.setValue(defaultSelectedItem);
+ dest.setDestinationBaseDirectoryName(defaultSelectedItem);
}
}
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/bundle/BundleManagerBeanTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/bundle/BundleManagerBeanTest.java
index fa55ec1..40a0168 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/bundle/BundleManagerBeanTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/bundle/BundleManagerBeanTest.java
@@ -1053,7 +1053,7 @@ public class BundleManagerBeanTest extends AbstractEJB3Test {
ResourceTypeBundleConfiguration rtbc = new ResourceTypeBundleConfiguration(new Configuration());
rtbc.addBundleDestinationBaseDirectory(TEST_DESTBASEDIR_NAME,
ResourceTypeBundleConfiguration.BundleDestinationBaseDirectory.Context.pluginConfiguration.name(),
- TEST_BUNDLE_DESTBASEDIR_PROP);
+ TEST_BUNDLE_DESTBASEDIR_PROP, null);
resourceType.setResourceTypeBundleConfiguration(rtbc);
resourceType.setPluginConfigurationDefinition(pcDef);
diff --git a/modules/plugins/jboss-as/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/jboss-as/src/main/resources/META-INF/rhq-plugin.xml
index dd1d008..a151196 100644
--- a/modules/plugins/jboss-as/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/jboss-as/src/main/resources/META-INF/rhq-plugin.xml
@@ -258,11 +258,11 @@
</content>
<bundle-target>
- <destination-base-dir name="Install Directory">
+ <destination-base-dir name="Install Directory" description="The top directory where the JBossAS Server is installed. (i.e. the value found in the 'JBoss Home Directory' connection property)">
<value-context>pluginConfiguration</value-context>
<value-name>jbossHomeDir</value-name>
</destination-base-dir>
- <destination-base-dir name="Configuration Set Directory">
+ <destination-base-dir name="Profile Directory" description="The profile configuration directory such as 'default', 'minimal', 'production' or similar location. (i.e. the value found in the 'Configuration Path' connection property)">
<value-context>pluginConfiguration</value-context>
<value-name>configurationPath</value-name>
</destination-base-dir>
diff --git a/modules/plugins/platform/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/platform/src/main/resources/META-INF/rhq-plugin.xml
index 3c56aa4..40f6975 100644
--- a/modules/plugins/platform/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/platform/src/main/resources/META-INF/rhq-plugin.xml
@@ -33,7 +33,7 @@
'>
<!ENTITY bundleTarget '
<bundle-target>
- <destination-base-dir name="Root File System">
+ <destination-base-dir name="Root File System" description="The top root directory on the platform (/)" >
<value-context>fileSystem</value-context>
<value-name>/</value-name>
</destination-base-dir>
12 years, 11 months