modules/core/arquillian-integration/container/src/main/java/org/rhq/test/arquillian/FakeServerInventory.java
| 6
modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/ConfigurationMetadataParser.java
| 9
modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/PluginMetadataParser.java
| 6
modules/core/dbutils/pom.xml
| 2
modules/core/dbutils/src/main/scripts/dbsetup/config-schema.xml
| 2
modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
| 3
modules/core/domain/src/main/java/org/rhq/core/domain/configuration/Configuration.java
| 77 +
modules/core/domain/src/main/java/org/rhq/core/domain/configuration/definition/ConfigurationDefinition.java
| 10
modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java
| 2
modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/RuntimeDiscoveryExecutor.java
| 2
modules/core/plugin-container/src/main/java/org/rhq/core/pc/upgrade/ResourceUpgradeDelegate.java
| 16
modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/FakeServerInventory.java
| 4
modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/ResourceUpgradeFailureHandlingTest.java
| 101 +-
modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/D3GroupGraphListView.java
| 1
modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
| 3
modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/monitoring/metric/MetricsGroupTableView.java
| 408 ++++++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/monitoring/metric/MetricsGroupView.java
| 193 ++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/monitoring/metric/MetricsGroupViewDataSource.java
| 314 +++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricAvailabilityView.java
| 223 +++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricsGridFieldName.java
| 63 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricsResourceView.java
| 3
modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricsTableView.java
| 30
modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricsViewDataSource.java
| 56 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/ResourceMetricAvailabilityView.java
| 224 -----
modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/util/rpc/TrackingRequestCallback.java
| 6
modules/enterprise/remoting/cli/src/etc/rhq-cli-env.sh
| 10
modules/enterprise/remoting/cli/src/etc/rhq-cli.sh
| 67 -
modules/enterprise/server/xml-schemas/src/main/java/org/rhq/enterprise/server/xmlschema/ConfigurationInstanceDescriptorUtil.java
| 8
modules/enterprise/server/xml-schemas/src/test/java/org/rhq/enterprise/server/xmlschema/ConfigurationInstanceDescriptorUtilTest.java
| 110 +-
29 files changed, 1506 insertions(+), 453 deletions(-)
New commits:
commit e0e6a56d96c39dd84d18b0111abcc5328bfaf382
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Tue Dec 17 17:03:44 2013 +0100
Various changes to fix (most) test suite issues.
diff --git
a/modules/core/arquillian-integration/container/src/main/java/org/rhq/test/arquillian/FakeServerInventory.java
b/modules/core/arquillian-integration/container/src/main/java/org/rhq/test/arquillian/FakeServerInventory.java
index 94654ee..dd44e81 100644
---
a/modules/core/arquillian-integration/container/src/main/java/org/rhq/test/arquillian/FakeServerInventory.java
+++
b/modules/core/arquillian-integration/container/src/main/java/org/rhq/test/arquillian/FakeServerInventory.java
@@ -63,7 +63,7 @@ import org.rhq.core.domain.resource.ResourceType;
* own. It is only meant as a helper.
* <p>
* This impl uses mockito for defining the answers to various calls.
- *
+ *
* @author Lukas Krejci
*/
public class FakeServerInventory {
@@ -75,7 +75,7 @@ public class FakeServerInventory {
* for the complete discovery to finish in case your
* fake server commits some resources (which starts off
* asynchronous discovery of children).
- *
+ *
*
* @author Lukas Krejci
*/
@@ -554,7 +554,7 @@ public class FakeServerInventory {
if (parent != null && parent != Resource.ROOT) {
parent = fakePersist(agentSideResource.getParentResource(),
requiredInventoryStatus, inProgressUUIds);
persisted.setParentResource(parent);
- parent.getChildResources().add(persisted);
+ parent.addChildResource(persisted);
} else {
persisted.setParentResource(parent);
}
diff --git
a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/ConfigurationMetadataParser.java
b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/ConfigurationMetadataParser.java
index d40d82d..f7dbb73 100644
---
a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/ConfigurationMetadataParser.java
+++
b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/ConfigurationMetadataParser.java
@@ -29,6 +29,7 @@ import javax.xml.bind.JAXBElement;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.jetbrains.annotations.NotNull;
import org.rhq.core.clientapi.agent.configuration.ConfigurationUtility;
import org.rhq.core.clientapi.descriptor.configuration.ConfigurationDescriptor;
@@ -79,13 +80,17 @@ public class ConfigurationMetadataParser {
private static Log log = LogFactory.getLog("ConfigurationMetadataParser");
- public static ConfigurationDefinition parse(String configurationName,
ConfigurationDescriptor descriptor)
+ public static ConfigurationDefinition parse(@NotNull String configurationName,
ConfigurationDescriptor descriptor)
throws InvalidPluginDescriptorException {
if (descriptor == null) {
return null;
}
- ConfigurationDefinition configurationDefinition = new
ConfigurationDefinition(configurationName.intern(),
+ if (configurationName==null) {
+ throw new IllegalArgumentException("ConfigurationName must not be
null");
+ }
+
+ ConfigurationDefinition configurationDefinition = new
ConfigurationDefinition(configurationName,
descriptor.getNotes());
configurationDefinition.setConfigurationFormat(getConfigurationFormat(descriptor));
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 e5d58b2..c4b1229 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
@@ -769,7 +769,11 @@ public class PluginMetadataParser {
private void registerResourceTypeAndComponentClasses(ResourceType resourceType,
String discoveryClass,
String componentClass) {
this.resourceTypes.add(resourceType);
- this.componentClasses.put(resourceType, componentClass.intern());
+ if (componentClass!=null) {
+ this.componentClasses.put(resourceType, componentClass.intern());
+ } else {
+ this.componentClasses.put(resourceType, null);
+ }
if (discoveryClass != null) {
this.discoveryClasses.put(resourceType, discoveryClass.intern());
}
diff --git a/modules/core/dbutils/pom.xml b/modules/core/dbutils/pom.xml
index 779f7b3..95eb62a 100644
--- a/modules/core/dbutils/pom.xml
+++ b/modules/core/dbutils/pom.xml
@@ -17,7 +17,7 @@
<description>Database schema setup, upgrade and other
utilities</description>
<properties>
- <db.schema.version>2.142</db.schema.version>
+ <db.schema.version>2.143</db.schema.version>
<rhq.ds.type-mapping>${rhq.test.ds.type-mapping}</rhq.ds.type-mapping>
<rhq.ds.server-name>${rhq.test.ds.server-name}</rhq.ds.server-name>
<rhq.ds.db-name>${rhq.test.ds.db-name}</rhq.ds.db-name>
diff --git a/modules/core/dbutils/src/main/scripts/dbsetup/config-schema.xml
b/modules/core/dbutils/src/main/scripts/dbsetup/config-schema.xml
index b484d2b..303b991 100644
--- a/modules/core/dbutils/src/main/scripts/dbsetup/config-schema.xml
+++ b/modules/core/dbutils/src/main/scripts/dbsetup/config-schema.xml
@@ -127,7 +127,7 @@
<table name="RHQ_RAW_CONFIG">
<column name="ID" type="INTEGER" required="true"
default="sequence-only" initial="10001"
primarykey="true"/>
- <column name="CONFIG_ID" type="INTEGER"
required="true" references="RHQ_CONFIG(ID)"/>
+ <column name="CONFIG_ID" type="INTEGER"
required="false" references="RHQ_CONFIG(ID)"/>
<column name="PATH" type="VARCHAR2"
required="false" size="512"/>
<column name="CONTENTS" type="CLOB"
required="true"/>
<column name="SHA256" type="VARCHAR2" size="64"
required="true"/>
diff --git a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
index dc7abfb..3d66d1d 100644
--- a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
+++ b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
@@ -2286,6 +2286,9 @@
<schemaSpec version="2.142">
<schema-javaTask
className="SystemSettingsPasswordObfuscationTask" />
</schemaSpec>
+ <schemaSpec version="2.143">
+ <schema-alterColumn table="RHQ_RAW_CONFIG"
column="config_ID" nullable="true"/>
+ </schemaSpec>
</dbupgrade>
</target>
</project>
diff --git
a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/Configuration.java
b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/Configuration.java
index 64dc441..65d760e 100644
---
a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/Configuration.java
+++
b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/Configuration.java
@@ -30,6 +30,7 @@ import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
+import java.util.NoSuchElementException;
import java.util.Set;
import javax.persistence.Column;
@@ -402,27 +403,33 @@ public class Configuration implements Serializable, Cloneable,
AbstractPropertyM
@Override
public int size() {
- return properties.size();
+ return properties==null ? 0: properties.size();
}
@Override
public boolean isEmpty() {
- return properties.isEmpty();
+ return properties == null || properties.isEmpty();
}
@Override
public boolean contains(Object o) {
- return properties.containsValue(o);
+ return properties==null ? false : properties.containsValue(o);
}
@Override
public Iterator<Property> iterator() {
- return properties.values().iterator();
+ if (properties == null) {
+ // TODO replace with Collections.emptyIterator(); when we require java 7
+ return Configuration.emptyIterator();
+ }
+ else {
+ return properties.values().iterator();
+ }
}
@Override
public Object[] toArray() {
- return properties.values().toArray();
+ return properties==null ? new Object[]{} :properties.values().toArray();
}
@Override
@@ -481,7 +488,9 @@ public class Configuration implements Serializable, Cloneable,
AbstractPropertyM
@Override
public void clear() {
- properties.clear();
+ if (properties!=null) {
+ properties.clear();
+ }
}
@Override
@@ -510,9 +519,9 @@ public class Configuration implements Serializable, Cloneable,
AbstractPropertyM
private transient PropertiesProxy propertiesProxy;
- @OneToMany(mappedBy = "configuration", fetch = FetchType.EAGER)
+ @OneToMany(mappedBy = "configuration", fetch = FetchType.LAZY)
@Cascade({ CascadeType.PERSIST, CascadeType.MERGE, CascadeType.DELETE_ORPHAN })
- private Set<RawConfiguration> rawConfigurations = new
HashSet<RawConfiguration>();
+ private Set<RawConfiguration> rawConfigurations;
@Column(name = "NOTES")
private String notes;
@@ -852,7 +861,7 @@ public class Configuration implements Serializable, Cloneable,
AbstractPropertyM
rawConfiguration.setConfiguration(null);
}
if (rawConfigurations.isEmpty()) {
- rawConfigurations = null;
+ rawConfigurations = Collections.emptySet();
}
return removed;
}
@@ -982,16 +991,34 @@ public class Configuration implements Serializable, Cloneable,
AbstractPropertyM
Configuration that = (Configuration) obj;
+ if (this.properties == null || this.properties.isEmpty()){
+ if ( that.properties== null || that.properties.isEmpty()) {
+ return true;
+ }
+ else {
+ return false;
+ }
+ } else {
+ if (!this.properties.equals(that.properties)) {
+ return false;
+ }
+ }
+
boolean rcEquals=true;
if (this.rawConfigurations!=null) {
rcEquals = this.getRawConfigurations().equals(that.getRawConfigurations());
- }
- return (this.properties.equals(that.properties)) && rcEquals;
+ }
+
+ return rcEquals;
}
@Override
public int hashCode() {
- int hc = properties.hashCode(); // TODO this requires loading of all properties
and is expensive
+ int hc = 1;
+ if (properties!=null ) {
+ hc = properties.hashCode(); // TODO this requires loading of all properties
and is expensive
+ }
+
if (rawConfigurations!=null) {
int rchc = rawConfigurations.hashCode() ;
hc = hc * rchc + 19;
@@ -1062,6 +1089,32 @@ public class Configuration implements Serializable, Cloneable,
AbstractPropertyM
* @return {@code Map<String, Property>}
*/
public Map<String, Property> getAllProperties() {
+ if (this.properties==null) {
+ return Collections.emptyMap();
+ }
return this.properties;
}
+
+
+ /*
+ ************ Copied from JDK7, as JDK6 is lacking that
+ * remove when we can require JDK 7
+ */
+
+ @SuppressWarnings("unchecked")
+ @Deprecated
+ public static <T> Iterator<T> emptyIterator() {
+ return (Iterator<T>) EmptyIterator.EMPTY_ITERATOR;
+ }
+
+ @Deprecated
+ private static class EmptyIterator<E> implements Iterator<E> {
+ static final EmptyIterator<Object> EMPTY_ITERATOR
+ = new EmptyIterator();
+
+ public boolean hasNext() { return false; }
+ public E next() { throw new NoSuchElementException(); }
+ public void remove() { throw new IllegalStateException(); }
+ }
+
}
diff --git
a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/definition/ConfigurationDefinition.java
b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/definition/ConfigurationDefinition.java
index d745b28..5e7457d 100644
---
a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/definition/ConfigurationDefinition.java
+++
b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/definition/ConfigurationDefinition.java
@@ -95,7 +95,7 @@ public class ConfigurationDefinition implements Serializable {
@MapKey(name = "name")
// base the insert-order on propDef Id (asc). Since rows are inserted in the order
presented in the
// plugin descriptor, iterating on the map (LinkedHashMap) will give us the same
ordering. So, unless
- // propDef.order is set and used for ordering by the accessing code, we'll
default to the descriptor order.
+ // propDef.order is set and used for ordering by the accessing code, we'll
default to the descriptor order.
@OrderBy
@org.hibernate.annotations.Cascade(org.hibernate.annotations.CascadeType.DELETE_ORPHAN)
@OneToMany(mappedBy = "configurationDefinition", cascade = CascadeType.ALL,
fetch = FetchType.EAGER)
@@ -104,7 +104,7 @@ public class ConfigurationDefinition implements Serializable {
// use the configTemplate name as the map key
@MapKey(name = "name")
// base the insert-order on configTemplate Id (asc). Since rows are inserted in the
order presented in the
- // plugin descriptor, iterating on the map (LinkedHashMap) will give us the same
ordering.
+ // plugin descriptor, iterating on the map (LinkedHashMap) will give us the same
ordering.
@OrderBy
@OneToMany(mappedBy = "configurationDefinition", cascade = CascadeType.ALL,
fetch = FetchType.EAGER)
private Map<String, ConfigurationTemplate> templates = new
LinkedHashMap<String, ConfigurationTemplate>();
@@ -118,7 +118,7 @@ public class ConfigurationDefinition implements Serializable {
}
public ConfigurationDefinition(@NotNull String name, String description) {
- this.name = name;
+ this.name = name.intern();
this.description = description;
}
@@ -136,7 +136,7 @@ public class ConfigurationDefinition implements Serializable {
}
public void setName(@NotNull String name) {
- this.name = name;
+ this.name = name.intern();
}
public String getDescription() {
@@ -151,7 +151,7 @@ public class ConfigurationDefinition implements Serializable {
* This property is currently used only for resource configuration which may support
structured config, raw
* config, both, or neither. For an older plugin that was implemented prior to raw
config support, this would be
* <code>null</code>.
- *
+ *
* @return The configuration format which may be structured, raw, or both.
<code>null</code> indicates an older
* plugin that was developed prior to raw configuration being supported.
*/
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 fd5713c..b5826da 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
@@ -3243,7 +3243,7 @@ public class InventoryManager extends AgentService implements
ContainerService,
if (parentResourceFromServer != null) {
ResourceContainer parentResourceContainer =
getResourceContainer(parentResourceFromServer);
if (parentResourceContainer == null) {
- parentResourceContainer =
getResourceContainer(parentResourceFromServer.getId());
+ parentResourceContainer =
getResourceContainer(parentResourceFromServer);
}
if (parentResourceContainer != null) {
parentResource = parentResourceContainer.getResource();
diff --git
a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/RuntimeDiscoveryExecutor.java
b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/RuntimeDiscoveryExecutor.java
index fd423a7..5265977 100644
---
a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/RuntimeDiscoveryExecutor.java
+++
b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/RuntimeDiscoveryExecutor.java
@@ -161,7 +161,7 @@ public class RuntimeDiscoveryExecutor implements Runnable,
Callable<InventoryRep
log.debug("Discovering child Resources for " + parent +
"...");
- ResourceContainer parentContainer =
this.inventoryManager.getResourceContainer(parent.getId());
+ ResourceContainer parentContainer =
this.inventoryManager.getResourceContainer(parent);
if (parentContainer == null) {
if (log.isDebugEnabled()) {
log.debug("Cannot perform service scan on parent [" + parent +
"] without a container");
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 503db49..303dcb6 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
@@ -47,12 +47,12 @@ import org.rhq.core.pluginapi.upgrade.ResourceUpgradeFacet;
/**
* This is a helper class to {@link InventoryManager} that takes care of resource
upgrade.
* Note that this class is not thread-safe in any manner.
- *
+ *
* This class must not call (explicitly or implicitly anywhere in its outgoing call
chain)
* any other plugin container manager other than the InventoryManager. This is because
* this delegate is called within the Inventory Manager's initialize method and
hence
* many other managers are not yet initialized themselves yet.
- *
+ *
* @author Lukas Krejci
*/
public class ResourceUpgradeDelegate {
@@ -73,7 +73,7 @@ public class ResourceUpgradeDelegate {
}
/**
- * Is the delegate enabled? In another words has the resource upgrade phase finished
in the {@link IventoryManager#initialize()}
+ * Is the delegate enabled? In another words has the resource upgrade phase finished
in the {@link InventoryManager#initialize()}
* method?
*/
public boolean enabled() {
@@ -96,7 +96,7 @@ public class ResourceUpgradeDelegate {
* If later on the upgrade fails to finish due to communication error with server or
the
* server doesn't approve some upgrades for whatever reason, the resources will
be restarted
* with the original data.
- *
+ *
* @param resourceContainer
* @return true if the resource was queued for upgrade with no problems,
* false if there was some problem upgrading and the resource container was
deactivated as
@@ -120,7 +120,7 @@ public class ResourceUpgradeDelegate {
/**
* Tells whether given resource had a upgrade failure during the {@link
#processAndQueue(ResourceContainer)} invocation.
- *
+ *
* @param resource the resource to test
* @return true if there was an error upgrading this resource, false otherwise
*/
@@ -131,7 +131,7 @@ public class ResourceUpgradeDelegate {
/**
* Tells whether at least one of the children with given resource type of the given
parent resource
* had an upgrade failure during {@link #processAndQueue(ResourceContainer)}
invocation.
- *
+ *
* @return true if at least one of the children of given type failed to upgrade,
false otherwise
*/
public boolean hasUpgradeFailedInChildren(Resource parentResource, ResourceType
childrenResourceType) {
@@ -157,7 +157,7 @@ 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.
+ //the user.
ResourceUpgradeRequest orig = findOriginal(request);
//orig should never be null, but let's be paranoid
@@ -193,7 +193,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
+ //the server makes to the upgrade data are applied to the
"vanilla" state
//of the resources. i.e we only want to make changes the server
approves.
for (ResourceUpgradeRequest request : originalResourceData) {
ResourceContainer container =
inventoryManager.getResourceContainer(request.getResourceId());
diff --git
a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/FakeServerInventory.java
b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/FakeServerInventory.java
index 3f2bbb9..cf9c1bb 100644
---
a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/FakeServerInventory.java
+++
b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/FakeServerInventory.java
@@ -210,7 +210,7 @@ public class FakeServerInventory {
ResourceError error = new ResourceError(resource,
ResourceErrorType.UPGRADE,
request.getUpgradeErrorMessage(),
request.getUpgradeErrorStackTrace(),
request.getTimestamp());
- resource.getResourceErrors().add(error);
+ resource.addResourceError(error);
}
responses.add(resp);
@@ -372,7 +372,7 @@ public class FakeServerInventory {
if (parent != null && parent != Resource.ROOT) {
parent = fakePersist(agentSideResource.getParentResource(), statusJudge,
inProgressUUIds);
persisted.setParentResource(parent);
- parent.getChildResources().add(persisted);
+ parent.addChildResource(persisted);
} else {
persisted.setParentResource(parent);
}
diff --git
a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/ResourceUpgradeFailureHandlingTest.java
b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/ResourceUpgradeFailureHandlingTest.java
index c559553..e86dda7 100644
---
a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/ResourceUpgradeFailureHandlingTest.java
+++
b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/ResourceUpgradeFailureHandlingTest.java
@@ -53,7 +53,7 @@ import org.rhq.test.pc.PluginContainerSetup;
* / \
* ParentDependency(parentdep) ParentDepSibling(parentsibling)
* / \
- * TestResource(test) TestResourceSibling(sibling)
+ * TestResource(test) TestResourceSibling(sibling)
* </pre>
* The dependencies in the above "chart" are formed using either the
<code><runs-inside></code>
* or <code>sourcePlugin/sourceType</code> approaches just to test that both
are handled correctly.
@@ -61,7 +61,7 @@ import org.rhq.test.pc.PluginContainerSetup;
* The <code>parentdep</code>, <code>parentsibling</code>,
<code>test</code> and <code>sibling</code> plugins are present
* in two versions and support the {@link ResourceUpgradeFacet}, while the rest of the
plugins is
* present only in single version.
- *
+ *
* @author Lukas Krejci
*/
@Test(singleThreaded = true, invocationCount = 1)
@@ -72,7 +72,7 @@ public class ResourceUpgradeFailureHandlingTest extends
AbstractResourceUpgradeH
private static final String FAILURE_ON_LEAF_TEST = "FAILURE_ON_LEAF_TEST";
private static final String FAILURE_ON_DEPENDENCIES_TEST =
"FAILURE_ON_DEPENDENCIES_TEST";
private static final String
RESOURCES_REVERTED_TO_ORIGINAL_STATE_AFTER_FAILED_UPGRAGE_TEST =
"RESOURCES_REVERTED_TO_ORIGINAL_STATE_AFTER_FAILED_UPGRAGE_TEST";
-
+
//plugin names
private static final String BASE_PLUGIN_NAME =
"classpath:///resource-upgrade-test-plugin-multi-base-1.0.0.jar";
private static final String PARENT_DEP_V1_PLUGIN_NAME =
"classpath:///resource-upgrade-test-plugin-multi-parentdep-1.0.0.jar";
@@ -101,17 +101,17 @@ public class ResourceUpgradeFailureHandlingTest extends
AbstractResourceUpgradeH
public void testSuccess_V1() throws Exception {
final FakeServerInventory inv = new FakeServerInventory();
setServerSideFake(SUCCESS_TEST, inv);
-
+
context.checking(new Expectations() {
{
defineDefaultExpectations(inv, this);
}
});
-
- //let the discovery run in V1
+
+ //let the discovery run in V1
startConfiguredPluginContainer();
}
-
+
@Test(dependsOnMethods = "testSuccess_V1")
@PluginContainerSetup(plugins = {TEST_V2_PLUGIN_NAME, PARENT_SIBLING_V2_PLUGIN_NAME,
BASE_PLUGIN_NAME, ROOT_PLUGIN_NAME, PARENT_DEP_V2_PLUGIN_NAME, SIBLING_V2_PLUGIN_NAME},
sharedGroup = SUCCESS_TEST, clearInventoryDat = false, numberOfInitialDiscoveries
= 3)
@@ -124,9 +124,9 @@ public class ResourceUpgradeFailureHandlingTest extends
AbstractResourceUpgradeH
});
startConfiguredPluginContainer();
-
+
Map<ResType, Set<Resource>> resources =
getResourcesFromInventory(inventory, ALL_TYPES);
-
+
checkPresenceOfResourceTypes(resources, ALL_TYPES);
checkNumberOfResources(resources, ROOT_TYPE, 1);
@@ -138,14 +138,14 @@ public class ResourceUpgradeFailureHandlingTest extends
AbstractResourceUpgradeH
checkResourcesUpgraded(resources.get(SIBLING_TYPE), 45);
checkResourcesUpgraded(resources.get(TEST_TYPE), 45);
}
-
+
@Test
- @PluginContainerSetup(plugins = {TEST_V1_PLUGIN_NAME, PARENT_SIBLING_V1_PLUGIN_NAME,
BASE_PLUGIN_NAME, ROOT_PLUGIN_NAME, PARENT_DEP_V1_PLUGIN_NAME, SIBLING_V1_PLUGIN_NAME},
+ @PluginContainerSetup(plugins = {TEST_V1_PLUGIN_NAME, PARENT_SIBLING_V1_PLUGIN_NAME,
BASE_PLUGIN_NAME, ROOT_PLUGIN_NAME, PARENT_DEP_V1_PLUGIN_NAME, SIBLING_V1_PLUGIN_NAME},
sharedGroup = FAILURE_ON_LEAF_TEST, clearDataDir = true,
numberOfInitialDiscoveries = 3)
public void testFailureOnLeaf_V1() throws Exception {
final FakeServerInventory inventory = new FakeServerInventory();
setServerSideFake(FAILURE_ON_LEAF_TEST, inventory);
-
+
context.checking(new Expectations() {
{
defineDefaultExpectations(inventory, this);
@@ -167,7 +167,7 @@ public class ResourceUpgradeFailureHandlingTest extends
AbstractResourceUpgradeH
}
@Test(dependsOnMethods = "testFailureOnLeaf_V1")
- @PluginContainerSetup(plugins = {TEST_V2_PLUGIN_NAME, PARENT_SIBLING_V2_PLUGIN_NAME,
BASE_PLUGIN_NAME, ROOT_PLUGIN_NAME, PARENT_DEP_V2_PLUGIN_NAME, SIBLING_V2_PLUGIN_NAME},
+ @PluginContainerSetup(plugins = {TEST_V2_PLUGIN_NAME, PARENT_SIBLING_V2_PLUGIN_NAME,
BASE_PLUGIN_NAME, ROOT_PLUGIN_NAME, PARENT_DEP_V2_PLUGIN_NAME, SIBLING_V2_PLUGIN_NAME},
sharedGroup = FAILURE_ON_LEAF_TEST, clearInventoryDat = false,
numberOfInitialDiscoveries = 3)
public void testFailureOnLeaf_V2() throws Exception {
final FakeServerInventory inventory = (FakeServerInventory)
getServerSideFake(FAILURE_ON_LEAF_TEST);
@@ -176,11 +176,11 @@ public class ResourceUpgradeFailureHandlingTest extends
AbstractResourceUpgradeH
defineDefaultExpectations(inventory, this);
}
});
-
+
startConfiguredPluginContainer();
-
+
Map<ResType, Set<Resource>> resources =
getResourcesFromInventory(inventory, ALL_TYPES);
-
+
checkPresenceOfResourceTypes(resources, ALL_TYPES);
checkNumberOfResources(resources, ROOT_TYPE, 1);
@@ -192,14 +192,14 @@ public class ResourceUpgradeFailureHandlingTest extends
AbstractResourceUpgradeH
Resource parent0 = findResourceWithOrdinal(PARENT_TYPE, 0);
Resource parent1 = findResourceWithOrdinal(PARENT_TYPE, 1);
Resource parent2 = findResourceWithOrdinal(PARENT_TYPE, 2);
-
+
Set<Resource> testsUnderParent0 =
filterResources(parent0.getChildResources(), TEST_TYPE);
Set<Resource> siblingsUnderParent0 =
filterResources(parent0.getChildResources(), SIBLING_TYPE);
Set<Resource> testsUnderParent1 =
filterResources(parent1.getChildResources(), TEST_TYPE);
Set<Resource> siblingsUnderParent1 =
filterResources(parent1.getChildResources(), SIBLING_TYPE);
Set<Resource> testsUnderParent2 =
filterResources(parent2.getChildResources(), TEST_TYPE);
Set<Resource> siblingsUnderParent2 =
filterResources(parent2.getChildResources(), SIBLING_TYPE);
-
+
//first check for the successful upgrades
checkResourcesUpgraded(testsUnderParent2, 15);
checkResourcesUpgraded(siblingsUnderParent2, 15);
@@ -212,8 +212,8 @@ public class ResourceUpgradeFailureHandlingTest extends
AbstractResourceUpgradeH
//check that the failed resources have the error attached to them
//we find the resource instance from the map provided to this method
- //because that map contains the resources as found on the server-side
- //(i.e. they include error objects).
+ //because that map contains the resources as found on the server-side
+ //(i.e. they include error objects).
Resource failedTest1 = getEqualFrom(resources.get(TEST_TYPE),
findResourceWithOrdinal(testsUnderParent0, 1));
Resource failedTest2 = getEqualFrom(resources.get(TEST_TYPE),
@@ -227,35 +227,35 @@ public class ResourceUpgradeFailureHandlingTest extends
AbstractResourceUpgradeH
findResourceWithOrdinal(siblingsUnderParent1, 1));
checkResourceFailedUpgrade(failedSibling);
- checkOthersUpgraded(siblingsUnderParent1, failedSibling);
+ checkOthersUpgraded(siblingsUnderParent1, failedSibling);
}
-
+
@Test
- @PluginContainerSetup(plugins = {TEST_V1_PLUGIN_NAME, PARENT_SIBLING_V1_PLUGIN_NAME,
BASE_PLUGIN_NAME, ROOT_PLUGIN_NAME, PARENT_DEP_V1_PLUGIN_NAME, SIBLING_V1_PLUGIN_NAME},
+ @PluginContainerSetup(plugins = {TEST_V1_PLUGIN_NAME, PARENT_SIBLING_V1_PLUGIN_NAME,
BASE_PLUGIN_NAME, ROOT_PLUGIN_NAME, PARENT_DEP_V1_PLUGIN_NAME, SIBLING_V1_PLUGIN_NAME},
sharedGroup = FAILURE_ON_DEPENDENCIES_TEST, clearDataDir = true,
numberOfInitialDiscoveries = 3)
public void testFailureOnDependencies_V1() throws Exception {
final FakeServerInventory inventory = new FakeServerInventory();
setServerSideFake(FAILURE_ON_DEPENDENCIES_TEST, inventory);
-
+
context.checking(new Expectations() {
{
defineDefaultExpectations(inventory, this);
}
});
-
- startConfiguredPluginContainer();
-
+
+ startConfiguredPluginContainer();
+
//in here we set up the failures that are going to happen when
//the v2 plugins are run
Resource parent = findResourceWithOrdinal(PARENT_DEP_TYPE, 0);
assertNotNull(parent, "Failed to find the parent to setup the failures
for.");
-
+
addChildrenToFail(parent, PARENT_TYPE, 0);
}
-
+
@Test(dependsOnMethods = "testFailureOnDependencies_V1")
- @PluginContainerSetup(plugins = {TEST_V2_PLUGIN_NAME, PARENT_SIBLING_V2_PLUGIN_NAME,
BASE_PLUGIN_NAME, ROOT_PLUGIN_NAME, PARENT_DEP_V2_PLUGIN_NAME, SIBLING_V2_PLUGIN_NAME},
+ @PluginContainerSetup(plugins = {TEST_V2_PLUGIN_NAME, PARENT_SIBLING_V2_PLUGIN_NAME,
BASE_PLUGIN_NAME, ROOT_PLUGIN_NAME, PARENT_DEP_V2_PLUGIN_NAME, SIBLING_V2_PLUGIN_NAME},
sharedGroup = FAILURE_ON_DEPENDENCIES_TEST, clearInventoryDat = false,
numberOfInitialDiscoveries = 3)
public void testFailureOnDependencies_V2() throws Exception {
final FakeServerInventory inventory = (FakeServerInventory)
getServerSideFake(FAILURE_ON_DEPENDENCIES_TEST);
@@ -264,11 +264,11 @@ public class ResourceUpgradeFailureHandlingTest extends
AbstractResourceUpgradeH
defineDefaultExpectations(inventory, this);
}
});
-
+
startConfiguredPluginContainer();
-
+
Map<ResType, Set<Resource>> resources =
getResourcesFromInventory(inventory, ALL_TYPES);
-
+
checkPresenceOfResourceTypes(resources, ALL_TYPES);
checkNumberOfResources(resources, ROOT_TYPE, 1);
@@ -277,7 +277,7 @@ public class ResourceUpgradeFailureHandlingTest extends
AbstractResourceUpgradeH
//check that the failed resources have the error attached to them
//we find the resource instance from the map provided to this method
- //because that map contains the resources as found on the server-side
+ //because that map contains the resources as found on the server-side
//(i.e. they include error objects).
Resource parent0 = getEqualFrom(resources.get(PARENT_TYPE),
findResourceWithOrdinal(PARENT_TYPE, 0));
Resource parent1 = getEqualFrom(resources.get(PARENT_TYPE),
findResourceWithOrdinal(PARENT_TYPE, 1));
@@ -288,37 +288,37 @@ public class ResourceUpgradeFailureHandlingTest extends
AbstractResourceUpgradeH
//v2 plugin discovers 3 resources but because parent0 failed to upgrade,
//the discovery shouldn't have occurred leaving us with the 2 already
existing resources.
checkNumberOfResources(resources, PARENT_TYPE, 2);
-
+
//parent1 upgraded ok, so discovering its children should have executed.
//this is v2, so we should find 15 of each.
checkResourcesUpgraded(filterResources(parent1.getChildResources(), TEST_TYPE),
15);
checkResourcesUpgraded(filterResources(parent1.getChildResources(),
SIBLING_TYPE), 15);
-
+
//these shouldn't have been upgraded. in v1 we had 10 resources of TEST_TYPE
//and 10 resources of SIBLING_TYPE and that's what we should be seeing
//now.
checkResourcesNotUpgraded(filterResources(parent0.getChildResources(),
TEST_TYPE), 10);
- checkResourcesNotUpgraded(filterResources(parent0.getChildResources(),
SIBLING_TYPE), 10);
+ checkResourcesNotUpgraded(filterResources(parent0.getChildResources(),
SIBLING_TYPE), 10);
}
-
+
@Test
- @PluginContainerSetup(plugins = {TEST_V1_PLUGIN_NAME, PARENT_SIBLING_V1_PLUGIN_NAME,
BASE_PLUGIN_NAME, ROOT_PLUGIN_NAME, PARENT_DEP_V1_PLUGIN_NAME, SIBLING_V1_PLUGIN_NAME},
+ @PluginContainerSetup(plugins = {TEST_V1_PLUGIN_NAME, PARENT_SIBLING_V1_PLUGIN_NAME,
BASE_PLUGIN_NAME, ROOT_PLUGIN_NAME, PARENT_DEP_V1_PLUGIN_NAME, SIBLING_V1_PLUGIN_NAME},
sharedGroup = RESOURCES_REVERTED_TO_ORIGINAL_STATE_AFTER_FAILED_UPGRAGE_TEST,
clearDataDir = true, numberOfInitialDiscoveries = 3)
public void testResourcesRevertedToOriginalStateAfterFailedUpgrade_V1() throws
Exception {
final FakeServerInventory inventory = new FakeServerInventory();
setServerSideFake(RESOURCES_REVERTED_TO_ORIGINAL_STATE_AFTER_FAILED_UPGRAGE_TEST,
inventory);
-
+
context.checking(new Expectations() {
{
defineDefaultExpectations(inventory, this);
}
});
-
- startConfiguredPluginContainer();
+
+ startConfiguredPluginContainer();
}
-
+
@Test(dependsOnMethods =
"testResourcesRevertedToOriginalStateAfterFailedUpgrade_V1")
- @PluginContainerSetup(plugins = {TEST_V2_PLUGIN_NAME, PARENT_SIBLING_V2_PLUGIN_NAME,
BASE_PLUGIN_NAME, ROOT_PLUGIN_NAME, PARENT_DEP_V2_PLUGIN_NAME, SIBLING_V2_PLUGIN_NAME},
+ @PluginContainerSetup(plugins = {TEST_V2_PLUGIN_NAME, PARENT_SIBLING_V2_PLUGIN_NAME,
BASE_PLUGIN_NAME, ROOT_PLUGIN_NAME, PARENT_DEP_V2_PLUGIN_NAME, SIBLING_V2_PLUGIN_NAME},
sharedGroup = RESOURCES_REVERTED_TO_ORIGINAL_STATE_AFTER_FAILED_UPGRAGE_TEST,
clearInventoryDat = false, numberOfInitialDiscoveries = 3)
public void testResourcesRevertedToOriginalStateAfterFailedUpgrade_V2() throws
Exception {
final FakeServerInventory inventory = (FakeServerInventory)
getServerSideFake(RESOURCES_REVERTED_TO_ORIGINAL_STATE_AFTER_FAILED_UPGRAGE_TEST);
@@ -329,11 +329,11 @@ public class ResourceUpgradeFailureHandlingTest extends
AbstractResourceUpgradeH
});
inventory.setFailUpgrade(true);
-
+
startConfiguredPluginContainer();
-
+
Map<ResType, Set<Resource>> resources =
getResourcesFromInventory(inventory, ALL_TYPES);
-
+
checkPresenceOfResourceTypes(resources, ALL_TYPES);
checkNumberOfResources(resources, ROOT_TYPE, 1);
@@ -343,7 +343,7 @@ public class ResourceUpgradeFailureHandlingTest extends
AbstractResourceUpgradeH
checkResourcesNotUpgraded(resources.get(PARENT_DEP_SIBLING_TYPE), 1);
checkResourcesNotUpgraded(resources.get(PARENT_TYPE), 2);
checkResourcesNotUpgraded(resources.get(SIBLING_TYPE), 20);
- checkResourcesNotUpgraded(resources.get(TEST_TYPE), 20);
+ checkResourcesNotUpgraded(resources.get(TEST_TYPE), 20);
}
protected static void checkPresenceOfResourceTypes(Map<ResType,
Set<Resource>> resources, Collection<ResType> expectedTypes) {
@@ -367,6 +367,9 @@ public class ResourceUpgradeFailureHandlingTest extends
AbstractResourceUpgradeH
ResourceContainer parentContainer =
inventoryManager.getResourceContainer(parent);
BaseResourceComponentInterface parentComponent = (BaseResourceComponentInterface)
parentContainer
.getResourceComponent();
+ if (parentComponent==null) {
+ throw new RuntimeException("Did not get a container for parent " +
parent.getName() + ", " + parent.getUuid() + ", " + parent.getId());
+ }
Map<String, Set<Integer>> childrenToFail = new HashMap<String,
Set<Integer>>();
Set<Integer> ordinals = new HashSet<Integer>();
@@ -416,7 +419,7 @@ public class ResourceUpgradeFailureHandlingTest extends
AbstractResourceUpgradeH
Set<Resource> rs = inventory.findResourcesByType(resType);
resources.put(type, rs);
}
-
+
return resources;
}
diff --git
a/modules/enterprise/server/xml-schemas/src/main/java/org/rhq/enterprise/server/xmlschema/ConfigurationInstanceDescriptorUtil.java
b/modules/enterprise/server/xml-schemas/src/main/java/org/rhq/enterprise/server/xmlschema/ConfigurationInstanceDescriptorUtil.java
index 7c6687a..8a74074 100644
---
a/modules/enterprise/server/xml-schemas/src/main/java/org/rhq/enterprise/server/xmlschema/ConfigurationInstanceDescriptorUtil.java
+++
b/modules/enterprise/server/xml-schemas/src/main/java/org/rhq/enterprise/server/xmlschema/ConfigurationInstanceDescriptorUtil.java
@@ -66,7 +66,7 @@ import
org.rhq.enterprise.server.xmlschema.generated.configuration.instance.Prop
import
org.rhq.enterprise.server.xmlschema.generated.configuration.instance.SimplePropertyInstanceDescriptor;
/**
- *
+ *
*
* @author Lukas Krejci
*/
@@ -420,7 +420,7 @@ public class ConfigurationInstanceDescriptorUtil {
ConfigurationInstanceDescriptor descriptor) {
ConfigurationAndDefinition ret = new ConfigurationAndDefinition();
Configuration configuration = new Configuration();
- ConfigurationDefinition definition = new ConfigurationDefinition(null,
null);
+ ConfigurationDefinition definition = new
ConfigurationDefinition("tmp", null);
ret.configuration = configuration;
ret.definition = definition;
@@ -514,7 +514,7 @@ public class ConfigurationInstanceDescriptorUtil {
ConfigurationDescriptor tmp = new ConfigurationDescriptor();
tmp.getConfigurationProperty().add(
new JAXBElement<ConfigurationProperty>(getTagName(def),
ConfigurationProperty.class, def));
- ConfigurationDefinition configDef =
ConfigurationMetadataParser.parse(null, tmp);
+ ConfigurationDefinition configDef =
ConfigurationMetadataParser.parse("null", tmp);
return configDef.getPropertyDefinitions().values().iterator().next();
} catch (InvalidPluginDescriptorException e) {
@@ -572,7 +572,7 @@ public class ConfigurationInstanceDescriptorUtil {
* configuration instance with defined values. This is used during the config
synchronization
* to output the default configuration of an importer directly in the export file so
that the
* users have an easy way of modifying that configuration.
- *
+ *
* @param definition
* @param configuration
* @return
diff --git
a/modules/enterprise/server/xml-schemas/src/test/java/org/rhq/enterprise/server/xmlschema/ConfigurationInstanceDescriptorUtilTest.java
b/modules/enterprise/server/xml-schemas/src/test/java/org/rhq/enterprise/server/xmlschema/ConfigurationInstanceDescriptorUtilTest.java
index 28f05de..a11be8f 100644
---
a/modules/enterprise/server/xml-schemas/src/test/java/org/rhq/enterprise/server/xmlschema/ConfigurationInstanceDescriptorUtilTest.java
+++
b/modules/enterprise/server/xml-schemas/src/test/java/org/rhq/enterprise/server/xmlschema/ConfigurationInstanceDescriptorUtilTest.java
@@ -59,7 +59,7 @@ import
org.rhq.enterprise.server.xmlschema.generated.configuration.instance.List
import
org.rhq.enterprise.server.xmlschema.generated.configuration.instance.SimplePropertyInstanceDescriptor;
/**
- *
+ *
*
* @author Lukas Krejci
*/
@@ -90,7 +90,7 @@ public class ConfigurationInstanceDescriptorUtilTest {
}
public void testSimplePropertyConversion() throws Exception {
- ConfigurationDefinition def = new ConfigurationDefinition(null, null);
+ ConfigurationDefinition def = new ConfigurationDefinition("null",
null);
PropertyDefinitionSimple propDef =
new PropertyDefinitionSimple("prop", "prop descr", true,
PropertySimpleType.BOOLEAN);
def.put(propDef);
@@ -117,7 +117,7 @@ public class ConfigurationInstanceDescriptorUtilTest {
}
public void testListOfSimplesPropertyConversion() throws Exception {
- ConfigurationDefinition def = new ConfigurationDefinition(null, null);
+ ConfigurationDefinition def = new ConfigurationDefinition("null",
null);
PropertyDefinitionList listDef =
new PropertyDefinitionList("list", "list descr", true,
new PropertyDefinitionSimple("prop", "prop descr",
false, PropertySimpleType.FLOAT));
@@ -160,7 +160,7 @@ public class ConfigurationInstanceDescriptorUtilTest {
}
public void testListOfMapsPropertyConversion() throws Exception {
- ConfigurationDefinition def = new ConfigurationDefinition(null, null);
+ ConfigurationDefinition def = new ConfigurationDefinition("null",
null);
PropertyDefinitionList listDef =
new PropertyDefinitionList("list", "list descr", true,
new PropertyDefinitionMap("map", "map descr", true,
new PropertyDefinitionSimple("prop1", "prop1 descr",
true, PropertySimpleType.BOOLEAN),
@@ -201,12 +201,12 @@ public class ConfigurationInstanceDescriptorUtilTest {
assertEquals(map1.getComplexValue().size(), 2, "Unexpected number of map
elements in the first map value.");
assertEquals(map2.getComplexValue().size(), 2, "Unexpected number of map
elements in the second map value.");
-
+
ComplexValueSimpleDescriptor value11 = (ComplexValueSimpleDescriptor)
map1.getComplexValue().get(0).getValue();
ComplexValueSimpleDescriptor value12 = (ComplexValueSimpleDescriptor)
map1.getComplexValue().get(1).getValue();
ComplexValueSimpleDescriptor value21 = (ComplexValueSimpleDescriptor)
map2.getComplexValue().get(0).getValue();
ComplexValueSimpleDescriptor value22 = (ComplexValueSimpleDescriptor)
map2.getComplexValue().get(1).getValue();
-
+
assertEquals(value11.getPropertyName(), "prop1", "Unexpected name
of the first property in the first map value");
assertEquals(value11.getValue(), "value1", "Unexpected value of
the first property in the first map value");
assertEquals(value12.getPropertyName(), "prop2", "Unexpected name
of the second property in the first map value");
@@ -215,7 +215,7 @@ public class ConfigurationInstanceDescriptorUtilTest {
assertEquals(value21.getValue(), "value2", "Unexpected value of
the first property in the second map value");
assertEquals(value22.getPropertyName(), "prop2", "Unexpected name
of the second property in the second map value");
assertEquals(value22.getValue(), "value2", "Unexpected value of
the second property in the second map value");
-
+
logInstance("List of maps", instance);
}
@@ -228,33 +228,33 @@ public class ConfigurationInstanceDescriptorUtilTest {
"<standaloneConfigurationInstance
xmlns:ci='urn:xmlns:rhq-configuration-instance'
xmlns:c='urn:xmlns:rhq-configuration'>" +
" <ci:simple-property value='42' name='my-name'
type='integer'/>" +
"</standaloneConfigurationInstance>";
-
+
ConfigurationInstanceDescriptor descriptor = (ConfigurationInstanceDescriptor)
CONFIGURATION_INSTANCE_UNMARSHALLER.unmarshal(new StringReader(xml));
-
+
ConfigurationInstanceDescriptorUtil.ConfigurationAndDefinition ccd =
ConfigurationInstanceDescriptorUtil.createConfigurationAndDefinition(descriptor);
-
+
ConfigurationDefinition def = ccd.definition;
Configuration conf = ccd.configuration;
-
+
assertEquals(def.getPropertyDefinitions().size(), 1, "Unexpected number of
defined properties");
assertEquals(conf.getProperties().size(), 1, "Unexpected number of
properties");
-
+
PropertyDefinition propDef = def.get("my-name");
Property prop = conf.get("my-name");
-
+
assertNotNull(propDef, "Could not find the expected property
definition");
assertNotNull(prop, "Could not find the expected property");
-
+
assertEquals(propDef.getClass(), PropertyDefinitionSimple.class, "Unexpected
type of the property definition");
assertEquals(prop.getClass(), PropertySimple.class, "Unexpecetd type of the
property");
-
+
PropertyDefinitionSimple simpleDef = (PropertyDefinitionSimple) propDef;
PropertySimple simpleProp = (PropertySimple) prop;
-
+
assertEquals(simpleDef.getType(), PropertySimpleType.INTEGER, "Unexpected
type of the simple property definition");
- assertEquals(simpleProp.getIntegerValue(), Integer.valueOf(42), "Unexpected
value of the simple property");
+ assertEquals(simpleProp.getIntegerValue(), Integer.valueOf(42), "Unexpected
value of the simple property");
}
-
+
public void testReverseListPropertyConversion() throws Exception {
String xml = "" +
"<standaloneConfigurationInstance
xmlns:ci='urn:xmlns:rhq-configuration-instance'
xmlns:c='urn:xmlns:rhq-configuration'>" +
@@ -269,44 +269,44 @@ public class ConfigurationInstanceDescriptorUtilTest {
"</standaloneConfigurationInstance>";
ConfigurationInstanceDescriptor descriptor = (ConfigurationInstanceDescriptor)
CONFIGURATION_INSTANCE_UNMARSHALLER.unmarshal(new StringReader(xml));
-
+
ConfigurationInstanceDescriptorUtil.ConfigurationAndDefinition ccd =
ConfigurationInstanceDescriptorUtil.createConfigurationAndDefinition(descriptor);
-
+
ConfigurationDefinition def = ccd.definition;
Configuration conf = ccd.configuration;
-
+
assertEquals(def.getPropertyDefinitions().size(), 1, "Unexpected number of
defined properties");
assertEquals(conf.getProperties().size(), 1, "Unexpected number of
properties");
PropertyDefinition propDef = def.get("list");
Property prop = conf.get("list");
-
+
assertNotNull(propDef, "Could not find the expected property
definition");
assertNotNull(prop, "Could not find the expected property");
-
+
assertEquals(propDef.getClass(), PropertyDefinitionList.class, "Unexpected
type of the property definition");
assertEquals(prop.getClass(), PropertyList.class, "Unexpecetd type of the
property");
-
+
PropertyDefinitionList listDef = (PropertyDefinitionList) propDef;
PropertyList listProp = (PropertyList) prop;
-
+
PropertyDefinition memberDef = listDef.getMemberDefinition();
assertEquals(memberDef.getClass(), PropertyDefinitionSimple.class,
"Unexpected type of the list member property definition");
-
+
PropertyDefinitionSimple memberSimpleDef = (PropertyDefinitionSimple) memberDef;
assertEquals(memberSimpleDef.getName(), "member");
assertEquals(memberSimpleDef.getType(), PropertySimpleType.INTEGER);
-
+
assertEquals(listProp.getList().size(), 3, "Unexpected number of list
members");
-
+
for(int i = 0; i < 3; ++i) {
Property memberProp = listProp.getList().get(i);
assertEquals(memberProp.getClass(), PropertySimple.class, "Unexpected
type of the property in the list on index " + i);
assertEquals(memberProp.getName(), "member");
assertEquals(((PropertySimple)memberProp).getIntegerValue(),
Integer.valueOf(i + 1));
- }
+ }
}
-
+
public void testReverseMapPropertyConversion() throws Exception {
String xml = "" +
"<standaloneConfigurationInstance
xmlns:ci='urn:xmlns:rhq-configuration-instance'
xmlns:c='urn:xmlns:rhq-configuration'>" +
@@ -321,56 +321,56 @@ public class ConfigurationInstanceDescriptorUtilTest {
"</standaloneConfigurationInstance>";
ConfigurationInstanceDescriptor descriptor = (ConfigurationInstanceDescriptor)
CONFIGURATION_INSTANCE_UNMARSHALLER.unmarshal(new StringReader(xml));
-
+
ConfigurationInstanceDescriptorUtil.ConfigurationAndDefinition ccd =
ConfigurationInstanceDescriptorUtil.createConfigurationAndDefinition(descriptor);
-
+
ConfigurationDefinition def = ccd.definition;
Configuration conf = ccd.configuration;
-
+
assertEquals(def.getPropertyDefinitions().size(), 1, "Unexpected number of
defined properties");
assertEquals(conf.getProperties().size(), 1, "Unexpected number of
properties");
PropertyDefinition propDef = def.get("map");
Property prop = conf.get("map");
-
+
assertNotNull(propDef, "Could not find the expected property
definition");
assertNotNull(prop, "Could not find the expected property");
-
+
assertEquals(propDef.getClass(), PropertyDefinitionMap.class, "Unexpected
type of the property definition");
assertEquals(prop.getClass(), PropertyMap.class, "Unexpecetd type of the
property");
-
+
PropertyDefinitionMap mapDef = (PropertyDefinitionMap) propDef;
PropertyMap mapProp = (PropertyMap) prop;
assertEquals(mapDef.getMap().size(), 2, "Unexpected number of map member
definitions");
assertEquals(mapProp.getMap().size(), 2, "Unexpected number of map
members");
-
+
PropertyDefinition m1Def = mapDef.get("m1");
PropertyDefinition m2Def = mapDef.get("m2");
Property m1Prop = mapProp.get("m1");
Property m2Prop = mapProp.get("m2");
-
+
assertEquals(m1Def.getClass(), PropertyDefinitionSimple.class);
assertEquals(m2Def.getClass(), PropertyDefinitionSimple.class);
assertEquals(m1Prop.getClass(), PropertySimple.class);
assertEquals(m2Prop.getClass(), PropertySimple.class);
-
+
PropertyDefinitionSimple m1SimpleDef = (PropertyDefinitionSimple) m1Def;
PropertyDefinitionSimple m2SimpleDef = (PropertyDefinitionSimple) m2Def;
PropertySimple m1SimpleProp = (PropertySimple) m1Prop;
PropertySimple m2SimpleProp = (PropertySimple) m2Prop;
-
+
assertEquals(m1SimpleDef.getName(), "m1");
assertEquals(m2SimpleDef.getName(), "m2");
assertEquals(m1SimpleDef.getType(), PropertySimpleType.INTEGER);
assertEquals(m2SimpleDef.getType(), PropertySimpleType.STRING);
-
+
assertEquals(m1SimpleProp.getName(), "m1");
assertEquals(m2SimpleProp.getName(), "m2");
assertEquals(m1SimpleProp.getIntegerValue(), Integer.valueOf(1));
assertEquals(m2SimpleProp.getStringValue(), "v");
}
-
+
public void testReverseListOfMapsConversion() throws Exception {
String xml = "" +
"<standaloneConfigurationInstance
xmlns:ci='urn:xmlns:rhq-configuration-instance'
xmlns:c='urn:xmlns:rhq-configuration'>" +
@@ -393,41 +393,41 @@ public class ConfigurationInstanceDescriptorUtilTest {
"</standaloneConfigurationInstance>";
ConfigurationInstanceDescriptor descriptor = (ConfigurationInstanceDescriptor)
CONFIGURATION_INSTANCE_UNMARSHALLER.unmarshal(new StringReader(xml));
-
+
ConfigurationInstanceDescriptorUtil.ConfigurationAndDefinition ccd =
ConfigurationInstanceDescriptorUtil.createConfigurationAndDefinition(descriptor);
-
+
ConfigurationDefinition def = ccd.definition;
Configuration conf = ccd.configuration;
-
+
assertEquals(def.getPropertyDefinitions().size(), 1, "Unexpected number of
defined properties");
- assertEquals(conf.getProperties().size(), 1, "Unexpected number of
properties");
-
+ assertEquals(conf.getProperties().size(), 1, "Unexpected number of
properties");
+
PropertyDefinitionList listDef = (PropertyDefinitionList)
def.get("list");
PropertyList listProp = (PropertyList) conf.get("list");
-
+
PropertyDefinitionMap mapDef = (PropertyDefinitionMap)
listDef.getMemberDefinition();
PropertyDefinitionSimple m1Def = (PropertyDefinitionSimple)
mapDef.get("m1");
PropertyDefinitionSimple m2Def = (PropertyDefinitionSimple)
mapDef.get("m2");
-
+
assertEquals(mapDef.getName(), "map");
assertEquals(m1Def.getType(), PropertySimpleType.INTEGER);
assertEquals(m2Def.getType(), PropertySimpleType.STRING);
-
+
assertEquals(listProp.getList().size(), 2, "Unexpected number of maps in the
list");
-
+
PropertyMap firstMapValue = (PropertyMap) listProp.getList().get(0);
PropertyMap secondMapValue = (PropertyMap) listProp.getList().get(1);
-
+
assertEquals(firstMapValue.getName(), "map");
assertEquals(secondMapValue.getName(), "map");
-
+
assertEquals(firstMapValue.getSimpleValue("m1", null), "1",
"Unexpected value of m1 property in the first map.");
assertEquals(firstMapValue.getSimpleValue("m2", null), "m1",
"Unexpected value of m2 property in the first map.");
-
+
assertEquals(secondMapValue.getSimpleValue("m1", null), "2",
"Unexpected value of m1 property in the second map.");
assertEquals(secondMapValue.getSimpleValue("m2", null), "m2",
"Unexpected value of m2 property in the second map.");
}
-
+
private static void logInstance(String message, ConfigurationInstanceDescriptor
instance) throws JAXBException,
IOException {
StringWriter wrt = new StringWriter();
commit d8c0cedf853a3ffd1bfc9479ca78be288739a52f
Author: Jirka Kremser <jkremser(a)redhat.com>
Date: Mon Dec 16 19:23:37 2013 +0100
[BZ 970181] - RHQ doesn't work after restart with open GUI in web browser. - if
the server restarts at the background, the session id is lost on the server therefore we
can't allow the logged user to continue sending the requests without a new AuthN. It
would be a security risk to allow it. Now, if the server restarts the UI requires the new
log in (the login form is displayed).
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/util/rpc/TrackingRequestCallback.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/util/rpc/TrackingRequestCallback.java
index 07893f6..b443c1a 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/util/rpc/TrackingRequestCallback.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/util/rpc/TrackingRequestCallback.java
@@ -23,6 +23,7 @@ import com.google.gwt.http.client.RequestCallback;
import com.google.gwt.http.client.Response;
import org.rhq.coregui.client.CoreGUI;
+import org.rhq.coregui.client.LoginView;
import org.rhq.coregui.client.UserSessionManager;
import org.rhq.coregui.client.util.Log;
@@ -86,6 +87,11 @@ public class TrackingRequestCallback implements RequestCallback {
switch (statusCode) {
case STATUS_CODE_OK:
+ if (response != null && response.getText() != null &&
response.getText().isEmpty()
+ && !LoginView.isLoginShowing()) { // this happen when the RHQ
server was restarted
+ new LoginView().showLoginDialog();
+ break;
+ }
RPCTracker.getInstance().succeedCall(this);
callback.onResponseReceived(request, response);
break;
commit b6206b7b938ea3c34f9a01f037f3a711c3cf09da
Author: Mike Thompson <mithomps(a)redhat.com>
Date: Fri Dec 13 15:51:56 2013 -0800
[BZ 1034512] Update Group Metric Graphs to be more like new Resource Metrics Graphs
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/D3GroupGraphListView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/D3GroupGraphListView.java
index d0b56a7..f6805e2 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/D3GroupGraphListView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/D3GroupGraphListView.java
@@ -189,6 +189,7 @@ public final class D3GroupGraphListView extends
AbstractD3GraphListView implemen
private void buildIndividualGraph(MeasurementDefinition measurementDefinition,
List<MeasurementDataNumericHighLowComposite> data) {
+ Log.debug("\n***** D3GroupGraphListView.MD: "+measurementDefinition);
MetricGraphData metricGraphData =
MetricGraphData.createForResourceGroup(resourceGroup.getId(),
resourceGroup.getName(), measurementDefinition, data);
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
index 9ddbb77..8394217 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
@@ -63,6 +63,7 @@ import
org.rhq.coregui.client.inventory.groups.detail.configuration.HistoryGroup
import
org.rhq.coregui.client.inventory.groups.detail.inventory.GroupPluginConfigurationEditView;
import
org.rhq.coregui.client.inventory.groups.detail.inventory.HistoryGroupPluginConfigurationView;
import org.rhq.coregui.client.inventory.groups.detail.inventory.MembersView;
+import
org.rhq.coregui.client.inventory.groups.detail.monitoring.metric.MetricsGroupView;
import
org.rhq.coregui.client.inventory.groups.detail.monitoring.schedules.ResourceGroupSchedulesView;
import
org.rhq.coregui.client.inventory.groups.detail.monitoring.table.GroupMonitoringTablesView;
import org.rhq.coregui.client.inventory.groups.detail.monitoring.traits.TraitsView;
@@ -332,7 +333,7 @@ public class ResourceGroupDetailView extends
viewFactory = (!showOnPage) ? null : new ViewFactory() {
@Override
public Canvas createView() {
- return createD3GraphListView();
+ return MetricsGroupView.create(groupComposite.getResourceGroup());
}
};
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/monitoring/metric/MetricsGroupTableView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/monitoring/metric/MetricsGroupTableView.java
new file mode 100644
index 0000000..89d4f67
--- /dev/null
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/monitoring/metric/MetricsGroupTableView.java
@@ -0,0 +1,408 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2013 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.coregui.client.inventory.groups.detail.monitoring.metric;
+
+import static
org.rhq.coregui.client.inventory.resource.detail.monitoring.table.MetricsGridFieldName.METRIC_DEF_ID;
+import static
org.rhq.coregui.client.inventory.resource.detail.monitoring.table.MetricsGridFieldName.RESOURCE_GROUP_ID;
+
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Set;
+
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.user.client.Timer;
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.smartgwt.client.types.ExpansionMode;
+import com.smartgwt.client.types.SelectionStyle;
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.HTMLFlow;
+import com.smartgwt.client.widgets.IButton;
+import com.smartgwt.client.widgets.events.ClickEvent;
+import com.smartgwt.client.widgets.form.fields.SelectItem;
+import com.smartgwt.client.widgets.form.fields.events.ChangeEvent;
+import com.smartgwt.client.widgets.form.fields.events.ChangeHandler;
+import com.smartgwt.client.widgets.grid.ListGrid;
+import com.smartgwt.client.widgets.grid.ListGridField;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
+import com.smartgwt.client.widgets.grid.events.DataArrivedEvent;
+import com.smartgwt.client.widgets.grid.events.DataArrivedHandler;
+import com.smartgwt.client.widgets.grid.events.RecordCollapseEvent;
+import com.smartgwt.client.widgets.grid.events.RecordCollapseHandler;
+import com.smartgwt.client.widgets.grid.events.RecordExpandEvent;
+import com.smartgwt.client.widgets.grid.events.RecordExpandHandler;
+import com.smartgwt.client.widgets.grid.events.SelectionChangedHandler;
+import com.smartgwt.client.widgets.grid.events.SelectionEvent;
+import com.smartgwt.client.widgets.grid.events.SortChangedHandler;
+import com.smartgwt.client.widgets.grid.events.SortEvent;
+import com.smartgwt.client.widgets.layout.VLayout;
+import com.smartgwt.client.widgets.toolbar.ToolStrip;
+
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.criteria.DashboardCriteria;
+import org.rhq.core.domain.dashboard.Dashboard;
+import org.rhq.core.domain.dashboard.DashboardPortlet;
+import org.rhq.core.domain.measurement.MeasurementDefinition;
+import org.rhq.core.domain.measurement.composite.MeasurementDataNumericHighLowComposite;
+import org.rhq.core.domain.resource.group.GroupCategory;
+import org.rhq.core.domain.resource.group.ResourceGroup;
+import org.rhq.core.domain.util.PageList;
+import org.rhq.coregui.client.CoreGUI;
+import org.rhq.coregui.client.components.table.Table;
+import
org.rhq.coregui.client.dashboard.portlets.inventory.groups.graph.ResourceGroupD3GraphPortlet;
+import org.rhq.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.coregui.client.inventory.common.AbstractD3GraphListView;
+import org.rhq.coregui.client.inventory.common.graph.CustomDateRangeState;
+import org.rhq.coregui.client.inventory.common.graph.MetricGraphData;
+import org.rhq.coregui.client.inventory.common.graph.Refreshable;
+import
org.rhq.coregui.client.inventory.common.graph.graphtype.StackedBarMetricGraphImpl;
+import org.rhq.coregui.client.inventory.resource.detail.monitoring.MetricD3Graph;
+import org.rhq.coregui.client.util.BrowserUtility;
+import org.rhq.coregui.client.util.Log;
+import org.rhq.coregui.client.util.message.Message;
+
+/**
+ * Views a resource's metrics in a tabular view with sparkline graph and optional
detailed d3 graph.
+ *
+ * @author John Mazzitelli
+ * @author Mike Thompson
+ */
+public class MetricsGroupTableView extends Table<MetricsGroupViewDataSource>
implements Refreshable {
+
+ private final ResourceGroup resourceGroup;
+ private final AbstractD3GraphListView abstractD3GraphListView;
+ private ToolStrip toolStrip;
+ private SelectItem dashboardSelectItem;
+ private Dashboard selectedDashboard;
+ private IButton addToDashboardButton;
+ private LinkedHashMap<String, String> dashboardMenuMap;
+ private LinkedHashMap<Integer, Dashboard> dashboardMap;
+ private Set<Integer> expandedRows;
+ private MetricsTableListGrid metricsTableListGrid;
+ private int selectedMetricDefinitionId;
+
+ public MetricsGroupTableView(ResourceGroup resourceGroup, AbstractD3GraphListView
abstractD3GraphListView,
+ Set<Integer> expandedRows) {
+ super();
+ this.resourceGroup = resourceGroup;
+ this.abstractD3GraphListView = abstractD3GraphListView;
+ dashboardMenuMap = new LinkedHashMap<String, String>();
+ dashboardMap = new LinkedHashMap<Integer, Dashboard>();
+ setDataSource(new MetricsGroupViewDataSource(resourceGroup));
+ this.expandedRows = expandedRows;
+ }
+
+ @Override
+ protected void onInit() {
+ super.onInit();
+ }
+
+ /**
+ * Creates this Table's list grid (called by onInit()). Subclasses can override
this if they require a custom
+ * subclass of ListGrid.
+ *
+ * @return this Table's list grid (must be an instance of ListGrid)
+ */
+ @Override
+ protected ListGrid createListGrid() {
+ metricsTableListGrid = new MetricsTableListGrid(this, resourceGroup);
+ metricsTableListGrid.addSelectionChangedHandler(new SelectionChangedHandler() {
+ @Override
+ public void onSelectionChanged(SelectionEvent selectionEvent) {
+ if (resourceGroup.getGroupCategory() == GroupCategory.COMPATIBLE) {
+ addToDashboardButton.enable();
+ ListGridRecord selectedRecord = selectionEvent.getSelectedRecord();
+ if (null != selectedRecord) {
+ selectedMetricDefinitionId =
selectedRecord.getAttributeAsInt(METRIC_DEF_ID.getValue());
+ }
+ }
+ }
+ });
+
+ if (null == toolStrip) {
+ toolStrip = createToolstrip();
+ }
+ addExtraWidget(toolStrip, false);
+ addToDashboardButton.disable();
+ return metricsTableListGrid;
+ }
+
+ protected void configureTable() {
+ ArrayList<ListGridField> fields = getDataSource().getListGridFields();
+ setListGridFields(fields.toArray(new ListGridField[0]));
+ }
+
+ private ToolStrip createToolstrip() {
+ toolStrip = new ToolStrip();
+ toolStrip.setWidth(300);
+ toolStrip.setMembersMargin(15);
+ toolStrip.setPadding(5);
+ toolStrip.addSpacer(10);
+ addToDashboardButton = new IButton(MSG.chart_metrics_add_to_dashboard_button());
+ addToDashboardButton.setWidth(80);
+ dashboardSelectItem = new SelectItem();
+ dashboardSelectItem.setTitle(MSG.chart_metrics_add_to_dashboard_label());
+ dashboardSelectItem.setWidth(240);
+ dashboardSelectItem.setWrapTitle(false);
+ populateDashboardMenu();
+ toolStrip.addFormItem(dashboardSelectItem);
+ toolStrip.addMember(addToDashboardButton);
+
+ dashboardSelectItem.addChangeHandler(new ChangeHandler() {
+ @Override
+ public void onChange(ChangeEvent changeEvent) {
+ Integer selectedDashboardId = Integer.valueOf((String)
changeEvent.getValue());
+ selectedDashboard = dashboardMap.get(selectedDashboardId);
+ }
+ });
+ addToDashboardButton.addClickHandler(new
com.smartgwt.client.widgets.events.ClickHandler() {
+ @Override
+ public void onClick(ClickEvent clickEvent) {
+ for (MeasurementDefinition measurementDefinition :
resourceGroup.getResourceType()
+ .getMetricDefinitions()) {
+ if (measurementDefinition.getId() == selectedMetricDefinitionId) {
+ Log.debug("Add to Dashboard -- Storing: " +
measurementDefinition.getDisplayName() + " in "
+ + selectedDashboard.getName());
+
+ storeDashboardMetric(selectedDashboard, resourceGroup.getId(),
measurementDefinition);
+ break;
+ }
+ }
+ }
+ });
+ return toolStrip;
+ }
+
+ @Override
+ /**
+ * Redraw Graphs in this context means to refresh the table and redraw open graphs.
+ */
+ public void refreshData() {
+ new Timer() {
+ @Override
+ public void run() {
+ metricsTableListGrid.expandOpenedRows();
+ BrowserUtility.graphSparkLines();
+ }
+ }.schedule(150);
+
+ }
+
+ @Override
+ public void refresh() {
+ super.refresh(false);
+ metricsTableListGrid.expandOpenedRows();
+ }
+
+ private void populateDashboardMenu() {
+ dashboardMenuMap.clear();
+ dashboardMap.clear();
+
+ DashboardCriteria criteria = new DashboardCriteria();
+ GWTServiceLookup.getDashboardService().findDashboardsByCriteria(criteria,
+ new AsyncCallback<PageList<Dashboard>>() {
+
+ public void onFailure(Throwable caught) {
+
CoreGUI.getErrorHandler().handleError(MSG.view_tree_common_contextMenu_loadFailed_dashboard(),
+ caught);
+ }
+
+ public void onSuccess(PageList<Dashboard> dashboards) {
+ if (dashboards.size() > 0) {
+ for (final Dashboard dashboard : dashboards) {
+ dashboardMenuMap.put(String.valueOf(dashboard.getId()),
dashboard.getName());
+ dashboardMap.put(dashboard.getId(), dashboard);
+ }
+ selectedDashboard = dashboards.get(0);
+ dashboardSelectItem.setValueMap(dashboardMenuMap);
+ dashboardSelectItem.setValue(selectedDashboard.getId());
+ }
+ }
+ });
+ }
+
+ private void storeDashboardMetric(Dashboard dashboard, int resourceGroupId,
MeasurementDefinition definition) {
+
+ DashboardPortlet dashboardPortlet = new
DashboardPortlet(MSG.view_tree_common_contextMenu_groupGraph(),
+ ResourceGroupD3GraphPortlet.KEY, 260);
+ dashboardPortlet.getConfiguration().put(
+ new PropertySimple(ResourceGroupD3GraphPortlet.CFG_RESOURCE_GROUP_ID,
resourceGroupId));
+ dashboardPortlet.getConfiguration().put(
+ new PropertySimple(ResourceGroupD3GraphPortlet.CFG_DEFINITION_ID,
definition.getId()));
+
+ dashboard.addPortlet(dashboardPortlet);
+
+ GWTServiceLookup.getDashboardService().storeDashboard(dashboard, new
AsyncCallback<Dashboard>() {
+ public void onFailure(Throwable caught) {
+
CoreGUI.getErrorHandler().handleError(MSG.view_tree_common_contextMenu_saveChartToDashboardFailure(),
+ caught);
+ }
+
+ public void onSuccess(Dashboard result) {
+ String msg =
MSG.view_tree_common_contextMenu_saveChartToDashboardSuccessful(result.getName());
+ CoreGUI.getMessageCenter().notify(new Message(msg,
Message.Severity.Info));
+ }
+ });
+ }
+
+ public class MetricsTableListGrid extends ListGrid {
+
+ private static final int TREEVIEW_DETAIL_CHART_HEIGHT = 205;
+ private static final int NUM_METRIC_POINTS = 60;
+ final MetricsGroupTableView metricsTableView;
+ private ResourceGroup group;
+
+ public MetricsTableListGrid(final MetricsGroupTableView metricsTableView, final
ResourceGroup group) {
+ super();
+ this.group = group;
+ this.metricsTableView = metricsTableView;
+ setCanExpandRecords(true);
+ setSelectionType(SelectionStyle.SINGLE);
+ setCanExpandMultipleRecords(true);
+ setExpansionMode(ExpansionMode.DETAIL_FIELD);
+
+ addRecordExpandHandler(new RecordExpandHandler() {
+ @Override
+ public void onRecordExpand(RecordExpandEvent recordExpandEvent) {
+
metricsTableView.expandedRows.add(recordExpandEvent.getRecord().getAttributeAsInt(
+ METRIC_DEF_ID.getValue()));
+ refreshData();
+ }
+
+ });
+ addRecordCollapseHandler(new RecordCollapseHandler() {
+ @Override
+ public void onRecordCollapse(RecordCollapseEvent recordCollapseEvent) {
+
metricsTableView.expandedRows.remove(recordCollapseEvent.getRecord().getAttributeAsInt(
+ METRIC_DEF_ID.getValue()));
+ refresh();
+ new Timer() {
+ @Override
+ public void run() {
+ BrowserUtility.graphSparkLines();
+ }
+ }.schedule(150);
+ }
+ });
+ addSortChangedHandler(new SortChangedHandler() {
+ @Override
+ public void onSortChanged(SortEvent sortEvent) {
+ refreshData();
+ }
+ });
+
+ addDataArrivedHandler(new DataArrivedHandler() {
+ @Override
+ public void onDataArrived(DataArrivedEvent dataArrivedEvent) {
+ expandOpenedRows();
+ }
+ });
+
+ }
+
+ public void expandOpenedRows() {
+ int startRow = 0;
+ int endRow = this.getRecords().length;
+ for (int i = startRow; i < endRow; i++) {
+ ListGridRecord listGridRecord = getRecord(i);
+ if (null != listGridRecord) {
+ int metricDefinitionId =
listGridRecord.getAttributeAsInt(METRIC_DEF_ID.getValue());
+ if (null != metricsTableView && null != expandedRows
+ &&
metricsTableView.expandedRows.contains(metricDefinitionId)) {
+ expandRecord(listGridRecord);
+ }
+ }
+ }
+ }
+
+ @Override
+ /**
+ * If you expand a grid row then create a graph.
+ */
+ protected Canvas getExpansionComponent(final ListGridRecord record) {
+ final Integer definitionId =
record.getAttributeAsInt(METRIC_DEF_ID.getValue());
+ final Integer resourceGroupId =
record.getAttributeAsInt(RESOURCE_GROUP_ID.getValue());
+ VLayout vLayout = new VLayout();
+ vLayout.setPadding(5);
+
+ final String chartId = "rChart-" + resourceGroupId + "-"
+ definitionId;
+ HTMLFlow htmlFlow = new
HTMLFlow(MetricD3Graph.createGraphMarkerTemplate(chartId,
+ TREEVIEW_DETAIL_CHART_HEIGHT));
+ vLayout.addMember(htmlFlow);
+
+ int[] definitionArrayIds = new int[1];
+ definitionArrayIds[0] = definitionId;
+
GWTServiceLookup.getMeasurementDataService().findDataForCompatibleGroup(resourceGroupId,
+ definitionArrayIds, CustomDateRangeState.getInstance().getStartTime(),
+ CustomDateRangeState.getInstance().getEndTime(), NUM_METRIC_POINTS,
+ new
AsyncCallback<List<List<MeasurementDataNumericHighLowComposite>>>() {
+ @Override
+ public void onFailure(Throwable caught) {
+ Log.warn("Error retrieving recent metrics charting data for
resource group [" + resourceGroupId
+ + "]:" + caught.getMessage());
+ }
+
+ @Override
+ public void
onSuccess(List<List<MeasurementDataNumericHighLowComposite>> results) {
+ if (!results.isEmpty()) {
+
+ //load the data results for the given metric definition
+ List<MeasurementDataNumericHighLowComposite>
measurementList = results.get(0);
+
+ MeasurementDefinition measurementDefinition = null;
+ for (MeasurementDefinition definition :
group.getResourceType().getMetricDefinitions()) {
+ if (definition.getId() == definitionId) {
+ measurementDefinition = definition;
+ break;
+ }
+ }
+
+ MetricGraphData metricGraphData =
MetricGraphData.createForResourceGroup(group.getId(),
+ group.getName(), measurementDefinition,
measurementList);
+ metricGraphData.setHideLegend(true);
+
+ StackedBarMetricGraphImpl graph =
GWT.create(StackedBarMetricGraphImpl.class);
+ graph.setMetricGraphData(metricGraphData);
+ final MetricD3Graph graphView = new MetricD3Graph(graph,
abstractD3GraphListView);
+ new Timer() {
+ @Override
+ public void run() {
+ graphView.drawJsniChart();
+ new Timer() {
+ @Override
+ public void run() {
+ BrowserUtility.graphSparkLines();
+ }
+ }.schedule(150);
+ }
+ }.schedule(150);
+
+ } else {
+ Log.warn("No chart data retrieving for resource group
[" + resourceGroupId + "-"
+ + definitionId + "]");
+ }
+ }
+ });
+
+ return vLayout;
+ }
+ }
+
+}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/monitoring/metric/MetricsGroupView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/monitoring/metric/MetricsGroupView.java
new file mode 100644
index 0000000..1e07e7a
--- /dev/null
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/monitoring/metric/MetricsGroupView.java
@@ -0,0 +1,193 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2013 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.coregui.client.inventory.groups.detail.monitoring.metric;
+
+import java.util.List;
+import java.util.Set;
+
+import com.google.gwt.user.client.Timer;
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.smartgwt.client.types.Overflow;
+import com.smartgwt.client.types.VerticalAlignment;
+import com.smartgwt.client.widgets.Img;
+import com.smartgwt.client.widgets.events.ClickEvent;
+import com.smartgwt.client.widgets.events.ClickHandler;
+
+import org.rhq.core.domain.common.EntityContext;
+import org.rhq.core.domain.measurement.Availability;
+import org.rhq.core.domain.resource.group.ResourceGroup;
+import org.rhq.coregui.client.CoreGUI;
+import org.rhq.coregui.client.IconEnum;
+import org.rhq.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.coregui.client.inventory.common.AbstractD3GraphListView;
+import org.rhq.coregui.client.inventory.common.detail.AbstractTwoLevelTabSetView;
+import org.rhq.coregui.client.inventory.common.graph.CustomDateRangeState;
+import
org.rhq.coregui.client.inventory.common.graph.graphtype.AvailabilityOverUnderGraphType;
+import org.rhq.coregui.client.inventory.resource.detail.monitoring.ExpandedRowsMomento;
+import
org.rhq.coregui.client.inventory.resource.detail.monitoring.avail.AvailabilityD3GraphView;
+import
org.rhq.coregui.client.inventory.resource.detail.monitoring.table.MetricAvailabilityView;
+import org.rhq.coregui.client.util.BrowserUtility;
+import org.rhq.coregui.client.util.async.CountDownLatch;
+import org.rhq.coregui.client.util.enhanced.EnhancedHLayout;
+
+/**
+ * The consolidated metrics view showing metric graphs and availability data both in
graphical and tabular form.
+ * @author Mike Thompson
+ */
+public class MetricsGroupView extends AbstractD3GraphListView implements
+ AbstractTwoLevelTabSetView.ViewRenderedListener {
+
+ private static final String COLLAPSED_TOOLTIP =
MSG.chart_metrics_collapse_tooltip();
+ private static final String EXPANDED_TOOLTIP = MSG.chart_metrics_expand_tooltip();
+
+ private final ResourceGroup resourceGroup;
+ private EnhancedHLayout expandCollapseHLayout;
+ private MetricsGroupTableView metricsTableView;
+ private static Integer lastResourceGroupId = 0;
+
+ /**
+ * Encapsulate the creation logic and not let it leak out into other objects.
+ * Clear the expanded rows set when changing resources as well.
+ * @see ExpandedRowsMomento
+ * @param group
+ * @return MetricsGroupView
+ */
+ public static MetricsGroupView create(ResourceGroup group ){
+
+ boolean isDifferentResource = (group.getId() != lastResourceGroupId);
+
+ if(isDifferentResource){
+ ExpandedRowsMomento.getInstance().clear();
+ }
+
+ return new MetricsGroupView(group,
ExpandedRowsMomento.getInstance().getExpandedRows());
+
+ }
+
+ private MetricsGroupView(ResourceGroup resourceGroup, Set<Integer>
expandedRows) {
+ super();
+ setOverflow(Overflow.AUTO);
+ setWidth100();
+ setHeight100();
+ this.resourceGroup = resourceGroup;
+ metricsTableView = new MetricsGroupTableView(resourceGroup, this, expandedRows);
+
+ final MetricAvailabilityView availabilityDetails = new
MetricAvailabilityView(resourceGroup.getId());
+ availabilityDetails.hide();
+
+ metricsTableView.setHeight100();
+
+ availabilityGraph = AvailabilityD3GraphView.create( new
AvailabilityOverUnderGraphType(resourceGroup.getId()));
+
+ expandCollapseHLayout = new EnhancedHLayout();
+ //add expand/collapse icon
+ final Img expandCollapseArrow = new
Img(IconEnum.COLLAPSED_ICON.getIcon16x16Path(), 16, 16);
+ expandCollapseArrow.setTooltip(COLLAPSED_TOOLTIP);
+ expandCollapseArrow.setLayoutAlign(VerticalAlignment.BOTTOM);
+ expandCollapseArrow.addClickHandler(new ClickHandler() {
+ private boolean collapsed = true;
+
+ @Override
+ public void onClick(ClickEvent event) {
+ collapsed = !collapsed;
+ if (collapsed) {
+
expandCollapseArrow.setSrc(IconEnum.COLLAPSED_ICON.getIcon16x16Path());
+ expandCollapseArrow.setTooltip(COLLAPSED_TOOLTIP);
+ availabilityDetails.hide();
+ } else {
+
expandCollapseArrow.setSrc(IconEnum.EXPANDED_ICON.getIcon16x16Path());
+ expandCollapseArrow.setTooltip(EXPANDED_TOOLTIP);
+ availabilityDetails.show();
+
+ }
+ drawAvailabilityGraphAndSparklines();
+ }
+ });
+ expandCollapseHLayout.addMember(expandCollapseArrow);
+ addAvailabilityGraph();
+
+ addMember(buttonBarDateTimeRangeEditor);
+ addMember(expandCollapseHLayout);
+ addMember(availabilityDetails);
+ addMember(metricsTableView);
+ lastResourceGroupId = resourceGroup.getId();
+ }
+
+
+ private void addAvailabilityGraph() {
+ expandCollapseHLayout.removeMember(availabilityGraph);
+ availabilityGraph.destroy();
+
+ availabilityGraph = AvailabilityD3GraphView.create(new
AvailabilityOverUnderGraphType(resourceGroup.getId()));
+
+ expandCollapseHLayout.addMember(availabilityGraph);
+
+ queryAvailability(EntityContext.forGroup(resourceGroup.getId()),
CustomDateRangeState.getInstance().getStartTime(),
+ CustomDateRangeState.getInstance().getEndTime(), null);
+ }
+
+
+ @Override
+ protected void queryAvailability(final EntityContext context, Long startTime, Long
endTime, CountDownLatch notUsed) {
+
+ // now return the availability
+
GWTServiceLookup.getAvailabilityService().getAvailabilitiesForResource(context.getGroupId(),
startTime,
+ endTime, new AsyncCallback<List<Availability>>() {
+ @Override
+ public void onFailure(Throwable caught) {
+
CoreGUI.getErrorHandler().handleError(MSG.view_resource_monitor_availability_loadFailed(),
caught);
+ }
+
+ @Override
+ public void onSuccess(List<Availability> availList) {
+ availabilityGraph.setAvailabilityList(availList);
+ new Timer() {
+ @Override
+ public void run() {
+ buttonBarDateTimeRangeEditor.updateTimeRangeToNow();
+ availabilityGraph.drawJsniChart();
+
+ }
+ }.schedule(150);
+ }
+ });
+ }
+
+ private void drawAvailabilityGraphAndSparklines() {
+ new Timer() {
+ @Override
+ public void run() {
+ availabilityGraph.drawJsniChart();
+ BrowserUtility.graphSparkLines();
+ }
+ }.schedule(150);
+ }
+
+ @Override
+ public void refreshData() {
+ addAvailabilityGraph();
+ metricsTableView.refresh();
+ }
+
+ @Override
+ public void onViewRendered() {
+ // refresh the graphs on subtab nav because we are a cached view not new
+ refreshData();
+ }
+}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/monitoring/metric/MetricsGroupViewDataSource.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/monitoring/metric/MetricsGroupViewDataSource.java
new file mode 100644
index 0000000..a5f1353
--- /dev/null
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/monitoring/metric/MetricsGroupViewDataSource.java
@@ -0,0 +1,314 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2013 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.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+package org.rhq.coregui.client.inventory.groups.detail.monitoring.metric;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import com.google.gwt.user.client.Timer;
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.smartgwt.client.data.DSRequest;
+import com.smartgwt.client.data.DSResponse;
+import com.smartgwt.client.data.Record;
+import com.smartgwt.client.widgets.grid.CellFormatter;
+import com.smartgwt.client.widgets.grid.ListGridField;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
+
+import org.rhq.core.domain.criteria.Criteria;
+import org.rhq.core.domain.measurement.MeasurementDefinition;
+import org.rhq.core.domain.measurement.composite.MeasurementDataNumericHighLowComposite;
+import org.rhq.core.domain.measurement.ui.MetricDisplaySummary;
+import org.rhq.core.domain.measurement.ui.MetricDisplayValue;
+import org.rhq.core.domain.resource.group.ResourceGroup;
+import org.rhq.coregui.client.CoreGUI;
+import org.rhq.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.coregui.client.inventory.common.graph.CustomDateRangeState;
+import org.rhq.coregui.client.util.BrowserUtility;
+import org.rhq.coregui.client.util.Log;
+import org.rhq.coregui.client.util.MeasurementUtility;
+import org.rhq.coregui.client.util.RPCDataSource;
+import org.rhq.coregui.client.util.async.Command;
+import org.rhq.coregui.client.util.async.CountDownLatch;
+
+import static org.rhq.core.domain.measurement.DataType.COMPLEX;
+import static org.rhq.core.domain.measurement.DataType.MEASUREMENT;
+import static
org.rhq.coregui.client.inventory.resource.detail.monitoring.table.MetricsGridFieldName.*;
+
+/**
+ * A simple data source to read in metric data summaries for a resource.
+ * This doesn't support paging - everything is returned in one query. Since
+ * the number of metrics per resource is relatively small (never more than tens of
them),
+ * we just load them all in at once.
+ *
+ * @author John Mazzitelli
+ * @author Mike Thompson
+ */
+public class MetricsGroupViewDataSource extends RPCDataSource<MetricDisplaySummary,
Criteria> {
+
+ private static final int NUMBER_OF_METRIC_POINTS = 60;
+
+ private final ResourceGroup resourceGroup;
+ private List<MetricDisplaySummary> metricDisplaySummaries;
+ private List<List<MeasurementDataNumericHighLowComposite>>
metricsDataList;
+ private int[] definitionArrayIds;
+
+ public MetricsGroupViewDataSource(ResourceGroup resourceGroup) {
+ this.resourceGroup = resourceGroup;
+ }
+
+ /**
+ * The view that contains the list grid which will display this datasource's data
will call this
+ * method to get the field information which is used to control the display of the
data.
+ *
+ * @return list grid fields used to display the datasource data
+ */
+ public ArrayList<ListGridField> getListGridFields() {
+ ArrayList<ListGridField> fields = new ArrayList<ListGridField>(7);
+
+ ListGridField sparklineField = new ListGridField(SPARKLINE.getValue(),
MSG.chart_metrics_sparkline_header());
+ sparklineField.setCellFormatter(new CellFormatter() {
+ @Override
+ public String format(Object value, ListGridRecord record, int rowNum, int
colNum) {
+ if (value == null) {
+ return "";
+ }
+ String contents = "<span id='sparkline_" +
resourceGroup.getId() + "-"
+ + record.getAttributeAsInt(METRIC_DEF_ID.getValue()) + "'
class='dynamicsparkline' width='70' "
+ + "values='" +
record.getAttribute(SPARKLINE.getValue()) + "'></span>";
+ return contents;
+
+ }
+ });
+
+ sparklineField.setWidth(80);
+ fields.add(sparklineField);
+
+ ListGridField nameField = new ListGridField(METRIC_LABEL.getValue(),
METRIC_LABEL.getLabel());
+ nameField.setWidth("30%");
+ fields.add(nameField);
+
+ ListGridField minField = new ListGridField(MIN_VALUE.getValue(),
MIN_VALUE.getLabel());
+ minField.setWidth("15%");
+ fields.add(minField);
+
+ ListGridField maxField = new ListGridField(MAX_VALUE.getValue(),
MAX_VALUE.getLabel());
+ maxField.setWidth("15%");
+ fields.add(maxField);
+
+ ListGridField avgField = new ListGridField(AVG_VALUE.getValue(),
AVG_VALUE.getLabel());
+ avgField.setWidth("15%");
+ fields.add(avgField);
+
+ ListGridField alertsField = new ListGridField(ALERT_COUNT.getValue(),
ALERT_COUNT.getLabel());
+ alertsField.setWidth("10%");
+ fields.add(alertsField);
+
+ return fields;
+ }
+
+ @Override
+ public MetricDisplaySummary copyValues(Record from) {
+ // we should never need this method - we only go in one direction
+ // if we ever need this, just have copyValues store an "object"
attribute whose value is "from"
+ // which this method then just reads out. Since we don't need this now, save
memory by not
+ // keeping the MetricDisplayValue around
+ return null;
+ }
+
+ @Override
+ public ListGridRecord copyValues(MetricDisplaySummary from) {
+ MeasurementUtility.formatSimpleMetrics(from);
+
+ ListGridRecord record = new ListGridRecord();
+ record.setAttribute(SPARKLINE.getValue(),
getCsvMetricsForSparkline(from.getDefinitionId()));
+ record.setAttribute(METRIC_LABEL.getValue(), from.getLabel());
+ record.setAttribute(ALERT_COUNT.getValue(),
String.valueOf(from.getAlertCount()));
+ record.setAttribute(MIN_VALUE.getValue(),
getMetricStringValue(from.getMinMetric()));
+ record.setAttribute(MAX_VALUE.getValue(),
getMetricStringValue(from.getMaxMetric()));
+ record.setAttribute(AVG_VALUE.getValue(),
getMetricStringValue(from.getAvgMetric()));
+ record.setAttribute(METRIC_DEF_ID.getValue(), from.getDefinitionId());
+ record.setAttribute(METRIC_SCHEDULE_ID.getValue(), from.getScheduleId());
+ record.setAttribute(METRIC_UNITS.getValue(), from.getUnits());
+ record.setAttribute(METRIC_NAME.getValue(), from.getMetricName());
+ record.setAttribute(RESOURCE_GROUP_ID.getValue(), resourceGroup.getId());
+ return record;
+ }
+
+ private String getCsvMetricsForSparkline(int definitionId) {
+ StringBuilder sb = new StringBuilder();
+ List<MeasurementDataNumericHighLowComposite> selectedMetricsList =
getMeasurementsForMeasurementDefId(definitionId);
+
+ for (MeasurementDataNumericHighLowComposite measurementData :
selectedMetricsList) {
+ if (!Double.isNaN(measurementData.getValue())) {
+ sb.append((int) measurementData.getValue());
+ sb.append(",");
+ }
+ }
+
+ if (sb.toString().endsWith(",")) {
+ sb.setLength(sb.length() - 1);
+ }
+ // handle the case where we have just installed the server so not much history
+ // and our date range is set such that only one value returns which the
+ // sparkline graph will not plot anything, so we need at least 2 values
+ if (!sb.toString().contains(",")) {
+ // append another value just so we have 2 values and it will graph
+ return "0," + sb.toString();
+ }
+
+ return sb.toString();
+ }
+
+ private List<MeasurementDataNumericHighLowComposite>
getMeasurementsForMeasurementDefId(int definitionId) {
+ int selectedIndex = 0;
+
+ // find the ordinal position as specified when querying the metrics
+ for (int i = 0; i < definitionArrayIds.length; i++) {
+ if (definitionArrayIds[i] == definitionId) {
+ selectedIndex = i;
+ break;
+ }
+ }
+
+ return metricsDataList.get(selectedIndex);
+ }
+
+ protected String getMetricStringValue(MetricDisplayValue value) {
+ return (value != null) ? value.toString() : "";
+ }
+
+ @Override
+ protected Criteria getFetchCriteria(DSRequest request) {
+ // NOTE: we don't use criterias for this datasource, just return null
+ return null;
+ }
+
+ @Override
+ protected void executeFetch(final DSRequest request, final DSResponse response, final
Criteria unused) {
+
+ // This latch is the last thing that gets executed after we have executed the
+ // 1 query
+ final CountDownLatch countDownLatch = CountDownLatch.create(1, new Command() {
+
+ @Override
+ public void execute() {
+
+ // NOTE: this runs after the queryMetricDisplaySummaries is complete
+ queryGroupMetrics(resourceGroup, request, response);
+ }
+ });
+
+ organizeMeasurementDefinitionOrder(resourceGroup);
+ queryMetricDisplaySummaries(definitionArrayIds,
CustomDateRangeState.getInstance().getStartTime(),
+ CustomDateRangeState.getInstance().getEndTime(), countDownLatch);
+
+ }
+
+ private void queryGroupMetrics(final ResourceGroup resourceGroup, final DSRequest
request, final DSResponse response) {
+
+
GWTServiceLookup.getMeasurementDataService().findDataForCompatibleGroup(resourceGroup.getId(),
+ definitionArrayIds, CustomDateRangeState.getInstance().getStartTime(),
+ CustomDateRangeState.getInstance().getEndTime(), NUMBER_OF_METRIC_POINTS,
+ new
AsyncCallback<List<List<MeasurementDataNumericHighLowComposite>>>() {
+ @Override
+ public void onFailure(Throwable caught) {
+ Log.warn("Error retrieving recent metrics charting data for
resource [" + resourceGroup.getId()
+ + "]:" + caught.getMessage());
+ }
+
+ @Override
+ public void
onSuccess(List<List<MeasurementDataNumericHighLowComposite>>
measurementDataList) {
+ if (null != measurementDataList &&
!measurementDataList.isEmpty()) {
+ metricsDataList = measurementDataList;
+ response.setData(buildRecords(metricDisplaySummaries));
+ processResponse(request.getRequestId(), response);
+ new Timer() {
+ @Override
+ public void run() {
+ BrowserUtility.graphSparkLines();
+ }
+ }.schedule(150);
+ }
+ }
+ });
+
+ }
+
+ private void organizeMeasurementDefinitionOrder(ResourceGroup resourceGroup) {
+ Set<MeasurementDefinition> definitions =
getMetricDefinitions(resourceGroup);
+
+ //build id mapping for measurementDefinition instances Ex. Free Memory ->
MeasurementDefinition[100071]
+ final HashMap<String, MeasurementDefinition> measurementDefMap = new
HashMap<String, MeasurementDefinition>();
+ for (MeasurementDefinition definition : definitions) {
+ measurementDefMap.put(definition.getDisplayName(), definition);
+ }
+ //bundle definition ids for asynch call.
+ definitionArrayIds = new int[definitions.size()];
+ final String[] displayOrder = new String[definitions.size()];
+ measurementDefMap.keySet().toArray(displayOrder);
+ //sort the charting data ex. Free Memory, Free Swap Space,..System Load
+ Arrays.sort(displayOrder);
+
+ //organize definitionArrayIds for ordered request on server.
+ int index = 0;
+ for (String definitionToDisplay : displayOrder) {
+ definitionArrayIds[index++] =
measurementDefMap.get(definitionToDisplay).getId();
+ }
+ }
+
+ private void queryMetricDisplaySummaries(int[] measurementDefIds, Long startTime,
Long endTime,
+ final CountDownLatch countDownLatch) {
+
GWTServiceLookup.getMeasurementChartsService().getMetricDisplaySummariesForCompatibleGroup(
+ resourceGroup.getId(), measurementDefIds, startTime, endTime, false,
+ new AsyncCallback<ArrayList<MetricDisplaySummary>>() {
+ @Override
+ public void onSuccess(ArrayList<MetricDisplaySummary>
metricDisplaySummaries) {
+ setMetricDisplaySummaries(metricDisplaySummaries);
+ countDownLatch.countDown();
+ }
+
+ @Override
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Cannot load
metrics", caught);
+ countDownLatch.countDown();
+ }
+ }
+
+ );
+ }
+
+ private void setMetricDisplaySummaries(List<MetricDisplaySummary>
metricDisplaySummaries) {
+ this.metricDisplaySummaries = metricDisplaySummaries;
+ }
+
+ private Set<MeasurementDefinition> getMetricDefinitions(ResourceGroup
resourceGroup) {
+ Set<MeasurementDefinition> definitions = new
HashSet<MeasurementDefinition>();
+ for (MeasurementDefinition measurementDefinition :
resourceGroup.getResourceType().getMetricDefinitions()) {
+ if (measurementDefinition.getDataType() == MEASUREMENT ||
measurementDefinition.getDataType() == COMPLEX) {
+ definitions.add(measurementDefinition);
+ }
+ }
+ return definitions;
+ }
+}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricAvailabilityView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricAvailabilityView.java
new file mode 100644
index 0000000..4b542c9
--- /dev/null
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricAvailabilityView.java
@@ -0,0 +1,223 @@
+/*
+ * RHQ Management Platform
+ * Copyright 2012, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * 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.coregui.client.inventory.resource.detail.monitoring.table;
+
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.smartgwt.client.widgets.form.DynamicForm;
+import com.smartgwt.client.widgets.form.fields.FormItem;
+import com.smartgwt.client.widgets.form.fields.StaticTextItem;
+
+import org.rhq.core.domain.measurement.AvailabilityType;
+import org.rhq.core.domain.measurement.MeasurementUnits;
+import org.rhq.core.domain.resource.composite.ResourceAvailabilitySummary;
+import org.rhq.coregui.client.CoreGUI;
+import org.rhq.coregui.client.components.table.TimestampCellFormatter;
+import org.rhq.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.coregui.client.util.MeasurementConverterClient;
+import org.rhq.coregui.client.util.enhanced.EnhancedVLayout;
+
+/**
+ * This shows the availability history for a resource.
+ *
+ * @author Jay Shaughnessy
+ * @author John Mazzitelli
+ * @author Mike Thompson
+ */
+public class MetricAvailabilityView extends EnhancedVLayout {
+
+ private int resourceId;
+ private StaticTextItem currentField;
+ private StaticTextItem availField;
+ private StaticTextItem availTimeField;
+ private StaticTextItem downField;
+ private StaticTextItem downTimeField;
+ private StaticTextItem disabledField;
+ private StaticTextItem disabledTimeField;
+ private StaticTextItem failureCountField;
+ private StaticTextItem disabledCountField;
+ private StaticTextItem mtbfField;
+ private StaticTextItem mttrField;
+ private StaticTextItem unknownField;
+ private StaticTextItem currentTimeField;
+
+ public MetricAvailabilityView(int resourceId) {
+ super();
+
+ this.resourceId = resourceId;
+
+ setWidth100();
+ setHeight(165);
+ }
+
+ @Override
+ protected void onInit() {
+ super.onInit();
+
+ addMember(createSummaryForm());
+ }
+
+ private DynamicForm createSummaryForm() {
+ DynamicForm form = new DynamicForm();
+ form.setWidth100();
+ form.setAutoHeight();
+ form.setMargin(10);
+ form.setNumCols(4);
+
+ // row 1
+ currentField = new StaticTextItem("current",
MSG.view_resource_monitor_availability_currentStatus());
+ currentField.setWrapTitle(false);
+ currentField.setColSpan(4);
+
+ // row 2
+ availField = new StaticTextItem("avail",
MSG.common_title_availability());
+ availField.setWrapTitle(false);
+ prepareTooltip(availField, MSG.view_resource_monitor_availability_tooltip_up());
+
+ availTimeField = new StaticTextItem("availTime",
MSG.view_resource_monitor_availability_uptime());
+ availTimeField.setWrapTitle(false);
+ prepareTooltip(availTimeField,
MSG.view_resource_monitor_availability_uptime_tooltip());
+
+ // row 3
+ downField = new StaticTextItem("down",
MSG.common_status_avail_down_lower());
+ downField.setWrapTitle(false);
+ prepareTooltip(downField,
MSG.view_resource_monitor_availability_tooltip_down());
+
+ downTimeField = new StaticTextItem("downTime",
MSG.view_resource_monitor_availability_downtime());
+ downTimeField.setWrapTitle(false);
+ prepareTooltip(downTimeField,
MSG.view_resource_monitor_availability_downtime_tooltip());
+
+ // row 4
+ disabledField = new StaticTextItem("disabled",
MSG.common_status_avail_disabled_lower());
+ disabledField.setWrapTitle(false);
+ prepareTooltip(disabledField,
MSG.view_resource_monitor_availability_tooltip_disabled());
+
+ disabledTimeField = new StaticTextItem("disabledTime",
MSG.view_resource_monitor_availability_disabledTime());
+ disabledTimeField.setWrapTitle(false);
+ prepareTooltip(disabledTimeField,
MSG.view_resource_monitor_availability_disabledTime_tooltip());
+
+ // row 5
+ failureCountField = new StaticTextItem("failureCount",
MSG.view_resource_monitor_availability_numFailures());
+ failureCountField.setWrapTitle(false);
+ prepareTooltip(failureCountField,
MSG.view_resource_monitor_availability_numFailures_tooltip());
+
+ disabledCountField = new StaticTextItem("disabledCount",
MSG.view_resource_monitor_availability_numDisabled());
+ disabledCountField.setWrapTitle(false);
+ prepareTooltip(disabledCountField,
MSG.view_resource_monitor_availability_numDisabled_tooltip());
+
+ // row 6
+ mtbfField = new StaticTextItem("mtbf",
MSG.view_resource_monitor_availability_mtbf());
+ mtbfField.setWrapTitle(false);
+ prepareTooltip(mtbfField,
MSG.view_resource_monitor_availability_mtbf_tooltip());
+
+ mttrField = new StaticTextItem("mttr",
MSG.view_resource_monitor_availability_mttr());
+ mttrField.setWrapTitle(false);
+ prepareTooltip(mttrField,
MSG.view_resource_monitor_availability_mttr_tooltip());
+
+ // row 7
+ unknownField = new StaticTextItem("unknown");
+ unknownField.setWrapTitle(false);
+ unknownField.setColSpan(4);
+ unknownField.setShowTitle(false);
+
+ // row 8
+ currentTimeField = new StaticTextItem("currentTime");
+ currentTimeField.setWrapTitle(false);
+ currentTimeField.setColSpan(4);
+ currentTimeField.setShowTitle(false);
+
+ form.setItems(currentField, availField, availTimeField, downField, downTimeField,
disabledField,
+ disabledTimeField, failureCountField, disabledCountField, mtbfField,
mttrField, unknownField,
+ currentTimeField);
+
+ reloadSummaryData();
+
+ return form;
+ }
+
+ private void reloadSummaryData() {
+ GWTServiceLookup.getResourceService().getResourceAvailabilitySummary(resourceId,
+ new AsyncCallback<ResourceAvailabilitySummary>() {
+
+ @Override
+ public void onSuccess(ResourceAvailabilitySummary result) {
+
+
currentField.setValue(MSG.view_resource_monitor_availability_currentStatus_value(
+ getAvailabilityTypeMessage(result.getCurrent()),
+
TimestampCellFormatter.format(result.getLastChange().getTime())));
+
availField.setValue(MeasurementConverterClient.format(result.getUpPercentage(),
+ MeasurementUnits.PERCENTAGE, true));
+ availTimeField.setValue(MeasurementConverterClient.format((double)
result.getUpTime(),
+ MeasurementUnits.MILLISECONDS, true));
+
downField.setValue(MeasurementConverterClient.format(result.getDownPercentage(),
+ MeasurementUnits.PERCENTAGE, true));
+ downTimeField.setValue(MeasurementConverterClient.format((double)
result.getDownTime(),
+ MeasurementUnits.MILLISECONDS, true));
+
disabledField.setValue(MeasurementConverterClient.format(result.getDisabledPercentage(),
+ MeasurementUnits.PERCENTAGE, true));
+ disabledTimeField.setValue(MeasurementConverterClient.format((double)
result.getDisabledTime(),
+ MeasurementUnits.MILLISECONDS, true));
+ failureCountField.setValue(result.getFailures());
+ disabledCountField.setValue(result.getDisabled());
+ mtbfField.setValue(MeasurementConverterClient.format((double)
result.getMTBF(),
+ MeasurementUnits.MILLISECONDS, true));
+ mttrField.setValue(MeasurementConverterClient.format((double)
result.getMTTR(),
+ MeasurementUnits.MILLISECONDS, true));
+
+ if (result.getUnknownTime() > 0L) {
+
unknownField.setValue(MSG.view_resource_monitor_availability_unknown(MeasurementConverterClient
+ .format((double) result.getUnknownTime(),
MeasurementUnits.MILLISECONDS, true)));
+ } else {
+ unknownField.setValue("");
+ }
+
+
currentTimeField.setValue(MSG.view_resource_monitor_availability_currentAsOf(TimestampCellFormatter
+ .format(result.getCurrentTime())));
+ }
+
+ @Override
+ public void onFailure(Throwable caught) {
+ currentField.setValue(MSG.common_label_error());
+ CoreGUI.getErrorHandler()
+
.handleError(MSG.view_resource_monitor_availability_summaryError(), caught);
+ }
+ });
+ }
+
+ private String getAvailabilityTypeMessage(AvailabilityType availabilityType) {
+ switch (availabilityType) {
+ case UP:
+ return MSG.common_status_avail_up();
+ case DOWN:
+ return MSG.common_status_avail_down();
+ case DISABLED:
+ return MSG.common_status_avail_disabled();
+ case UNKNOWN:
+ default:
+ return MSG.common_status_avail_unknown();
+ }
+ }
+
+ private void prepareTooltip(FormItem item, String tooltip) {
+ item.setHoverWidth(400);
+ item.setPrompt(tooltip);
+ }
+
+}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricsGridFieldName.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricsGridFieldName.java
new file mode 100644
index 0000000..f912dee
--- /dev/null
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricsGridFieldName.java
@@ -0,0 +1,63 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2014 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.coregui.client.inventory.resource.detail.monitoring.table;
+
+import static org.rhq.core.domain.measurement.ui.MetricDisplayConstants.AVERAGE_KEY;
+import static org.rhq.core.domain.measurement.ui.MetricDisplayConstants.MAX_KEY;
+import static org.rhq.core.domain.measurement.ui.MetricDisplayConstants.MIN_KEY;
+
+import org.rhq.coregui.client.CoreGUI;
+
+/**
+ * Typesafe field names used in consolidated metrics screen grids for Resource and
ResourceGroup.
+ * Also associates the proper label with the value.
+ *
+ * @author Mike Thompson
+ */
+@SuppressWarnings("GwtInconsistentSerializableClass")
+public enum MetricsGridFieldName {
+
+ SPARKLINE("sparkline"), METRIC_LABEL("label",
CoreGUI.getMessages().common_title_name()), ALERT_COUNT("alertCount",
+ CoreGUI.getMessages().common_title_alerts()), MAX_VALUE(MAX_KEY,
CoreGUI.getMessages()
+ .common_title_monitor_maximum()), MIN_VALUE(MIN_KEY,
CoreGUI.getMessages().common_title_monitor_minimum()), AVG_VALUE(
+ AVERAGE_KEY, CoreGUI.getMessages().common_title_monitor_average()),
METRIC_DEF_ID("defId"), METRIC_SCHEDULE_ID(
+ "schedId"), METRIC_UNITS("units"),
METRIC_NAME("name"), RESOURCE_GROUP_ID("resourceGroupId"),
+ RESOURCE_ID("resourceId"), LIVE_VALUE("live",
CoreGUI.getMessages().view_resource_monitor_table_live());
+
+ private final String value;
+ private final String label;
+
+ MetricsGridFieldName(String value, String label) {
+ this.value = value;
+ this.label = label;
+ }
+
+ MetricsGridFieldName(String value) {
+ this.value = value;
+ this.label = "";
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public String getLabel() {
+ return label;
+ }
+}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricsResourceView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricsResourceView.java
index efba122..7e84c3d 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricsResourceView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricsResourceView.java
@@ -41,7 +41,6 @@ import
org.rhq.coregui.client.inventory.common.graph.graphtype.AvailabilityOverU
import org.rhq.coregui.client.inventory.resource.detail.monitoring.ExpandedRowsMomento;
import
org.rhq.coregui.client.inventory.resource.detail.monitoring.avail.AvailabilityD3GraphView;
import org.rhq.coregui.client.util.BrowserUtility;
-import org.rhq.coregui.client.util.Log;
import org.rhq.coregui.client.util.async.CountDownLatch;
import org.rhq.coregui.client.util.enhanced.EnhancedHLayout;
@@ -87,7 +86,7 @@ public class MetricsResourceView extends AbstractD3GraphListView
implements
this.resource = resource;
metricsTableView = new MetricsTableView(resource, this, expandedRows);
- final ResourceMetricAvailabilityView availabilityDetails = new
ResourceMetricAvailabilityView(resource);
+ final MetricAvailabilityView availabilityDetails = new
MetricAvailabilityView(resource.getId());
availabilityDetails.hide();
metricsTableView.setHeight100();
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricsTableView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricsTableView.java
index 63a6619..6f0f7f7 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricsTableView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricsTableView.java
@@ -74,6 +74,8 @@ import org.rhq.coregui.client.util.BrowserUtility;
import org.rhq.coregui.client.util.Log;
import org.rhq.coregui.client.util.message.Message;
+import static
org.rhq.coregui.client.inventory.resource.detail.monitoring.table.MetricsGridFieldName.*;
+
/**
* Views a resource's metrics in a tabular view with sparkline graph and optional
detailed d3 graph.
*
@@ -125,10 +127,8 @@ public class MetricsTableView extends
Table<MetricsViewDataSource> implements Re
addToDashboardButton.enable();
ListGridRecord selectedRecord = selectionEvent.getSelectedRecord();
if (null != selectedRecord) {
- //Log.debug("Selected Metric Label: "
- // +
selectedRecord.getAttribute(MetricsViewDataSource.FIELD_METRIC_LABEL));
- selectedMetricDefinitionId = selectedRecord
- .getAttributeAsInt(MetricsViewDataSource.FIELD_METRIC_DEF_ID);
+ selectedMetricDefinitionId =
selectedRecord.getAttributeAsInt(METRIC_DEF_ID
+ .getValue());
}
}
});
@@ -176,7 +176,7 @@ public class MetricsTableView extends
Table<MetricsViewDataSource> implements Re
if (measurementDefinition.getId() == selectedMetricDefinitionId) {
Log.debug("Add to Dashboard -- Storing: " +
measurementDefinition.getDisplayName() + " in "
+ selectedDashboard.getName());
- storeDashboardMetric(selectedDashboard, resource,
measurementDefinition);
+ storeDashboardMetric(selectedDashboard, resource.getId(),
measurementDefinition);
break;
}
}
@@ -233,11 +233,11 @@ public class MetricsTableView extends
Table<MetricsViewDataSource> implements Re
});
}
- private void storeDashboardMetric(Dashboard dashboard, Resource resource,
MeasurementDefinition definition) {
+ private void storeDashboardMetric(Dashboard dashboard, int resourceId,
MeasurementDefinition definition) {
DashboardPortlet dashboardPortlet = new
DashboardPortlet(MSG.view_tree_common_contextMenu_resourceGraph(),
- ResourceD3GraphPortlet.KEY, 200);
+ ResourceD3GraphPortlet.KEY, 260);
dashboardPortlet.getConfiguration().put(
- new PropertySimple(ResourceD3GraphPortlet.CFG_RESOURCE_ID,
resource.getId()));
+ new PropertySimple(ResourceD3GraphPortlet.CFG_RESOURCE_ID, resourceId));
dashboardPortlet.getConfiguration().put(
new PropertySimple(ResourceD3GraphPortlet.CFG_DEFINITION_ID,
definition.getId()));
@@ -278,7 +278,7 @@ public class MetricsTableView extends
Table<MetricsViewDataSource> implements Re
@Override
public void onRecordExpand(RecordExpandEvent recordExpandEvent) {
metricsTableView.expandedRows.add(recordExpandEvent.getRecord().getAttributeAsInt(
- MetricsViewDataSource.FIELD_METRIC_DEF_ID));
+ METRIC_DEF_ID.getValue()));
refreshData();
}
@@ -287,7 +287,7 @@ public class MetricsTableView extends
Table<MetricsViewDataSource> implements Re
@Override
public void onRecordCollapse(RecordCollapseEvent recordCollapseEvent) {
metricsTableView.expandedRows.remove(recordCollapseEvent.getRecord().getAttributeAsInt(
- MetricsViewDataSource.FIELD_METRIC_DEF_ID));
+ METRIC_DEF_ID.getValue()));
refresh();
new Timer() {
@Override
@@ -321,7 +321,7 @@ public class MetricsTableView extends
Table<MetricsViewDataSource> implements Re
ListGridRecord listGridRecord = getRecord(i);
if (null != listGridRecord) {
int metricDefinitionId = listGridRecord
- .getAttributeAsInt(MetricsViewDataSource.FIELD_METRIC_DEF_ID);
+ .getAttributeAsInt(METRIC_DEF_ID.getValue());
if (null != metricsTableView && null != expandedRows
&&
metricsTableView.expandedRows.contains(metricDefinitionId)) {
expandRecord(listGridRecord);
@@ -330,18 +330,14 @@ public class MetricsTableView extends
Table<MetricsViewDataSource> implements Re
}
}
- public void expandOpenedRows(Set<Integer> selectedRows) {
- expandedRows = selectedRows;
- expandOpenedRows();
- }
@Override
/**
* If you expand a grid row then create a graph.
*/
protected Canvas getExpansionComponent(final ListGridRecord record) {
- final Integer definitionId =
record.getAttributeAsInt(MetricsViewDataSource.FIELD_METRIC_DEF_ID);
- final Integer resourceId =
record.getAttributeAsInt(MetricsViewDataSource.FIELD_RESOURCE_ID);
+ final Integer definitionId =
record.getAttributeAsInt(METRIC_DEF_ID.getValue());
+ final Integer resourceId = record.getAttributeAsInt(RESOURCE_ID.getValue());
VLayout vLayout = new VLayout();
vLayout.setPadding(5);
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricsViewDataSource.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricsViewDataSource.java
index 4c9c7c1..248eee0 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricsViewDataSource.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricsViewDataSource.java
@@ -61,6 +61,7 @@ import org.rhq.coregui.client.util.RPCDataSource;
import org.rhq.coregui.client.util.async.Command;
import org.rhq.coregui.client.util.async.CountDownLatch;
import org.rhq.coregui.client.util.preferences.MeasurementUserPreferences;
+import static
org.rhq.coregui.client.inventory.resource.detail.monitoring.table.MetricsGridFieldName.*;
/**
* A simple data source to read in metric data summaries for a resource.
@@ -75,19 +76,6 @@ public class MetricsViewDataSource extends
RPCDataSource<MetricDisplaySummary, C
private static final int NUMBER_OF_METRIC_POINTS = 60;
- public static final String FIELD_SPARKLINE = "sparkline";
- public static final String FIELD_METRIC_LABEL = "label";
- public static final String FIELD_ALERT_COUNT = "alertCount";
- public static final String FIELD_MIN_VALUE = "min";
- public static final String FIELD_MAX_VALUE = "max";
- public static final String FIELD_AVG_VALUE = "avg";
- public static final String FIELD_LIVE_VALUE = "live";
- public static final String FIELD_METRIC_DEF_ID = "defId";
- public static final String FIELD_METRIC_SCHED_ID = "schedId";
- public static final String FIELD_METRIC_UNITS = "units";
- public static final String FIELD_METRIC_NAME = "name";
- public static final String FIELD_RESOURCE_ID = "resourceId";
-
private final Resource resource;
private List<MetricDisplaySummary> metricDisplaySummaries;
private List<List<MeasurementDataNumericHighLowComposite>>
metricsDataList;
@@ -111,7 +99,7 @@ public class MetricsViewDataSource extends
RPCDataSource<MetricDisplaySummary, C
public ArrayList<ListGridField> getListGridFields() {
ArrayList<ListGridField> fields = new ArrayList<ListGridField>(7);
- ListGridField sparklineField = new ListGridField(FIELD_SPARKLINE,
MSG.chart_metrics_sparkline_header());
+ ListGridField sparklineField = new ListGridField(SPARKLINE.getValue(),
MSG.chart_metrics_sparkline_header());
sparklineField.setCellFormatter(new CellFormatter() {
@Override
public String format(Object value, ListGridRecord record, int rowNum, int
colNum) {
@@ -119,8 +107,8 @@ public class MetricsViewDataSource extends
RPCDataSource<MetricDisplaySummary, C
return "";
}
String contents = "<span id='sparkline_" +
resource.getId() + "-"
- + record.getAttributeAsInt(FIELD_METRIC_DEF_ID) + "'
class='dynamicsparkline' width='70' "
- + "values='" + record.getAttribute(FIELD_SPARKLINE)
+ "'></span>";
+ + record.getAttributeAsInt(METRIC_DEF_ID.getValue()) +
"' class='dynamicsparkline' width='70' "
+ + "values='" +
record.getAttribute(SPARKLINE.getValue()) + "'></span>";
return contents;
}
@@ -129,27 +117,27 @@ public class MetricsViewDataSource extends
RPCDataSource<MetricDisplaySummary, C
sparklineField.setWidth(80);
fields.add(sparklineField);
- ListGridField nameField = new ListGridField(FIELD_METRIC_LABEL,
MSG.common_title_name());
+ ListGridField nameField = new ListGridField(METRIC_LABEL.getValue(),
METRIC_LABEL.getLabel());
nameField.setWidth("30%");
fields.add(nameField);
- ListGridField minField = new ListGridField(FIELD_MIN_VALUE,
MSG.common_title_monitor_minimum());
+ ListGridField minField = new ListGridField(MIN_VALUE.getValue(),
MIN_VALUE.getLabel());
minField.setWidth("15%");
fields.add(minField);
- ListGridField maxField = new ListGridField(FIELD_MAX_VALUE,
MSG.common_title_monitor_maximum());
+ ListGridField maxField = new ListGridField(MAX_VALUE.getValue(),
MAX_VALUE.getLabel());
maxField.setWidth("15%");
fields.add(maxField);
- ListGridField avgField = new ListGridField(FIELD_AVG_VALUE,
MSG.common_title_monitor_average());
+ ListGridField avgField = new ListGridField(AVG_VALUE.getValue(),
AVG_VALUE.getLabel());
avgField.setWidth("15%");
fields.add(avgField);
- ListGridField liveField = new ListGridField(FIELD_LIVE_VALUE,
MSG.view_resource_monitor_table_live());
+ ListGridField liveField = new ListGridField(LIVE_VALUE.getValue(),
LIVE_VALUE.getLabel());
liveField.setWidth("15%");
fields.add(liveField);
- ListGridField alertsField = new ListGridField(FIELD_ALERT_COUNT,
MSG.common_title_alerts());
+ ListGridField alertsField = new ListGridField(ALERT_COUNT.getValue(),
ALERT_COUNT.getLabel());
alertsField.setWidth("10%");
fields.add(alertsField);
@@ -170,18 +158,18 @@ public class MetricsViewDataSource extends
RPCDataSource<MetricDisplaySummary, C
MeasurementUtility.formatSimpleMetrics(from);
ListGridRecord record = new ListGridRecord();
- record.setAttribute(FIELD_SPARKLINE,
getCsvMetricsForSparkline(from.getDefinitionId()));
- record.setAttribute(FIELD_METRIC_LABEL, from.getLabel());
- record.setAttribute(FIELD_ALERT_COUNT, String.valueOf(from.getAlertCount()));
- record.setAttribute(FIELD_MIN_VALUE, getMetricStringValue(from.getMinMetric()));
- record.setAttribute(FIELD_MAX_VALUE, getMetricStringValue(from.getMaxMetric()));
- record.setAttribute(FIELD_AVG_VALUE, getMetricStringValue(from.getAvgMetric()));
- record.setAttribute(FIELD_LIVE_VALUE, buildLiveValue(from));
- record.setAttribute(FIELD_METRIC_DEF_ID, from.getDefinitionId());
- record.setAttribute(FIELD_METRIC_SCHED_ID, from.getScheduleId());
- record.setAttribute(FIELD_METRIC_UNITS, from.getUnits());
- record.setAttribute(FIELD_METRIC_NAME, from.getMetricName());
- record.setAttribute(FIELD_RESOURCE_ID, resource.getId());
+ record.setAttribute(SPARKLINE.getValue(),
getCsvMetricsForSparkline(from.getDefinitionId()));
+ record.setAttribute(METRIC_LABEL.getValue(), from.getLabel());
+ record.setAttribute(ALERT_COUNT.getValue(),
String.valueOf(from.getAlertCount()));
+ record.setAttribute(MIN_VALUE.getValue(),
getMetricStringValue(from.getMinMetric()));
+ record.setAttribute(MAX_VALUE.getValue(),
getMetricStringValue(from.getMaxMetric()));
+ record.setAttribute(AVG_VALUE.getValue(),
getMetricStringValue(from.getAvgMetric()));
+ record.setAttribute(LIVE_VALUE.getValue(), buildLiveValue(from));
+ record.setAttribute(METRIC_DEF_ID.getValue(), from.getDefinitionId());
+ record.setAttribute(METRIC_SCHEDULE_ID.getValue(), from.getScheduleId());
+ record.setAttribute(METRIC_UNITS.getValue(), from.getUnits());
+ record.setAttribute(METRIC_NAME.getValue(), from.getMetricName());
+ record.setAttribute(RESOURCE_ID.getValue(), resource.getId());
return record;
}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/ResourceMetricAvailabilityView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/ResourceMetricAvailabilityView.java
deleted file mode 100644
index 5919f83..0000000
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/ResourceMetricAvailabilityView.java
+++ /dev/null
@@ -1,224 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright 2012, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * 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.coregui.client.inventory.resource.detail.monitoring.table;
-
-import com.google.gwt.user.client.rpc.AsyncCallback;
-import com.smartgwt.client.widgets.form.DynamicForm;
-import com.smartgwt.client.widgets.form.fields.FormItem;
-import com.smartgwt.client.widgets.form.fields.StaticTextItem;
-
-import org.rhq.core.domain.measurement.AvailabilityType;
-import org.rhq.core.domain.measurement.MeasurementUnits;
-import org.rhq.core.domain.resource.Resource;
-import org.rhq.core.domain.resource.composite.ResourceAvailabilitySummary;
-import org.rhq.coregui.client.CoreGUI;
-import org.rhq.coregui.client.components.table.TimestampCellFormatter;
-import org.rhq.coregui.client.gwt.GWTServiceLookup;
-import org.rhq.coregui.client.util.MeasurementConverterClient;
-import org.rhq.coregui.client.util.enhanced.EnhancedVLayout;
-
-/**
- * This shows the availability history for a resource.
- *
- * @author Jay Shaughnessy
- * @author John Mazzitelli
- * @author Mike Thompson
- */
-public class ResourceMetricAvailabilityView extends EnhancedVLayout {
-
- private Resource resource;
- private StaticTextItem currentField;
- private StaticTextItem availField;
- private StaticTextItem availTimeField;
- private StaticTextItem downField;
- private StaticTextItem downTimeField;
- private StaticTextItem disabledField;
- private StaticTextItem disabledTimeField;
- private StaticTextItem failureCountField;
- private StaticTextItem disabledCountField;
- private StaticTextItem mtbfField;
- private StaticTextItem mttrField;
- private StaticTextItem unknownField;
- private StaticTextItem currentTimeField;
-
- public ResourceMetricAvailabilityView(Resource resource) {
- super();
-
- this.resource = resource;
-
- setWidth100();
- setHeight(165);
- }
-
- @Override
- protected void onInit() {
- super.onInit();
-
- addMember(createSummaryForm());
- }
-
- private DynamicForm createSummaryForm() {
- DynamicForm form = new DynamicForm();
- form.setWidth100();
- form.setAutoHeight();
- form.setMargin(10);
- form.setNumCols(4);
-
- // row 1
- currentField = new StaticTextItem("current",
MSG.view_resource_monitor_availability_currentStatus());
- currentField.setWrapTitle(false);
- currentField.setColSpan(4);
-
- // row 2
- availField = new StaticTextItem("avail",
MSG.common_title_availability());
- availField.setWrapTitle(false);
- prepareTooltip(availField, MSG.view_resource_monitor_availability_tooltip_up());
-
- availTimeField = new StaticTextItem("availTime",
MSG.view_resource_monitor_availability_uptime());
- availTimeField.setWrapTitle(false);
- prepareTooltip(availTimeField,
MSG.view_resource_monitor_availability_uptime_tooltip());
-
- // row 3
- downField = new StaticTextItem("down",
MSG.common_status_avail_down_lower());
- downField.setWrapTitle(false);
- prepareTooltip(downField,
MSG.view_resource_monitor_availability_tooltip_down());
-
- downTimeField = new StaticTextItem("downTime",
MSG.view_resource_monitor_availability_downtime());
- downTimeField.setWrapTitle(false);
- prepareTooltip(downTimeField,
MSG.view_resource_monitor_availability_downtime_tooltip());
-
- // row 4
- disabledField = new StaticTextItem("disabled",
MSG.common_status_avail_disabled_lower());
- disabledField.setWrapTitle(false);
- prepareTooltip(disabledField,
MSG.view_resource_monitor_availability_tooltip_disabled());
-
- disabledTimeField = new StaticTextItem("disabledTime",
MSG.view_resource_monitor_availability_disabledTime());
- disabledTimeField.setWrapTitle(false);
- prepareTooltip(disabledTimeField,
MSG.view_resource_monitor_availability_disabledTime_tooltip());
-
- // row 5
- failureCountField = new StaticTextItem("failureCount",
MSG.view_resource_monitor_availability_numFailures());
- failureCountField.setWrapTitle(false);
- prepareTooltip(failureCountField,
MSG.view_resource_monitor_availability_numFailures_tooltip());
-
- disabledCountField = new StaticTextItem("disabledCount",
MSG.view_resource_monitor_availability_numDisabled());
- disabledCountField.setWrapTitle(false);
- prepareTooltip(disabledCountField,
MSG.view_resource_monitor_availability_numDisabled_tooltip());
-
- // row 6
- mtbfField = new StaticTextItem("mtbf",
MSG.view_resource_monitor_availability_mtbf());
- mtbfField.setWrapTitle(false);
- prepareTooltip(mtbfField,
MSG.view_resource_monitor_availability_mtbf_tooltip());
-
- mttrField = new StaticTextItem("mttr",
MSG.view_resource_monitor_availability_mttr());
- mttrField.setWrapTitle(false);
- prepareTooltip(mttrField,
MSG.view_resource_monitor_availability_mttr_tooltip());
-
- // row 7
- unknownField = new StaticTextItem("unknown");
- unknownField.setWrapTitle(false);
- unknownField.setColSpan(4);
- unknownField.setShowTitle(false);
-
- // row 8
- currentTimeField = new StaticTextItem("currentTime");
- currentTimeField.setWrapTitle(false);
- currentTimeField.setColSpan(4);
- currentTimeField.setShowTitle(false);
-
- form.setItems(currentField, availField, availTimeField, downField, downTimeField,
disabledField,
- disabledTimeField, failureCountField, disabledCountField, mtbfField,
mttrField, unknownField,
- currentTimeField);
-
- reloadSummaryData();
-
- return form;
- }
-
- private void reloadSummaryData() {
-
GWTServiceLookup.getResourceService().getResourceAvailabilitySummary(resource.getId(),
- new AsyncCallback<ResourceAvailabilitySummary>() {
-
- @Override
- public void onSuccess(ResourceAvailabilitySummary result) {
-
-
currentField.setValue(MSG.view_resource_monitor_availability_currentStatus_value(
- getAvailabilityTypeMessage(result.getCurrent()),
-
TimestampCellFormatter.format(result.getLastChange().getTime())));
-
availField.setValue(MeasurementConverterClient.format(result.getUpPercentage(),
- MeasurementUnits.PERCENTAGE, true));
- availTimeField.setValue(MeasurementConverterClient.format((double)
result.getUpTime(),
- MeasurementUnits.MILLISECONDS, true));
-
downField.setValue(MeasurementConverterClient.format(result.getDownPercentage(),
- MeasurementUnits.PERCENTAGE, true));
- downTimeField.setValue(MeasurementConverterClient.format((double)
result.getDownTime(),
- MeasurementUnits.MILLISECONDS, true));
-
disabledField.setValue(MeasurementConverterClient.format(result.getDisabledPercentage(),
- MeasurementUnits.PERCENTAGE, true));
- disabledTimeField.setValue(MeasurementConverterClient.format((double)
result.getDisabledTime(),
- MeasurementUnits.MILLISECONDS, true));
- failureCountField.setValue(result.getFailures());
- disabledCountField.setValue(result.getDisabled());
- mtbfField.setValue(MeasurementConverterClient.format((double)
result.getMTBF(),
- MeasurementUnits.MILLISECONDS, true));
- mttrField.setValue(MeasurementConverterClient.format((double)
result.getMTTR(),
- MeasurementUnits.MILLISECONDS, true));
-
- if (result.getUnknownTime() > 0L) {
-
unknownField.setValue(MSG.view_resource_monitor_availability_unknown(MeasurementConverterClient
- .format((double) result.getUnknownTime(),
MeasurementUnits.MILLISECONDS, true)));
- } else {
- unknownField.setValue("");
- }
-
-
currentTimeField.setValue(MSG.view_resource_monitor_availability_currentAsOf(TimestampCellFormatter
- .format(result.getCurrentTime())));
- }
-
- @Override
- public void onFailure(Throwable caught) {
- currentField.setValue(MSG.common_label_error());
- CoreGUI.getErrorHandler()
-
.handleError(MSG.view_resource_monitor_availability_summaryError(), caught);
- }
- });
- }
-
- private String getAvailabilityTypeMessage(AvailabilityType availabilityType) {
- switch (availabilityType) {
- case UP:
- return MSG.common_status_avail_up();
- case DOWN:
- return MSG.common_status_avail_down();
- case DISABLED:
- return MSG.common_status_avail_disabled();
- case UNKNOWN:
- default:
- return MSG.common_status_avail_unknown();
- }
- }
-
- private void prepareTooltip(FormItem item, String tooltip) {
- item.setHoverWidth(400);
- item.setPrompt(tooltip);
- }
-
-}
commit ba14a590a9c7e2d98c9a405087ce0f82da2d84a1
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Fri Dec 13 17:39:57 2013 +0100
[BZ 1042892] Don't use ${} notation for shell variables in CLI scripts.
As of BZ 959603, the files are subject to maven resource filtering and
so it can happen that the build server passes a variable to the build
process that clashes with the variable name defined in the script.
(Yes, this actually happened on our Jenkins server that passed
"-DCLASSPATH=" to the maven process for some reason, which resulted in
wonderful corruption of the rhq-cli.sh script).
diff --git a/modules/enterprise/remoting/cli/src/etc/rhq-cli-env.sh
b/modules/enterprise/remoting/cli/src/etc/rhq-cli-env.sh
index 112ec66..80f24c5 100755
--- a/modules/enterprise/remoting/cli/src/etc/rhq-cli-env.sh
+++ b/modules/enterprise/remoting/cli/src/etc/rhq-cli-env.sh
@@ -3,6 +3,14 @@
#===========================================================================
#
+# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+# IMPORTANT: Avoid enclosing shell variables in braces using the ${XXX}
+# notation. This file is subject to maven resource variable expansion
+# during the build and so it can happen that the build environment
+# could corrupt this file by expanding variables that clash with
+# the names defined herein.
+# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
# RHQ_CLI_DEBUG - If this is defined, the script will emit debug
# messages. It will also enable debug
# messages to be emitted from the cli itself.
@@ -41,7 +49,7 @@
# to the CLI's defaults, then you will want to
# use RHQ_CLI_ADDITIONAL_JAVA_OPTS instead.
#
-#RHQ_CLI_JAVA_OPTS="-Xms64m -Xmx128m -Djava.net.preferIPv4Stack=true
-Drhq.scripting.modules.root-dir=${RHQ_CLI_MODULES_DIR}"
+#RHQ_CLI_JAVA_OPTS="-Xms64m -Xmx128m -Djava.net.preferIPv4Stack=true
-Drhq.scripting.modules.root-dir=$RHQ_CLI_MODULES_DIR"
# RHQ_CLI_JAVA_ENDORSED_DIRS - Java VM command line option to set the
# endorsed dirs for the CLI's VM. If this
diff --git a/modules/enterprise/remoting/cli/src/etc/rhq-cli.sh
b/modules/enterprise/remoting/cli/src/etc/rhq-cli.sh
index 8399b50..b0980e6 100644
--- a/modules/enterprise/remoting/cli/src/etc/rhq-cli.sh
+++ b/modules/enterprise/remoting/cli/src/etc/rhq-cli.sh
@@ -11,6 +11,14 @@
# set via rhq-client-env.sh, which is sourced by this script.
# =============================================================================
+# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+# IMPORTANT: Avoid enclosing shell variables in braces using the ${XXX}
+# notation. This file is subject to maven resource variable expansion
+# during the build and so it can happen that the build environment
+# could corrupt this file by expanding variables that clash with
+# the names defined herein.
+# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
# ----------------------------------------------------------------------
# Subroutine that simply dumps a message iff debug mode is enabled
# ----------------------------------------------------------------------
@@ -42,16 +50,17 @@ esac
_DOLLARZERO=`readlink "$0" 2>/dev/null || echo "$0"`
RHQ_CLI_BIN_DIR_PATH=`dirname "$_DOLLARZERO"`
-if [ -f "${RHQ_CLI_BIN_DIR_PATH}/rhq-cli-env.sh" ]; then
- debug_msg "Loading environment script:
${RHQ_CLI_BIN_DIR_PATH}/rhq-cli-env.sh"
- . "${RHQ_CLI_BIN_DIR_PATH}/rhq-cli-env.sh" $*
+if [ -f "$RHQ_CLI_BIN_DIR_PATH/rhq-cli-env.sh" ]; then
+ debug_msg "Loading environment script:
$RHQ_CLI_BIN_DIR_PATH/rhq-cli-env.sh"
+ . "$RHQ_CLI_BIN_DIR_PATH/rhq-cli-env.sh" $*
else
- debug_msg "No environment script found at:
${RHQ_CLI_BIN_DIR_PATH}/rhq-cli-env.sh"
+ debug_msg "No environment script found at:
$RHQ_CLI_BIN_DIR_PATH/rhq-cli-env.sh"
fi
# this variable is set during the build and defines the desired default behavior for
directory changing
# we do want to change the dir in RHQ, but possibly don't want to do that in JBoss ON
for backwards compatibility
# reasons.
+# (yes, this USES ${} in the source (not in the distribution) because we seed the default
value from the build)
RHQ_CLI_CHANGE_DIR_ON_START_DEFAULT=${rhq.cli.change-dir-on-start-default}
if [ -z "$RHQ_CLI_CHANGE_DIR_ON_START" ]; then
RHQ_CLI_CHANGE_DIR_ON_START="$RHQ_CLI_CHANGE_DIR_ON_START_DEFAULT"
@@ -61,24 +70,24 @@ fi
# Previous versions always changed directory.
if [ -n "$RHQ_CLI_CHANGE_DIR_ON_START" -a
"$RHQ_CLI_CHANGE_DIR_ON_START" != "false" ]; then
if [ -z "$RHQ_CLI_HOME" ]; then
- cd "${RHQ_CLI_BIN_DIR_PATH}/.."
+ cd "$RHQ_CLI_BIN_DIR_PATH/.."
else
- cd "${RHQ_CLI_HOME}" || {
- echo "Cannot go to the RHQ_CLI_HOME directory: ${RHQ_CLI_HOME}"
+ cd "$RHQ_CLI_HOME" || {
+ echo "Cannot go to the RHQ_CLI_HOME directory: $RHQ_CLI_HOME"
exit 1
}
fi
RHQ_CLI_HOME=`pwd`
else
if [ -z "$RHQ_CLI_HOME" ]; then
- RHQ_CLI_HOME="${RHQ_CLI_BIN_DIR_PATH}/.."
+ RHQ_CLI_HOME="$RHQ_CLI_BIN_DIR_PATH/.."
fi
#get an absolute path
RHQ_CLI_HOME=`readlink -f "$RHQ_CLI_HOME"`
if [ ! -d "$RHQ_CLI_HOME" ]; then
- echo "RHQ_CLI_HOME detected or defined as [${RHQ_CLI_HOME}] doesn't seem
to exist or is not a directory"
+ echo "RHQ_CLI_HOME detected or defined as [$RHQ_CLI_HOME] doesn't seem
to exist or is not a directory"
exit 1
fi
fi
@@ -90,7 +99,7 @@ debug_msg "RHQ_CLI_HOME: $RHQ_CLI_HOME"
# sample modules.
# ----------------------------------------------------------------------
if [ -z "$RHQ_CLI_MODULES_DIR" ]; then
- RHQ_CLI_MODULES_DIR="${RHQ_CLI_HOME}/samples/modules"
+ RHQ_CLI_MODULES_DIR="$RHQ_CLI_HOME/samples/modules"
fi
# ----------------------------------------------------------------------
@@ -110,7 +119,7 @@ fi
if [ -z "$RHQ_CLI_JAVA_EXE_FILE_PATH" ]; then
if [ -z "$RHQ_CLI_JAVA_HOME" ]; then
- RHQ_CLI_JAVA_HOME="${RHQ_CLI_HOME}/jre"
+ RHQ_CLI_JAVA_HOME="$RHQ_CLI_HOME/jre"
if [ -d "$RHQ_CLI_JAVA_HOME" ]; then
debug_msg "Using the embedded JRE"
else
@@ -119,7 +128,7 @@ if [ -z "$RHQ_CLI_JAVA_EXE_FILE_PATH" ]; then
fi
fi
debug_msg "RHQ_CLI_JAVA_HOME: $RHQ_CLI_JAVA_HOME"
- RHQ_CLI_JAVA_EXE_FILE_PATH=${RHQ_CLI_JAVA_HOME}/bin/java
+ RHQ_CLI_JAVA_EXE_FILE_PATH="$RHQ_CLI_JAVA_HOME/bin/java"
fi
debug_msg "RHQ_CLI_JAVA_EXE_FILE_PATH: $RHQ_CLI_JAVA_EXE_FILE_PATH"
@@ -133,14 +142,14 @@ fi
# Prepare the classpath (take into account possible spaces in dir names)
# ----------------------------------------------------------------------
-CLASSPATH="${RHQ_CLI_HOME}/conf"
-_JAR_FILES=`cd "${RHQ_CLI_HOME}/lib";ls -1 *.jar`
+CLASSPATH="$RHQ_CLI_HOME/conf"
+_JAR_FILES=`cd "$RHQ_CLI_HOME/lib";ls -1 *.jar`
for _JAR in $_JAR_FILES ; do
- _JAR="${RHQ_CLI_HOME}/lib/${_JAR}"
+ _JAR="$RHQ_CLI_HOME/lib/$_JAR"
if [ -z "$CLASSPATH" ]; then
- CLASSPATH="${_JAR}"
+ CLASSPATH="$_JAR"
else
- CLASSPATH="${CLASSPATH}:${_JAR}"
+ CLASSPATH="$CLASSPATH:$_JAR"
fi
debug_msg "CLASSPATH entry: $_JAR"
done
@@ -151,7 +160,7 @@ debug_msg "CLASSPATH entry: $_JAR"
# ----------------------------------------------------------------------
if [ -z "$RHQ_CLI_JAVA_OPTS" ]; then
- RHQ_CLI_JAVA_OPTS="-Xms64m -Xmx128m -Djava.net.preferIPv4Stack=true
-Drhq.scripting.modules.root-dir=${RHQ_CLI_MODULES_DIR}"
+ RHQ_CLI_JAVA_OPTS="-Xms64m -Xmx128m -Djava.net.preferIPv4Stack=true
-Drhq.scripting.modules.root-dir=$RHQ_CLI_MODULES_DIR"
fi
debug_msg "RHQ_CLI_JAVA_OPTS: $RHQ_CLI_JAVA_OPTS"
@@ -159,7 +168,7 @@ if [ "$RHQ_CLI_JAVA_ENDORSED_DIRS" = "none" ];
then
debug_msg "Not explicitly setting java.endorsed.dirs"
else
if [ -z "$RHQ_CLI_JAVA_ENDORSED_DIRS" ]; then
- RHQ_CLI_JAVA_ENDORSED_DIRS="${RHQ_CLI_HOME}/lib/endorsed"
+ RHQ_CLI_JAVA_ENDORSED_DIRS="$RHQ_CLI_HOME/lib/endorsed"
fi
# convert the path if on Windows
@@ -167,14 +176,14 @@ else
RHQ_CLI_JAVA_ENDORSED_DIRS=`cygpath --windows --path
"$RHQ_CLI_JAVA_ENDORSED_DIRS"`
fi
debug_msg "RHQ_CLI_JAVA_ENDORSED_DIRS: $RHQ_CLI_JAVA_ENDORSED_DIRS"
-
_JAVA_ENDORSED_DIRS_OPT="-Djava.endorsed.dirs=\"${RHQ_CLI_JAVA_ENDORSED_DIRS}\""
+
_JAVA_ENDORSED_DIRS_OPT="-Djava.endorsed.dirs=\"$RHQ_CLI_JAVA_ENDORSED_DIRS\""
fi
if [ "$RHQ_CLI_JAVA_LIBRARY_PATH" = "none" ]; then
debug_msg "Not explicitly setting java.library.path"
else
if [ -z "$RHQ_CLI_JAVA_LIBRARY_PATH" ]; then
- RHQ_CLI_JAVA_LIBRARY_PATH="${RHQ_CLI_HOME}/lib"
+ RHQ_CLI_JAVA_LIBRARY_PATH="$RHQ_CLI_HOME/lib"
fi
# convert the path if on Windows
@@ -182,7 +191,7 @@ else
RHQ_CLI_JAVA_LIBRARY_PATH=`cygpath --windows --path
"$RHQ_CLI_JAVA_LIBRARY_PATH"`
fi
debug_msg "RHQ_CLI_JAVA_LIBRARY_PATH: $RHQ_CLI_JAVA_LIBRARY_PATH"
-
_JAVA_LIBRARY_PATH_OPT="-Djava.library.path=\"${RHQ_CLI_JAVA_LIBRARY_PATH}\""
+
_JAVA_LIBRARY_PATH_OPT="-Djava.library.path=\"$RHQ_CLI_JAVA_LIBRARY_PATH\""
fi
debug_msg "RHQ_CLI_ADDITIONAL_JAVA_OPTS: $RHQ_CLI_ADDITIONAL_JAVA_OPTS"
@@ -201,8 +210,8 @@ if [ -n "$RHQ_CLI_DEBUG" ]; then
fi
# create the logs directory
-if [ ! -d "${RHQ_CLI_HOME}/logs" ]; then
- mkdir "${RHQ_CLI_HOME}/logs"
+if [ ! -d "$RHQ_CLI_HOME/logs" ]; then
+ mkdir "$RHQ_CLI_HOME/logs"
fi
# convert some of the paths if we are on Windows
@@ -220,15 +229,15 @@ fi
debug_msg "Executing the CLI with this command line:"
exit_code=0
if [ -z "$RHQ_CLI_CMDLINE_OPTS" ]; then
- debug_msg "${RHQ_CLI_JAVA_EXE_FILE_PATH} ${_JAVA_ENDORSED_DIRS_OPT}
${_JAVA_LIBRARY_PATH_OPT} ${RHQ_CLI_JAVA_OPTS} ${RHQ_CLI_ADDITIONAL_JAVA_OPTS}
${_LOG_CONFIG} -cp ${CLASSPATH} org.rhq.enterprise.client.ClientMain $@"
- "${RHQ_CLI_JAVA_EXE_FILE_PATH}" ${_JAVA_ENDORSED_DIRS_OPT}
${_JAVA_LIBRARY_PATH_OPT} ${RHQ_CLI_JAVA_OPTS} ${RHQ_CLI_ADDITIONAL_JAVA_OPTS}
${_LOG_CONFIG} -cp "${CLASSPATH}" org.rhq.enterprise.client.ClientMain
"$@"
+ debug_msg "$RHQ_CLI_JAVA_EXE_FILE_PATH $_JAVA_ENDORSED_DIRS_OPT
$_JAVA_LIBRARY_PATH_OPT $RHQ_CLI_JAVA_OPTS $RHQ_CLI_ADDITIONAL_JAVA_OPTS $_LOG_CONFIG -cp
$CLASSPATH org.rhq.enterprise.client.ClientMain $@"
+ "$RHQ_CLI_JAVA_EXE_FILE_PATH" $_JAVA_ENDORSED_DIRS_OPT
$_JAVA_LIBRARY_PATH_OPT $RHQ_CLI_JAVA_OPTS $RHQ_CLI_ADDITIONAL_JAVA_OPTS $_LOG_CONFIG -cp
"$CLASSPATH" org.rhq.enterprise.client.ClientMain "$@"
exit_code=$?
else
- debug_msg "${RHQ_CLI_JAVA_EXE_FILE_PATH} ${_JAVA_ENDORSED_DIRS_OPT}
${_JAVA_LIBRARY_PATH_OPT} ${RHQ_CLI_JAVA_OPTS} ${RHQ_CLI_ADDITIONAL_JAVA_OPTS}
${_LOG_CONFIG} -cp ${CLASSPATH} org.rhq.enterprise.client.ClientMain
${RHQ_CLI_CMDLINE_OPTS}"
- "${RHQ_CLI_JAVA_EXE_FILE_PATH}" ${_JAVA_ENDORSED_DIRS_OPT}
${_JAVA_LIBRARY_PATH_OPT} ${RHQ_CLI_JAVA_OPTS} ${RHQ_CLI_ADDITIONAL_JAVA_OPTS}
${_LOG_CONFIG} -cp "${CLASSPATH}" org.rhq.enterprise.client.ClientMain
${RHQ_CLI_CMDLINE_OPTS}
+ debug_msg "$RHQ_CLI_JAVA_EXE_FILE_PATH $_JAVA_ENDORSED_DIRS_OPT
$_JAVA_LIBRARY_PATH_OPT $RHQ_CLI_JAVA_OPTS $RHQ_CLI_ADDITIONAL_JAVA_OPTS $_LOG_CONFIG -cp
$CLASSPATH org.rhq.enterprise.client.ClientMain $RHQ_CLI_CMDLINE_OPTS"
+ "$RHQ_CLI_JAVA_EXE_FILE_PATH" $_JAVA_ENDORSED_DIRS_OPT
$_JAVA_LIBRARY_PATH_OPT $RHQ_CLI_JAVA_OPTS $RHQ_CLI_ADDITIONAL_JAVA_OPTS $_LOG_CONFIG -cp
"$CLASSPATH" org.rhq.enterprise.client.ClientMain $RHQ_CLI_CMDLINE_OPTS
exit_code=$?
fi
debug_msg "$0 done."
-exit ${exit_code}
+exit $exit_code