Remove all InterruptTimer changes

Using a branch instead

git-svn-id: https://svn.apache.org/repos/asf/jmeter/trunk@1700113 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Sebastian Bazley 2015-08-30 12:51:42 +00:00
parent 39a5a12470
commit bdeaf30dc7
8 changed files with 0 additions and 311 deletions

View File

@ -165,8 +165,6 @@ IncludeController=org.apache.jmeter.control.IncludeController
IncludeControllerGui=org.apache.jmeter.control.gui.IncludeControllerGui
InterleaveControl=org.apache.jmeter.control.InterleaveControl
InterleaveControlGui=org.apache.jmeter.control.gui.InterleaveControlGui
InterruptTimer=org.apache.jmeter.timers.InterruptTimer
InterruptTimerGui=org.apache.jmeter.timers.gui.InterruptTimerGui
JavaConfig=org.apache.jmeter.protocol.java.config.JavaConfig
JavaConfigGui=org.apache.jmeter.protocol.java.config.gui.JavaConfigGui
JavaSampler=org.apache.jmeter.protocol.java.sampler.JavaSampler

View File

@ -1,154 +0,0 @@
package org.apache.jmeter.timers;
import java.io.Serializable;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.TimeUnit;
import org.apache.jmeter.engine.event.LoopIterationEvent;
import org.apache.jmeter.engine.event.LoopIterationListener;
import org.apache.jmeter.samplers.Interruptible;
import org.apache.jmeter.samplers.Sampler;
import org.apache.jmeter.testelement.AbstractTestElement;
import org.apache.jmeter.testelement.TestElement;
import org.apache.jmeter.threads.JMeterContext;
import org.apache.jmeter.threads.JMeterContextService;
import org.apache.jmeter.util.JMeterUtils;
import org.apache.jorphan.logging.LoggingManager;
import org.apache.log.Logger;
public class InterruptTimer extends AbstractTestElement implements Timer, Serializable, LoopIterationListener {
private static final long serialVersionUID = 1L;
private static final Logger LOG = LoggingManager.getLoggerForClass();
private static final String TIMEOUT = "InterruptTimer.timeout"; //$NON-NLS-1$
private long timeout = 0;
private JMeterContext context;
private ScheduledFuture<?> future;
private ScheduledExecutorService tpool;
private final boolean debug;
/**
* No-arg constructor.
*/
public InterruptTimer() {
// LOG.setPriority(org.apache.log.Priority.DEBUG); // for local debugging
debug = LOG.isDebugEnabled(); // TODO is this the best place for this?
}
/**
* Set the timeout for this timer.
* @param timeout The timeout for this timer
*/
public void setTimeout(String timeout) {
setProperty(TIMEOUT, timeout);
}
/**
* Get the timeout value for display.
*
* @return the timeout value for display.
*/
public String getTimeout() {
return getPropertyAsString(TIMEOUT);
}
/**
* Retrieve the delay to use during test execution.
* This is called just before starting a sampler.
* It is used to schedule future task to interrupt the sampler.
*
* @return Always returns zero, because this timer does not wait
*/
@Override
public long delay() {
if (debug) {
LOG.debug(whoAmI("delay()", this));
}
if (future != null) {
if (!future.isDone()) {
boolean cancelled = future.cancel(false);
if (debug) {
LOG.debug("Cancelled the task:" + future + " with result " + cancelled);
}
}
future = null;
}
if (timeout <= 0) {
return 0;
}
final Sampler samp = context.getCurrentSampler();
if (!(samp instanceof Interruptible)) {
// Log this?
return 0;
}
final Interruptible sampler = (Interruptible) samp;
Runnable run=new Runnable() {
public void run() {
boolean interrupted = sampler.interrupt();
if (interrupted) {
LOG.warn("Interruped the sampler " + getInfo(samp));
} else {
if (debug) {
LOG.debug("Did not interrupt the sampler " + getInfo(samp));
}
}
}
};
// schedule the interrupt to occur
if (debug) {
LOG.debug("Scheduling timer for " + getInfo(samp));
}
future = tpool.schedule(run, timeout, TimeUnit.MILLISECONDS);
return 0;
}
/**
* Provide a description of this timer class.
*
* @return the description of this timer class.
*/
@Override
public String toString() {
return JMeterUtils.getResString("interrupt_timer_memo"); //$NON-NLS-1$
}
/**
* Gain access to any variables that have been defined.
*
* @see LoopIterationListener#iterationStart(LoopIterationEvent)
*/
@Override
public void iterationStart(LoopIterationEvent event) {
if (debug) {
LOG.debug(whoAmI("iterationStart()", this));
}
timeout = getPropertyAsLong(TIMEOUT);
context = JMeterContextService.getContext(); // TODO is this called from the correct thread?
tpool = Executors.newScheduledThreadPool(1, // ditto
new ThreadFactory() {
public Thread newThread(Runnable r) {
Thread t = Executors.defaultThreadFactory().newThread(r);
t.setDaemon(true);
return t;
}
});
}
private String whoAmI(String id, TestElement o) {
return id + " @" + System.identityHashCode(o)+ " '"+ o.getName() + "'";
}
private String getInfo(TestElement o) {
return whoAmI(o.getClass().getSimpleName(), o);
}
}

View File

@ -1,131 +0,0 @@
/*
* 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.timers.gui;
import javax.swing.Box;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import org.apache.jmeter.testelement.TestElement;
import org.apache.jmeter.timers.InterruptTimer;
import org.apache.jmeter.util.JMeterUtils;
import org.apache.jorphan.gui.layout.VerticalLayout;
/**
* The GUI for InterruptTimer.
*
*/
public class InterruptTimerGui extends AbstractTimerGui {
private static final long serialVersionUID = 240L;
/**
* The default value for the timeout.
*/
private static final String DEFAULT_TIMEOUT = "10000";
private JTextField timeoutField;
/**
* No-arg constructor.
*/
public InterruptTimerGui() {
init();
}
/**
* Handle an error.
*
* @param e
* the Exception that was thrown.
* @param thrower
* the JComponent that threw the Exception.
*/
public static void error(Exception e, JComponent thrower) {
JOptionPane.showMessageDialog(thrower, e, "Error", JOptionPane.ERROR_MESSAGE);
}
@Override
public String getLabelResource() {
return "interrupt_timer_title"; // $NON-NLS-1$
}
/**
* Create the test element underlying this GUI component.
*
* @see org.apache.jmeter.gui.JMeterGUIComponent#createTestElement()
*/
@Override
public TestElement createTestElement() {
InterruptTimer timer = new InterruptTimer();
modifyTestElement(timer);
return timer;
}
/**
* Modifies a given TestElement to mirror the data in the gui components.
*
* @see org.apache.jmeter.gui.JMeterGUIComponent#modifyTestElement(TestElement)
*/
@Override
public void modifyTestElement(TestElement timer) {
this.configureTestElement(timer);
((InterruptTimer) timer).setTimeout(timeoutField.getText());
}
/**
* Configure this GUI component from the underlying TestElement.
*
* @see org.apache.jmeter.gui.JMeterGUIComponent#configure(TestElement)
*/
@Override
public void configure(TestElement el) {
super.configure(el);
timeoutField.setText(((InterruptTimer) el).getTimeout());
}
/**
* Initialize this component.
*/
private void init() {
setLayout(new VerticalLayout(5, VerticalLayout.BOTH, VerticalLayout.TOP));
setBorder(makeBorder());
add(makeTitlePanel());
Box timeoutPanel = Box.createHorizontalBox();
JLabel timeoutLabel = new JLabel(JMeterUtils.getResString("interrupt_timer_timeout"));//$NON-NLS-1$
timeoutPanel.add(timeoutLabel);
timeoutField = new JTextField(6);
timeoutField.setText(DEFAULT_TIMEOUT);
timeoutPanel.add(timeoutField);
add(timeoutPanel);
}
/**
* {@inheritDoc}
*/
@Override
public void clearGui() {
timeoutField.setText(DEFAULT_TIMEOUT);
super.clearGui();
}
}

View File

@ -423,9 +423,6 @@ insert_after=Insert After
insert_before=Insert Before
insert_parent=Insert Parent
interleave_control_title=Interleave Controller
interrupt_timer_memo=Interrupt the sampler if it times out
interrupt_timer_timeout=Sampler timeout (in milliseconds)\:
interrupt_timer_title=Interrupt Timer
intsum_param_1=First int to add.
intsum_param_2=Second int to add - further ints can be summed by adding further arguments.
invalid_data=Invalid data

View File

@ -416,9 +416,6 @@ insert_after=Ins\u00E9rer apr\u00E8s
insert_before=Ins\u00E9rer avant
insert_parent=Ins\u00E9rer en tant que parent
interleave_control_title=Contr\u00F4leur Interleave
interrupt_timer_memo=Interrompre l'\u00E9chantillon si le d\u00E9lai est d\u00E9pass\u00E9
interrupt_timer_timeout=D\u00E9lai d'attente avant interruption (en millisecondes) \:
interrupt_timer_title=Compteur Interruption
intsum_param_1=Premier entier \u00E0 ajouter
intsum_param_2=Deuxi\u00E8me entier \u00E0 ajouter - les entier(s) suivants peuvent \u00EAtre ajout\u00E9(s) avec les arguments suivants.
invalid_data=Donn\u00E9e invalide

View File

@ -104,7 +104,6 @@ Summary
<h3>Timers, Assertions, Config, Pre- &amp; Post-Processors</h3>
<ul>
<li><bug>58299</bug>Add interrupt Timer</li>
</ul>
<h3>Functions</h3>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.9 KiB

View File

@ -5236,23 +5236,6 @@ to the random delay.</property>
</component>
<component name="Interrupt Timer" index="&sect-num;.6.1" anchor="interrupt" width="336" height="148" screenshot="timers/interrupt_timer.png">
<description>
<p>This is not strictly a timer, as it does not cause a delay before a sampler.
Instead it interrupts the sampler if that has taken longer than the timeout.
The timeout is ignored if it is zero or negative.
For this to work, the sampler must implement Interruptible.
The following samplers are known to do so:<br></br>
AJP, BeanShell, FTP, HTTP, Soap, AccessLog, MailReader, JMS Subscriber, TCPSampler, TestAction
</p></description>
<properties>
<property name="Name" required="No">Descriptive name for this timer that is shown in the tree.</property>
<property name="Sampler Timeout" required="Yes">If the sampler takes longer to complete, it will be interrupted.</property>
</properties>
</component>
<a href="#">^</a>
</section>