[jboss-svn-commits] JBL Code SVN: r23395 - labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/src/org/jboss/soa/esb/listeners/message.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Thu Oct 9 10:48:40 EDT 2008


Author: kevin.conner at jboss.com
Date: 2008-10-09 10:48:39 -0400 (Thu, 09 Oct 2008)
New Revision: 23395

Modified:
   labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/src/org/jboss/soa/esb/listeners/message/ActionProcessingPipeline.java
   labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/src/org/jboss/soa/esb/listeners/message/ServiceMessageCounter.java
Log:
Fixed metrics: JBESB-2043

Modified: labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/src/org/jboss/soa/esb/listeners/message/ActionProcessingPipeline.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/src/org/jboss/soa/esb/listeners/message/ActionProcessingPipeline.java	2008-10-09 14:09:46 UTC (rev 23394)
+++ labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/src/org/jboss/soa/esb/listeners/message/ActionProcessingPipeline.java	2008-10-09 14:48:39 UTC (rev 23395)
@@ -558,10 +558,6 @@
 						MessageCounterStatistics.getMessageCounterStatistics().update(new MessageStatusBean(totalProcTime, message,
 							MessageStatusBean.MESSAGE_FAILED));
 
-						final long processTime = System.nanoTime() - actionStart;
-						serviceMessageCounter.update(new ActionStatusBean(processTime, count, message,
-							ActionStatusBean.ACTION_FAILED));
-
 						if (throwRuntime)
 						{
 							throw (RuntimeException)ex ;

Modified: labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/src/org/jboss/soa/esb/listeners/message/ServiceMessageCounter.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/src/org/jboss/soa/esb/listeners/message/ServiceMessageCounter.java	2008-10-09 14:09:46 UTC (rev 23394)
+++ labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/src/org/jboss/soa/esb/listeners/message/ServiceMessageCounter.java	2008-10-09 14:48:39 UTC (rev 23395)
@@ -55,18 +55,18 @@
  * @since Version 4.2
  */
 public class ServiceMessageCounter implements DynamicMBean {
-	private Hashtable<String, Integer> actionCounterHash;
-	private Hashtable<String, Integer> actionFailedCounterHash;
-	private Hashtable<String, Long> actionProcessTimeHash;
-	private Hashtable<String, Integer> actionBytesProcessedHash;
-	private Hashtable<String, Integer> actionBytesFailedHash;
+	private Hashtable<String, IntHolder> actionCounterHash;
+	private Hashtable<String, IntHolder> actionFailedCounterHash;
+	private Hashtable<String, LongHolder> actionProcessTimeHash;
+	private Hashtable<String, IntHolder> actionBytesProcessedHash;
+	private Hashtable<String, IntHolder> actionBytesFailedHash;
 	
 	private String[] actionNames;
 	private final ObjectName listObjectName ;
 	
-	private Integer serviceCount;
-	private Integer bytesFailed;
-	private Integer bytesProcessed;
+	private int serviceCount;
+	private long bytesFailed;
+	private long bytesProcessed;
 	
 	public static final String RESET_COUNTER = "resetCounter";
 	private static final String MESSAGE_COUNTER = "messages successfully processed count";
@@ -88,16 +88,12 @@
 	 * @param objectName The name to use as the MBean.
 	 */
 	public ServiceMessageCounter(ConfigTree f_config, final String objectName) {
-		actionCounterHash = new Hashtable<String, Integer>();
-		actionFailedCounterHash = new Hashtable<String, Integer>();
-		actionProcessTimeHash = new Hashtable<String, Long>();
-		actionBytesProcessedHash = new Hashtable<String, Integer>();
-		actionBytesFailedHash = new Hashtable<String, Integer>();
+		actionCounterHash = new Hashtable<String, IntHolder>();
+		actionFailedCounterHash = new Hashtable<String, IntHolder>();
+		actionProcessTimeHash = new Hashtable<String, LongHolder>();
+		actionBytesProcessedHash = new Hashtable<String, IntHolder>();
+		actionBytesFailedHash = new Hashtable<String, IntHolder>();
 		
-		serviceCount = new Integer(0);
-		bytesProcessed = new Integer(0);
-		bytesFailed = new Integer(0);
-		
 		init(f_config);
 		ObjectName listObjectName = null ;
 		try
@@ -130,7 +126,7 @@
 	 * Increment the total message count of this service.
 	 */
 	public synchronized void incrementTotalCount() {
-		serviceCount = new Integer(serviceCount.intValue() + 1);
+		serviceCount += 1 ;
 	}
 	
 	/**
@@ -145,11 +141,11 @@
 		for (int count = 0 ; count < numActions ; count++) {
 			final ConfigTree actionConfig = actionList[count] ;
 			String actionId = getActionId(actionConfig);
-			actionCounterHash.put(actionId + " " + MESSAGE_COUNTER, new Integer(0));
-			actionFailedCounterHash.put(actionId + " " + FAILED_MESSAGE_COUNTER, new Integer(0));
-			actionProcessTimeHash.put(actionId + " " + PROCESSING_TIME, new Long(0));
-			actionBytesFailedHash.put(actionId + " " + BYTES_FAILED, new Integer(0));
-			actionBytesProcessedHash.put(actionId + " " + BYTES_PROCESSED, new Integer(0));
+			actionCounterHash.put(actionId + " " + MESSAGE_COUNTER, new IntHolder());
+			actionFailedCounterHash.put(actionId + " " + FAILED_MESSAGE_COUNTER, new IntHolder());
+			actionProcessTimeHash.put(actionId + " " + PROCESSING_TIME, new LongHolder());
+			actionBytesFailedHash.put(actionId + " " + BYTES_FAILED, new IntHolder());
+			actionBytesProcessedHash.put(actionId + " " + BYTES_PROCESSED, new IntHolder());
 			actionNames[count] = actionId ;
 		}
 		serviceCount = new Integer(0);
@@ -162,28 +158,28 @@
 	 * and in the action process time hash to zero.
 	 */
 	public synchronized void resetCounter() {
-		serviceCount = new Integer(0);
-		bytesProcessed = new Integer(0);
-		bytesFailed = new Integer(0);
+		serviceCount = 0 ;
+		bytesProcessed = 0 ;
+		bytesFailed = 0 ;
 		
 		for (String key : actionCounterHash.keySet()) {
-			actionCounterHash.put(key, new Integer(0));
+			actionCounterHash.put(key, new IntHolder());
 		}
 		
 		for (String key : actionFailedCounterHash.keySet()) {
-			actionFailedCounterHash.put(key, new Integer(0));
+			actionFailedCounterHash.put(key, new IntHolder());
 		}
 		
 		for (String key : actionProcessTimeHash.keySet()) {
-			actionProcessTimeHash.put(key, new Long(0));
+			actionProcessTimeHash.put(key, new LongHolder());
 		}
 		
 		for (String key : actionBytesFailedHash.keySet()) {
-			actionBytesFailedHash.put(key, new Integer(0));
+			actionBytesFailedHash.put(key, new IntHolder());
 		}
 		
 		for (String key : actionBytesProcessedHash.keySet()) {
-			actionBytesProcessedHash.put(key, new Integer(0));
+			actionBytesProcessedHash.put(key, new IntHolder());
 		}
 	}
 	
@@ -262,30 +258,25 @@
 	 */
 	public synchronized Object getAttribute(String key) throws AttributeNotFoundException, MBeanException, ReflectionException {
     	if (actionCounterHash.containsKey(key)) {
-    		Integer value = null;
-    		value = actionCounterHash.get(key);
-    		return value;
+    		return actionCounterHash.get(key).value;
     	} else if (actionProcessTimeHash.containsKey(key)) {
-    		Long processTotal = actionProcessTimeHash.get(key);
+    		long processTotal = actionProcessTimeHash.get(key).value;
     		String actionId = key.substring(0, key.indexOf(PROCESSING_TIME)-1);
-    		Integer successCount = actionCounterHash.get(actionId + " " + MESSAGE_COUNTER);
+    		int successCount = actionCounterHash.get(actionId + " " + MESSAGE_COUNTER).value;
     		Double value = null;
     		
-    		if (successCount.intValue() > 0) {
-    			value = ((double) processTotal / successCount.intValue());
+    		if (successCount > 0) {
+    			value = ((double) processTotal / successCount);
     		} else {
     			value = null;
     		}
     		return value;
     	} else if (actionFailedCounterHash.containsKey(key)) {
-    		Integer value = actionFailedCounterHash.get(key);
-    		return value;
+    		return actionFailedCounterHash.get(key).value;
     	} else if (actionBytesFailedHash.containsKey(key)) {
-    		Integer value = actionBytesFailedHash.get(key);
-    		return value;
+    		return actionBytesFailedHash.get(key).value;
     	} else if (actionBytesProcessedHash.containsKey(key)) {
-    		Integer value = actionBytesProcessedHash.get(key);
-    		return value;
+    		return actionBytesProcessedHash.get(key).value;
     	} else if (OVERALL_SERVICE_COUNT.equals(key)) {
     		return serviceCount;
     	} else if (OVERALL_BYTES_PROCESSED.equals(key)) {
@@ -310,12 +301,12 @@
 		attributeList.add(overallCount);
 		
 		for (String key : actionProcessTimeHash.keySet()) {
-			Long processTotal = actionProcessTimeHash.get(key);
+			long processTotal = actionProcessTimeHash.get(key).value;
 			String actionId = key.substring(0, key.indexOf(PROCESSING_TIME));
-			Integer successCount = actionCounterHash.get(actionId + " " + MESSAGE_COUNTER);
+			int successCount = actionCounterHash.get(actionId + " " + MESSAGE_COUNTER).value;
 			String avgTime = null;
-			if (successCount.intValue() > 0) {
-				avgTime = ((double) processTotal / successCount.intValue()) + " ns";
+			if (successCount > 0) {
+				avgTime = ((double) processTotal / successCount) + " ns";
 			}
 			Attribute at = new Attribute(key, avgTime);
 			attributeList.add(at);
@@ -424,29 +415,45 @@
 		String actionName = actionNames[asb.getProcCount()]; 
 
 		if (ActionStatusBean.ACTION_SENT.equals(asb.getStatus())) {
-			Integer count = actionCounterHash.get(actionName + " " + MESSAGE_COUNTER);
-			count = count.intValue() + 1;
-			actionCounterHash.put(actionName + " " + MESSAGE_COUNTER, count);
-			Long time = actionProcessTimeHash.get(actionName + " " + PROCESSING_TIME);
-			time = time.longValue() + asb.getProcTime();
-			actionProcessTimeHash.put(actionName + " " + PROCESSING_TIME, time);
-			Integer bProcessed = actionBytesProcessedHash.get(actionName + " " +  BYTES_PROCESSED);
-			bProcessed = bProcessed.intValue() + asb.getBytesProcessed();
-			actionBytesProcessedHash.put(actionName + " " + BYTES_PROCESSED, bProcessed);
-			bytesProcessed += new Integer(bytesProcessed.intValue() + asb.getBytesProcessed());
+			IntHolder count = actionCounterHash.get(actionName + " " + MESSAGE_COUNTER);
+			count.value++ ;
+			LongHolder time = actionProcessTimeHash.get(actionName + " " + PROCESSING_TIME);
+			time.value += asb.getProcTime();
+			IntHolder bProcessed = actionBytesProcessedHash.get(actionName + " " +  BYTES_PROCESSED);
+			bProcessed.value += asb.getBytesProcessed();
+			bytesProcessed += asb.getBytesProcessed();
 		} else if (ActionStatusBean.ACTION_FAILED.equals(asb.getStatus())) {
-			Integer count = actionFailedCounterHash.get(actionName + " " + FAILED_MESSAGE_COUNTER);
-			count = count.intValue() + 1;
-			actionFailedCounterHash.put(actionName + " " + FAILED_MESSAGE_COUNTER, count);
-			Integer bFailed = actionBytesFailedHash.get(actionName + " " +  BYTES_FAILED);
-			bFailed = bFailed.intValue() + asb.getBytesProcessed();
-			bytesFailed += new Integer(bytesFailed.intValue() + asb.getBytesProcessed());
-			actionBytesFailedHash.put(actionName + " " + BYTES_FAILED, bFailed);
-		}		
+			IntHolder count = actionFailedCounterHash.get(actionName + " " + FAILED_MESSAGE_COUNTER);
+			count.value++ ;
+			LongHolder time = actionProcessTimeHash.get(actionName + " " + PROCESSING_TIME);
+			time.value += asb.getProcTime();
+			IntHolder bFailed = actionBytesFailedHash.get(actionName + " " +  BYTES_FAILED);
+			bFailed.value += asb.getBytesProcessed();
+			bytesFailed += asb.getBytesProcessed();
+		}
 	}
 	
 	protected ObjectName getObjectName()
 	{
 		return listObjectName;
 	}
+	
+	// Very basic holder classes
+	private static final class IntHolder
+	{
+		int value ;
+		@Override
+		public String toString() {
+			return Integer.toString(value);
+		}
+	}
+	
+	private static final class LongHolder
+	{
+		long value ;
+		@Override
+		public String toString() {
+			return Long.toString(value);
+		}
+	}
 }




More information about the jboss-svn-commits mailing list