jsalvata 2004/01/15 18:31:35
Modified: src/components/org/apache/jmeter/timers
ConstantThroughputTimer.java
bin upgrade.properties
Added: src/components/org/apache/jmeter/timers
ConstantThroughputTimerResources.properties
ConstantThroughputTimerBeanInfo.java
Removed: src/components/org/apache/jmeter/timers/gui
ConstantThroughputTimerGui.java
Log:
Converted ConstantThroughputTimer into a TestBean. Woohoo!
Revision Changes Path
1.10 +57 -59
jakarta-jmeter/src/components/org/apache/jmeter/timers/ConstantThroughputTimer.java
Index: ConstantThroughputTimer.java
===================================================================
RCS file:
/home/cvs/jakarta-jmeter/src/components/org/apache/jmeter/timers/ConstantThroughputTimer.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- ConstantThroughputTimer.java 14 Jan 2004 23:27:27 -0000 1.9
+++ ConstantThroughputTimer.java 16 Jan 2004 02:31:35 -0000 1.10
@@ -54,10 +54,12 @@
*/
package org.apache.jmeter.timers;
-import java.io.Serializable;
-
-import org.apache.jmeter.testelement.AbstractTestElement;
+import org.apache.jmeter.engine.event.LoopIterationEvent;
+import org.apache.jmeter.testbeans.TestBean;
+import org.apache.jmeter.testelement.TestListener;
import org.apache.jmeter.util.JMeterUtils;
+import org.apache.jorphan.logging.LoggingManager;
+import org.apache.log.Logger;
/**
* This class implements a constant throughput timer. A Constant Throughtput
@@ -69,11 +71,11 @@
* @version $Id$
*/
public class ConstantThroughputTimer
- extends AbstractTestElement
- implements Timer, Serializable
+ extends TestBean
+ implements Timer, TestListener
{
- public final static String THROUGHPUT= "ConstantThroughputTimer.throughput";
-
+ protected static final Logger log = LoggingManager.getLoggerForClass();
+
/**
* Target time for the start of the next request. The delay provided by
* the timer will be calculated so that the next request happens at this
@@ -81,6 +83,11 @@
*/
private long targetTime= 0;
+ /**
+ * Desired throughput, in samples per minute.
+ */
+ private double throughput;
+
/**
* Constructor for a non-configured ConstantThroughputTimer.
*/
@@ -93,39 +100,9 @@
*
* @param throughput Desired sampling rate, in samples per minute.
*/
- public void setThroughput(String throughput)
- {
- setProperty(THROUGHPUT,throughput);
- }
-
- /**
- * Not implemented.
- */
- public void setRange(double range)
- {
- }
-
- /**
- * Not implemented.
- */
- public double getRange()
- {
- return (double)0;
- }
-
- /**
- * Not implemented.
- */
- public void setDelay(String delay)
- {
- }
-
- /**
- * Not implemented.
- */
- public String getDelay()
+ public void setThroughput(double throughput)
{
- return "";
+ this.throughput= throughput;
}
/**
@@ -133,16 +110,11 @@
*
* @return the rate at which samples should occur, in samples per minute.
*/
- public long getThroughput()
+ public double getThroughput()
{
- return getPropertyAsLong(THROUGHPUT);
+ return throughput;
}
- public String getThroughputString()
- {
- return getPropertyAsString(THROUGHPUT);
- }
-
/**
* Retrieve the delay to use during test execution.
*
@@ -150,9 +122,11 @@
*/
public synchronized long delay()
{
+ prepare();
+
long currentTime = System.currentTimeMillis();
long currentTarget = targetTime == 0 ? currentTime : targetTime;
- targetTime = currentTarget + 60000 / getThroughput();
+ targetTime = currentTarget + (long)( 60000.0 / getThroughput() );
if (currentTime > currentTarget)
{
// We're behind schedule -- try to catch up:
@@ -172,17 +146,41 @@
}
/**
- * Creates a copy of this ConstantThroughputTimer, ready to start
- * calculating delays for new samples. This is in assumption that cloning
- * always happens just before a test starts running.
- *
- * @return a fresh copy of this ConstantThroughputTimer
+ * Get the timer ready to compute delays for a new test.
+ *
+ * @see org.apache.jmeter.testelement.TestListener#testStarted()
+ */
+ public void testStarted()
+ {
+ log.debug("Test started - reset throughput calculation.");
+ targetTime= 0;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.jmeter.testelement.TestListener#testEnded()
+ */
+ public void testEnded()
+ {
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.jmeter.testelement.TestListener#testStarted(java.lang.String)
+ */
+ public void testStarted(String host)
+ {
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.jmeter.testelement.TestListener#testEnded(java.lang.String)
+ */
+ public void testEnded(String host)
+ {
+ }
+
+ /* (non-Javadoc)
+ * @see
org.apache.jmeter.testelement.TestListener#testIterationStart(org.apache.jmeter.engine.event.LoopIterationEvent)
*/
- public Object clone()
+ public void testIterationStart(LoopIterationEvent event)
{
- ConstantThroughputTimer result =
- (ConstantThroughputTimer) super.clone();
- result.targetTime = 0;
- return result;
}
-}
+}
\ No newline at end of file
1.1
jakarta-jmeter/src/components/org/apache/jmeter/timers/ConstantThroughputTimerResources.properties
Index: ConstantThroughputTimerResources.properties
===================================================================
displayName=Constant Throughput Timer
delay.displayName=Delay before each affected sampler
throughput.displayName=Throughput (samples per minute)
throughput.shortDescription=Maximum number of samples per minute you want to obtain
per thread from all affected samplers.
1.1
jakarta-jmeter/src/components/org/apache/jmeter/timers/ConstantThroughputTimerBeanInfo.java
Index: ConstantThroughputTimerBeanInfo.java
===================================================================
/*
* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2004 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache JMeter" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* "Apache JMeter", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Jordi Salvat i Alabart</a>
* @version $Id: ConstantThroughputTimerBeanInfo.java,v 1.1 2004/01/16 02:31:35
jsalvata Exp $
*/
package org.apache.jmeter.timers;
import java.beans.PropertyDescriptor;
import org.apache.jmeter.testbeans.gui.BeanInfoSupport;
public class ConstantThroughputTimerBeanInfo extends BeanInfoSupport
{
public ConstantThroughputTimerBeanInfo()
{
super(ConstantThroughputTimer.class);
createPropertyGroup("delay", new String[] { "throughput" });
PropertyDescriptor p= property("throughput");
p.setValue(NOT_UNDEFINED, Boolean.TRUE);
p.setValue(DEFAULT, new Double(0.0));
}
}
1.4 +14 -1 jakarta-jmeter/bin/upgrade.properties
Index: upgrade.properties
===================================================================
RCS file: /home/cvs/jakarta-jmeter/bin/upgrade.properties,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- upgrade.properties 7 Nov 2003 13:17:03 -0000 1.3
+++ upgrade.properties 16 Jan 2004 02:31:35 -0000 1.4
@@ -1,4 +1,17 @@
+# Class, property and value upgrade equivalences.
+#
+# Format is as follows --
+# for renamed test element & GUI classes:
+# old.class.Name=new.class.Name
+# for renamed properties:
+# old.class.Name/Old.propertyName=newPropertyName
+# for renamed values:
+# old.class.Name.old.propertyName/oldValue=newValue
+#
org.apache.jmeter.protocol.http.config.gui.UrlConfigGui=org.apache.jmeter.protocol.http.config.gui.HttpDefaultsGui
org.apache.jmeter.assertions.Assertion=org.apache.jmeter.assertions.ResponseAssertion
org.apache.jmeter.protocol.http.sampler.HTTPSamplerFull=org.apache.jmeter.protocol.http.sampler.HTTPSampler
-org.apache.jmeter.control.gui.RecordController=org.apache.jmeter.protocol.http.control.gui.RecordController
\ No newline at end of file
+org.apache.jmeter.control.gui.RecordController=org.apache.jmeter.protocol.http.control.gui.RecordController
+
+org.apache.jmeter.timers.gui.ConstantThroughputTimerGui=org.apache.jmeter.testbeans.gui.TestBeanGUI
+org.apache.jmeter.timers.ConstantThroughputTimer/ConstantThroughputTimer.throughput=throughput
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]