modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
| 5
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java
| 67 +++---
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DatasourceComponent.java
| 4
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DatasourceDiscovery.java
| 4
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SocketBindingDiscovery.java
| 108 ----------
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemComponent.java
| 58 -----
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java
| 2
modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
| 18 -
8 files changed, 60 insertions(+), 206 deletions(-)
New commits:
commit 4c3726f4046e43d05e96cb71e413c6e6356db298
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Thu Mar 24 13:13:49 2011 +0100
Support reading metrics.
diff --git
a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
index c136b20..0fb28b1 100644
---
a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
+++
b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
@@ -130,6 +130,11 @@ public class ASConnection {
return tree;
}
+ JsonNode getAttributeValue(@Nullable String base, @Nullable String attributeName)
throws Exception {
+ String op = "operation=attribute&name=" + attributeName;
+ return getLevelData(base,op);
+ }
+
boolean isErrorReply(JsonNode in) {
if (in.has("outcome")) {
diff --git
a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java
b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java
index f700597..ad3516e 100644
---
a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java
+++
b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java
@@ -23,7 +23,6 @@ import org.apache.commons.logging.LogFactory;
import org.codehaus.jackson.JsonNode;
import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.domain.configuration.Property;
import org.rhq.core.domain.configuration.PropertyList;
import org.rhq.core.domain.configuration.PropertyMap;
import org.rhq.core.domain.configuration.PropertySimple;
@@ -44,13 +43,9 @@ import
org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
import org.rhq.core.pluginapi.inventory.ResourceComponent;
import org.rhq.core.pluginapi.inventory.ResourceContext;
import org.rhq.core.pluginapi.measurement.MeasurementFacet;
-import org.rhq.core.pluginapi.operation.OperationContext;
-import org.rhq.core.pluginapi.operation.OperationFacet;
-import org.rhq.core.pluginapi.operation.OperationResult;
import org.rhq.modules.plugins.jbossas7.json.NameValuePair;
import java.util.Iterator;
-import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -117,26 +112,24 @@ public class BaseComponent implements ResourceComponent,
MeasurementFacet, Confi
/**
* Gather measurement data
- * @see
org.rhq.core.pluginapi.measurement.MeasurementFacet#getValues(org.rhq.core.domain.measurement.MeasurementReport,
java.util.Set)
+ * @see
org.rhq.core.pluginapi.measurement.MeasurementFacet#getValues(org.rhq.core.domain.measurement.MeasurementReport,
java.util.Set)
*/
public void getValues(MeasurementReport report,
Set<MeasurementScheduleRequest> metrics) throws Exception {
- JsonNode obj = connection.getLevelData(key,false,true);
for (MeasurementScheduleRequest req : metrics) {
- if (obj.has(req.getName())) {
-/*
- String val = obj.getString(req.getName());
- if (req.getDataType()== DataType.MEASUREMENT) {
-
- Double d = Double.parseDouble(val);
- MeasurementDataNumeric data = new MeasurementDataNumeric(req,d);
- report.addData(data);
- } else if (req.getDataType()== DataType.TRAIT) {
- MeasurementDataTrait data = new MeasurementDataTrait(req,val);
- report.addData(data);
- }
-*/
+
+ JsonNode obj = connection.getAttributeValue(key, req.getName()); // TODO
batching
+
+ String val = obj.getValueAsText();
+ if (req.getDataType()== DataType.MEASUREMENT) {
+
+ Double d = Double.parseDouble(val);
+ MeasurementDataNumeric data = new MeasurementDataNumeric(req,d);
+ report.addData(data);
+ } else if (req.getDataType()== DataType.TRAIT) {
+ MeasurementDataTrait data = new MeasurementDataTrait(req,val);
+ report.addData(data);
}
}
}
commit bbee70600f8faf000892e14a5fdea2a749f0bfb6
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Thu Mar 24 09:49:46 2011 +0100
Bindings are now a list of maps within the binding group.
diff --git
a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java
b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java
index 28c0592..f700597 100644
---
a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java
+++
b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java
@@ -25,10 +25,12 @@ import org.codehaus.jackson.JsonNode;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.Property;
import org.rhq.core.domain.configuration.PropertyList;
+import org.rhq.core.domain.configuration.PropertyMap;
import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
import org.rhq.core.domain.configuration.definition.PropertyDefinition;
import org.rhq.core.domain.configuration.definition.PropertyDefinitionList;
+import org.rhq.core.domain.configuration.definition.PropertyDefinitionMap;
import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple;
import org.rhq.core.domain.measurement.AvailabilityType;
import org.rhq.core.domain.measurement.DataType;
@@ -149,7 +151,7 @@ public class BaseComponent implements ResourceComponent,
MeasurementFacet, Confi
public Configuration loadResourceConfiguration() throws Exception {
ConfigurationDefinition configDef =
context.getResourceType().getResourceConfigurationDefinition();
- JsonNode json = connection.getLevelData(key,false,false); // TODO path ? key?
+ JsonNode json = connection.getLevelData(key,true,false); // TODO path ? key?
Configuration ret = new Configuration();
@@ -160,12 +162,30 @@ public class BaseComponent implements ResourceComponent,
MeasurementFacet, Confi
ret.put(propertySimple);
} else if (propDef instanceof PropertyDefinitionList) {
PropertyList propertyList = new PropertyList(propDef.getName());
- Iterator<JsonNode> values = sub.getElements();
- while (values.hasNext()) {
- JsonNode node = values.next();
- String value = node.getTextValue();
- PropertySimple propertySimple = new
PropertySimple(propDef.getName(),value);
- propertyList.add(propertySimple);
+ if (((PropertyDefinitionList) propDef).getMemberDefinition()==null) {
+ Iterator<JsonNode> values = sub.getElements();
+ while (values.hasNext()) {
+ JsonNode node = values.next();
+ String value = node.getTextValue();
+ PropertySimple propertySimple = new
PropertySimple(propDef.getName(),value);
+ propertyList.add(propertySimple);
+ }
+ }
+ else if (((PropertyDefinitionList) propDef).getMemberDefinition()
instanceof PropertyDefinitionMap) {
+ Iterator<String> entries = sub.getFieldNames();
+ while (entries.hasNext()) {
+ String entryKey = entries.next();
+ JsonNode node = sub.findPath(entryKey);
+ PropertyMap map = new PropertyMap(((PropertyDefinitionList)
propDef).getMemberDefinition().getName()); // TODO : name from def or 'entryKey'
?
+ Iterator<String> fields = node.getFieldNames(); // TODO
loop over fields from map and not from json
+ while (fields.hasNext()) {
+ String key = fields.next();
+
+ PropertySimple propertySimple = new
PropertySimple(key,node.findValue(key).getValueAsText());
+ map.put(propertySimple);
+ }
+ propertyList.add(map);
+ }
}
ret.put(propertyList);
}
diff --git
a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SocketBindingDiscovery.java
b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SocketBindingDiscovery.java
deleted file mode 100644
index c9b7a5e..0000000
---
a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SocketBindingDiscovery.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2011 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.modules.plugins.jbossas7;
-
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.codehaus.jackson.JsonNode;
-import org.codehaus.jackson.map.DeserializationConfig;
-import org.codehaus.jackson.map.ObjectMapper;
-import org.codehaus.jackson.type.TypeReference;
-
-import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.domain.configuration.PropertySimple;
-import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
-import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
-import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
-import org.rhq.modules.plugins.jbossas7.json.Domain;
-import org.rhq.modules.plugins.jbossas7.json.SocketBindingGroup;
-
-/**
- * Discover single bindings in a socket binding group
- *
- * TODO: Is this better a resource-configuration on the parent?
- *
- * @author Heiko W. Rupp
- */
-@SuppressWarnings("unused")
-public class SocketBindingDiscovery implements
ResourceDiscoveryComponent<BaseComponent> {
-
- private final Log log = LogFactory.getLog(this.getClass());
-
- public Set<DiscoveredResourceDetails>
discoverResources(ResourceDiscoveryContext<BaseComponent> context)
- throws Exception {
-
- Set<DiscoveredResourceDetails> details = new
HashSet<DiscoveredResourceDetails>(1);
-
- ObjectMapper mapper = new ObjectMapper();
-
mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES,false);
- mapper.configure(DeserializationConfig.Feature.READ_ENUMS_USING_TO_STRING,true);
-
- BaseComponent parentComponent = context.getParentResourceComponent();
- ASConnection connection = parentComponent.getASConnection();
-
- String path = parentComponent.getPath();
-
-
- JsonNode json = connection.getLevelData(path,true,false);
- if (!connection.isErrorReply(json)) {
-
- SocketBindingGroup bindingGroup = mapper.readValue(json, new
TypeReference<SocketBindingGroup>() {});
- // TODO put bindingGroup. {name, default-interface, port-offset into parent
-
-
- for (Map.Entry<String,SocketBindingGroup.Binding> entry:
bindingGroup.bindings.entrySet()) {
-
- String key = entry.getKey();
- String cpath = path + "/socket-binding/" + key;
-
-
- String resKey = context.getParentResourceContext().getResourceKey() +
"/" + key;
- String name = resKey.substring(resKey.lastIndexOf("/") + 1);
-
- Configuration config = context.getDefaultPluginConfiguration();
-
- PropertySimple propertySimple = new
PropertySimple("path",cpath);
- config.put(propertySimple);
-
- DiscoveredResourceDetails detail = new DiscoveredResourceDetails(
- context.getResourceType(), // DataType
- path, // Key
- name, // Name
- null, // Version
- "Binding Group", // Description
- config,
- null);
- details.add(detail);
- log.info("Added " + detail);
- }
-
- return details;
-
- }
-
- return Collections.emptySet();
- }
-
-}
diff --git a/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
b/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
index 9a04f04..7abbfeb 100644
--- a/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
@@ -223,16 +223,18 @@
<resource-configuration>
<c:simple-property name="default-interface"
readOnly="true" displayName="Default Interface"
description="Default Interface for these bindings. See NetworkInterfaces for its
definition" required="false"/>
<c:simple-property name="port-offset"
readOnly="true" displayName="Port Offset" description="Offset
from standard ports for this group" required="false"/>
+ <c:list-property name="socket-binding">
+ <c:map-property name="binding">
+ <c:simple-property name="name" description="The
name of the socket. Services which need to access the socket configuration information
will find it using this name."/>
+ <c:simple-property name="interface"
description="Name of the interface to which the socket should be bound, or, for
multicast sockets, the interface on which it should listen. This should be one of the
declared interfaces." required="false"/>
+ <c:simple-property name="port"
description="Number of the port to which the socket should be bound."
type="integer"/>
+ <c:simple-property name="fixed-port"
description="Whether the port value should remain fixed even if numeric offsets are
applied to the other sockets in the socket group." type="boolean"/>
+ <c:simple-property name="multicast-address"
description="Multicast address on which the socket should receive multicast traffic.
If unspecified, the socket will not be configured to receive multicast." />
+ <c:simple-property name="multicast-port"
description="Port on which the socket should receive multicast traffic. Must be
configured if 'multicast-address' is configured."
type="integer"/>
+ </c:map-property>
+ </c:list-property>
</resource-configuration>
- <service name="SocketBinding"
- discovery="SocketBindingDiscovery"
- class="BaseComponent">
- <plugin-configuration>
- <c:simple-property name="path"
readOnly="true"/>
- </plugin-configuration>
-
- </service>
</service>
commit 296dba2916369ca75012995cbf7aa1863745e9b0
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Wed Mar 23 21:19:19 2011 +0100
Fix naming for 'singleton' subsystems
diff --git
a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java
b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java
index 75683cb..a017194 100644
---
a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java
+++
b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java
@@ -106,7 +106,7 @@ public class SubsystemDiscovery implements
ResourceDiscoveryComponent<BaseCompon
else {
- String resKey = context.getParentResourceContext().getResourceKey();
+ String resKey = path;
String name = resKey.substring(resKey.lastIndexOf("/") + 1);
commit 3a14db1b4c745bd66b863f872c3fd062bb296f9f
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Wed Mar 23 21:09:45 2011 +0100
SubsystemComponent is (currently) not needed.
diff --git
a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DatasourceComponent.java
b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DatasourceComponent.java
index abf6d35..d23cd5d 100644
---
a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DatasourceComponent.java
+++
b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DatasourceComponent.java
@@ -28,9 +28,9 @@ import org.rhq.core.pluginapi.inventory.ResourceContext;
*
* @author Heiko W. Rupp
*/
-public class DatasourceComponent implements ResourceComponent<SubsystemComponent>
{
+public class DatasourceComponent implements ResourceComponent<BaseComponent> {
- public void start(ResourceContext<SubsystemComponent>
subsystemComponentResourceContext) throws InvalidPluginConfigurationException, Exception
{
+ public void start(ResourceContext<BaseComponent>
subsystemComponentResourceContext) throws InvalidPluginConfigurationException, Exception
{
// TODO: Customise this generated block
}
diff --git
a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DatasourceDiscovery.java
b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DatasourceDiscovery.java
index d756543..e205c29 100644
---
a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DatasourceDiscovery.java
+++
b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DatasourceDiscovery.java
@@ -32,9 +32,9 @@ import java.util.Set;
*
* @author Heiko W. Rupp
*/
-public class DatasourceDiscovery implements
ResourceDiscoveryComponent<SubsystemComponent> {
+public class DatasourceDiscovery implements
ResourceDiscoveryComponent<BaseComponent> {
- public Set<DiscoveredResourceDetails>
discoverResources(ResourceDiscoveryContext<SubsystemComponent> discoveryContext)
throws InvalidPluginConfigurationException, Exception {
+ public Set<DiscoveredResourceDetails>
discoverResources(ResourceDiscoveryContext<BaseComponent> discoveryContext) throws
InvalidPluginConfigurationException, Exception {
/*
if (subsys instanceof DataSourcesSubsystemElement) {
diff --git
a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemComponent.java
b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemComponent.java
deleted file mode 100644
index 09d753c..0000000
---
a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemComponent.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2011 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.modules.plugins.jbossas7;
-
-import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.domain.measurement.AvailabilityType;
-import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
-import org.rhq.core.pluginapi.inventory.ResourceComponent;
-import org.rhq.core.pluginapi.inventory.ResourceContext;
-
-/**
- * Resource component for subsystems
- *
- * Deprecated - use BaseComponent
- * @author Heiko W. Rupp
- */
-@Deprecated
-public class SubsystemComponent implements ResourceComponent<BaseComponent> {
-
- ResourceContext<BaseComponent> context;
- Configuration config;
- String path;
- String key ;
-
- public void start(ResourceContext<BaseComponent> context) throws
InvalidPluginConfigurationException, Exception {
- this.config = context.getPluginConfiguration();
- path = config.getSimpleValue("path", null);
- this.context = context;
- key = context.getResourceKey();
-
- }
-
- public void stop() {
- // TODO: Customise this generated block
- }
-
- public AvailabilityType getAvailability() {
- return AvailabilityType.UP; // TODO: Customise this generated block
- }
-
-
-}