[infinispan-commits] Infinispan SVN: r1131 - in trunk: jopr-plugin/src/main/java/org/infinispan/jopr and 1 other directories.

infinispan-commits at lists.jboss.org infinispan-commits at lists.jboss.org
Wed Nov 11 06:27:11 EST 2009


Author: galder.zamarreno at jboss.com
Date: 2009-11-11 06:27:10 -0500 (Wed, 11 Nov 2009)
New Revision: 1131

Modified:
   trunk/core/src/main/java/org/infinispan/remoting/rpc/RpcManagerImpl.java
   trunk/jopr-plugin/src/main/java/org/infinispan/jopr/CacheComponent.java
   trunk/jopr-plugin/src/main/resources/META-INF/rhq-plugin.xml
Log:
[ISPN-264] (Jopr CacheComponent is not handling String like measurements, so these are not shown!) Done.

Modified: trunk/core/src/main/java/org/infinispan/remoting/rpc/RpcManagerImpl.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/remoting/rpc/RpcManagerImpl.java	2009-11-11 10:21:35 UTC (rev 1130)
+++ trunk/core/src/main/java/org/infinispan/remoting/rpc/RpcManagerImpl.java	2009-11-11 11:27:10 UTC (rev 1131)
@@ -298,20 +298,20 @@
 
    @ManagedAttribute(description = "Number of successful replications")
    @Metric(displayName = "Number of successfull replications", measurementType = MeasurementType.TRENDSUP, displayType = DisplayType.SUMMARY)
-   public String getReplicationCount() {
+   public long getReplicationCount() {
       if (!isStatisticsEnabled()) {
-         return "N/A";
+         return -1;
       }
-      return String.valueOf(replicationCount.get());
+      return replicationCount.get();
    }
 
    @ManagedAttribute(description = "Number of failed replications")
    @Metric(displayName = "Number of failed replications", measurementType = MeasurementType.TRENDSUP, displayType = DisplayType.SUMMARY)
-   public String getReplicationFailures() {
+   public long getReplicationFailures() {
       if (!isStatisticsEnabled()) {
-         return "N/A";
+         return -1;
       }
-      return String.valueOf(replicationFailures.get());
+      return replicationFailures.get();
    }
 
    @Metric(displayName = "Statistics enabled", dataType = DataType.TRAIT)
@@ -342,8 +342,8 @@
 
    @ManagedAttribute(description = "Size of the cluster in number of nodes")
    @Metric(displayName = "Cluster size", displayType = DisplayType.SUMMARY)
-   public String getClusterSize() {
-      return t.getMembers().size() + "";
+   public int getClusterSize() {
+      return t.getMembers().size();
    }
 
    @ManagedAttribute(description = "Successful replications as a ratio of total replications")
@@ -360,6 +360,9 @@
    @ManagedAttribute(description = "The average time spent in the transport layer, in milliseconds")
    @Metric(displayName = "Average time spent in the transport layer", units = Units.MILLISECONDS, displayType = DisplayType.SUMMARY)
    public long getAverageReplicationTime() {
+      if (numReplications.get() == 0) {
+         return 0;
+      }
       return totalReplicationTime.get() / numReplications.get();
    }
 

Modified: trunk/jopr-plugin/src/main/java/org/infinispan/jopr/CacheComponent.java
===================================================================
--- trunk/jopr-plugin/src/main/java/org/infinispan/jopr/CacheComponent.java	2009-11-11 10:21:35 UTC (rev 1130)
+++ trunk/jopr-plugin/src/main/java/org/infinispan/jopr/CacheComponent.java	2009-11-11 11:27:10 UTC (rev 1131)
@@ -130,19 +130,11 @@
                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);
+                  if (o != null) {
+                     MeasurementDataNumeric res = constructMeasurementDataNumeric(attrType, o, req);
+                     if (res != null) report.addData(res);
+                  } else {
+                     if (log.isDebugEnabled()) log.debug("Metric ({0}) has null value, do not add to report", req.getName());
                   }
                } else if (type == DataType.TRAIT) {
                   String value = (String) o;
@@ -172,8 +164,6 @@
                                           Configuration parameters) throws Exception {
       EmsConnection conn = getConnection();
       String abbrev = name.substring(0, name.indexOf("."));
-//      String mbean = abbrevToMBean.get(abbrev);
-//      mbean = myNamePattern + mbean;
       String mbean = myNamePattern + abbrev;
       EmsBean bean = conn.getBean(mbean);
       String opName = name.substring(name.indexOf(".") + 1);
@@ -191,4 +181,24 @@
       return context.getParentResourceComponent().getConnection();
    }
 
+   private MeasurementDataNumeric constructMeasurementDataNumeric(Class attrType, Object o, MeasurementScheduleRequest req) {
+      boolean trace = log.isTraceEnabled();
+      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;
+         return new MeasurementDataNumeric(req, Double.valueOf(tmp));
+      } else if (attrType.equals(Double.class) || attrType.equals(double.class)) {
+         Double tmp = (Double) o;
+         return new MeasurementDataNumeric(req, tmp);
+      } else if (attrType.equals(Integer.class) || attrType.equals(int.class)) {
+         Integer tmp = (Integer) o;
+         return new MeasurementDataNumeric(req, Double.valueOf(tmp));
+      } else if (attrType.equals(String.class)) {
+         String tmp = (String) o;
+         return new MeasurementDataNumeric(req, Double.valueOf(tmp));
+      } 
+      
+      log.warn("Unknown {0} attribute type for {1}", attrType, o);
+      return null;
+   }
 }
\ No newline at end of file

Modified: trunk/jopr-plugin/src/main/resources/META-INF/rhq-plugin.xml
===================================================================
--- trunk/jopr-plugin/src/main/resources/META-INF/rhq-plugin.xml	2009-11-11 10:21:35 UTC (rev 1130)
+++ trunk/jopr-plugin/src/main/resources/META-INF/rhq-plugin.xml	2009-11-11 11:27:10 UTC (rev 1131)
@@ -61,8 +61,15 @@
           >
 
 
-           <operation name="Passivation.resetStatistics" displayName="[Passivation] Reset statistics" description="Resets statistics gathered by this component">
+           <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="Statistics.resetStatistics" displayName="[Statistics] Reset Statistics (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"/>
@@ -78,14 +85,13 @@
                  <c:simple-property name="key" description="Key to locate"/>
               </parameters>
            </operation>
+           <operation name="Activation.resetStatistics" displayName="[Activation] Reset statistics" description="Resets statistics gathered by this component">
+           </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 name="Cache.start" displayName="[Cache] Starts cache." description="Starts the cache.">
            </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 name="Cache.stop" displayName="[Cache] Stops cache." description="Stops the cache.">
            </operation>
            <operation name="RpcManager.resetStatistics" displayName="[RpcManager] Reset statistics" description="Resets statistics gathered by this component">
            </operation>
@@ -94,6 +100,12 @@
                  <c:simple-property name="enabled" description="Whether statistics should be enabled or disabled (true/false)"/>
               </parameters>
            </operation>
+           <operation name="CacheStore.resetStatistics" displayName="[CacheStore] Reset 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="Passivation.resetStatistics" displayName="[Passivation] Reset statistics" description="Resets statistics gathered by this component">
+           </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">
@@ -101,21 +113,33 @@
                  <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="Passivation.Passivations" displayName="[Passivation] Number of cache passivations" displayType="detail" units="none" dataType="measurement"
-                   description="Number of passivation events" />
+           <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="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="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"
@@ -126,14 +150,20 @@
                    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="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="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="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="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"
@@ -148,42 +178,10 @@
                    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="RpcManager.AverageReplicationTime" displayName="[RpcManager] Average time spent in the transport layer" displayType="summary" units="milliseconds" dataType="measurement"
+                   description="The average time spent in the transport layer, in milliseconds" />
+           <metric property="CacheStore.CacheLoaderStores" displayName="[CacheStore] Number of cache stores" displayType="detail" units="none" dataType="measurement"
+                   description="number of cache loader stores" />
            <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"
@@ -200,12 +198,16 @@
                    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="Passivation.Passivations" displayName="[Passivation] Number of cache passivations" displayType="detail" units="none" dataType="measurement"
+                   description="Number of passivation events" />
+           <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" />
 
 
        </service>



More information about the infinispan-commits mailing list