jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pmoua...@apache.org
Subject svn commit: r1519093 - in /jmeter/trunk: src/core/org/apache/jmeter/threads/RemoteThreadsLifeCycleListener.java src/core/org/apache/jmeter/threads/RemoteThreadsListenerImpl.java xdocs/changes.xml
Date Fri, 30 Aug 2013 21:40:50 GMT
Author: pmouawad
Date: Fri Aug 30 21:40:50 2013
New Revision: 1519093

URL: http://svn.apache.org/r1519093
Log:
Bug 55509 - Allow Plugins to be notified of remote thread number progression
Bugzilla Id: 55509

Added:
    jmeter/trunk/src/core/org/apache/jmeter/threads/RemoteThreadsLifeCycleListener.java  
(with props)
Modified:
    jmeter/trunk/src/core/org/apache/jmeter/threads/RemoteThreadsListenerImpl.java
    jmeter/trunk/xdocs/changes.xml

Added: jmeter/trunk/src/core/org/apache/jmeter/threads/RemoteThreadsLifeCycleListener.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/threads/RemoteThreadsLifeCycleListener.java?rev=1519093&view=auto
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/threads/RemoteThreadsLifeCycleListener.java (added)
+++ jmeter/trunk/src/core/org/apache/jmeter/threads/RemoteThreadsLifeCycleListener.java Fri
Aug 30 21:40:50 2013
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.jmeter.threads;
+
+/**
+ * Interface notified when number of active threads changes
+ * @since 2.10
+ */
+public interface RemoteThreadsLifeCycleListener {
+
+    /**
+     * 
+     * @param numberOfThreads number of active threads
+     */
+    void threadNumberIncreased(int numberOfThreads);
+
+    /**
+     * 
+     * @param numberOfThreads number of active threads
+     */
+    void threadNumberDecreased(int numberOfThreads);
+}

Propchange: jmeter/trunk/src/core/org/apache/jmeter/threads/RemoteThreadsLifeCycleListener.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: jmeter/trunk/src/core/org/apache/jmeter/threads/RemoteThreadsListenerImpl.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/threads/RemoteThreadsListenerImpl.java?rev=1519093&r1=1519092&r2=1519093&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/threads/RemoteThreadsListenerImpl.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/threads/RemoteThreadsListenerImpl.java Fri Aug
30 21:40:50 2013
@@ -18,12 +18,19 @@
 
 package org.apache.jmeter.threads;
 
+import java.io.IOException;
+import java.lang.reflect.Modifier;
 import java.rmi.RemoteException;
 import java.rmi.server.UnicastRemoteObject;
+import java.util.ArrayList;
+import java.util.List;
 
 import org.apache.jmeter.gui.GuiPackage;
 import org.apache.jmeter.testelement.ThreadListener;
 import org.apache.jmeter.util.JMeterUtils;
+import org.apache.jorphan.logging.LoggingManager;
+import org.apache.jorphan.reflect.ClassFinder;
+import org.apache.log.Logger;
 
 /**
  * RMI Implementation, client side code (ie executed on Controller)
@@ -31,6 +38,9 @@ import org.apache.jmeter.util.JMeterUtil
  */
 public class RemoteThreadsListenerImpl extends UnicastRemoteObject implements
         RemoteThreadsListener, ThreadListener {
+    private static final Logger log = LoggingManager.getLoggerForClass();
+    private final List<RemoteThreadsLifeCycleListener> listeners = new ArrayList<RemoteThreadsLifeCycleListener>();
+
     /**
      * 
      */
@@ -46,6 +56,30 @@ public class RemoteThreadsListenerImpl e
      */
     public RemoteThreadsListenerImpl() throws RemoteException {
         super(DEFAULT_LOCAL_PORT);
+        try {
+            List<String> listClasses = ClassFinder.findClassesThatExtend(
+                    JMeterUtils.getSearchPaths(), 
+                    new Class[] {RemoteThreadsLifeCycleListener.class }); 
+            for (String strClassName : listClasses) {
+                try {
+                    if(log.isDebugEnabled()) {
+                        log.debug("Loading class: "+ strClassName);
+                    }
+                    Class<?> commandClass = Class.forName(strClassName);
+                    if (!Modifier.isAbstract(commandClass.getModifiers())) {
+                        if(log.isDebugEnabled()) {
+                            log.debug("Instantiating: "+ commandClass.getName());
+                        }
+                        RemoteThreadsLifeCycleListener listener = (RemoteThreadsLifeCycleListener)
commandClass.newInstance();
+                        listeners.add(listener);
+                    }
+                } catch (Exception e) {
+                    log.error("Exception registering "+RemoteThreadsLifeCycleListener.class.getName()
+ " with implementation:"+strClassName, e);
+                }
+            }
+        } catch (IOException e) {
+            log.error("Exception finding implementations of "+RemoteThreadsLifeCycleListener.class,
e);
+        }
     }
 
     /**
@@ -59,6 +93,9 @@ public class RemoteThreadsListenerImpl e
         if (gp != null) {// check there is a GUI
             gp.getMainFrame().updateCounts();
         }
+        for (RemoteThreadsLifeCycleListener listener : listeners) {
+            listener.threadNumberIncreased(JMeterContextService.getNumberOfThreads());
+        }
     }
 
     /* (non-Javadoc)
@@ -71,5 +108,8 @@ public class RemoteThreadsListenerImpl e
         if (gp != null) {// check there is a GUI
             gp.getMainFrame().updateCounts();
         }
+        for (RemoteThreadsLifeCycleListener listener : listeners) {
+            listener.threadNumberDecreased(JMeterContextService.getNumberOfThreads());
+        }
     }
 }

Modified: jmeter/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1519093&r1=1519092&r2=1519093&view=diff
==============================================================================
--- jmeter/trunk/xdocs/changes.xml (original)
+++ jmeter/trunk/xdocs/changes.xml Fri Aug 30 21:40:50 2013
@@ -329,6 +329,7 @@ Previously the default was 1, which coul
 <li><bugzilla>55427</bugzilla> - TestBeanHelper should ignore properties
not supported by GenericTestBeanCustomizer</li>
 <li><bugzilla>55459</bugzilla> - Elements using ComboStringEditor lose
the input value if user selects another Test Element</li>
 <li><bugzilla>54152</bugzilla> - In distributed testing : activeThreads
and totalThreads always show 0</li>
+<li><bugzilla>55509</bugzilla> - Allow Plugins to be notified of remote
thread number progression</li>
 </ul>
 
 <!-- =================== Improvements =================== -->



Mime
View raw message