[jboss-svn-commits] JBL Code SVN: r15558 - labs/jbossesb/trunk/product/samples/quickstarts/load_generator/scripts.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Wed Oct 3 16:40:31 EDT 2007


Author: james.williams at jboss.com
Date: 2007-10-03 16:40:31 -0400 (Wed, 03 Oct 2007)
New Revision: 15558

Added:
   labs/jbossesb/trunk/product/samples/quickstarts/load_generator/scripts/LoadUtil.groovy
Log:
changed logic so it is less groovy hack-ish and more POJO friendly. Also switched to xml based config so more options
can be supported.

Added: labs/jbossesb/trunk/product/samples/quickstarts/load_generator/scripts/LoadUtil.groovy
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/load_generator/scripts/LoadUtil.groovy	                        (rev 0)
+++ labs/jbossesb/trunk/product/samples/quickstarts/load_generator/scripts/LoadUtil.groovy	2007-10-03 20:40:31 UTC (rev 15558)
@@ -0,0 +1,70 @@
+import javax.management.*
+import javax.naming.Context
+import javax.naming.InitialContext
+import javax.naming.NamingException
+
+/**
+ * Simple Groovy load script that will provide TPS statistics for a ESB service call and JMS Queues.
+ *
+ * @author <a href="mailto:james.williams at redhat.com">james.williams at redhat.com</a>
+ */
+ 
+class LoadUtil
+{
+   InitialContext ctx
+   MBeanServerConnection server	
+   
+   public LoadUtil()
+   {
+   		initContext()
+   }
+	
+   private initContext()
+   {
+   		ctx = new InitialContext(); // From jndi.properties
+		server = (MBeanServerConnection) ctx.lookup("jmx/invoker/RMIAdaptor")
+   }   
+
+   public float getEsbServiceTps(serviceReportBean)
+   {
+   		def serviceMessageCount = {
+   			server.getAttribute(new ObjectName("jboss.esb:service-name=$serviceReportBean.serviceName,deployment=$serviceReportBean.esbArchiveName,category=MessageCounter"), "overall service message count").toLong()
+   		}
+   		
+   		def processedMsgsBefore = serviceMessageCount()
+ 		sleep(1000)
+ 		def processedMsgsAfter = serviceMessageCount() 	
+ 		
+ 		return processedMsgsAfter - processedMsgsBefore	
+   }
+   
+   public boolean fastestQueueDone(queue)
+   {
+   		if (getQueueDepthFactor(queue) == 0)
+   		{
+   			return true
+   		}
+   		else
+   		{
+   			return false
+   		}
+   }
+   
+   public double getQueueDepthFactor(queue)
+   {
+   		def queueDepthCount = {
+   			server.getAttribute(new ObjectName("$queue"), "QueueDepth").toLong()
+   		}
+   		
+   		def depthBefore = queueDepthCount()
+ 		sleep(1000)
+ 		def depthAfter = queueDepthCount() 	
+ 		
+ 		return depthBefore - depthAfter
+   }   
+   
+}
+ 
+
+    
+   
\ No newline at end of file




More information about the jboss-svn-commits mailing list