[rhq] modules/core
by mazz
modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/PluginMetadataManager.java | 50 +++
modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/PluginMetadataParser.java | 78 +++++
modules/core/client-api/src/main/resources/rhq-plugin.xsd | 46 +++
modules/core/client-api/src/test/java/org/rhq/core/clientapi/agent/metadata/test/MetadataManagerTest.java | 22 +
modules/core/client-api/src/test/java/org/rhq/core/clientapi/agent/metadata/test/PluginMetadataParserTest.java | 83 ++++++
modules/core/client-api/src/test/resources/metadata-manager-test-2.xml | 7
modules/core/client-api/src/test/resources/metadata-manager-test-3.xml | 9
modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/inventory/ResourceDiscoveryCallback.java | 43 +++
modules/core/plugin-container-itest/src/test/java/org/rhq/core/pc/inventory/DiscoveryCallbackTest.java | 135 ++++++++++
modules/core/plugin-container-itest/src/test/java/org/rhq/core/pc/inventory/discoverycallback/PluginOneCallback.java | 22 +
modules/core/plugin-container-itest/src/test/java/org/rhq/core/pc/inventory/discoverycallback/PluginTwoCallback1.java | 21 +
modules/core/plugin-container-itest/src/test/java/org/rhq/core/pc/inventory/discoverycallback/PluginTwoCallback2.java | 19 +
modules/core/plugin-container-itest/src/test/resources/discovery-callback1.xml | 21 +
modules/core/plugin-container-itest/src/test/resources/discovery-callback2.xml | 24 +
modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java | 47 +++
modules/core/plugin-container/src/main/java/org/rhq/core/pc/plugin/PluginComponentFactory.java | 24 +
16 files changed, 643 insertions(+), 8 deletions(-)
New commits:
commit af523918b7e179c15bcae948cb8e7102e5072732
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Aug 30 15:16:58 2013 -0400
BZ 988735 - discovery callbacks that allow extension plugins to alter discovered details from some resource type
diff --git a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/PluginMetadataManager.java b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/PluginMetadataManager.java
index e75b7df..b9ee838 100644
--- a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/PluginMetadataManager.java
+++ b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/PluginMetadataManager.java
@@ -82,6 +82,11 @@ public class PluginMetadataManager {
private Set<ResourceType> ignoredResourceTypes = null;
private Object disabledIgnoredTypesLock = new Object(); // used when accessing disabled and ignored collections
+ // these define the discovery callbacks per resource type. The key is the resource type whose discovered details
+ // need to be funneled through callbacks. The value is a map whose key is plugin names and whose values are
+ // discovery callback implementation classes defined in the plugins.
+ private Map<ResourceType, Map<String, List<String>>> discoveryCallbacks = new HashMap<ResourceType, Map<String, List<String>>>();
+
public PluginMetadataManager() {
}
@@ -203,6 +208,18 @@ public class PluginMetadataManager {
findDisabledResourceTypesInAllPlugins();
}
+ // squirrel away all the discovery callbacks
+ Map<ResourceType, List<String>> discoveryCallbacksMap = parser.getDiscoveryCallbackClasses();
+ if (discoveryCallbacksMap != null) {
+ for (Map.Entry<ResourceType, List<String>> entry : discoveryCallbacksMap.entrySet()) {
+ ResourceType resourceType = entry.getKey();
+ for (String className : entry.getValue()) {
+ addDiscoveryCallbackClassName(resourceType, pluginDescriptor.getName(), className);
+ }
+ }
+ }
+
+ // return the top root types from the descriptor
Set<ResourceType> rootTypes = parser.getRootResourceTypes();
return rootTypes;
@@ -491,4 +508,37 @@ public class PluginMetadataManager {
}
return;
}
+
+ /**
+ * Given a resource type, this will return any discovery callbacks that are required to be invoked
+ * when that resource type is being discovered.
+ * @param resourceType the type whose discovery callbacks should be returned
+ * @return the collection of callbacks, grouped by the plugins that defined them (may be null)
+ */
+ public Map<String, List<String>> getDiscoveryCallbacks(ResourceType resourceType) {
+ synchronized (discoveryCallbacks) {
+ Map<String, List<String>> map = discoveryCallbacks.get(resourceType);
+ return map;
+ }
+ }
+
+ private void addDiscoveryCallbackClassName(ResourceType resourceType, String pluginName, String className) {
+ synchronized (discoveryCallbacks) {
+ Map<String, List<String>> map = discoveryCallbacks.get(resourceType);
+ if (map == null) {
+ map = new HashMap<String, List<String>>(1);
+ discoveryCallbacks.put(resourceType, map);
+ }
+
+ List<String> callbackListForPlugin = map.get(pluginName);
+ if (callbackListForPlugin == null) {
+ callbackListForPlugin = new ArrayList<String>(1);
+ map.put(pluginName, callbackListForPlugin);
+ }
+
+ callbackListForPlugin.add(className);
+ }
+
+ return;
+ }
}
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 d5ff2ef..f1bce29 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
@@ -37,6 +37,8 @@ import org.apache.commons.logging.LogFactory;
import org.rhq.core.clientapi.descriptor.plugin.Bundle;
import org.rhq.core.clientapi.descriptor.plugin.BundleTargetDescriptor;
import org.rhq.core.clientapi.descriptor.plugin.ContentDescriptor;
+import org.rhq.core.clientapi.descriptor.plugin.DiscoveryCallbacksType;
+import org.rhq.core.clientapi.descriptor.plugin.DiscoveryTypeCallbackType;
import org.rhq.core.clientapi.descriptor.plugin.DriftDescriptor;
import org.rhq.core.clientapi.descriptor.plugin.EventDescriptor;
import org.rhq.core.clientapi.descriptor.plugin.MetricDescriptor;
@@ -83,10 +85,11 @@ public class PluginMetadataParser {
private Set<ResourceType> rootResourceTypes = new LinkedHashSet<ResourceType>();
- // TODO: this isn't the most elegant... should we put these in the domain objects? or perhaps build another place for them to live?
private Map<ResourceType, String> discoveryClasses = new HashMap<ResourceType, String>();
private Map<ResourceType, String> componentClasses = new HashMap<ResourceType, String>();
+ private Map<ResourceType, List<String>> discoveryCallbackClasses = null;
+
// a map keyed on plugin name that contains the parsers for all other known plugin descriptors
// this map is managed by this parser's PluginMetadataManager and is how the manager shares information
// from other plugins to this parser instance
@@ -120,6 +123,20 @@ public class PluginMetadataParser {
return this.rootResourceTypes;
}
+ /**
+ * This returns all resource types that this plugin defines discovery callbacks for.
+ * When the resource types' discovery is run, the details will be funneled through the discovery
+ * callbacks to give this plugin a chance to alter the discovered details.
+ * Note that it is very possible that the resource type keys are types that are NOT defined
+ * by the plugin associated with this parser. The resource types will be defined either in
+ * this plugin or one of its dependencies.
+ *
+ * @return map of all types that have one or more discovery callbacks defined. May be null.
+ */
+ public Map<ResourceType, List<String>> getDiscoveryCallbackClasses() {
+ return discoveryCallbackClasses;
+ }
+
public void parseDescriptor() throws InvalidPluginDescriptorException {
ResourceType type;
@@ -147,6 +164,65 @@ public class PluginMetadataParser {
}
}
+ // find any declared discovery callbacks now - do this at the end in
+ // case we are defining callbacks on types in our own plugin
+ parseDiscoveryCallbacks();
+
+ return;
+ }
+
+ private void parseDiscoveryCallbacks() throws InvalidPluginDescriptorException {
+ DiscoveryCallbacksType jaxbCallbacks = pluginDescriptor.getDiscoveryCallbacks();
+ if (jaxbCallbacks == null) {
+ return;
+ }
+
+ List<DiscoveryTypeCallbackType> jaxbCallbacksList = jaxbCallbacks.getTypeCallback();
+ if (jaxbCallbacksList == null || jaxbCallbacksList.isEmpty()) {
+ return;
+ }
+
+ for (DiscoveryTypeCallbackType jaxbCallback : jaxbCallbacksList) {
+ String plugin = jaxbCallback.getPlugin();
+ String type = jaxbCallback.getType();
+ String callbackClass = jaxbCallback.getCallbackClass();
+
+ LOG.debug("Plugin [" + pluginDescriptor.getName() + "] defined a discovery class [" + callbackClass
+ + "] to listen for discovery details for type [{" + plugin + "}" + type + "].");
+
+ if (callbackClass == null || callbackClass.length() == 0) {
+ // this should never happen - the XML parser should have failed to even get this far
+ throw new InvalidPluginDescriptorException("Missing discovery class in plugin ["
+ + pluginDescriptor.getName() + "] -> {" + plugin + "}" + type);
+ }
+
+ if (plugin == null || plugin.length() == 0 || type == null || type.length() == 0) {
+ // this should never happen - the XML parser should have failed to even get this far
+ throw new InvalidPluginDescriptorException("Both plugin and type must be defined for discovery callbacks in plugin ["
+ + pluginDescriptor.getName() + "] -> {" + plugin + "}" + type + ":" + callbackClass);
+ }
+
+ ResourceType resourceType = getResourceTypeFromPlugin(type, plugin);
+ if (resourceType == null) {
+ LOG.warn("There is no type named [" + type + "] from a plugin named [" + plugin
+ + "]. This is probably because that plugin is missing. The discovery callback will be ignored");
+ continue;
+ }
+
+ if (discoveryCallbackClasses == null) {
+ discoveryCallbackClasses = new HashMap<ResourceType, List<String>>();
+ }
+
+ List<String> callbacksList = discoveryCallbackClasses.get(resourceType);
+ if (callbacksList == null) {
+ callbacksList = new ArrayList<String>(1);
+ discoveryCallbackClasses.put(resourceType, callbacksList);
+ }
+
+ String fqcn = getFullyQualifiedComponentClassName(pluginDescriptor.getPackage(), callbackClass);
+ callbacksList.add(fqcn);
+ }
+
return;
}
diff --git a/modules/core/client-api/src/main/resources/rhq-plugin.xsd b/modules/core/client-api/src/main/resources/rhq-plugin.xsd
index 2d50b8e..ee873aa 100644
--- a/modules/core/client-api/src/main/resources/rhq-plugin.xsd
+++ b/modules/core/client-api/src/main/resources/rhq-plugin.xsd
@@ -57,6 +57,18 @@
</xs:complexType>
</xs:element>
+ <xs:element ref="rhq:discovery-callbacks" minOccurs="0" maxOccurs="1">
+ <xs:annotation>
+ <xs:documentation>
+ Defines the types and discovery classes whose discovered resources must be
+ funneled through this plugin's discovery classback classes.
+ </xs:documentation>
+ <xs:appinfo>
+ <jaxb:property name="discoveryCallbacks" />
+ </xs:appinfo>
+ </xs:annotation>
+ </xs:element>
+
<xs:element ref="rhq:platform" minOccurs="0" maxOccurs="unbounded">
<xs:annotation>
<xs:documentation>
@@ -1154,4 +1166,38 @@
</xs:attribute>
</xs:attributeGroup>
+ <xs:element name="discovery-callbacks" type="rhq:DiscoveryCallbacksType">
+ <xs:annotation>
+ <xs:documentation>A set of discovery callbacks this plugin defines to help with resource discovery.</xs:documentation>
+ </xs:annotation>
+ </xs:element>
+
+ <xs:complexType name="DiscoveryCallbacksType">
+ <xs:sequence>
+ <xs:element name="type-callback" type="rhq:DiscoveryTypeCallbackType" maxOccurs="unbounded" minOccurs="1">
+ <xs:annotation>
+ <xs:documentation>A discovery callback to help with discovery for a specific resource type.</xs:documentation>
+ </xs:annotation>
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="DiscoveryTypeCallbackType">
+ <xs:attribute name="type" type="xs:string" use="required">
+ <xs:annotation>
+ <xs:documentation>When a discovery component detects this resource type, the discovered details will be processed by the discovery callback.</xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute name="plugin" type="xs:string" use="required">
+ <xs:annotation>
+ <xs:documentation>The plugin that defines the named resource type. Must be either this plugin or one of its dependencies.</xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute name="callbackClass" type="rhq:classNameType" use="required">
+ <xs:annotation>
+ <xs:documentation>The class name of this discovery callback implementation.</xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ </xs:complexType>
+
</xs:schema>
diff --git a/modules/core/client-api/src/test/java/org/rhq/core/clientapi/agent/metadata/test/MetadataManagerTest.java b/modules/core/client-api/src/test/java/org/rhq/core/clientapi/agent/metadata/test/MetadataManagerTest.java
index fbb6b1b..c6f3dc2 100644
--- a/modules/core/client-api/src/test/java/org/rhq/core/clientapi/agent/metadata/test/MetadataManagerTest.java
+++ b/modules/core/client-api/src/test/java/org/rhq/core/clientapi/agent/metadata/test/MetadataManagerTest.java
@@ -23,6 +23,7 @@
package org.rhq.core.clientapi.agent.metadata.test;
import java.net.URL;
+import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -177,6 +178,27 @@ public class MetadataManagerTest {
assert testD.getBundleType().getResourceType().equals(testD);
}
+ @Test(dependsOnMethods = "loadPluginDescriptorTest3")
+ public void testDiscoveryCallbackDefinitions() {
+ ResourceType serverAType = this.metadataManager.getType("Server A", "Test1");
+ ResourceType serverBType = this.metadataManager.getType("Extension Server B", "Test2");
+ assert serverAType != null : "Where's Server A?";
+ assert serverBType != null : "Where's Extension Server B?";
+
+ Map<String, List<String>> serverACallbacks = this.metadataManager.getDiscoveryCallbacks(serverAType);
+ assert serverACallbacks.size() == 1 : serverACallbacks;
+ assert serverACallbacks.get("Test3").size() == 2 : serverACallbacks;
+ assert serverACallbacks.get("Test3").get(0).equals("org.rhq.plugins.test3.DiscoveryCallback1") : serverACallbacks;
+ assert serverACallbacks.get("Test3").get(1).equals("org.rhq.plugins.test3.DiscoveryCallbackAnother1") : serverACallbacks;
+
+ Map<String, List<String>> serverBCallbacks = this.metadataManager.getDiscoveryCallbacks(serverBType);
+ assert serverBCallbacks.size() == 2 : serverBCallbacks;
+ assert serverBCallbacks.get("Test3").size() == 1 : serverBCallbacks;
+ assert serverBCallbacks.get("Test2").size() == 1 : serverBCallbacks;
+ assert serverBCallbacks.get("Test3").get(0).equals("org.rhq.plugins.test3.DiscoveryCallback2") : serverBCallbacks;
+ assert serverBCallbacks.get("Test2").get(0).equals("org.rhq.plugins.test2.DiscoveryCallbackTest2") : serverBCallbacks;
+ }
+
private ResourceType getResourceType(ResourceType typeToGet) {
for (ResourceType type : metadataManager.getAllTypes()) {
if (type.equals(typeToGet)) {
diff --git a/modules/core/client-api/src/test/java/org/rhq/core/clientapi/agent/metadata/test/PluginMetadataParserTest.java b/modules/core/client-api/src/test/java/org/rhq/core/clientapi/agent/metadata/test/PluginMetadataParserTest.java
index 5e08676..1c86934 100644
--- a/modules/core/client-api/src/test/java/org/rhq/core/clientapi/agent/metadata/test/PluginMetadataParserTest.java
+++ b/modules/core/client-api/src/test/java/org/rhq/core/clientapi/agent/metadata/test/PluginMetadataParserTest.java
@@ -51,13 +51,94 @@ import static org.testng.Assert.assertTrue;
public class PluginMetadataParserTest {
@Test
+ void discoveryCallback() throws Exception {
+ PluginDescriptor pluginDescriptor = toPluginDescriptor("" + //
+ "<plugin name='TestServer' displayName='Test Server' package='org.rhq.plugins.test'" + //
+ " xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'" + //
+ " xmlns='urn:xmlns:rhq-plugin'>" + //
+ " <discovery-callbacks>" + //
+ " <type-callback type='testServerType' plugin='TestServer' callbackClass='TestCallback' />" + //
+ " </discovery-callbacks>" + //
+ " <server name='testServerType'" + //
+ " class='org.rhq.plugins.test.TestServer'" + //
+ " discovery='org.rhq.plugins.test.TestServerDiscoveryComponent'/>" + //
+ "</plugin>");
+
+ Map<String, PluginMetadataParser> parsersByPlugin = new HashMap<String, PluginMetadataParser>(0);
+ PluginMetadataParser parser = new PluginMetadataParser(pluginDescriptor, parsersByPlugin);
+
+ Map<ResourceType, List<String>> map = parser.getDiscoveryCallbackClasses();
+ assertEquals(map.size(), 1, "Should have one discovery callback: " + map);
+ ResourceType rt = new ResourceType("testServerType", "TestServer", null, null);
+ assertEquals(map.get(rt).get(0), "org.rhq.plugins.test.TestCallback", "incorrect classname in map: " + map);
+
+ // in a second plugin, define a discovery callback that points back to a type in the first plugin
+ PluginDescriptor pluginDescriptor2 = toPluginDescriptor("" + //
+ "<plugin name='TestServer2' displayName='Test Server' package='org.rhq.plugins.test2'" + //
+ " xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'" + //
+ " xmlns='urn:xmlns:rhq-plugin'>" + //
+ " <discovery-callbacks>" + //
+ " <type-callback type='testServerType' plugin='TestServer' callbackClass='TestCallback2' />" + //
+ " </discovery-callbacks>" + //
+ " <server name='testServerType2'" + //
+ " class='org.rhq.plugins.test2.TestServer2'" + //
+ " discovery='org.rhq.plugins.test2.TestServerDiscoveryComponent2'/>" + //
+ "</plugin>");
+
+ parsersByPlugin.put("TestServer", parser);
+ PluginMetadataParser parser2 = new PluginMetadataParser(pluginDescriptor2, parsersByPlugin);
+ map = parser2.getDiscoveryCallbackClasses();
+ assertEquals(map.size(), 1, "Should have one discovery callback: " + map);
+ rt = new ResourceType("testServerType", "TestServer", null, null);
+ assertEquals(map.get(rt).get(0), "org.rhq.plugins.test2.TestCallback2", "incorrect classname in map: " + map);
+
+ // define multiple callbacks to multiple plugins
+ PluginDescriptor pluginDescriptor3 = toPluginDescriptor("" + //
+ "<plugin name='TestServer3' displayName='Test Server' package='org.rhq.plugins.test3'" + //
+ " xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'" + //
+ " xmlns='urn:xmlns:rhq-plugin'>" + //
+ " <discovery-callbacks>" + //
+ " <type-callback type='testServerType' plugin='TestServer' callbackClass='TestCallback31' />" + //
+ " <type-callback type='testServerType2' plugin='TestServer2' callbackClass='TestCallback32' />" + //
+ " <type-callback type='testServerType3' plugin='TestServer3' callbackClass='TestCallback33' />" + //
+ " <type-callback type='testServerType3' plugin='TestServer3' callbackClass='TestCallback34' />" + //
+ " </discovery-callbacks>" + //
+ " <server name='testServerType3'" + //
+ " class='org.rhq.plugins.test3.TestServer3'" + //
+ " discovery='org.rhq.plugins.test3.TestServerDiscoveryComponent3'/>" + //
+ "</plugin>");
+
+ parsersByPlugin.put("TestServer2", parser2);
+ PluginMetadataParser parser3 = new PluginMetadataParser(pluginDescriptor3, parsersByPlugin);
+ map = parser3.getDiscoveryCallbackClasses();
+ assertEquals(map.size(), 3, "Should have three keys in discovery callbacks map: " + map);
+
+ rt = new ResourceType("testServerType", "TestServer", null, null);
+ List<String> list = map.get(rt);
+ assertEquals(list.size(), 1);
+ assertEquals(list.get(0), "org.rhq.plugins.test3.TestCallback31", "incorrect classname in map: " + map);
+
+ rt = new ResourceType("testServerType2", "TestServer2", null, null);
+ list = map.get(rt);
+ assertEquals(list.size(), 1);
+ assertEquals(list.get(0), "org.rhq.plugins.test3.TestCallback32", "incorrect classname in map: " + map);
+
+ rt = new ResourceType("testServerType3", "TestServer3", null, null);
+ list = map.get(rt);
+ assertEquals(list.size(), 2);
+ assertEquals(list.get(0), "org.rhq.plugins.test3.TestCallback33", "incorrect classname in map: " + map);
+ assertEquals(list.get(1), "org.rhq.plugins.test3.TestCallback34", "incorrect classname in map: " + map);
+
+ }
+
+ @Test
void allTypesShouldHaveOneElementForDescriptorWithOnlyOneResourceType() throws Exception {
PluginDescriptor pluginDescriptor = toPluginDescriptor("" + //
"<plugin name='TestServer' displayName='Test Server' package='org.rhq.plugins.test'" + //
" xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'" + //
" xmlns='urn:xmlns:rhq-plugin'>" + //
" <server name='testServer'" + //
- " class='org.rhq.plugins.test.TestServer'" + //
+ " class='org.rhq.plugins.test.TestServer'" + //
" discovery='org.rhq.plugins.test.TestServerDiscoveryComponent'/>" + //
"</plugin>");
diff --git a/modules/core/client-api/src/test/resources/metadata-manager-test-2.xml b/modules/core/client-api/src/test/resources/metadata-manager-test-2.xml
index f19b2f4..144ffcc 100644
--- a/modules/core/client-api/src/test/resources/metadata-manager-test-2.xml
+++ b/modules/core/client-api/src/test/resources/metadata-manager-test-2.xml
@@ -3,7 +3,12 @@
xmlns="urn:xmlns:rhq-plugin">
<depends plugin="Test1" />
- <server name="Extension Server B" discovery="ServerBComponent" class="ServerBServerComponent"
+
+ <discovery-callbacks>
+ <type-callback type="Extension Server B" plugin="Test2" callbackClass="DiscoveryCallbackTest2"/>
+ </discovery-callbacks>
+
+ <server name="Extension Server B" discovery="ServerBComponent" class="ServerBServerComponent"
description="Extension Server B Test Server"
sourcePlugin="Test1" sourceType="Server A">
diff --git a/modules/core/client-api/src/test/resources/metadata-manager-test-3.xml b/modules/core/client-api/src/test/resources/metadata-manager-test-3.xml
index 48cd715..41907cc 100644
--- a/modules/core/client-api/src/test/resources/metadata-manager-test-3.xml
+++ b/modules/core/client-api/src/test/resources/metadata-manager-test-3.xml
@@ -1,9 +1,16 @@
-<plugin name="Test3" displayName="Test Two" package="org.rhq.plugins.test2"
+<plugin name="Test3" displayName="Test Three" package="org.rhq.plugins.test3"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="urn:xmlns:rhq-plugin">
<depends plugin="Test1" />
<depends plugin="Test2" />
+
+ <discovery-callbacks>
+ <type-callback type="Server A" plugin="Test1" callbackClass="DiscoveryCallback1"/>
+ <type-callback type="Server A" plugin="Test1" callbackClass="DiscoveryCallbackAnother1"/>
+ <type-callback type="Extension Server B" plugin="Test2" callbackClass="DiscoveryCallback2"/>
+ </discovery-callbacks>
+
<server name="Injection C To Server A" discovery="ServerCComponent" class="ServerCServerComponent"
description="injects child C to server A and server B">
<runs-inside>
diff --git a/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/inventory/ResourceDiscoveryCallback.java b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/inventory/ResourceDiscoveryCallback.java
new file mode 100644
index 0000000..a1360af
--- /dev/null
+++ b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/inventory/ResourceDiscoveryCallback.java
@@ -0,0 +1,43 @@
+/*
+ * 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, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * 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 and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser 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.core.pluginapi.inventory;
+
+import java.util.Set;
+
+/**
+ * When another discovery component discovers resources, the discovered details can be funneled through
+ * implementations of this callback interface, thus allowing callbacks to tweek details of discovered resources.
+ * This is helpful, for example, when one plugin wants to alter the name or description of some other plugin's
+ * resource type. This is mainly used when writing plugins that cooperate with each other.
+ */
+public interface ResourceDiscoveryCallback {
+ /**
+ * When a set of resource details have been discovered, those details are passed to the callback via this method.
+ * The callback can tweek those details as it sees fit or it can simply leave the details as-is and simply return.
+ *
+ * @param discoveredDetails a set of resource details that were discovered and can be altered by the callback
+ *
+ * @throws Exception
+ */
+ void discoveredResources(Set<DiscoveredResourceDetails> discoveredDetails) throws Exception;
+}
\ No newline at end of file
diff --git a/modules/core/plugin-container-itest/src/test/java/org/rhq/core/pc/inventory/DiscoveryCallbackTest.java b/modules/core/plugin-container-itest/src/test/java/org/rhq/core/pc/inventory/DiscoveryCallbackTest.java
new file mode 100644
index 0000000..4b4b985
--- /dev/null
+++ b/modules/core/plugin-container-itest/src/test/java/org/rhq/core/pc/inventory/DiscoveryCallbackTest.java
@@ -0,0 +1,135 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2012 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.core.pc.inventory;
+
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.container.test.api.TargetsContainer;
+import org.jboss.arquillian.test.api.ArquillianResource;
+import org.jboss.arquillian.testng.Arquillian;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.rhq.core.clientapi.server.discovery.InventoryReport;
+import org.rhq.core.domain.resource.InventoryStatus;
+import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.pc.PluginContainer;
+import org.rhq.core.pc.PluginContainerConfiguration;
+import org.rhq.core.pc.inventory.discoverycallback.PluginOneCallback;
+import org.rhq.core.pc.inventory.discoverycallback.PluginTwoCallback1;
+import org.rhq.core.pc.inventory.discoverycallback.PluginTwoCallback2;
+import org.rhq.core.pc.inventory.testplugin.TestResourceComponent;
+import org.rhq.core.pc.inventory.testplugin.TestResourceDiscoveryComponent;
+import org.rhq.test.arquillian.AfterDiscovery;
+import org.rhq.test.arquillian.BeforeDiscovery;
+import org.rhq.test.arquillian.FakeServerInventory;
+import org.rhq.test.arquillian.MockingServerServices;
+import org.rhq.test.arquillian.RunDiscovery;
+import org.rhq.test.shrinkwrap.RhqAgentPluginArchive;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import java.util.Set;
+
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.when;
+
+/**
+ * A unit test for testing discovery callbacks.
+ */
+public class DiscoveryCallbackTest extends Arquillian {
+
+ @Deployment(name = "test")
+ @TargetsContainer("pc")
+ public static RhqAgentPluginArchive getTestOnePlugin() {
+ RhqAgentPluginArchive pluginJar1 = ShrinkWrap.create(RhqAgentPluginArchive.class, "test-discovery-callback1-plugin.jar");
+ RhqAgentPluginArchive pluginJar2 = ShrinkWrap.create(RhqAgentPluginArchive.class, "test-discovery-callback2-plugin.jar");
+ pluginJar1.setPluginDescriptor("discovery-callback1.xml").addClasses(
+ TestResourceDiscoveryComponent.class, TestResourceComponent.class, PluginOneCallback.class);
+ pluginJar2.setPluginDescriptor("discovery-callback2.xml").addClasses(
+ TestResourceDiscoveryComponent.class, TestResourceComponent.class, PluginTwoCallback1.class, PluginTwoCallback2.class);
+ pluginJar2.withRequiredPluginsFrom(pluginJar1);
+ return pluginJar2;
+ }
+
+ @ArquillianResource
+ private MockingServerServices serverServices;
+
+ @ArquillianResource
+ private PluginContainerConfiguration pluginContainerConfiguration;
+
+ @ArquillianResource
+ private PluginContainer pluginContainer;
+
+ private FakeServerInventory fakeServerInventory;
+
+ private FakeServerInventory.CompleteDiscoveryChecker discoveryCompleteChecker;
+
+ @BeforeDiscovery
+ public void resetServerServices() throws Exception {
+ // Set up our fake server discovery ServerService, which will auto-import all Resources in reports it receives.
+ serverServices.resetMocks();
+ fakeServerInventory = new FakeServerInventory();
+ discoveryCompleteChecker = fakeServerInventory.createAsyncDiscoveryCompletionChecker(2);
+ when(serverServices.getDiscoveryServerService().mergeInventoryReport(any(InventoryReport.class))).then(
+ fakeServerInventory.mergeInventoryReport(InventoryStatus.COMMITTED));
+ }
+
+ @AfterDiscovery
+ public void waitForAsyncDiscoveries() throws Exception {
+ if (discoveryCompleteChecker != null) {
+ discoveryCompleteChecker.waitForDiscoveryComplete(10000);
+ }
+ }
+
+ @RunDiscovery
+ @Test(groups = "pc.itest.discoverycallbacks", priority = 20) // setting the group is important! otherwise, other tests will fail
+ public void testDiscoveryCallbacks() throws Exception {
+ // make sure our inventory is as we expect it to be
+ validatePluginContainerInventory();
+ }
+
+ private void validatePluginContainerInventory() throws Exception {
+ System.out.println("Validating PC inventory...");
+
+ Resource platform = pluginContainer.getInventoryManager().getPlatform();
+ Assert.assertNotNull(platform);
+ Assert.assertEquals(platform.getInventoryStatus(), InventoryStatus.COMMITTED);
+
+ Set<Resource> servers = platform.getChildResources();
+ Assert.assertNotNull(servers);
+ Assert.assertEquals(servers.size(), 2);
+
+ for (Resource server : servers) {
+ if (server.getResourceType().getName().equals("TestServerOne")) {
+ Assert.assertEquals(server.getName(), "PluginTwoCallback1:name");
+ Assert.assertEquals(server.getVersion(), "PluginTwoCallback1:1.0");
+ Assert.assertEquals(server.getPluginConfiguration().getSimpleValue("TestServerOne.prop1"), "PluginOneCallback:prop1");
+ Assert.assertEquals(server.getPluginConfiguration().getSimpleValue("TestServerOne.prop2"), "PluginTwoCallback1:prop2");
+ } else if (server.getResourceType().getName().equals("TestServerTwo")) {
+ Assert.assertEquals(server.getName(), "PluginTwoCallback2:name");
+ Assert.assertEquals(server.getVersion(), "PluginTwoCallback2:1.0");
+ Assert.assertEquals(server.getPluginConfiguration().getSimpleValue("TestServerTwo.prop1"), null);
+ Assert.assertEquals(server.getPluginConfiguration().getSimpleValue("TestServerTwo.prop2"), "PluginTwoCallback2:prop2");
+ } else {
+ assert false : "got a resource we were not expecting: " + server;
+ }
+ }
+
+ System.out.println("PC inventory validated successfully!");
+ }
+
+}
diff --git a/modules/core/plugin-container-itest/src/test/java/org/rhq/core/pc/inventory/discoverycallback/PluginOneCallback.java b/modules/core/plugin-container-itest/src/test/java/org/rhq/core/pc/inventory/discoverycallback/PluginOneCallback.java
new file mode 100644
index 0000000..6b24987
--- /dev/null
+++ b/modules/core/plugin-container-itest/src/test/java/org/rhq/core/pc/inventory/discoverycallback/PluginOneCallback.java
@@ -0,0 +1,22 @@
+package org.rhq.core.pc.inventory.discoverycallback;
+
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryCallback;
+
+import java.util.Set;
+
+public class PluginOneCallback implements ResourceDiscoveryCallback{
+ @Override
+ public void discoveredResources(Set<DiscoveredResourceDetails> discoveredDetails) throws Exception {
+ // we know our test discovery component detects one singleton server, let's tweek the details.
+ // note that plugin 2 (the one that depends our plugin) will also have a callback and will
+ // have a chance to overwrite what we do here. Our test code will test that the child plugin
+ // callback in that plugin's callback (PluginTwoCallback1) can tweek what we do here.
+ DiscoveredResourceDetails details = discoveredDetails.iterator().next();
+ details.setResourceName("This will be overwritten by plugin two's test callback, so this string doesn't matter");
+ details.setResourceVersion("This will be overwritten by plugin two's test callback, so this string doesn't matter");
+ details.getPluginConfiguration().put(new PropertySimple("TestServerOne.prop1", "PluginOneCallback:prop1"));
+ System.out.println("!!!!!!!!!!!!!!" + this.getClass().getName() + "==>" + discoveredDetails);
+ }
+}
diff --git a/modules/core/plugin-container-itest/src/test/java/org/rhq/core/pc/inventory/discoverycallback/PluginTwoCallback1.java b/modules/core/plugin-container-itest/src/test/java/org/rhq/core/pc/inventory/discoverycallback/PluginTwoCallback1.java
new file mode 100644
index 0000000..e346b5a
--- /dev/null
+++ b/modules/core/plugin-container-itest/src/test/java/org/rhq/core/pc/inventory/discoverycallback/PluginTwoCallback1.java
@@ -0,0 +1,21 @@
+package org.rhq.core.pc.inventory.discoverycallback;
+
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryCallback;
+
+import java.util.Set;
+
+public class PluginTwoCallback1 implements ResourceDiscoveryCallback{
+ @Override
+ public void discoveredResources(Set<DiscoveredResourceDetails> discoveredDetails) throws Exception {
+ // the resource was discovered, and our plugin one's callback has tweeked these details, but now we can
+ // further tweek the details here
+ DiscoveredResourceDetails details = discoveredDetails.iterator().next();
+ details.setResourceName("PluginTwoCallback1:name");
+ details.setResourceVersion("PluginTwoCallback1:1.0");
+ // notice we do not touch plugin config property TestServerOne.prop1, let the first plugin's callback touch it
+ details.getPluginConfiguration().put(new PropertySimple("TestServerOne.prop2", "PluginTwoCallback1:prop2"));
+ System.out.println("!!!!!!!!!!!!!!" + this.getClass().getName() + "==>" + discoveredDetails);
+ }
+}
diff --git a/modules/core/plugin-container-itest/src/test/java/org/rhq/core/pc/inventory/discoverycallback/PluginTwoCallback2.java b/modules/core/plugin-container-itest/src/test/java/org/rhq/core/pc/inventory/discoverycallback/PluginTwoCallback2.java
new file mode 100644
index 0000000..fdcab1c
--- /dev/null
+++ b/modules/core/plugin-container-itest/src/test/java/org/rhq/core/pc/inventory/discoverycallback/PluginTwoCallback2.java
@@ -0,0 +1,19 @@
+package org.rhq.core.pc.inventory.discoverycallback;
+
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryCallback;
+
+import java.util.Set;
+
+public class PluginTwoCallback2 implements ResourceDiscoveryCallback{
+ @Override
+ public void discoveredResources(Set<DiscoveredResourceDetails> discoveredDetails) throws Exception {
+ DiscoveredResourceDetails details = discoveredDetails.iterator().next();
+ details.setResourceName("PluginTwoCallback2:name");
+ details.setResourceVersion("PluginTwoCallback2:1.0");
+ // notice we do not touch plugin config property TestServerTwo.prop1, our test code will check that it is null
+ details.getPluginConfiguration().put(new PropertySimple("TestServerTwo.prop2", "PluginTwoCallback2:prop2"));
+ System.out.println("!!!!!!!!!!!!!!" + this.getClass().getName() + "==>" + discoveredDetails);
+ }
+}
diff --git a/modules/core/plugin-container-itest/src/test/resources/discovery-callback1.xml b/modules/core/plugin-container-itest/src/test/resources/discovery-callback1.xml
new file mode 100644
index 0000000..addfabd
--- /dev/null
+++ b/modules/core/plugin-container-itest/src/test/resources/discovery-callback1.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<plugin name="DiscoveryCallbackPluginOne"
+ package="org.rhq.core.pc.inventory.testplugin"
+ version="1.0"
+ xmlns="urn:xmlns:rhq-plugin"
+ xmlns:c="urn:xmlns:rhq-configuration">
+
+ <discovery-callbacks>
+ <type-callback plugin="DiscoveryCallbackPluginOne" type="TestServerOne" callbackClass="org.rhq.core.pc.inventory.discoverycallback.PluginOneCallback"/>
+ </discovery-callbacks>
+
+ <server name="TestServerOne"
+ discovery="TestResourceDiscoveryComponent"
+ class="TestResourceComponent">
+ <plugin-configuration>
+ <c:simple-property name="TestServerOne.prop1"/>
+ <c:simple-property name="TestServerOne.prop2"/>
+ </plugin-configuration>
+ </server>
+</plugin>
diff --git a/modules/core/plugin-container-itest/src/test/resources/discovery-callback2.xml b/modules/core/plugin-container-itest/src/test/resources/discovery-callback2.xml
new file mode 100644
index 0000000..fcf24ef
--- /dev/null
+++ b/modules/core/plugin-container-itest/src/test/resources/discovery-callback2.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<plugin name="DiscoveryCallbackPluginTwo"
+ package="org.rhq.core.pc.inventory.testplugin"
+ version="1.0"
+ xmlns="urn:xmlns:rhq-plugin"
+ xmlns:c="urn:xmlns:rhq-configuration">
+
+ <depends plugin="DiscoveryCallbackPluginOne" />
+
+ <discovery-callbacks>
+ <type-callback plugin="DiscoveryCallbackPluginOne" type="TestServerOne" callbackClass="org.rhq.core.pc.inventory.discoverycallback.PluginTwoCallback1" />
+ <type-callback plugin="DiscoveryCallbackPluginTwo" type="TestServerTwo" callbackClass="org.rhq.core.pc.inventory.discoverycallback.PluginTwoCallback2" />
+ </discovery-callbacks>
+
+ <server name="TestServerTwo"
+ discovery="TestResourceDiscoveryComponent"
+ class="TestResourceComponent">
+ <plugin-configuration>
+ <c:simple-property name="TestServerTwo.prop1" />
+ <c:simple-property name="TestServerTwo.prop2" />
+ </plugin-configuration>
+ </server>
+</plugin>
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 406d65d..f838af5 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
@@ -117,6 +117,7 @@ import org.rhq.core.pluginapi.inventory.ManualAddFacet;
import org.rhq.core.pluginapi.inventory.ProcessScanResult;
import org.rhq.core.pluginapi.inventory.ResourceComponent;
import org.rhq.core.pluginapi.inventory.ResourceContext;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryCallback;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
import org.rhq.core.pluginapi.operation.OperationContext;
@@ -337,20 +338,58 @@ public class InventoryManager extends AgentService implements ContainerService,
long timeout = getDiscoveryComponentTimeout(context.getResourceType());
+ Set<DiscoveredResourceDetails> results;
+
try {
ResourceDiscoveryComponent proxy = this.discoveryComponentProxyFactory.getDiscoveryComponentProxy(
context.getResourceType(), component, timeout, parentResourceContainer);
- Set<DiscoveredResourceDetails> results = proxy.discoverResources(context);
- return results;
+ results = proxy.discoverResources(context);
} catch (TimeoutException te) {
log.warn("Discovery for Resources of [" + context.getResourceType() + "] has been running for more than "
+ timeout + " milliseconds. This may be a plugin bug.", te);
- return null;
+ results = null;
} catch (BlacklistedException be) {
// Discovery did not run, because the ResourceType was blacklisted during a prior discovery scan.
log.debug(ThrowableUtil.getAllMessages(be));
- return null;
+ results = null;
+ }
+
+ if (results == null || results.isEmpty()) {
+ return results;
}
+
+ // funnel the results through any discovery callbacks that are defined on the discovered resource type
+ Map<String, List<String>> callbacks = this.pluginManager.getMetadataManager().getDiscoveryCallbacks(context.getResourceType());
+ if (callbacks == null || callbacks.isEmpty()) {
+ return results; // no callbacks defined, return the discovered details as-is
+ }
+
+ ClassLoader originalContextClassLoader = Thread.currentThread().getContextClassLoader();
+ int callbackCount = 0;
+ PluginComponentFactory pluginComponentFactory = PluginContainer.getInstance().getPluginComponentFactory();
+ for (Map.Entry<String, List<String>> entry : callbacks.entrySet()) {
+ String pluginName = entry.getKey();
+ List<String> callbackClassNames = entry.getValue();
+ for (String className : callbackClassNames) {
+ ResourceDiscoveryCallback callback = pluginComponentFactory.getDiscoveryCallback(pluginName, className);
+ try {
+ Thread.currentThread().setContextClassLoader(callback.getClass().getClassLoader());
+ // notice we call inline, in our calling thread - no time outs or anything; hopefully the plugin plays nice
+ callback.discoveredResources(results);
+ callbackCount++;
+ if (log.isDebugEnabled()) {
+ log.debug("Discovery callback [{" + pluginName + "}" + className + "] done. #invocations=" + callbackCount);
+ }
+ } catch (Throwable t) {
+ log.error("Discovery callback [{" + pluginName + "}" + className + "] failed with exception: "
+ + ThrowableUtil.getAllMessages(t), t);
+ } finally {
+ Thread.currentThread().setContextClassLoader(originalContextClassLoader);
+ }
+ }
+ }
+
+ return results;
}
/**
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/plugin/PluginComponentFactory.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/plugin/PluginComponentFactory.java
index 1f3fcd7..9f0502c 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/plugin/PluginComponentFactory.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/plugin/PluginComponentFactory.java
@@ -43,6 +43,7 @@ import org.rhq.core.pc.inventory.ResourceContainer;
import org.rhq.core.pluginapi.inventory.ClassLoaderFacet;
import org.rhq.core.pluginapi.inventory.ResourceComponent;
import org.rhq.core.pluginapi.inventory.ResourceContext;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryCallback;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
/**
@@ -225,6 +226,29 @@ public class PluginComponentFactory implements ContainerService {
}
}
+ /**
+ * This will create a new {@link ResourceDiscoveryCallback} instance that can be used to process
+ * details of newly discovered resources.
+ *
+ * @return a new discovery callback loaded in the proper classloader
+ * @throws PluginContainerException if failed to create the discovery callback instance
+ */
+ public ResourceDiscoveryCallback getDiscoveryCallback(String pluginName, String callbackClassName)
+ throws PluginContainerException {
+
+ // same classloader as plugin discovery component would use - with null parent, its just the plugin classloader
+ ClassLoader classLoader = getDiscoveryComponentClassLoader(null, pluginName);
+
+ ResourceDiscoveryCallback callback = (ResourceDiscoveryCallback) instantiateClass(classLoader,
+ callbackClassName);
+
+ if (log.isDebugEnabled()) {
+ log.debug("Created discovery callback [" + callbackClassName + "] for plugin [" + pluginName + ']');
+ }
+
+ return callback;
+ }
+
private List<URL> askDiscoveryComponentForAdditionalClasspathUrls(Resource resource,
ResourceContainer parentContainer) throws Throwable {
10 years, 8 months
[rhq] modules/core
by Heiko W. Rupp
modules/core/domain/intentional-api-changes-since-4.8.0.xml | 6 ++++++
1 file changed, 6 insertions(+)
New commits:
commit e36cb2bc14ae1c9764556188551d80075510dcc9
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Fri Aug 30 20:44:46 2013 +0200
Follow up with removal of StorageNode.getJmxPort().
diff --git a/modules/core/domain/intentional-api-changes-since-4.8.0.xml b/modules/core/domain/intentional-api-changes-since-4.8.0.xml
index cd7a4c4..3b9b5dd 100644
--- a/modules/core/domain/intentional-api-changes-since-4.8.0.xml
+++ b/modules/core/domain/intentional-api-changes-since-4.8.0.xml
@@ -55,4 +55,10 @@
<method>void setJmxPort(int)</method>
<justification>No longer needed</justification>
</difference>
+ <difference>
+ <className>org/rhq/core/domain/cloud/StorageNode</className>
+ <differenceType>7002</differenceType> <!-- method removed -->
+ <method>int getJmxPort()</method>
+ <justification>No longer needed</justification>
+ </difference>
</differences>
10 years, 8 months
[rhq] modules/core
by snegrea
modules/core/domain/src/main/java/org/rhq/core/domain/cloud/StorageNode.java | 4 ----
1 file changed, 4 deletions(-)
New commits:
commit 5c3d0a5482f5faa5a7614d27a25262b77bd5b38a
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Fri Aug 30 12:46:47 2013 -0500
Remove the fake getJmxPort from the storage node entity. The jmx port is no longer needed for the storage cluster communication.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/cloud/StorageNode.java b/modules/core/domain/src/main/java/org/rhq/core/domain/cloud/StorageNode.java
index cdd314b..c8dc368 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/cloud/StorageNode.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/cloud/StorageNode.java
@@ -174,10 +174,6 @@ public class StorageNode implements Serializable {
this.address = address;
}
- public int getJmxPort() {
- return 7299;
- }
-
public int getCqlPort() {
return cqlPort;
}
10 years, 8 months
[rhq] modules/enterprise
by Jiri Kremser
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/storage/StorageNodeDetailView.java | 1 -
1 file changed, 1 deletion(-)
New commits:
commit 7ff5a96d25055dcdf856c758b02b7916b8882367
Author: Jirka Kremser <jkremser(a)redhat.com>
Date: Fri Aug 30 19:42:50 2013 +0200
In my previous commit (478faa718) I missed this occurence.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/storage/StorageNodeDetailView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/storage/StorageNodeDetailView.java
index b240b77..beb1ba4 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/storage/StorageNodeDetailView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/storage/StorageNodeDetailView.java
@@ -307,7 +307,6 @@ public class StorageNodeDetailView extends EnhancedVLayout implements Bookmarkab
cqlPortItem.setValue(storageNode.getCqlPort());
jmxPortItem = new StaticTextItem("jmxPort", "JMX Port");
- jmxPortItem.setValue(storageNode.getJmxPort());
// final StaticTextItem jmxConnectionUrlItem = new StaticTextItem("jmxConnectionUrl",
// MSG.view_adminTopology_storageNode_jmxConnectionUrl());
10 years, 8 months
[rhq] modules/common modules/core
by snegrea
modules/common/cassandra-schema/src/main/java/org/rhq/cassandra/schema/SchemaManager.java | 5 ++++-
modules/common/cassandra-schema/src/main/java/org/rhq/cassandra/schema/VersionManager.java | 5 +++++
modules/core/util/pom.xml | 8 +++++++-
3 files changed, 16 insertions(+), 2 deletions(-)
New commits:
commit 6eb9a98f7316382cd070922402fc1d9957e41076
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Fri Aug 30 12:24:02 2013 -0500
[BZ 1001128] Do not immediately fail if a connection cannot be established with the RHQ username. It is possible that the schema was never installed. Continue the drop procedure and by attempting to login with the generic Cassandra user as expected in the drop procedure.
Also update the command line runner to use password obfuscation before calling the scheman manager code.
diff --git a/modules/common/cassandra-schema/src/main/java/org/rhq/cassandra/schema/SchemaManager.java b/modules/common/cassandra-schema/src/main/java/org/rhq/cassandra/schema/SchemaManager.java
index fdad697..1e67b1f 100644
--- a/modules/common/cassandra-schema/src/main/java/org/rhq/cassandra/schema/SchemaManager.java
+++ b/modules/common/cassandra-schema/src/main/java/org/rhq/cassandra/schema/SchemaManager.java
@@ -33,6 +33,8 @@ import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.apache.log4j.PatternLayout;
+import org.rhq.core.util.obfuscation.PicketBoxObfuscator;
+
/**
* @author John Sanda
*/
@@ -168,7 +170,8 @@ public class SchemaManager {
int cqlPort = Integer.parseInt(args[3]);
String[] hosts = Arrays.copyOfRange(args, 4, args.length);
- SchemaManager schemaManager = new SchemaManager(username, password, hosts, cqlPort);
+ SchemaManager schemaManager = new SchemaManager(username, PicketBoxObfuscator.encode(password), hosts,
+ cqlPort);
if ("install".equalsIgnoreCase(command)) {
schemaManager.install();
diff --git a/modules/common/cassandra-schema/src/main/java/org/rhq/cassandra/schema/VersionManager.java b/modules/common/cassandra-schema/src/main/java/org/rhq/cassandra/schema/VersionManager.java
index b0d75e3..9184af3 100644
--- a/modules/common/cassandra-schema/src/main/java/org/rhq/cassandra/schema/VersionManager.java
+++ b/modules/common/cassandra-schema/src/main/java/org/rhq/cassandra/schema/VersionManager.java
@@ -214,6 +214,11 @@ class VersionManager extends AbstractManager {
//1. Reinstated Cassandra superuser
execute(updateFolder.getUpdateFiles().get(0), properties);
log.info("Cassandra user reverted to default configuration.");
+ } catch (AuthenticationException e) {
+ //if the initial auth failed then let later code to attempt to use
+ //the generic user cassandra user to do the cleanup
+ log.debug("Cannot establish connection with the RHQ specific user. "
+ + "Will continue the drop procedure with the Cassandra admin user.");
} catch (Exception e) {
throw new RuntimeException(e);
} finally {
diff --git a/modules/core/util/pom.xml b/modules/core/util/pom.xml
index 654a2fb..2b4d557 100644
--- a/modules/core/util/pom.xml
+++ b/modules/core/util/pom.xml
@@ -17,7 +17,7 @@
<properties>
<rhq.internal>false</rhq.internal>
</properties>
-
+
<dependencies>
<!-- Used by the (deprecated) legacy XML parser, which is used to parse RHQ license files. -->
@@ -45,6 +45,12 @@
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.picketbox</groupId>
+ <artifactId>picketbox</artifactId>
+ <version>${picketbox.version}</version>
+ </dependency>
+
</dependencies>
<build>
10 years, 8 months
[rhq] modules/enterprise
by Jiri Kremser
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/storage/StorageNodeDatasource.java | 2 --
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/storage/StorageNodeDatasourceField.java | 2 --
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/storage/StorageNodeDetailView.java | 5 +++--
3 files changed, 3 insertions(+), 6 deletions(-)
New commits:
commit 478faa7185a70c1ffe6005cbe41ec03ff128ad1c
Author: Jirka Kremser <jkremser(a)redhat.com>
Date: Fri Aug 30 16:47:08 2013 +0200
Reflecting the changes to storage node JMX port (ca8b82bc0, e838c1484) in the UI layer.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/storage/StorageNodeDatasource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/storage/StorageNodeDatasource.java
index 9800736..941c8dc 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/storage/StorageNodeDatasource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/storage/StorageNodeDatasource.java
@@ -27,7 +27,6 @@ import static org.rhq.enterprise.gui.coregui.client.admin.storage.StorageNodeDat
import static org.rhq.enterprise.gui.coregui.client.admin.storage.StorageNodeDatasourceField.FIELD_ERROR_MESSAGE;
import static org.rhq.enterprise.gui.coregui.client.admin.storage.StorageNodeDatasourceField.FIELD_FAILED_OPERATION;
import static org.rhq.enterprise.gui.coregui.client.admin.storage.StorageNodeDatasourceField.FIELD_ID;
-import static org.rhq.enterprise.gui.coregui.client.admin.storage.StorageNodeDatasourceField.FIELD_JMX_PORT;
import static org.rhq.enterprise.gui.coregui.client.admin.storage.StorageNodeDatasourceField.FIELD_MEMORY;
import static org.rhq.enterprise.gui.coregui.client.admin.storage.StorageNodeDatasourceField.FIELD_MTIME;
import static org.rhq.enterprise.gui.coregui.client.admin.storage.StorageNodeDatasourceField.FIELD_OPERATION_MODE;
@@ -250,7 +249,6 @@ public class StorageNodeDatasource extends RPCDataSource<StorageNodeLoadComposit
if (node != null) {
record.setAttribute(FIELD_ID.propertyName(), node.getId());
record.setAttribute(FIELD_ADDRESS.propertyName(), node.getAddress());
- record.setAttribute(FIELD_JMX_PORT.propertyName(), node.getJmxPort());
record.setAttribute(FIELD_CQL_PORT.propertyName(), node.getCqlPort());
record.setAttribute(FIELD_OPERATION_MODE.propertyName(), node.getOperationMode());
record.setAttribute(FIELD_STATUS.propertyName(), node.getStatus());
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/storage/StorageNodeDatasourceField.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/storage/StorageNodeDatasourceField.java
index bd12ed0..706cdc0 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/storage/StorageNodeDatasourceField.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/storage/StorageNodeDatasourceField.java
@@ -31,8 +31,6 @@ public enum StorageNodeDatasourceField {
FIELD_ID("id", CoreGUI.getMessages().common_title_id()),
FIELD_ADDRESS("address", CoreGUI.getMessages().view_adminTopology_server_endpointAddress()),
-
- FIELD_JMX_PORT("jmxPort", "JMX Port"),
FIELD_ALERTS("alerts", "Alerts"),
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/storage/StorageNodeDetailView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/storage/StorageNodeDetailView.java
index 9388abd..b240b77 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/storage/StorageNodeDetailView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/storage/StorageNodeDetailView.java
@@ -24,7 +24,6 @@ import static org.rhq.enterprise.gui.coregui.client.admin.storage.StorageNodeDat
import static org.rhq.enterprise.gui.coregui.client.admin.storage.StorageNodeDatasourceField.FIELD_AVAILABILITY;
import static org.rhq.enterprise.gui.coregui.client.admin.storage.StorageNodeDatasourceField.FIELD_CQL_PORT;
import static org.rhq.enterprise.gui.coregui.client.admin.storage.StorageNodeDatasourceField.FIELD_CTIME;
-import static org.rhq.enterprise.gui.coregui.client.admin.storage.StorageNodeDatasourceField.FIELD_JMX_PORT;
import static org.rhq.enterprise.gui.coregui.client.admin.storage.StorageNodeDatasourceField.FIELD_MTIME;
import static org.rhq.enterprise.gui.coregui.client.admin.storage.StorageNodeDatasourceField.FIELD_OPERATION_MODE;
import static org.rhq.enterprise.gui.coregui.client.admin.storage.StorageNodeDatasourceField.FIELD_STATUS;
@@ -97,6 +96,7 @@ public class StorageNodeDetailView extends EnhancedVLayout implements Bookmarkab
private StaticTextItem alertsItem;
private HTMLFlow header;
private boolean alerts = false;
+ private StaticTextItem jmxPortItem;
private volatile int initSectionCount = 0;
private int unackAlerts = -1;
@@ -177,6 +177,7 @@ public class StorageNodeDetailView extends EnhancedVLayout implements Bookmarkab
@Override
public void onSuccess(StorageNodeConfigurationComposite result) {
+ jmxPortItem.setValue(result.getJmxPort());
prepareResourceConfigEditor(result);
}
});
@@ -305,7 +306,7 @@ public class StorageNodeDetailView extends EnhancedVLayout implements Bookmarkab
final StaticTextItem cqlPortItem = new StaticTextItem(FIELD_CQL_PORT.propertyName(), FIELD_CQL_PORT.title());
cqlPortItem.setValue(storageNode.getCqlPort());
- final StaticTextItem jmxPortItem = new StaticTextItem(FIELD_JMX_PORT.propertyName(), FIELD_JMX_PORT.title());
+ jmxPortItem = new StaticTextItem("jmxPort", "JMX Port");
jmxPortItem.setValue(storageNode.getJmxPort());
// final StaticTextItem jmxConnectionUrlItem = new StaticTextItem("jmxConnectionUrl",
10 years, 8 months
[rhq] modules/common modules/enterprise
by John Sanda
modules/common/cassandra-installer/pom.xml | 6 +
modules/common/cassandra-installer/src/main/java/org/rhq/storage/installer/StorageInstaller.java | 39 +++++-----
modules/common/cassandra-installer/src/main/resources/module/main/module.xml | 1
modules/common/cassandra-util/src/main/java/org/rhq/cassandra/util/ConfigEditor.java | 11 ++
modules/enterprise/server/appserver/src/main/scripts/rhq-container.build.xml | 2
5 files changed, 39 insertions(+), 20 deletions(-)
New commits:
commit 3a36720ad018a3e48532bf50650d6dbb065de695
Author: John Sanda <jsanda(a)redhat.com>
Date: Fri Aug 30 11:47:00 2013 -0400
set the rhq.storage.gossip-port during installation/upgrade
diff --git a/modules/common/cassandra-installer/pom.xml b/modules/common/cassandra-installer/pom.xml
index 4492e70..4c737fc 100644
--- a/modules/common/cassandra-installer/pom.xml
+++ b/modules/common/cassandra-installer/pom.xml
@@ -24,6 +24,12 @@
</dependency>
<dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>rhq-cassandra-util</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
<version>1.2</version>
diff --git a/modules/common/cassandra-installer/src/main/java/org/rhq/storage/installer/StorageInstaller.java b/modules/common/cassandra-installer/src/main/java/org/rhq/storage/installer/StorageInstaller.java
index de13f5c..243620f 100644
--- a/modules/common/cassandra-installer/src/main/java/org/rhq/storage/installer/StorageInstaller.java
+++ b/modules/common/cassandra-installer/src/main/java/org/rhq/storage/installer/StorageInstaller.java
@@ -60,11 +60,11 @@ import org.apache.commons.exec.PumpStreamHandler;
import org.apache.commons.io.output.NullOutputStream;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.yaml.snakeyaml.Yaml;
import org.rhq.cassandra.Deployer;
import org.rhq.cassandra.DeploymentOptions;
import org.rhq.cassandra.DeploymentOptionsFactory;
+import org.rhq.cassandra.util.ConfigEditor;
import org.rhq.core.util.PropertiesFileUpdate;
import org.rhq.core.util.StringUtil;
import org.rhq.core.util.exception.ThrowableUtil;
@@ -107,7 +107,7 @@ public class StorageInstaller {
private int defaultNativeTransportPort = 9142;
- private int storagePort = 7100;
+ private int defaultStoragePort = 7100;
private int sslStoragePort = 7101;
@@ -151,7 +151,7 @@ public class StorageInstaller {
nativeTransportPortOption.setArgName("PORT");
Option storagePortOption = new Option(null, "storage-port", true, "The port on which to listen for requests "
- + " from other nodes. Defaults to " + storagePort);
+ + " from other nodes. Defaults to " + defaultStoragePort);
storagePortOption.setArgName("PORT");
Option sslStoragePortOption = new Option(null, "ssl-storage-port", true, "The port on which to listen for "
@@ -218,6 +218,8 @@ public class StorageInstaller {
String hostname;
int jmxPort;
+ int nativeTransportPort;
+ int storagePort;
File logFile = new File(logDir, "rhq-storage.log");
if (cmdLine.hasOption("upgrade")) {
@@ -283,15 +285,13 @@ public class StorageInstaller {
replaceFile(internodeAuthConfFile, new File(newConfDir, internodeAuthConfFile.getName()));
}
- log.info("Finished installing RHQ Storage Node.");
-
- log.info("Updating rhq-server.properties...");
File yamlFile = new File(newConfDir, "cassandra.yaml");
+ ConfigEditor yamlEditor = new ConfigEditor(yamlFile);
+ yamlEditor.load();
- Yaml yaml = new Yaml();
- Map<String, Object> config = (Map<String, Object>) yaml.load(new FileInputStream(yamlFile));
-
- hostname = (String) config.get("listen_address");
+ hostname = yamlEditor.getListenAddress();
+ nativeTransportPort = yamlEditor.getNativeTransportPort();
+ storagePort = yamlEditor.getStoragePort();
} else {
if (cmdLine.hasOption("dir")) {
File basedir = new File(cmdLine.getOptionValue("dir"));
@@ -342,7 +342,8 @@ public class StorageInstaller {
}
jmxPort = getPort(cmdLine, "jmx-port", defaultJmxPort);
- int nativeTransportPort = getPort(cmdLine, "client-port", defaultNativeTransportPort);
+ nativeTransportPort = getPort(cmdLine, "client-port", defaultNativeTransportPort);
+ storagePort = getPort(cmdLine, "storage-port", defaultStoragePort);
deploymentOptions.setCommitLogDir(commitLogDir);
deploymentOptions.setDataDir(dataDir);
@@ -352,7 +353,7 @@ public class StorageInstaller {
deploymentOptions.setRpcPort(rpcPort);
deploymentOptions.setJmxPort(jmxPort);
deploymentOptions.setNativeTransportPort(nativeTransportPort);
- deploymentOptions.setStoragePort(getPort(cmdLine, "storage-port", storagePort));
+ deploymentOptions.setStoragePort(storagePort);
deploymentOptions.setSslStoragePort(getPort(cmdLine, "ssl-storage-port", sslStoragePort));
// The out of box default for native_transport_max_threads is 128. We default
@@ -395,14 +396,16 @@ public class StorageInstaller {
Set<InetAddress> addresses = new HashSet<InetAddress>();
addresses.add(InetAddress.getByName(hostname));
deployer.updateStorageAuthConf(addresses);
+ }
- log.info("Finished installing RHQ Storage Node.");
+ PropertiesFileUpdate serverPropertiesUpdater = getServerProperties();
+ log.info("Updating rhq-server.properties...");
+ Properties properties = new Properties();
+ properties.setProperty("rhq.storage.nodes", hostname);
+ properties.setProperty("rhq.storage.cql-port", Integer.toString(nativeTransportPort));
+ properties.setProperty("rhq.storage.gossip-port", Integer.toString(storagePort));
- PropertiesFileUpdate serverPropertiesUpdater = getServerProperties();
- log.info("Updating rhq-server.properties...");
- serverPropertiesUpdater.update("rhq.storage.nodes", hostname);
- serverPropertiesUpdater.update("rhq.storage.cql-port", nativeTransportPort + "");
- }
+ serverPropertiesUpdater.update(properties);
boolean startNode = Boolean.parseBoolean(cmdLine.getOptionValue("start", "true"));
if (startNode) {
diff --git a/modules/common/cassandra-installer/src/main/resources/module/main/module.xml b/modules/common/cassandra-installer/src/main/resources/module/main/module.xml
index bf66025..3e10262 100644
--- a/modules/common/cassandra-installer/src/main/resources/module/main/module.xml
+++ b/modules/common/cassandra-installer/src/main/resources/module/main/module.xml
@@ -7,6 +7,7 @@
<resource-root path="${project.build.finalName}.jar"/>
<resource-root path="rhq-cassandra-ccm-core-${project.version}.jar"/>
<resource-root path="rhq-core-util-${project.version}.jar"/>
+ <resource-root path="rhq-cassandra-util-${project.version}.jar"/>
<resource-root path="snakeyaml-${cassandra.snakeyaml.version}.jar"/>
</resources>
diff --git a/modules/common/cassandra-util/src/main/java/org/rhq/cassandra/util/ConfigEditor.java b/modules/common/cassandra-util/src/main/java/org/rhq/cassandra/util/ConfigEditor.java
index 42e531f..1d727c9 100644
--- a/modules/common/cassandra-util/src/main/java/org/rhq/cassandra/util/ConfigEditor.java
+++ b/modules/common/cassandra-util/src/main/java/org/rhq/cassandra/util/ConfigEditor.java
@@ -32,14 +32,23 @@ public class ConfigEditor {
}
public void load() {
+ FileInputStream inputStream = null;
try {
DumperOptions options = new DumperOptions();
options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
yaml = new Yaml(options);
- config = (Map) yaml.load(new FileInputStream(configFile));
+ inputStream = new FileInputStream(configFile);
+ config = (Map) yaml.load(inputStream);
createBackup();
} catch (FileNotFoundException e) {
throw new ConfigEditorException("Failed to load " + configFile, e);
+ } finally {
+ if (inputStream != null) {
+ try {
+ inputStream.close();
+ } catch (IOException e) {
+ }
+ }
}
}
diff --git a/modules/enterprise/server/appserver/src/main/scripts/rhq-container.build.xml b/modules/enterprise/server/appserver/src/main/scripts/rhq-container.build.xml
index 566a0c9..2bc16a7 100644
--- a/modules/enterprise/server/appserver/src/main/scripts/rhq-container.build.xml
+++ b/modules/enterprise/server/appserver/src/main/scripts/rhq-container.build.xml
@@ -694,7 +694,7 @@ rhq.storage.nodes=
# Both properties are required.
#
rhq.storage.cql-port=${rhq.cassandra.native-transport-port}
-rhq.storage.gossip-port=${rhq.cassandra.native-transport-port}
+rhq.storage.gossip-port=${rhq.cassandra.storage-port}
# If enabled data sent to and from storage nodes will be compressed using
# snappy (https://code.google.com/p/snappy) compression. Note that this is an
10 years, 8 months
[rhq] modules/enterprise
by Jiri Kremser
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LinkManager.java | 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/storage/StorageNodeAdminView.java | 31 --
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/storage/StorageNodeAlertHistoryView.java | 131 ++++++----
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/StorageGWTService.java | 5
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/StorageGWTServiceImpl.java | 14 -
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerBean.java | 42 +--
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerLocal.java | 4
7 files changed, 147 insertions(+), 84 deletions(-)
New commits:
commit ac8a69feb34a5b1b9b3af5035a9170c512811c4e
Author: Jirka Kremser <jkremser(a)redhat.com>
Date: Fri Aug 30 15:19:20 2013 +0200
C* UI: Adding a link to the storage node whose child caused the alert to the alert table.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LinkManager.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LinkManager.java
index dd7aaa3..db5da39 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LinkManager.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LinkManager.java
@@ -276,6 +276,10 @@ public class LinkManager {
return link;
}
+
+ public static String getStorageNodeLink(int storageNodeId) {
+ return "#Administration/Topology/StorageNodes/" + storageNodeId;
+ }
public static String getAutodiscoveryQueueLink() {
if (GWT) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/storage/StorageNodeAdminView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/storage/StorageNodeAdminView.java
index 5526c34..cb3ab83 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/storage/StorageNodeAdminView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/storage/StorageNodeAdminView.java
@@ -19,6 +19,7 @@
package org.rhq.enterprise.gui.coregui.client.admin.storage;
import java.util.EnumSet;
+import java.util.Map;
import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.rpc.AsyncCallback;
@@ -27,7 +28,6 @@ import com.smartgwt.client.widgets.tab.events.TabSelectedEvent;
import com.smartgwt.client.widgets.tab.events.TabSelectedHandler;
import org.rhq.core.domain.resource.ResourceType;
-import org.rhq.core.domain.util.collection.ArrayUtils;
import org.rhq.enterprise.gui.coregui.client.BookmarkableView;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.IconEnum;
@@ -66,7 +66,7 @@ public class StorageNodeAdminView extends EnhancedVLayout implements Bookmarkabl
private TabInfo backupTabInfo = new TabInfo(3, new ViewName("Backup"));
private StorageNodeTableView table;
- private int[] resIds;
+ private Map<Integer, Integer> resIdsToStorageNodeIdsMap;
public StorageNodeAdminView() {
super();
@@ -115,11 +115,11 @@ public class StorageNodeAdminView extends EnhancedVLayout implements Bookmarkabl
} else if (tabInfo.equals(backupTabInfo)) {
tabset.getTabByName(tabInfo.name.getName()).setPane(new Label("in progress.."));
} else if (tabInfo.equals(alertsTabInfo)) {
- if (resIds != null) {
+ if (resIdsToStorageNodeIdsMap != null) {
tabset.getTabByName(tabInfo.name.getName()).setPane(
- new StorageNodeAlertHistoryView("storageNodesAlerts", resIds));
+ new StorageNodeAlertHistoryView("storageNodesAlerts", resIdsToStorageNodeIdsMap));
} else {
- GWTServiceLookup.getStorageService().findResourcesWithAlertDefinitions(new AsyncCallback<Integer[]>() {
+ GWTServiceLookup.getStorageService().findResourcesWithAlertDefinitions(new AsyncCallback<Map<Integer, Integer>>() {
@Override
public void onFailure(Throwable caught) {
Message message = new Message("Unable to render storage node alert view: "
@@ -128,15 +128,15 @@ public class StorageNodeAdminView extends EnhancedVLayout implements Bookmarkabl
}
@Override
- public void onSuccess(Integer[] result) {
- if (result == null || result.length == 0) {
+ public void onSuccess(Map<Integer, Integer> result) {
+ if (result == null || result.size() == 0) {
onFailure(new Exception(
"Unfortunately, there are no associated resources for the available storage nodes. " +
"Check if the agents are running on the machines where the storage nodes are deployed."));
} else {
- resIds = ArrayUtils.unwrapArray(result);
+ resIdsToStorageNodeIdsMap = result;
tabset.getTabByName(tabInfo.name.getName()).setPane(
- new StorageNodeAlertHistoryView("storageNodesAlerts", resIds));
+ new StorageNodeAlertHistoryView("storageNodesAlerts", resIdsToStorageNodeIdsMap));
tabset.selectTab(tabInfo.index);
}
}
@@ -176,19 +176,6 @@ public class StorageNodeAdminView extends EnhancedVLayout implements Bookmarkabl
}
}
- private void loadResourceType(int resourceTypeId) {
- ResourceTypeRepository.Cache.getInstance().getResourceTypes(
- resourceTypeId,
- EnumSet.of(ResourceTypeRepository.MetadataType.content, ResourceTypeRepository.MetadataType.operations,
- ResourceTypeRepository.MetadataType.measurements, ResourceTypeRepository.MetadataType.events,
- ResourceTypeRepository.MetadataType.resourceConfigurationDefinition),
- new ResourceTypeRepository.TypeLoadedCallback() {
- public void onTypesLoaded(ResourceType type) {
-
- }
- });
- }
-
private void scheduleUnacknowledgedAlertsPollingJob(final NamedTab alerts) {
new Timer() {
public void run() {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/storage/StorageNodeAlertHistoryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/storage/StorageNodeAlertHistoryView.java
index 9fa55a6..6005cf6 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/storage/StorageNodeAlertHistoryView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/storage/StorageNodeAlertHistoryView.java
@@ -19,6 +19,9 @@
package org.rhq.enterprise.gui.coregui.client.admin.storage;
import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.Record;
@@ -36,6 +39,7 @@ import org.rhq.core.domain.cloud.StorageNode;
import org.rhq.core.domain.criteria.AlertCriteria;
import org.rhq.core.domain.criteria.StorageNodeCriteria;
import org.rhq.core.domain.util.PageList;
+import org.rhq.core.domain.util.collection.ArrayUtils;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.ImageManager;
import org.rhq.enterprise.gui.coregui.client.LinkManager;
@@ -48,50 +52,35 @@ import org.rhq.enterprise.gui.coregui.client.inventory.resource.AncestryUtil;
import org.rhq.enterprise.gui.coregui.client.util.StringUtility;
/**
+ * The view for accessing alerts on storage node resource and its children.
+ *
* @author Jirka Kremser
- *
*/
public class StorageNodeAlertHistoryView extends AlertHistoryView {
private boolean isGouped = true;
private final HTMLFlow header;
private final int storageNodeId;
+ private final boolean allStorageNodes;
+ private Map<Integer, Integer> resourceIdToStorageNodeIdMap;
+ private Map<Integer, String> storageNodeIdToAddressMap;
- public StorageNodeAlertHistoryView(String tableTitle, int[] resourceIds) {
- this(tableTitle, resourceIds, null, -1);
+ public StorageNodeAlertHistoryView(String tableTitle, Map<Integer, Integer> resourceIdToStorageNodeIdMap) {
+ this(tableTitle, ArrayUtils.unwrapArray(resourceIdToStorageNodeIdMap.keySet().toArray(new Integer[]{})), null, -1);
+ this.resourceIdToStorageNodeIdMap = resourceIdToStorageNodeIdMap;
}
public StorageNodeAlertHistoryView(String tableTitle, int[] resourceIds, HTMLFlow header, int storageNodeId) {
super(tableTitle, resourceIds);
this.header = header;
- this.storageNodeId = storageNodeId;
+ this.storageNodeId = -1;
+ this.allStorageNodes = storageNodeId == -1;
+ storageNodeIdToAddressMap = new HashMap<Integer, String>();
}
@Override
protected void onInit() {
super.onInit();
- if (header != null && storageNodeId != -1) {
- StorageNodeCriteria criteria = new StorageNodeCriteria();
- criteria.addFilterId(storageNodeId);
- GWTServiceLookup.getStorageService().findStorageNodesByCriteria(criteria,
- new AsyncCallback<PageList<StorageNode>>() {
- public void onSuccess(final PageList<StorageNode> storageNodes) {
- if (storageNodes == null || storageNodes.isEmpty() || storageNodes.size() != 1) {
- CoreGUI.getErrorHandler().handleError(
- MSG.view_adminTopology_message_fetchServerFail(String.valueOf(storageNodeId)));
- }
- final StorageNode node = storageNodes.get(0);
- header
- .setContents("<div style='text-align: center; font-weight: bold; font-size: medium;'> Storage Node ("
- + node.getAddress() + ")</div>");
- }
-
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError(
- MSG.view_adminTopology_message_fetchServerFail(String.valueOf(storageNodeId)) + " "
- + caught.getMessage(), caught);
- }
- });
- }
+ fetchAddresses();
}
@Override
@@ -107,19 +96,20 @@ public class StorageNodeAlertHistoryView extends AlertHistoryView {
|| AncestryUtil.RESOURCE_ANCESTRY.equals(field.getName())) {
continue;
} if (AlertCriteria.SORT_FIELD_CTIME.equals(field.getName())) {
- field.setWidth(240);
- field.setShowGridSummary(true);
- field.setShowGroupSummary(true);
- field.setSummaryFunction(new SummaryFunction() {
- public Object getSummaryValue(Record[] records, ListGridField field) {
- if (records != null && records.length > 0 && records[0] != null) {
- Integer resourceId = records[0].getAttributeAsInt(AncestryUtil.RESOURCE_ID);
- Integer defId = records[0].getAttributeAsInt("definitionId");
- String url = LinkManager.getSubsystemAlertDefinitionLink(resourceId, defId);
- return LinkManager.getHref(url, "Link to Definition");
- } else return "";
- }
- });
+// field.setShowGridSummary(true);
+// field.setShowGroupSummary(true);
+// field.setSummaryFunction(new SummaryFunction() {
+// public Object getSummaryValue(Record[] records, ListGridField field) {
+// if (records != null && records.length > 0 && records[0] != null) {
+// http://localhost:7080/coregui/#Administration/Configuration/AlertDefTempl...
+//
+// Integer resourceId = records[0].getAttributeAsInt(AncestryUtil.RESOURCE_ID);
+// Integer defId = records[0].getAttributeAsInt("definitionId");
+// String url = LinkManager.getSubsystemAlertDefinitionLink(resourceId, defId);
+// return LinkManager.getHref(url, "Link to Definition");
+// } else return "";
+// }
+// });
field.setCellFormatter(new CellFormatter() {
public String format(Object o, ListGridRecord listGridRecord, int i, int i1) {
if (listGridRecord.getAttribute("groupValue") != null) {
@@ -180,6 +170,24 @@ public class StorageNodeAlertHistoryView extends AlertHistoryView {
ListGridField descriptionField = new ListGridField("description", MSG.common_title_description());
descriptionField.setCanSortClientOnly(true);
newFields.add(descriptionField);
+
+ if (allStorageNodes) { // all storage nodes
+ ListGridField storageNodeLinkField = new ListGridField("storageNodeLink", "Storage Node");
+ storageNodeLinkField.setCellFormatter(new CellFormatter() {
+ public String format(Object o, ListGridRecord listGridRecord, int i, int i1) {
+ if (listGridRecord.getAttribute("groupValue") != null) {
+ return (String) o;
+ }
+ Integer resourceId = listGridRecord.getAttributeAsInt(AncestryUtil.RESOURCE_ID);
+ int storageNodeId = resourceIdToStorageNodeIdMap.get(resourceId);
+ String url = LinkManager.getStorageNodeLink(storageNodeId);
+ return LinkManager.getHref(url, storageNodeIdToAddressMap.get(storageNodeId));
+
+ }
+ });
+ storageNodeLinkField.setWidth(90);
+ newFields.add(2, storageNodeLinkField);
+ }
return newFields;
}
};
@@ -217,6 +225,49 @@ public class StorageNodeAlertHistoryView extends AlertHistoryView {
CoreGUI.goToView(getDetailUrlFromRecord(record));
}
+ private void fetchAddresses() {
+ if (header != null && !allStorageNodes) {
+ StorageNodeCriteria criteria = new StorageNodeCriteria();
+ criteria.addFilterId(storageNodeId);
+ GWTServiceLookup.getStorageService().findStorageNodesByCriteria(criteria,
+ new AsyncCallback<PageList<StorageNode>>() {
+ public void onSuccess(final PageList<StorageNode> storageNodes) {
+ if (storageNodes == null || storageNodes.isEmpty() || storageNodes.size() != 1) {
+ CoreGUI.getErrorHandler().handleError(
+ MSG.view_adminTopology_message_fetchServerFail(String.valueOf(storageNodeId)));
+ }
+ final StorageNode node = storageNodes.get(0);
+ header
+ .setContents("<div style='text-align: center; font-weight: bold; font-size: medium;'> Storage Node ("
+ + node.getAddress() + ")</div>");
+ }
+
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(
+ MSG.view_adminTopology_message_fetchServerFail(String.valueOf(storageNodeId)) + " "
+ + caught.getMessage(), caught);
+ }
+ });
+ } else { // fetch the addresses of all storage nodes
+ GWTServiceLookup.getStorageService().getStorageNodes(new AsyncCallback<List<StorageNode>>() {
+ public void onSuccess(final List<StorageNode> storageNodes) {
+ if (storageNodes != null && !storageNodes.isEmpty()) {
+ for (StorageNode node : storageNodes) {
+ storageNodeIdToAddressMap.put(node.getId(), node.getAddress());
+ }
+ }
+ }
+
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(
+ MSG.view_adminTopology_message_fetchServerFail(String.valueOf(storageNodeId)) + " "
+ + caught.getMessage(), caught);
+ }
+ });
+
+ }
+ }
+
private String getDetailUrlFromRecord(ListGridRecord record) {
if (record == null) {
throw new IllegalArgumentException("'record' parameter is null.");
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/StorageGWTService.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/StorageGWTService.java
index 9470302..f24e4b0 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/StorageGWTService.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/StorageGWTService.java
@@ -27,7 +27,6 @@ import java.util.Map;
import com.google.gwt.user.client.rpc.RemoteService;
-import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.cloud.StorageClusterSettings;
import org.rhq.core.domain.cloud.StorageNode;
import org.rhq.core.domain.cloud.StorageNodeConfigurationComposite;
@@ -76,7 +75,9 @@ public interface StorageGWTService extends RemoteService {
PageList<StorageNodeLoadComposite> getStorageNodeComposites() throws RuntimeException;
- Integer[] findResourcesWithAlertDefinitions() throws RuntimeException;
+ List<StorageNode> getStorageNodes() throws RuntimeException;
+
+ Map<Integer, Integer> findResourcesWithAlertDefinitions() throws RuntimeException;
Integer[] findResourcesWithAlertDefinitions(StorageNode storageNode) throws RuntimeException;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/StorageGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/StorageGWTServiceImpl.java
index 9ce328e..9d6c7ba 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/StorageGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/StorageGWTServiceImpl.java
@@ -111,9 +111,19 @@ public class StorageGWTServiceImpl extends AbstractGWTServiceImpl implements Sto
}
@Override
- public Integer[] findResourcesWithAlertDefinitions() throws RuntimeException {
+ public List<StorageNode> getStorageNodes() throws RuntimeException {
try {
- return storageNodeManager.findResourcesWithAlertDefinitions();
+ return SerialUtility.prepare(storageNodeManager.getStorageNodes(),
+ "StorageGWTServiceImpl.getStorageNodes");
+ } catch (Throwable t) {
+ throw getExceptionToThrowToClient(t);
+ } }
+
+ @Override
+ public Map<Integer, Integer> findResourcesWithAlertDefinitions() throws RuntimeException {
+ try {
+ return SerialUtility.prepare(storageNodeManager.findResourcesWithAlertDefinitions(),
+ "StorageGWTServiceImpl.findResourcesWithAlertDefinitions");
} catch (Throwable t) {
throw getExceptionToThrowToClient(t);
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerBean.java
index b30e50a..eda6ae1 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerBean.java
@@ -670,12 +670,21 @@ public class StorageNodeManagerBean implements StorageNodeManagerLocal, StorageN
}
@Override
- public Integer[] findResourcesWithAlertDefinitions() {
- return this.findResourcesWithAlertDefinitions(null);
+ public Map<Integer, Integer> findResourcesWithAlertDefinitions() {
+ return this.findResourcesWithAlertsToStorageNodeMap(null);
}
@Override
public Integer[] findResourcesWithAlertDefinitions(StorageNode storageNode) {
+ Map<Integer, Integer> result = findResourcesWithAlertsToStorageNodeMap(storageNode);
+ if (result != null) {
+ Set<Integer> resourceIds = result.keySet();
+ return resourceIds.toArray(new Integer[resourceIds.size()]);
+ }
+ return new Integer[0];
+ }
+
+ private Map<Integer, Integer> findResourcesWithAlertsToStorageNodeMap(StorageNode storageNode) {
List<StorageNode> initialStorageNodes = getStorageNodes();
if (storageNode == null) {
initialStorageNodes = getStorageNodes();
@@ -684,29 +693,30 @@ public class StorageNodeManagerBean implements StorageNodeManagerLocal, StorageN
StorageNode.class, storageNode.getId()) : storageNode);
}
+ Map<Integer, Integer> resourceIdsToStorageNodeMap = new HashMap<Integer, Integer>();
Queue<Resource> unvisitedResources = new LinkedList<Resource>();
+
+ // we are assuming here that the set of resources is disjunktive across different storage nodes
for (StorageNode initialStorageNode : initialStorageNodes) {
if (initialStorageNode.getResource() != null) {
unvisitedResources.add(initialStorageNode.getResource());
- }
- }
-
- List<Integer> resourceIdsWithAlertDefinitions = new ArrayList<Integer>();
- while (!unvisitedResources.isEmpty()) {
- Resource resource = unvisitedResources.poll();
- if (resource.getAlertDefinitions() != null) {
- resourceIdsWithAlertDefinitions.add(resource.getId());
- }
+ while (!unvisitedResources.isEmpty()) {
+ Resource resource = unvisitedResources.poll();
+ if (resource.getAlertDefinitions() != null) {
+ resourceIdsToStorageNodeMap.put(resource.getId(), initialStorageNode.getId());
+ }
- Set<Resource> childResources = resource.getChildResources();
- if (childResources != null) {
- for (Resource child : childResources) {
- unvisitedResources.add(child);
+ Set<Resource> childResources = resource.getChildResources();
+ if (childResources != null) {
+ for (Resource child : childResources) {
+ unvisitedResources.add(child);
+ }
+ }
}
}
}
- return resourceIdsWithAlertDefinitions.toArray(new Integer[resourceIdsWithAlertDefinitions.size()]);
+ return resourceIdsToStorageNodeMap;
}
@Override
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerLocal.java
index b689b8b..f740a27 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerLocal.java
@@ -128,9 +128,9 @@ public interface StorageNodeManagerLocal {
* have alert definitions. This can be used by the resource criteria queries to find
* all alerts triggered for storage nodes resources.
*
- * @return resource ids
+ * @return map with resource (with defined alert) id as a key and storage node id as a value
*/
- Integer[] findResourcesWithAlertDefinitions();
+ Map<Integer, Integer> findResourcesWithAlertDefinitions();
/**
* Find ids for all resources and sub-resources, of the specified storage node, that
10 years, 8 months
[rhq] 2 commits - modules/enterprise
by John Sanda
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementDataManagerBean.java | 15 ++++++++--
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java | 2 -
2 files changed, 14 insertions(+), 3 deletions(-)
New commits:
commit ac1124b8223ef44ecc19e9839ddede067ee02e13
Author: John Sanda <jsanda(a)redhat.com>
Date: Fri Aug 30 08:15:14 2013 -0400
[BZ 1002210] fixing regression caused by previous commit for this bug
Now that getSummaryAggregate is not transaction, the schedule's resource
association needs to be initialized.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementDataManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementDataManagerBean.java
index c94d61b..8757430 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementDataManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementDataManagerBean.java
@@ -88,6 +88,7 @@ import org.rhq.enterprise.server.agentclient.AgentClient;
import org.rhq.enterprise.server.alert.AlertManagerLocal;
import org.rhq.enterprise.server.alert.engine.AlertConditionCacheManagerLocal;
import org.rhq.enterprise.server.alert.engine.AlertConditionCacheStats;
+import org.rhq.enterprise.server.auth.SubjectManagerLocal;
import org.rhq.enterprise.server.authz.AuthorizationManagerLocal;
import org.rhq.enterprise.server.authz.PermissionException;
import org.rhq.enterprise.server.storage.StorageClientManagerBean;
@@ -162,6 +163,9 @@ public class MeasurementDataManagerBean implements MeasurementDataManagerLocal,
@EJB
private MeasurementScheduleManagerLocal measurementScheduleManager;
+ @EJB
+ private SubjectManagerLocal subjectManager;
+
// doing a bulk delete in here, need to be in its own tx
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
@TransactionTimeout(6 * 60 * 60)
@@ -596,12 +600,19 @@ public class MeasurementDataManagerBean implements MeasurementDataManagerLocal,
log.debug(callingMethod + ": " + stats.toString());
}
+ @Override
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public MeasurementAggregate getAggregate(Subject subject, int scheduleId, long startTime, long endTime) {
- MeasurementSchedule schedule = entityManager.find(MeasurementSchedule.class, scheduleId);
- if (schedule == null) {
+ MeasurementScheduleCriteria criteria = new MeasurementScheduleCriteria();
+ criteria.addFilterId(scheduleId);
+ criteria.fetchResource(true);
+
+ PageList<MeasurementSchedule> schedules = measurementScheduleManager.findSchedulesByCriteria(
+ subjectManager.getOverlord(), criteria);
+ if (schedules.isEmpty()) {
throw new MeasurementException("Could not fine MeasurementSchedule with the id[" + scheduleId + "]");
}
+ MeasurementSchedule schedule = schedules.get(0);
if (authorizationManager.canViewResource(subject, schedule.getResource().getId()) == false) {
throw new PermissionException("User[" + subject.getName()
commit c14fd37f96ef5acaff25588a7451a52b933a347e
Author: John Sanda <jsanda(a)redhat.com>
Date: Fri Aug 30 07:44:29 2013 -0400
fix name of server jar deployment
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java
index b29c8a4..2e90e32 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java
@@ -393,7 +393,7 @@ public final class LookupUtil {
public static StorageClientManagerBean getStorageClientManager() {
try {
return (StorageClientManagerBean) new InitialContext().lookup(
- "java:global/rhq/rhq-enterprise-server-ejb3/" + StorageClientManagerBean.class.getSimpleName());
+ "java:global/rhq/rhq-server/" + StorageClientManagerBean.class.getSimpleName());
} catch (NamingException e) {
String msg = "Unable to access " + StorageClientManagerBean.class + " due to JNDI error. You may " +
"need to restart the server so that the storage client subsystem can be reinitialized.";
10 years, 8 months
[rhq] modules/common modules/enterprise modules/helpers
by Thomas Segismont
modules/common/cassandra-ccm/cassandra-ccm-arquillian/src/main/java/org/rhq/cassandra/ccm/arquillian/CCMSuiteDeploymentExtension.java | 44 ++++------
modules/common/cassandra-ccm/cassandra-ccm-core/src/main/java/org/rhq/cassandra/ClusterInitService.java | 36 +++-----
modules/common/cassandra-ccm/cassandra-ccm-testng/src/main/java/org/rhq/cassandra/CCMTestNGListener.java | 36 +++-----
modules/enterprise/server/itests-2/pom.xml | 8 +
modules/helpers/metrics-simulator/src/main/java/org/rhq/metrics/simulator/Simulator.java | 36 +++-----
5 files changed, 70 insertions(+), 90 deletions(-)
New commits:
commit a8003000c0017c7726a9dd2934b25df1d9be4f27
Author: Thomas Segismont <tsegismo(a)redhat.com>
Date: Fri Aug 30 13:07:16 2013 +0200
Fix itests-2 suite: Missing picket box test dep, obfuscated password and wrong cluster init wait period
diff --git a/modules/common/cassandra-ccm/cassandra-ccm-arquillian/src/main/java/org/rhq/cassandra/ccm/arquillian/CCMSuiteDeploymentExtension.java b/modules/common/cassandra-ccm/cassandra-ccm-arquillian/src/main/java/org/rhq/cassandra/ccm/arquillian/CCMSuiteDeploymentExtension.java
index c52f778..d051d9d 100644
--- a/modules/common/cassandra-ccm/cassandra-ccm-arquillian/src/main/java/org/rhq/cassandra/ccm/arquillian/CCMSuiteDeploymentExtension.java
+++ b/modules/common/cassandra-ccm/cassandra-ccm-arquillian/src/main/java/org/rhq/cassandra/ccm/arquillian/CCMSuiteDeploymentExtension.java
@@ -1,26 +1,20 @@
/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2013 Red Hat, Inc.
+ * All rights reserved.
*
- * * RHQ Management Platform
- * * Copyright (C) 2005-2012 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, version 2, as
- * * published by the Free Software Foundation, and/or the GNU Lesser
- * * General Public License, version 2.1, also as published by the Free
- * * Software Foundation.
- * *
- * * 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 and the GNU Lesser General Public License
- * * for more details.
- * *
- * * You should have received a copy of the GNU General Public License
- * * and the GNU Lesser 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.
+ * 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.cassandra.ccm.arquillian;
@@ -125,7 +119,7 @@ public class CCMSuiteDeploymentExtension implements LoadableExtension {
File clusterDir = new File(basedir, "cassandra");
options.setUsername("rhqadmin");
- options.setPassword("rhqadmin");
+ options.setPassword("1eeb2f255e832171df8592078de921bc");
options.setClusterDir(clusterDir.getAbsolutePath());
options.setHeapSize("256M");
options.setHeapNewSize("64M");
@@ -141,8 +135,8 @@ public class CCMSuiteDeploymentExtension implements LoadableExtension {
ccm.startCluster(false);
try {
- clusterInitService.waitForClusterToStart(nodes, jmxPorts, nodes.length, 20, 5, 1500);
- schemaManager = new SchemaManager("rhqadmin", "rhqadmin", nodes, cqlPort);
+ clusterInitService.waitForClusterToStart(nodes, jmxPorts, nodes.length, 2000, 20, 10);
+ schemaManager = new SchemaManager("rhqadmin", "1eeb2f255e832171df8592078de921bc", nodes, cqlPort);
} catch (Exception e) {
if (null != ccm) {
@@ -159,7 +153,7 @@ public class CCMSuiteDeploymentExtension implements LoadableExtension {
cqlPort = Integer.parseInt(cqlPortString);
//jmxPorts = parseNodeJmxPorts(seed);
- schemaManager = new SchemaManager("rhqadmin", "rhqadmin", nodes, cqlPort);
+ schemaManager = new SchemaManager("rhqadmin", "1eeb2f255e832171df8592078de921bc", nodes, cqlPort);
} catch (Exception e) {
throw new RuntimeException("External Cassandra initialization failed", e);
@@ -272,4 +266,4 @@ public class CCMSuiteDeploymentExtension implements LoadableExtension {
}
}
}
-}
\ No newline at end of file
+}
diff --git a/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/java/org/rhq/cassandra/ClusterInitService.java b/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/java/org/rhq/cassandra/ClusterInitService.java
index cbbfad5..d2bb984 100644
--- a/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/java/org/rhq/cassandra/ClusterInitService.java
+++ b/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/java/org/rhq/cassandra/ClusterInitService.java
@@ -1,26 +1,20 @@
/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2013 Red Hat, Inc.
+ * All rights reserved.
*
- * * RHQ Management Platform
- * * Copyright (C) 2005-2012 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, version 2, as
- * * published by the Free Software Foundation, and/or the GNU Lesser
- * * General Public License, version 2.1, also as published by the Free
- * * Software Foundation.
- * *
- * * 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 and the GNU Lesser General Public License
- * * for more details.
- * *
- * * You should have received a copy of the GNU General Public License
- * * and the GNU Lesser 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.
+ * 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.cassandra;
@@ -123,7 +117,6 @@ public final class ClusterInitService {
* before returning.
* @param retries The number of times to retry connecting. A runtime exception will be
* thrown when the number of failed connections exceeds this value.
- * @param hosts The cluster nodes to which a connection should be made
*/
public void waitForClusterToStart(String[] storageNodes, int jmxPorts[], int numHosts, int retries) {
waitForClusterToStart(storageNodes, jmxPorts, numHosts, 250, retries, 1);
@@ -147,7 +140,6 @@ public final class ClusterInitService {
* @param retries The number of times to retry connecting. A runtime exception will be
* thrown when the number of failed connections exceeds this value.
* @param initialWait The amount of seconds before first try.
- * @param hosts The cluster nodes to which a connection should be made
*/
public void waitForClusterToStart(String[] storageNodes, int jmxPorts[], int numHosts, long delay,
int retries, int initialWait) {
diff --git a/modules/common/cassandra-ccm/cassandra-ccm-testng/src/main/java/org/rhq/cassandra/CCMTestNGListener.java b/modules/common/cassandra-ccm/cassandra-ccm-testng/src/main/java/org/rhq/cassandra/CCMTestNGListener.java
index 5790ab6..ab58c95 100644
--- a/modules/common/cassandra-ccm/cassandra-ccm-testng/src/main/java/org/rhq/cassandra/CCMTestNGListener.java
+++ b/modules/common/cassandra-ccm/cassandra-ccm-testng/src/main/java/org/rhq/cassandra/CCMTestNGListener.java
@@ -1,26 +1,20 @@
/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2013 Red Hat, Inc.
+ * All rights reserved.
*
- * * RHQ Management Platform
- * * Copyright (C) 2005-2012 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, version 2, as
- * * published by the Free Software Foundation, and/or the GNU Lesser
- * * General Public License, version 2.1, also as published by the Free
- * * Software Foundation.
- * *
- * * 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 and the GNU Lesser General Public License
- * * for more details.
- * *
- * * You should have received a copy of the GNU General Public License
- * * and the GNU Lesser 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.
+ * 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.cassandra;
@@ -122,7 +116,7 @@ public class CCMTestNGListener implements IInvokedMethodListener {
ccm.startCluster(false);
- clusterInitService.waitForClusterToStart(nodes, jmxPorts, nodes.length, 20, 2, 10);
+ clusterInitService.waitForClusterToStart(nodes, jmxPorts, nodes.length, 2000, 20, 10);
SchemaManager schemaManager = new SchemaManager(annotation.username(), annotation.password(), nodes,
ccm.getCqlPort());
diff --git a/modules/enterprise/server/itests-2/pom.xml b/modules/enterprise/server/itests-2/pom.xml
index 0dacb1a..43afd79 100644
--- a/modules/enterprise/server/itests-2/pom.xml
+++ b/modules/enterprise/server/itests-2/pom.xml
@@ -34,7 +34,7 @@
<!-- cassandra connection properties -->
<rhq.storage.username>rhqadmin</rhq.storage.username>
- <rhq.storage.password>rhqadmin</rhq.storage.password>
+ <rhq.storage.password>1eeb2f255e832171df8592078de921bc</rhq.storage.password>
<rhq.storage.nodes>127.0.0.1,127.0.0.2</rhq.storage.nodes>
<rhq.storage.cql-port>9042</rhq.storage.cql-port>
</properties>
@@ -777,6 +777,12 @@
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.picketbox</groupId>
+ <artifactId>picketbox</artifactId>
+ <scope>test</scope>
+ </dependency>
+
</dependencies>
</profile>
diff --git a/modules/helpers/metrics-simulator/src/main/java/org/rhq/metrics/simulator/Simulator.java b/modules/helpers/metrics-simulator/src/main/java/org/rhq/metrics/simulator/Simulator.java
index a5a3994..af012dd 100644
--- a/modules/helpers/metrics-simulator/src/main/java/org/rhq/metrics/simulator/Simulator.java
+++ b/modules/helpers/metrics-simulator/src/main/java/org/rhq/metrics/simulator/Simulator.java
@@ -1,26 +1,20 @@
/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2013 Red Hat, Inc.
+ * All rights reserved.
*
- * * RHQ Management Platform
- * * Copyright (C) 2005-2012 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, version 2, as
- * * published by the Free Software Foundation, and/or the GNU Lesser
- * * General Public License, version 2.1, also as published by the Free
- * * Software Foundation.
- * *
- * * 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 and the GNU Lesser General Public License
- * * for more details.
- * *
- * * You should have received a copy of the GNU General Public License
- * * and the GNU Lesser 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.
+ * 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.metrics.simulator;
@@ -208,7 +202,7 @@ public class Simulator implements ShutdownManager {
private void waitForClusterToInitialize() {
log.info("Waiting for cluster to initialize");
ClusterInitService clusterInitService = new ClusterInitService();
- clusterInitService.waitForClusterToStart(ccm.getNodes(), ccm.getJmxPorts(), ccm.getNodes().length, 20, 2, 1500);
+ clusterInitService.waitForClusterToStart(ccm.getNodes(), ccm.getJmxPorts(), ccm.getNodes().length, 2000, 20, 10);
}
private void createSchema() {
10 years, 8 months