[infinispan-commits] Infinispan SVN: r1021 - in trunk: jopr-plugin/src/main/java/org/infinispan/jopr and 4 other directories.
infinispan-commits at lists.jboss.org
infinispan-commits at lists.jboss.org
Mon Oct 26 14:26:07 EDT 2009
Author: galder.zamarreno at jboss.com
Date: 2009-10-26 14:26:06 -0400 (Mon, 26 Oct 2009)
New Revision: 1021
Added:
trunk/tools/src/main/java/org/infinispan/tools/BeanConventions.java
trunk/tools/src/main/java/org/infinispan/tools/jopr/
trunk/tools/src/main/java/org/infinispan/tools/jopr/RhqPluginXmlGenerator.java
Modified:
trunk/jopr-plugin/pom.xml
trunk/jopr-plugin/src/main/java/org/infinispan/jopr/CacheComponent.java
trunk/jopr-plugin/src/main/java/org/infinispan/jopr/CacheDiscovery.java
trunk/jopr-plugin/src/main/java/org/infinispan/jopr/CacheManagerComponent.java
trunk/jopr-plugin/src/main/java/org/infinispan/jopr/CacheManagerDiscovery.java
trunk/jopr-plugin/src/main/resources/META-INF/
trunk/jopr-plugin/src/main/resources/META-INF/rhq-plugin.xml
trunk/tools/pom.xml
Log:
[ISPN-135] ( Automatically generate the JOPR XML descriptor for the JOPR plugin) Done. Also fixed the information showed by the JOPR plugin in terms of the different components.
Modified: trunk/jopr-plugin/pom.xml
===================================================================
--- trunk/jopr-plugin/pom.xml 2009-10-26 18:22:58 UTC (rev 1020)
+++ trunk/jopr-plugin/pom.xml 2009-10-26 18:26:06 UTC (rev 1021)
@@ -22,9 +22,96 @@
<properties>
<scm.module.path>plugin/infinispan</scm.module.path>
<rhq.defaultDevContainerPath>/jon/dev-container</rhq.defaultDevContainerPath>
+ <version.rhq>1.2.0.GA</version.rhq>
+ <version.rhq.plugingen>1.4.0-SNAPSHOT</version.rhq.plugingen>
+ <version.mc4j>1.2.6</version.mc4j>
+ <version.hibernate.core>3.3.1.GA</version.hibernate.core>
+ <version.hibernate.annotations>3.4.0.GA</version.hibernate.annotations>
+ <version.javax.persistence>1.0</version.javax.persistence>
</properties>
+ <dependencies>
+ <dependency>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-core-domain</artifactId>
+ <version>${version.rhq}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-core-plugin-api</artifactId>
+ <version>${version.rhq}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-jmx-plugin</artifactId>
+ <version>${version.rhq}</version>
+ <scope>provided</scope>
+ </dependency>
+
+<!--
+ <dependency>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-pluginGen</artifactId>
+ <version>${version.rhq.plugingen}</version>
+ <scope>provided</scope>
+ </dependency>
+ -->
+ <dependency>
+ <groupId>mc4j</groupId>
+ <artifactId>org-mc4j-ems</artifactId>
+ <version>${version.mc4j}</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <!-- TODO: This is beyond horrible. Surely we don't need these dependencies!! -->
+
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-core</artifactId>
+ <version>${version.hibernate.core}</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-annotations</artifactId>
+ <version>${version.hibernate.annotations}</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.persistence</groupId>
+ <artifactId>persistence-api</artifactId>
+ <version>${version.javax.persistence}</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <!-- END unnenessary deps -->
+
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>infinispan-core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>infinispan-tools</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>infinispan-core</artifactId>
+ <version>${project.version}</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
<build>
<plugins>
<plugin>
@@ -56,8 +143,74 @@
</execution>
</executions>
</plugin>
+
+ <plugin>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <version>2.0</version>
+ <executions>
+ <execution>
+ <id>copy-infinispan-jopr-plugin-jar</id>
+ <phase>process-resources</phase>
+ <goals>
+ <goal>copy</goal>
+ </goals>
+ <configuration>
+ <artifactItems>
+ <!-- TODO include other needed external jars
+ that should go into your jar file -->
+ <artifactItem>
+ <groupId>org.infinispan</groupId>
+ <artifactId>infinispan-core</artifactId>
+ <version>${project.version}</version>
+ </artifactItem>
+ </artifactItems>
+ <outputDirectory>${project.build.outputDirectory}/lib</outputDirectory>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <configuration>
+ <doclet>org.infinispan.tools.jopr.RhqPluginXmlGenerator</doclet>
+ <docletArtifact>
+ <groupId>org.infinispan</groupId>
+ <artifactId>infinispan-tools</artifactId>
+ <version>${project.version}</version>
+ </docletArtifact>
+ <useStandardDocletOptions>false</useStandardDocletOptions>
+ </configuration>
+ <executions>
+ <execution>
+ <phase>process-classes</phase>
+ <goals>
+ <goal>javadoc</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ <!--
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>exec-maven-plugin</artifactId>
+ <version>1.1</version>
+ <executions>
+ <execution>
+ <phase>process-classes</phase>
+ <goals>
+ <goal>java</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <mainClass>org.infinispan.jopr.util.RhqPluginDescriptorGenerator</mainClass>
+ </configuration>
+ </plugin>
+ -->
-
</plugins>
</build>
@@ -171,71 +324,4 @@
</pluginRepository>
</pluginRepositories>
-
- <dependencies>
- <dependency>
- <groupId>org.rhq</groupId>
- <artifactId>rhq-core-domain</artifactId>
- <version>1.2.0.GA</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.rhq</groupId>
- <artifactId>rhq-core-plugin-api</artifactId>
- <version>1.2.0.GA</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.rhq</groupId>
- <artifactId>rhq-jmx-plugin</artifactId>
- <version>1.2.0.GA</version>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
- <groupId>mc4j</groupId>
- <artifactId>org-mc4j-ems</artifactId>
- <version>1.2.6</version>
- <scope>provided</scope>
- </dependency>
-
- <!-- TODO: This is beyond horrible. Surely we don't need these dependencies!! -->
-
- <dependency>
- <groupId>org.hibernate</groupId>
- <artifactId>hibernate-core</artifactId>
- <version>3.3.1.GA</version>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
- <groupId>org.hibernate</groupId>
- <artifactId>hibernate-annotations</artifactId>
- <version>3.4.0.GA</version>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
- <groupId>javax.persistence</groupId>
- <artifactId>persistence-api</artifactId>
- <version>1.0</version>
- <scope>provided</scope>
- </dependency>
-
- <!-- END unnenessary deps -->
-
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>infinispan-core</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>infinispan-core</artifactId>
- <version>${project.version}</version>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
- </dependencies>
</project>
Modified: trunk/jopr-plugin/src/main/java/org/infinispan/jopr/CacheComponent.java
===================================================================
--- trunk/jopr-plugin/src/main/java/org/infinispan/jopr/CacheComponent.java 2009-10-26 18:22:58 UTC (rev 1020)
+++ trunk/jopr-plugin/src/main/java/org/infinispan/jopr/CacheComponent.java 2009-10-26 18:26:06 UTC (rev 1021)
@@ -21,6 +21,7 @@
*/
package org.infinispan.jopr;
+import org.infinispan.lifecycle.ComponentStatus;
import org.infinispan.util.logging.Log;
import org.infinispan.util.logging.LogFactory;
import org.mc4j.ems.connection.EmsConnection;
@@ -29,7 +30,9 @@
import org.mc4j.ems.connection.bean.operation.EmsOperation;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.measurement.AvailabilityType;
+import org.rhq.core.domain.measurement.DataType;
import org.rhq.core.domain.measurement.MeasurementDataNumeric;
+import org.rhq.core.domain.measurement.MeasurementDataTrait;
import org.rhq.core.domain.measurement.MeasurementReport;
import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
import org.rhq.core.pluginapi.inventory.ResourceComponent;
@@ -38,8 +41,6 @@
import org.rhq.core.pluginapi.operation.OperationFacet;
import org.rhq.core.pluginapi.operation.OperationResult;
-import java.util.HashMap;
-import java.util.Map;
import java.util.Set;
/**
@@ -49,24 +50,11 @@
* @author Galder Zamarreño
*/
public class CacheComponent implements ResourceComponent<CacheManagerComponent>, MeasurementFacet, OperationFacet {
- private final Log log = LogFactory.getLog(this.getClass());
+ private static final Log log = LogFactory.getLog(CacheComponent.class);
- /**
- * Map to match an abbreviation for the MBean to the full MBean name
- */
- private static final Map<String, String> abbrevToMBean = new HashMap<String, String>();
-
- static {
- abbrevToMBean.put("Statistics", "Statistics");
- abbrevToMBean.put("LockManager", "LockManager");
- abbrevToMBean.put("Transactions", "Transactions");
- }
-
-
private ResourceContext<CacheManagerComponent> context;
- /**
- * The naming pattern of the current bean without the actual bean name
- */
+
+ /** The naming pattern of the current bean without the actual bean name */
private String myNamePattern;
/**
@@ -75,8 +63,23 @@
* @see org.rhq.core.pluginapi.inventory.ResourceComponent#getAvailability()
*/
public AvailabilityType getAvailability() {
- // TODO does a cache have a lifecycle of its own?
- return context.getParentResourceComponent().getAvailability();
+ boolean trace = log.isTraceEnabled();
+ EmsConnection conn = getConnection();
+ try {
+ conn.refresh();
+ EmsBean bean = conn.getBean(context.getResourceKey());
+ EmsAttribute attribute = bean.getAttribute("CacheStatus");
+ if (attribute.getValue().equals(ComponentStatus.RUNNING.toString())) {
+ if (trace) log.trace("Cache status is running, so it's up.");
+ bean.refreshAttributes();
+ return AvailabilityType.UP;
+ }
+ if (trace) log.trace("Cache status is anything other than running, so it's down.");
+ return AvailabilityType.DOWN;
+ } catch (Exception e) {
+ if (trace) log.trace("There was an exception checking availability, so cache status is down.");
+ return AvailabilityType.DOWN;
+ }
}
@@ -86,23 +89,17 @@
* @see org.rhq.core.pluginapi.inventory.ResourceComponent#start(org.rhq.core.pluginapi.inventory.ResourceContext)
*/
public void start(ResourceContext<CacheManagerComponent> context) throws Exception {
-
this.context = context;
- //
myNamePattern = context.getResourceKey();
myNamePattern = myNamePattern.substring(0, myNamePattern.indexOf("jmx-resource=") + 13);
-
}
-
/**
* Tear down the rescource connection
*
* @see org.rhq.core.pluginapi.inventory.ResourceComponent#stop()
*/
public void stop() {
-
-
}
@@ -113,34 +110,48 @@
* java.util.Set)
*/
public void getValues(MeasurementReport report, Set<MeasurementScheduleRequest> metrics) throws Exception {
-
+ boolean trace = log.isTraceEnabled();
+ if (trace) log.trace("Get values metrics");
EmsConnection conn = getConnection();
for (MeasurementScheduleRequest req : metrics) {
+ if (trace) log.trace("Inspect metric {0}", req);
String metric = req.getName();
try {
String abbrev = metric.substring(0, metric.indexOf("."));
- String mbean = abbrevToMBean.get(abbrev);
- mbean = myNamePattern + mbean;
+ String mbean = myNamePattern + abbrev;
EmsBean bean = conn.getBean(mbean);
- bean.refreshAttributes();
- String attName = metric.substring(metric.indexOf(".") + 1);
- EmsAttribute att = bean.getAttribute(attName);
-
- // Attribute values are of various data types ...
- Object o = att.getValue();
- Class type = att.getTypeClass();
- if (type.equals(Long.class) || type.equals(long.class)) {
- Long tmp = (Long) o;
- MeasurementDataNumeric res = new MeasurementDataNumeric(req, Double.valueOf(tmp));
- report.addData(res);
- } else if (type.equals(Double.class) || type.equals(double.class)) {
- Double tmp = (Double) o;
- MeasurementDataNumeric res = new MeasurementDataNumeric(req, tmp);
- report.addData(res);
- } else if (type.equals(Integer.class) || type.equals(int.class)) {
- Integer tmp = (Integer) o;
- MeasurementDataNumeric res = new MeasurementDataNumeric(req, Double.valueOf(tmp));
- report.addData(res);
+ if (bean != null) {
+ if (trace) log.trace("Retrieved mbean with name {0}", mbean);
+ bean.refreshAttributes();
+ String attName = metric.substring(metric.indexOf(".") + 1);
+ EmsAttribute att = bean.getAttribute(attName);
+ // Attribute values are of various data types
+ Object o = att.getValue();
+ Class attrType = att.getTypeClass();
+ DataType type = req.getDataType();
+ if (type == DataType.MEASUREMENT) {
+ if (trace) log.trace("Metric ({0}) is measurement with value {1}", req.getName(), o);
+ if (attrType.equals(Long.class) || attrType.equals(long.class)) {
+ Long tmp = (Long) o;
+ MeasurementDataNumeric res = new MeasurementDataNumeric(req, Double.valueOf(tmp));
+ report.addData(res);
+ } else if (attrType.equals(Double.class) || attrType.equals(double.class)) {
+ Double tmp = (Double) o;
+ MeasurementDataNumeric res = new MeasurementDataNumeric(req, tmp);
+ report.addData(res);
+ } else if (attrType.equals(Integer.class) || attrType.equals(int.class)) {
+ Integer tmp = (Integer) o;
+ MeasurementDataNumeric res = new MeasurementDataNumeric(req, Double.valueOf(tmp));
+ report.addData(res);
+ }
+ } else if (type == DataType.TRAIT) {
+ String value = (String) o;
+ if (trace) log.trace("Metric ({0}) is trait with value {1}", req.getName(), value);
+ MeasurementDataTrait res = new MeasurementDataTrait(req, value);
+ report.addData(res);
+ }
+ } else {
+ if (trace) log.trace("No mbean found with name {0}", mbean);
}
}
catch (Exception e) {
@@ -161,8 +172,9 @@
Configuration parameters) throws Exception {
EmsConnection conn = getConnection();
String abbrev = name.substring(0, name.indexOf("."));
- String mbean = abbrevToMBean.get(abbrev);
- mbean = myNamePattern + mbean;
+// String mbean = abbrevToMBean.get(abbrev);
+// mbean = myNamePattern + mbean;
+ String mbean = myNamePattern + abbrev;
EmsBean bean = conn.getBean(mbean);
String opName = name.substring(name.indexOf(".") + 1);
EmsOperation ops = bean.getOperation(opName);
Modified: trunk/jopr-plugin/src/main/java/org/infinispan/jopr/CacheDiscovery.java
===================================================================
--- trunk/jopr-plugin/src/main/java/org/infinispan/jopr/CacheDiscovery.java 2009-10-26 18:22:58 UTC (rev 1020)
+++ trunk/jopr-plugin/src/main/java/org/infinispan/jopr/CacheDiscovery.java 2009-10-26 18:26:06 UTC (rev 1021)
@@ -43,33 +43,28 @@
public class CacheDiscovery implements ResourceDiscoveryComponent<CacheManagerComponent> {
private static final Log log = LogFactory.getLog(CacheDiscovery.class);
- /**
- * Naming pattern of the cache MgmtInterceptor
- */
- private static final String CACHE_QUERY = "*:cache-name=%name%,jmx-resource=Cache";
+ /** Naming pattern of the cache mbean */
+ static final String CACHE_QUERY = "*:cache-name=%name%,jmx-resource=Cache";
- /**
- * Run the discovery
- */
+ /** Run the discovery */
public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<CacheManagerComponent> discoveryContext) throws Exception {
- if (log.isTraceEnabled()) log.trace("Discover resources with context: " + discoveryContext);
+ boolean trace = log.isTraceEnabled();
+ if (trace) log.trace("Discover resources with context: " + discoveryContext);
Set<DiscoveredResourceDetails> discoveredResources = new HashSet<DiscoveredResourceDetails>();
EmsConnection conn = discoveryContext.getParentResourceComponent().getConnection();
- if (log.isTraceEnabled()) log.trace("Connection to ems server stablished: " + conn);
+ if (trace) log.trace("Connection to ems server stablished: " + conn);
ObjectNameQueryUtility queryUtility = new ObjectNameQueryUtility(CACHE_QUERY);
List<EmsBean> beans = conn.queryBeans(queryUtility.getTranslatedQuery());
- if (log.isTraceEnabled()) log.trace("Querying [" + queryUtility.getTranslatedQuery() + "] returned beans: " + beans);
+ if (trace) log.trace("Querying [" + queryUtility.getTranslatedQuery() + "] returned beans: " + beans);
for (EmsBean bean : beans) {
- /**
- * A discovered resource must have a unique key, that must
+ /* A discovered resource must have a unique key, that must
* stay the same when the resource is discovered the next
- * time
- */
- String name = bean.getBeanName().getCanonicalName();
- name = name.substring(name.indexOf("jmx-resource=") + 13);
+ * time */
+ String name = bean.getAttribute("CacheName").getValue().toString();
+ if (trace) log.trace("Resource name is {0}", name);
DiscoveredResourceDetails detail = new DiscoveredResourceDetails(
discoveryContext.getResourceType(), // Resource Type
bean.getBeanName().getCanonicalName(), // Resource Key
Modified: trunk/jopr-plugin/src/main/java/org/infinispan/jopr/CacheManagerComponent.java
===================================================================
--- trunk/jopr-plugin/src/main/java/org/infinispan/jopr/CacheManagerComponent.java 2009-10-26 18:22:58 UTC (rev 1020)
+++ trunk/jopr-plugin/src/main/java/org/infinispan/jopr/CacheManagerComponent.java 2009-10-26 18:26:06 UTC (rev 1021)
@@ -21,10 +21,14 @@
*/
package org.infinispan.jopr;
+import org.infinispan.util.logging.Log;
+import org.infinispan.util.logging.LogFactory;
import org.mc4j.ems.connection.EmsConnection;
import org.mc4j.ems.connection.bean.EmsBean;
import org.rhq.core.domain.measurement.AvailabilityType;
+import org.rhq.core.domain.measurement.DataType;
import org.rhq.core.domain.measurement.MeasurementDataNumeric;
+import org.rhq.core.domain.measurement.MeasurementDataTrait;
import org.rhq.core.domain.measurement.MeasurementReport;
import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
@@ -41,10 +45,10 @@
* @author Galder Zamarreño
*/
public class CacheManagerComponent implements ResourceComponent, MeasurementFacet {
+ private static final Log log = LogFactory.getLog(CacheManagerComponent.class);
private ResourceContext context;
private ConnectionHelper helper;
-
/**
* Return availability of this resource. We do this by checking the connection to it. If the Manager would expose
* some "run state" we could check for that too.
@@ -70,7 +74,6 @@
* @see org.rhq.core.pluginapi.inventory.ResourceComponent#start(org.rhq.core.pluginapi.inventory.ResourceContext)
*/
public void start(ResourceContext context) throws InvalidPluginConfigurationException, Exception {
-
this.context = context;
helper = new ConnectionHelper();
getConnection();
@@ -93,17 +96,25 @@
* java.util.Set)
*/
public void getValues(MeasurementReport report, Set<MeasurementScheduleRequest> metrics) throws Exception {
-
+ boolean trace = log.isTraceEnabled();
+ if (trace) log.trace("Get values for these metrics: {0}", metrics);
EmsConnection conn = getConnection();
EmsBean bean = conn.getBean(context.getPluginConfiguration().getSimpleValue("objectName", null));
bean.refreshAttributes();
-
for (MeasurementScheduleRequest req : metrics) {
- // TODO check with Traits in the future - also why are the values Strings?
- String tmp = (String) bean.getAttribute(req.getName()).getValue();
- Double val = Double.valueOf(tmp);
- MeasurementDataNumeric res = new MeasurementDataNumeric(req, val);
- report.addData(res);
+ DataType type = req.getDataType();
+ if (type == DataType.MEASUREMENT) {
+ String tmp = (String) bean.getAttribute(req.getName()).getValue();
+ Double val = Double.valueOf(tmp);
+ if (trace) log.trace("Metric ({0}) is measurement with value {1}", req.getName(), val);
+ MeasurementDataNumeric res = new MeasurementDataNumeric(req, val);
+ report.addData(res);
+ } else if (type == DataType.TRAIT) {
+ String value = (String) bean.getAttribute(req.getName()).getValue();
+ if (trace) log.trace("Metric ({0}) is trait with value {1}", req.getName(), value);
+ MeasurementDataTrait res = new MeasurementDataTrait(req, value);
+ report.addData(res);
+ }
}
}
Modified: trunk/jopr-plugin/src/main/java/org/infinispan/jopr/CacheManagerDiscovery.java
===================================================================
--- trunk/jopr-plugin/src/main/java/org/infinispan/jopr/CacheManagerDiscovery.java 2009-10-26 18:22:58 UTC (rev 1020)
+++ trunk/jopr-plugin/src/main/java/org/infinispan/jopr/CacheManagerDiscovery.java 2009-10-26 18:26:06 UTC (rev 1021)
@@ -49,11 +49,9 @@
public class CacheManagerDiscovery implements ResourceDiscoveryComponent<CacheManagerComponent> {
private static final Log log = LogFactory.getLog(CacheManagerDiscovery.class);
-// // Assume a java5+ jmx-remote connector on port 6996
-// public static String REMOTE = "service:jmx:rmi://127.0.0.1/jndi/rmi://127.0.0.1:6996/jmxrmi";
+ // Assume a java5+ jmx-remote connector on port 6996
+ public static String REMOTE = "service:jmx:rmi://127.0.0.1/jndi/rmi://127.0.0.1:6996/jmxrmi";
-// public static String MANAGER_OBJECT = "*:cache-name=[global],jmx-resource=CacheManager";
-
private static final String MANAGER_OBJECT = "*:" + CACHE_NAME_KEY + '=' + GLOBAL_JMX_GROUP + "," + JMX_RESOURCE_KEY + "=" + OBJECT_NAME;
private static final String CONNECTOR = "org.mc4j.ems.connection.support.metadata.J2SE5ConnectionTypeDescriptor";
@@ -62,52 +60,50 @@
*/
public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<CacheManagerComponent> discoveryContext) throws Exception {
boolean trace = log.isTraceEnabled();
- if (trace) log.trace("Discover resources with context: " + discoveryContext);
+ if (trace) log.trace("Discover resources with context: {0}", discoveryContext);
Set<DiscoveredResourceDetails> discoveredResources = new HashSet<DiscoveredResourceDetails>();
// TODO check if we e.g. run inside a JBossAS to which we have a connection already that we can reuse.
- Configuration c = discoveryContext.getDefaultPluginConfiguration();
- c.put(c.getSimple(JMXDiscoveryComponent.CONNECTOR_ADDRESS_CONFIG_PROPERTY));
+ Configuration c = new Configuration();
+ c.put(new PropertySimple(JMXDiscoveryComponent.CONNECTOR_ADDRESS_CONFIG_PROPERTY, REMOTE));
c.put(new PropertySimple(JMXDiscoveryComponent.CONNECTION_TYPE, CONNECTOR));
c.put(new PropertySimple("objectName", MANAGER_OBJECT));
+ if (trace) log.trace("To be used configuration is {0}", c.toString(true));
-// c.put(new PropertySimple(JMXDiscoveryComponent.CONNECTOR_ADDRESS_CONFIG_PROPERTY, c.getSimple(JMXDiscoveryComponent.CONNECTOR_ADDRESS_CONFIG_PROPERTY)));
-// c.put(new PropertySimple(JMXDiscoveryComponent.CONNECTION_TYPE, connector));
-// c.put(new PropertySimple("objectName", MANAGER_OBJECT));
-
ConnectionHelper helper = new ConnectionHelper();
EmsConnection conn = helper.getEmsConnection(c);
- if (trace) log.trace("Connection to ems server stablished: " + conn);
+ if (trace) log.trace("Connection to ems server stablished: {0}", conn);
// Run query for manager_object
ObjectNameQueryUtility queryUtility = new ObjectNameQueryUtility(MANAGER_OBJECT);
List<EmsBean> beans = conn.queryBeans(queryUtility.getTranslatedQuery());
- if (trace) log.trace("Querying [" + queryUtility.getTranslatedQuery() + "] returned beans: " + beans);
+ if (trace) log.trace("Querying [{0}] returned beans: {1}", queryUtility.getTranslatedQuery(), beans);
for (EmsBean bean : beans) {
String managerName = bean.getBeanName().getCanonicalName();
c.put(new PropertySimple("objectName", managerName));
- /**
- *
- * A discovered resource must have a unique key, that must
+ String resourceName = bean.getAttribute("Name").getValue().toString();
+ String version = bean.getAttribute("Version").getValue().toString();
+ /* A discovered resource must have a unique key, that must
* stay the same when the resource is discovered the next
- * time
- */
+ * time */
+ if (trace) log.trace("Add resource with name '{0}', version '{1}' and type {2}",
+ resourceName, version, discoveryContext.getResourceType());
DiscoveredResourceDetails detail = new DiscoveredResourceDetails(
- discoveryContext.getResourceType(), // ResourceType
- managerName, // Resource Key
- "Infinispan Cache Manager", // Resource Name
- null, // Version TODO can we get that from discovery ?
- "The Infinispan Manager", // Description
- c, // Plugin Config
+ discoveryContext.getResourceType(), // Resource type
+ managerName, // Resource key
+ resourceName, // Resource name
+ version, // Resource version
+ "A cache manager within Infinispan", // Description
+ c, // Plugin config
null // Process info from a process scan
);
// Add to return values
discoveredResources.add(detail);
- log.info("Discovered Infinispan instance: " + managerName);
+ log.info("Discovered Infinispan instance: {0}", managerName);
}
return discoveredResources;
Property changes on: trunk/jopr-plugin/src/main/resources/META-INF
___________________________________________________________________
Name: svn:ignore
+
Modified: trunk/jopr-plugin/src/main/resources/META-INF/rhq-plugin.xml
===================================================================
--- trunk/jopr-plugin/src/main/resources/META-INF/rhq-plugin.xml 2009-10-26 18:22:58 UTC (rev 1020)
+++ trunk/jopr-plugin/src/main/resources/META-INF/rhq-plugin.xml 2009-10-26 18:26:06 UTC (rev 1021)
@@ -1,90 +1,214 @@
<?xml version="1.0"?>
-<plugin name="infinispan"
- displayName="infinispanPlugin"
- package="org.infinispan.jopr.infinispan"
+<plugin name="Infinispan"
+ displayName="InfinispanPlugin"
+ description="Supports management and monitoring of Infinispan"
+ package="org.infinispan.jopr"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="urn:xmlns:rhq-plugin"
xmlns:c="urn:xmlns:rhq-configuration">
<depends plugin="JMX" useClasses="true"/>
- <server
- name="infinispan"
- discovery="InfinispanDiscovery"
- class="InfinispanComponent"
- singleton="true"
+ <server name="Infinispan Cache Manager"
+ discovery="CacheManagerDiscovery"
+ class="CacheManagerComponent"
+ singleton="true"
+ supportsManualAdd="true"
+
+ >
- >
+ <plugin-configuration>
+ <c:simple-property name="connectorAddress" description="JMX Remoting address of the remote Infinispan Instance" />
+ <c:simple-property name="objectName" description="ObjectName of the Manager" type="string" readOnly="true"/>
+ <!-- The template section is only for manual resource additions, and default parameters and the ones presented to the user. -->
+ <c:template name="default" description="The default setup for Infinispan">
+ <c:simple-property name="connectorAddress" displayName="URL of the remote server"
+ defaultValue="service:jmx:rmi://127.0.0.1/jndi/rmi://127.0.0.1:6996/jmxrmi"/>
+ </c:template>
+ </plugin-configuration>
- <plugin-configuration>
- <c:simple-property name="connectorAddress" description="JMX Remoting address of the remote Infinispan Instance"/>
- <c:simple-property name="objectName" description="ObjectName of the Manager" type="string" readOnly="true"/>
- <c:template name="default" description="The default setup for Infinispan">
- <c:simple-property name="connectorAddress" displayName="URL of the remote server"
- defaultValue="service:jmx:rmi://127.0.0.1/jndi/rmi://127.0.0.1:6996/jmxrmi"/>
- </c:template>
- </plugin-configuration>
+ <operation name="getCache" displayName="Starts the default cache." description="Retrieves the default cache associated with this cache manager and starts it up.">
+ </operation>
+ <operation name="getCacheWithCacheName" displayName="Starts a cache with the given name." description="Retrieves a named cache from the system and starts it up.">
+ <parameters>
+ <c:simple-property name="cacheName" description="Name of cache to start"/>
+ </parameters>
+ </operation>
- <!-- TODO process scans -->
+ <metric property="Name" displayName="Cache manager name" displayType="summary" units="none" dataType="trait"
+ description="The name of this cache manager" />
+ <metric property="Version" displayName="Infinispan version" displayType="summary" units="none" dataType="trait"
+ description="Infinispan version." />
+ <metric property="CacheManagerStatus" displayName="Cache manager status" displayType="summary" units="none" dataType="trait"
+ description="The status of the cache manager instance." />
+ <metric property="DefinedCacheNames" displayName="List of defined caches" displayType="summary" units="none" dataType="trait"
+ description="The defined cache names and their statuses. The default cache is not included in this representation." />
+ <metric property="DefinedCacheCount" displayName="Number of caches defined" displayType="summary" units="none" dataType="measurement"
+ description="The total number of defined caches, excluding the default cache." />
+ <metric property="CreatedCacheCount" displayName="Number of caches created" displayType="summary" units="none" dataType="measurement"
+ description="The total number of created caches, including the default cache." />
+ <metric property="RunningCacheCount" displayName="Number of running caches" displayType="summary" units="none" dataType="measurement"
+ description="The total number of running caches, including the default cache." />
- <metric property="createdCacheCount" displayName="Number of Caches created." displayType="summary" units="none"/>
- <metric property="definedCacheCount" displayName="Number of Caches defined." displayType="summary" units="none"/>
- <service
- name="Cache"
+ <service name="Infinispan Cache"
discovery="CacheDiscovery"
class="CacheComponent"
- description="One individual cache in Infinispan"
- >
+
+
+
+ >
- <operation name="Statistics.resetStatistics" displayName="Reset Statistics (Statistics)"
- description="Reset statistics on the CacheManagement Interceptor"/>
- <operation name="Transactions.resetStatistics" displayName="Reset Statistics (Transactions)"
- description="Reset statistics on the Transaction Interceptor"/>
- <metric property="Statistics.averageReadTime" displayName="Average Read Time"
- description="Average time to read an entry from the cache"
- units="milliseconds" measurementType="dynamic"/>
- <metric property="Statistics.averageWriteTime" displayName="Average Write Time"
- description="Average time to write an entry to the cache"
- units="milliseconds" measurementType="dynamic"/>
- <metric property="Statistics.evictions" displayName="Evictions" measurementType="trendsup"
- description="How many items got evicted from the cache" displayType="summary"/>
- <metric property="Statistics.hitRatio" displayName="Hit Ratio"
- description="Hit ratio of this cache" displayType="summary"
- units="percentage"/>
- <metric property="Statistics.hits" displayName="Hits" description="Number of cache hits"
- measurementType="trendsup"/>
- <metric property="Statistics.misses" displayName="Misses" description="Number of cache misses"
- measurementType="trendsup"/>
- <metric property="Statistics.numberOfEntries" displayName="Number of Entries"
- description="The number of entries in this cache"/>
- <metric property="Statistics.readWriteRatio" displayName="Read write ratio"
- description="The ratio between reads and writes of this cache"
- units="percentage"/>
- <metric property="Statistics.stores" displayName="Stores" description="Number of stores in the cache"
- measurementType="trendsup"/>
+ <operation name="Passivation.resetStatistics" displayName="[Passivation] Reset statistics" description="Resets statistics gathered by this component">
+ </operation>
+ <operation name="DistributionManager.isAffectedByRehash" displayName="[DistributionManager] Could key be affected by reshah?" description="Determines whether a given key is affected by an ongoing rehash, if any.">
+ <parameters>
+ <c:simple-property name="key" description="Key to check"/>
+ </parameters>
+ </operation>
+ <operation name="DistributionManager.isLocatedLocally" displayName="[DistributionManager] Is key local?" description="Tells you whether a given key is local to this instance of the cache. Only works with String keys.">
+ <parameters>
+ <c:simple-property name="key" description="Key to query"/>
+ </parameters>
+ </operation>
+ <operation name="DistributionManager.locateKey" displayName="[DistributionManager] Locate key" description="Locates an object in a cluster. Only works with String keys.">
+ <parameters>
+ <c:simple-property name="key" description="Key to locate"/>
+ </parameters>
+ </operation>
+ <operation name="CacheLoader.resetStatistics" displayName="[CacheLoader] Reset Statistics" description="Resets statistics gathered by this component">
+ </operation>
+ <operation name="Invalidation.resetStatistics" displayName="[Invalidation] Reset statistics" description="Resets statistics gathered by this component">
+ </operation>
+ <operation name="Invalidation.setStatisticsEnabled" displayName="[Invalidation] Enable/disable statistics" description="Enable/disable statistics">
+ <parameters>
+ <c:simple-property name="enabled" description="Whether statistics should be enabled or disabled (true/false)"/>
+ </parameters>
+ </operation>
+ <operation name="RpcManager.resetStatistics" displayName="[RpcManager] Reset statistics" description="Resets statistics gathered by this component">
+ </operation>
+ <operation name="RpcManager.setStatisticsEnabled" displayName="[RpcManager] Enable/disable statistics" description="Enable/disable statistics">
+ <parameters>
+ <c:simple-property name="enabled" description="Whether statistics should be enabled or disabled (true/false)"/>
+ </parameters>
+ </operation>
+ <operation name="Transactions.resetStatistics" displayName="[Transactions] Reset Statistics" description="Resets statistics gathered by this component">
+ </operation>
+ <operation name="Transactions.setStatisticsEnabled" displayName="[Transactions] Enable/disable statistics" description="Enable/disable statistics">
+ <parameters>
+ <c:simple-property name="enabled" description="Whether statistics should be enabled or disabled (true/false)"/>
+ </parameters>
+ </operation>
+ <operation name="Activation.resetStatistics" displayName="[Activation] Reset statistics" description="Resets statistics gathered by this component">
+ </operation>
+ <operation name="Statistics.resetStatistics" displayName="[Statistics] Reset Statistics (Statistics)" description="Resets statistics gathered by this component">
+ </operation>
+ <operation name="DeadlockDetectingLockManager.resetStatistics" displayName="[DeadlockDetectingLockManager] Reset statistics" description="Resets statistics gathered by this component">
+ </operation>
+ <operation name="CacheStore.resetStatistics" displayName="[CacheStore] Reset statistics" description="Resets statistics gathered by this component">
+ </operation>
+ <operation name="Cache.start" displayName="[Cache] Starts cache." description="Starts the cache.">
+ </operation>
+ <operation name="Cache.stop" displayName="[Cache] Stops cache." description="Stops the cache.">
+ </operation>
- <metric property="LockManager.numerOfLocksAvailable" displayName="Number of Locks availabe"
- description="How many locks are still available in this Cache"
- units="none" measurementType="dynamic"/>
- <metric property="LockManager.concurrencyLevel" displayName="Concurrency Level"/>
- <!-- TODO description -->
- <metric property="LockManager.numberOfLocksHeld" displayName="Number of Locks held"/>
+ <metric property="Passivation.Passivations" displayName="[Passivation] Number of cache passivations" displayType="detail" units="none" dataType="measurement"
+ description="Number of passivation events" />
+ <metric property="LockManager.ConcurrencyLevel" displayName="[LockManager] Concurrency level" displayType="detail" units="none" dataType="trait"
+ description="The concurrency level that the MVCC Lock Manager has been configured with." />
+ <metric property="LockManager.NumberOfLocksHeld" displayName="[LockManager] Number of locks held" displayType="detail" units="none" dataType="measurement"
+ description="The number of exclusive locks that are held." />
+ <metric property="LockManager.NumberOfLocksAvailable" displayName="[LockManager] Number of locks available" displayType="detail" units="none" dataType="measurement"
+ description="The number of exclusive locks that are available." />
+ <metric property="DistributionManager.RehashInProgress" displayName="[DistributionManager] Is rehash in progress?" displayType="detail" units="none" dataType="trait"
+ description="Checks whether the node is involved in a rehash." />
+ <metric property="DistributionManager.JoinComplete" displayName="[DistributionManager] Is join completed?" displayType="detail" units="none" dataType="trait"
+ description="If true, the node has successfully joined the grid and is considered to hold state. If false, the join process is still in progress." />
+ <metric property="CacheLoader.CacheLoaderLoads" displayName="[CacheLoader] Number of cache store loads" displayType="detail" units="none" dataType="measurement"
+ description="Number of entries loaded from cache store" />
+ <metric property="CacheLoader.CacheLoaderMisses" displayName="[CacheLoader] Number of cache store load misses" displayType="detail" units="none" dataType="measurement"
+ description="Number of entries that did not exist in cache store" />
+ <metric property="Invalidation.StatisticsEnabled" displayName="[Invalidation] Statistics enabled" displayType="detail" units="none" dataType="trait"
+ description="Statistics enabled" />
+ <metric property="Invalidation.Invalidations" displayName="[Invalidation] Number of invalidations" displayType="detail" units="none" dataType="measurement"
+ description="Number of invalidations" />
+ <metric property="RpcManager.Address" displayName="[RpcManager] Network address" displayType="summary" units="none" dataType="trait"
+ description="The network address associated with this instance" />
+ <metric property="RpcManager.Members" displayName="[RpcManager] Cluster members" displayType="summary" units="none" dataType="trait"
+ description="List of members in the cluster" />
+ <metric property="RpcManager.ReplicationCount" displayName="[RpcManager] Number of successfull replications" displayType="summary" units="none" dataType="measurement"
+ description="Number of successful replications" />
+ <metric property="RpcManager.ReplicationFailures" displayName="[RpcManager] Number of failed replications" displayType="summary" units="none" dataType="measurement"
+ description="Number of failed replications" />
+ <metric property="RpcManager.StatisticsEnabled" displayName="[RpcManager] Statistics enabled" displayType="detail" units="none" dataType="trait"
+ description="Statistics enabled" />
+ <metric property="RpcManager.ClusterSize" displayName="[RpcManager] Cluster size" displayType="summary" units="none" dataType="measurement"
+ description="Size of the cluster in number of nodes" />
+ <metric property="RpcManager.SuccessRatio" displayName="[RpcManager] Successful replication ratio" displayType="summary" units="percentage" dataType="measurement"
+ description="Successful replications as a ratio of total replications" />
+ <metric property="Transactions.StatisticsEnabled" displayName="[Transactions] Statistics enabled" displayType="detail" units="none" dataType="trait"
+ description="Statistics enabled" />
+ <metric property="Transactions.Prepares" displayName="[Transactions] Prepares" displayType="summary" units="none" dataType="measurement"
+ description="Number of transaction prepares performed since last reset" />
+ <metric property="Transactions.Commits" displayName="[Transactions] Commits" displayType="summary" units="none" dataType="measurement"
+ description="Number of transaction commits performed since last reset" />
+ <metric property="Transactions.Rollbacks" displayName="[Transactions] Rollbacks" displayType="summary" units="none" dataType="measurement"
+ description="Number of transaction rollbacks performed since last reset" />
+ <metric property="Activation.Activations" displayName="[Activation] Number of cache entries activated" displayType="detail" units="none" dataType="measurement"
+ description="Number of activation events" />
+ <metric property="Activation.CacheLoaderLoads" displayName="[Activation] Number of cache store loads" displayType="detail" units="none" dataType="measurement"
+ description="Number of entries loaded from cache store" />
+ <metric property="Activation.CacheLoaderMisses" displayName="[Activation] Number of cache store load misses" displayType="detail" units="none" dataType="measurement"
+ description="Number of entries that did not exist in cache store" />
+ <metric property="Statistics.Stores" displayName="[Statistics] Number of cache puts" displayType="summary" units="none" dataType="measurement"
+ description="number of cache attribute put operations" />
+ <metric property="Statistics.Hits" displayName="[Statistics] Number of cache hits" displayType="summary" units="none" dataType="measurement"
+ description="Number of cache attribute hits" />
+ <metric property="Statistics.Misses" displayName="[Statistics] Number of cache misses" displayType="summary" units="none" dataType="measurement"
+ description="Number of cache attribute misses" />
+ <metric property="Statistics.Evictions" displayName="[Statistics] Number of cache evictions" displayType="summary" units="none" dataType="measurement"
+ description="Number of cache eviction operations" />
+ <metric property="Statistics.HitRatio" displayName="[Statistics] Hit ratio" displayType="summary" units="percentage" dataType="measurement"
+ description="Percentage hit/(hit+miss) ratio for the cache" />
+ <metric property="Statistics.ReadWriteRatio" displayName="[Statistics] Read/write ratio" displayType="summary" units="percentage" dataType="measurement"
+ description="read/writes ratio for the cache" />
+ <metric property="Statistics.AverageReadTime" displayName="[Statistics] Average read time" displayType="summary" units="milliseconds" dataType="measurement"
+ description="Average number of milliseconds for a read operation on the cache" />
+ <metric property="Statistics.AverageWriteTime" displayName="[Statistics] Average write time" displayType="summary" units="milliseconds" dataType="measurement"
+ description="Average number of milliseconds for a write operation in the cache" />
+ <metric property="Statistics.NumberOfEntries" displayName="[Statistics] Number of cache entries" displayType="summary" units="none" dataType="measurement"
+ description="Number of entries in the cache" />
+ <metric property="Statistics.ElapsedTime" displayName="[Statistics] Seconds since cache started" displayType="summary" units="seconds" dataType="measurement"
+ description="Number of seconds since cache started" />
+ <metric property="Statistics.TimeSinceReset" displayName="[Statistics] Seconds since cache statistics were reset" displayType="summary" units="seconds" dataType="measurement"
+ description="Number of seconds since the cache statistics were last reset" />
+ <metric property="DeadlockDetectingLockManager.OverlapWithNotDeadlockAwareLockOwners" displayName="[DeadlockDetectingLockManager] Number of unsolvable deadlock situations" displayType="detail" units="none" dataType="measurement"
+ description="Number of situtations when we try to determine a deadlock and the other lock owner is e.g. a local tx. In this scenario we cannot run the deadlock detection mechanism" />
+ <metric property="DeadlockDetectingLockManager.LocallyInterruptedTransactions" displayName="[DeadlockDetectingLockManager] Number of interrupted local transactions" displayType="detail" units="none" dataType="measurement"
+ description="Number of locally originated transactions that were interrupted as a deadlock situation was detected" />
+ <metric property="DeadlockDetectingLockManager.DetectedRemoteDeadlocks" displayName="[DeadlockDetectingLockManager] Number of detected remote deadlocks" displayType="detail" units="none" dataType="measurement"
+ description="Number of remote deadlocks detected" />
+ <metric property="DeadlockDetectingLockManager.DetectedLocalDeadlocks" displayName="[DeadlockDetectingLockManager] Number of detected local deadlocks" displayType="detail" units="none" dataType="measurement"
+ description="Number of local detected deadlocks" />
+ <metric property="DeadlockDetectingLockManager.TotalNumberOfDetectedDeadlocks" displayName="[DeadlockDetectingLockManager] Number of total detected deadlocks" displayType="detail" units="none" dataType="measurement"
+ description="Total number of local detected deadlocks" />
+ <metric property="DeadlockDetectingLockManager.ConcurrencyLevel" displayName="[DeadlockDetectingLockManager] Concurrency level" displayType="detail" units="none" dataType="trait"
+ description="The concurrency level that the MVCC Lock Manager has been configured with." />
+ <metric property="DeadlockDetectingLockManager.NumberOfLocksHeld" displayName="[DeadlockDetectingLockManager] Number of locks held" displayType="detail" units="none" dataType="measurement"
+ description="The number of exclusive locks that are held." />
+ <metric property="DeadlockDetectingLockManager.NumberOfLocksAvailable" displayName="[DeadlockDetectingLockManager] Number of locks available" displayType="detail" units="none" dataType="measurement"
+ description="The number of exclusive locks that are available." />
+ <metric property="CacheStore.CacheLoaderStores" displayName="[CacheStore] Number of cache stores" displayType="detail" units="none" dataType="measurement"
+ description="number of cache loader stores" />
+ <metric property="Cache.CacheName" displayName="[Cache] Cache name" displayType="summary" units="none" dataType="trait"
+ description="Returns the cache name" />
+ <metric property="Cache.CacheStatus" displayName="[Cache] Cache status" displayType="summary" units="none" dataType="trait"
+ description="Returns the cache status" />
- <metric property="Transactions.commits" displayName="Commits"
- description="Number of transaction commits performed since last reset"
- units="none" measurementType="trendsup" displayType="summary"/>
- <metric property="Transactions.prepares" displayName="Prepares"
- description="Number of transaction prepares performed since last reset"
- units="none" measurementType="trendsup"/>
- <metric property="Transactions.rollbacks" displayName="Rollbacks"
- description="Number of transaction rollbacks performed since last reset"
- units="none" measurementType="trendsup" displayType="summary"/>
- </service>
+ </service>
</server>
-
</plugin>
\ No newline at end of file
Modified: trunk/tools/pom.xml
===================================================================
--- trunk/tools/pom.xml 2009-10-26 18:22:58 UTC (rev 1020)
+++ trunk/tools/pom.xml 2009-10-26 18:26:06 UTC (rev 1021)
@@ -22,7 +22,13 @@
<url>http://download.java.net/maven/2</url>
</repository>
</repositories>
-
+
+ <properties>
+ <version.rhq.plugingen>1.4.0-SNAPSHOT</version.rhq.plugingen>
+ <version.xsom>20081112</version.xsom>
+ <version.commons.logging>1.1</version.commons.logging>
+ </properties>
+
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
@@ -38,59 +44,25 @@
<scope>test</scope>
</dependency>
- <!-- needs to depend on all other modules it is trying to document! -->
<dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>infinispan-cachestore-bdbje</artifactId>
- <version>${project.version}</version>
+ <groupId>org.rhq.helpers</groupId>
+ <artifactId>rhq-pluginGen</artifactId>
+ <version>${version.rhq.plugingen}</version>
+ <scope>provided</scope>
</dependency>
-
<dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>infinispan-cachestore-jdbc</artifactId>
- <version>${project.version}</version>
+ <groupId>com.sun.xsom</groupId>
+ <artifactId>xsom</artifactId>
+ <version>${version.xsom}</version>
</dependency>
-
<dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>infinispan-cachestore-jdbm</artifactId>
- <version>${project.version}</version>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>${version.commons.logging}</version>
+ <scope>test</scope>
</dependency>
-
-
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>infinispan-cachestore-s3</artifactId>
- <version>${project.version}</version>
- </dependency>
-
-
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>infinispan-gui-demo</artifactId>
- <version>${project.version}</version>
- </dependency>
-
-
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>infinispan-jopr-plugin</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>infinispan-tree</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <dependency>
- <groupId>com.sun.xsom</groupId>
- <artifactId>xsom</artifactId>
- <version>20081112</version>
- </dependency>
</dependencies>
<profiles>
Added: trunk/tools/src/main/java/org/infinispan/tools/BeanConventions.java
===================================================================
--- trunk/tools/src/main/java/org/infinispan/tools/BeanConventions.java (rev 0)
+++ trunk/tools/src/main/java/org/infinispan/tools/BeanConventions.java 2009-10-26 18:26:06 UTC (rev 1021)
@@ -0,0 +1,55 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat, Inc. and/or its affiliates, and
+ * individual contributors as indicated by the @author tags. See the
+ * copyright.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.infinispan.tools;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+
+/**
+ * BeanConventions.
+ *
+ * @author Galder Zamarreño
+ * @since 4.0
+ */
+public class BeanConventions {
+
+ public static String getPropertyFromBeanConvention(Method method) {
+ String getterOrSetter = method.getName();
+ if (getterOrSetter.startsWith("get") || getterOrSetter.startsWith("set")) {
+ String withoutGet = getterOrSetter.substring(4);
+ // not specifically BEAN convention, but this is what is bound in JMX.
+ return Character.toUpperCase(getterOrSetter.charAt(3)) + withoutGet;
+ } else if (getterOrSetter.startsWith("is")) {
+ String withoutIs = getterOrSetter.substring(3);
+ return Character.toUpperCase(getterOrSetter.charAt(2)) + withoutIs;
+ }
+ return getterOrSetter;
+ }
+
+ public static String getPropertyFromBeanConvention(Field field) {
+ String fieldName = field.getName();
+ String withoutFirstChar = fieldName.substring(1);
+ return Character.toUpperCase(fieldName.charAt(0)) + withoutFirstChar;
+ }
+
+}
Added: trunk/tools/src/main/java/org/infinispan/tools/jopr/RhqPluginXmlGenerator.java
===================================================================
--- trunk/tools/src/main/java/org/infinispan/tools/jopr/RhqPluginXmlGenerator.java (rev 0)
+++ trunk/tools/src/main/java/org/infinispan/tools/jopr/RhqPluginXmlGenerator.java 2009-10-26 18:26:06 UTC (rev 1021)
@@ -0,0 +1,289 @@
+package org.infinispan.tools.jopr;
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat, Inc. and/or its affiliates, and
+ * individual contributors as indicated by the @author tags. See the
+ * copyright.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.nio.channels.FileChannel;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.infinispan.factories.scopes.Scope;
+import org.infinispan.factories.scopes.Scopes;
+import org.infinispan.jmx.annotations.MBean;
+import org.infinispan.jmx.annotations.ManagedAttribute;
+import org.infinispan.jmx.annotations.ManagedOperation;
+import org.infinispan.tools.BeanConventions;
+import org.infinispan.util.ClassFinder;
+import org.infinispan.util.logging.Log;
+import org.infinispan.util.logging.LogFactory;
+import org.rhq.helpers.pluginAnnotations.agent.Metric;
+import org.rhq.helpers.pluginAnnotations.agent.Operation;
+import org.rhq.helpers.pluginAnnotations.agent.Parameter;
+import org.rhq.helpers.pluginGen.PluginGen;
+import org.rhq.helpers.pluginGen.Props;
+import org.rhq.helpers.pluginGen.ResourceCategory;
+import org.rhq.helpers.pluginGen.Props.MetricProps;
+import org.rhq.helpers.pluginGen.Props.OperationProps;
+import org.rhq.helpers.pluginGen.Props.SimpleProperty;
+import org.rhq.helpers.pluginGen.Props.Template;
+
+import com.sun.javadoc.DocErrorReporter;
+import com.sun.javadoc.RootDoc;
+
+/**
+ * RhqPluginDoclet.
+ *
+ * @author Galder Zamarreño
+ * @since 4.0
+ */
+public class RhqPluginXmlGenerator {
+ private static final Log log = LogFactory.getLog(RhqPluginXmlGenerator.class);
+ private static String cp;
+
+ public static void main(String[] args) throws Exception {
+ cp = System.getProperty("java.class.path");
+ start(null);
+ }
+
+ public static boolean validOptions(String options[][], DocErrorReporter reporter) {
+ for (String[] option : options) {
+ if (option[0].equals("-classpath"))
+ cp = option[1];
+ }
+
+ return true;
+ }
+
+ public static boolean start(RootDoc rootDoc) throws IOException {
+ List<Class<?>> mbeanIspnClasses = getMBeanClasses();
+ List<Class<?>> globalClasses = new ArrayList<Class<?>>();
+ List<Class<?>> namedCacheClasses = new ArrayList<Class<?>>();
+ for (Class<?> clazz : mbeanIspnClasses) {
+ Scope scope = clazz.getAnnotation(Scope.class);
+ if (scope != null && scope.value() == Scopes.GLOBAL) {
+ debug("Add as global class " + clazz);
+ globalClasses.add(clazz);
+ } else {
+ debug("Add as named cache class " + clazz);
+ namedCacheClasses.add(clazz);
+ }
+ }
+
+ PluginGen pg = new PluginGen();
+
+ Props root = new Props();
+ root.setPluginName("Infinispan");
+ root.setPluginDescription("Supports management and monitoring of Infinispan");
+ root.setName("Infinispan Cache Manager");
+ root.setPkg("org.infinispan.jopr");
+ root.setDependsOnJmxPlugin(true);
+ root.setManualAddOfResourceType(true);
+ root.setDiscoveryClass("CacheManagerDiscovery");
+ root.setComponentClass("CacheManagerComponent");
+ root.setSingleton(true);
+ root.setCategory(ResourceCategory.SERVER);
+ populateMetricsAndOperations(globalClasses, root, false);
+
+ SimpleProperty connect = new SimpleProperty("connectorAddress");
+ connect.setDescription("JMX Remoting address of the remote Infinispan Instance");
+ connect.setReadOnly(false);
+ root.getSimpleProps().add(connect);
+
+ SimpleProperty objectName = new SimpleProperty("objectName");
+ objectName.setDescription("ObjectName of the Manager");
+ objectName.setType("string");
+ objectName.setReadOnly(true);
+ root.getSimpleProps().add(objectName);
+ Template defaultTemplate = new Template("default");
+ defaultTemplate.setDescription("The default setup for Infinispan");
+ SimpleProperty connect2 = new SimpleProperty("connectorAddress");
+ connect2.setDisplayName("URL of the remote server");
+ connect2.setDefaultValue("service:jmx:rmi://127.0.0.1/jndi/rmi://127.0.0.1:6996/jmxrmi");
+ defaultTemplate.getSimpleProps().add(connect2);
+ root.getTemplates().add(defaultTemplate);
+
+ Props cache = new Props();
+ cache.setName("Infinispan Cache");
+ cache.setPkg("org.infinispan.jopr");
+ cache.setDependsOnJmxPlugin(true);
+ cache.setDiscoveryClass("CacheDiscovery");
+ cache.setComponentClass("CacheComponent");
+ cache.setSingleton(false);
+ cache.setCategory(ResourceCategory.SERVICE);
+ populateMetricsAndOperations(namedCacheClasses, cache, true);
+
+ root.getChildren().add(cache);
+
+ pg.createFile(root, "descriptor", "rhq-plugin.xml", "../../../src/main/resources/META-INF");
+ copyFile(new File("../../../src/main/resources/META-INF/rhq-plugin.xml"), new File("../../../target/classes/META-INF/rhq-plugin.xml"));
+
+ return true;
+ }
+
+ private static void copyFile(File in, File out) throws IOException {
+ FileChannel inCh = new FileInputStream(in).getChannel();
+ FileChannel outCh = new FileOutputStream(out).getChannel();
+ try {
+ inCh.transferTo(0, inCh.size(), outCh);
+ } catch (IOException e) {
+ throw e;
+ } finally {
+ if (inCh != null) inCh.close();
+ if (outCh != null) outCh.close();
+ }
+ }
+
+ private static List<Class<?>> getMBeanClasses() throws IOException {
+ try {
+ return ClassFinder.withAnnotationDeclared(ClassFinder.infinispanClasses(cp), MBean.class);
+ } catch (Exception e) {
+ IOException ioe = new IOException("Unable to get Infinispan classes");
+ ioe.initCause(e);
+ throw ioe;
+ }
+ }
+
+ private static void populateMetricsAndOperations(List<Class<?>> classes, Props props, boolean withNamePrefix) {
+ props.setHasOperations(true);
+ props.setHasMetrics(true);
+ for (Class<?> clazz : classes) {
+ MBean mbean = clazz.getAnnotation(MBean.class);
+ String prefix = withNamePrefix ? mbean.objectName() + '.' : "";
+ Method[] methods = clazz.getMethods();
+ for (Method method : methods) {
+ Metric rhqMetric = method.getAnnotation(Metric.class);
+ ManagedAttribute managedAttr = method.getAnnotation(ManagedAttribute.class);
+ ManagedOperation managedOp = method.getAnnotation(ManagedOperation.class);
+ Operation rhqOperation = method.getAnnotation(Operation.class);
+ if (rhqMetric != null) {
+ debug("Metric annotation found " + rhqMetric);
+ // Property and description resolution are the reason why annotation scanning is done here.
+ // These two fields are calculated from either the method name or the Managed* annotations,
+ // and so, only the infinispan side knows about that.
+ String property = prefix + BeanConventions.getPropertyFromBeanConvention(method);
+ if (!rhqMetric.property().isEmpty()) {
+ property = prefix + rhqMetric.property();
+ }
+ MetricProps metric = new MetricProps(property);
+ String displayName = withNamePrefix ? "[" + mbean.objectName() + "] " + rhqMetric.displayName() : rhqMetric.displayName();
+ metric.setDisplayName(displayName);
+ metric.setDisplayType(rhqMetric.displayType());
+ metric.setDataType(rhqMetric.dataType());
+ metric.setUnits(rhqMetric.units());
+ if (managedAttr != null) {
+ debug("Metric has ManagedAttribute annotation " + managedAttr);
+ metric.setDescription(managedAttr.description());
+ } else if (managedOp != null) {
+ debug("Metric has ManagedOperation annotation " + managedOp);
+ metric.setDescription(managedOp.description());
+ } else {
+ log.debug("Metric has no managed annotations, so take the description from the display name.");
+ metric.setDescription(rhqMetric.displayName());
+ }
+ props.getMetrics().add(metric);
+ }
+
+ if (rhqOperation != null) {
+ debug("Operation annotation found " + rhqOperation);
+ String name = prefix + method.getName();
+ if (!rhqOperation.name().isEmpty()) {
+ name = prefix + rhqOperation.name();
+ }
+ OperationProps operation = new OperationProps(name);
+ String displayName = withNamePrefix ? "[" + mbean.objectName() + "] " + rhqOperation.displayName() : rhqOperation.displayName();
+ operation.setDisplayName(displayName);
+ if (managedAttr != null) {
+ debug("Operation has ManagedAttribute annotation " + managedAttr);
+ operation.setDescription(managedAttr.description());
+ } else if (managedOp != null) {
+ debug("Operation has ManagedOperation annotation " + managedOp);
+ operation.setDescription(managedOp.description());
+ } else {
+ debug("Operation has no managed annotations, so take the description from the display name.");
+ operation.setDescription(rhqOperation.displayName());
+ }
+
+ Annotation[][] paramAnnotations = method.getParameterAnnotations();
+ int i = 0;
+ for (Annotation[] paramAnnotationsInEach : paramAnnotations) {
+ boolean hadParameter = false;
+ for (Annotation annot : paramAnnotationsInEach) {
+ debug("Parameter annotation " + annot);
+ if (annot instanceof Parameter) {
+ Parameter param = (Parameter) annot;
+ SimpleProperty prop = new SimpleProperty(param.name());
+ prop.setDescription(param.description());
+ operation.getParams().add(prop);
+ hadParameter = true;
+ }
+ }
+ if (!hadParameter) {
+ operation.getParams().add(new SimpleProperty("p" + i++));
+ }
+ }
+ props.getOperations().add(operation);
+ }
+ }
+ Field[] fields = clazz.getDeclaredFields();
+ for (Field field : fields) {
+ System.out.println("Inspecting field " + field);
+ Metric rhqMetric = field.getAnnotation(Metric.class);
+ if (rhqMetric != null) {
+ System.out.println("Field " + field + " contains Metric annotation " + rhqMetric);
+ String property = prefix + BeanConventions.getPropertyFromBeanConvention(field);
+ if (!rhqMetric.property().isEmpty()) {
+ property = prefix + rhqMetric.property();
+ }
+ MetricProps metric = new MetricProps(property);
+ String displayName = withNamePrefix ? "[" + mbean.objectName() + "] " + rhqMetric.displayName() : rhqMetric.displayName();
+ metric.setDisplayName(displayName);
+ metric.setDisplayType(rhqMetric.displayType());
+ metric.setDataType(rhqMetric.dataType());
+ metric.setUnits(rhqMetric.units());
+ ManagedAttribute managedAttr = field.getAnnotation(ManagedAttribute.class);
+ if (managedAttr != null) {
+ debug("Metric has ManagedAttribute annotation " + managedAttr);
+ metric.setDescription(managedAttr.description());
+ } else {
+ log.debug("Metric has no managed annotations, so take the description from the display name.");
+ metric.setDescription(rhqMetric.displayName());
+ }
+ props.getMetrics().add(metric);
+ }
+ }
+
+ }
+ }
+
+ private static final void debug(Object o) {
+// if (log.isDebugEnabled()) log.debug(o);
+// System.out.println(o);
+ }
+
+}
More information about the infinispan-commits
mailing list