You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jmeter.apache.org by se...@apache.org on 2012/12/07 16:52:11 UTC
svn commit: r1418365 - in /jmeter/trunk:
src/core/org/apache/jmeter/resources/
src/protocol/tcp/org/apache/jmeter/protocol/tcp/config/gui/
src/protocol/tcp/org/apache/jmeter/protocol/tcp/sampler/ xdocs/
xdocs/usermanual/
Author: sebb
Date: Fri Dec 7 15:52:08 2012
New Revision: 1418365
URL: http://svn.apache.org/viewvc?rev=1418365&view=rev
Log:
TCP Sampler, additions of "Close Connection", "SO_LINGER" and "End of line(EOL) byte value" options
Bugzilla Id: 54230
Modified:
jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties
jmeter/trunk/src/protocol/tcp/org/apache/jmeter/protocol/tcp/config/gui/TCPConfigGui.java
jmeter/trunk/src/protocol/tcp/org/apache/jmeter/protocol/tcp/sampler/TCPSampler.java
jmeter/trunk/xdocs/changes.xml
jmeter/trunk/xdocs/usermanual/component_reference.xml
Modified: jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties?rev=1418365&r1=1418364&r2=1418365&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties Fri Dec 7 15:52:08 2012
@@ -161,6 +161,7 @@ clear_all=Clear All
clear_cache_per_iter=Clear cache each iteration?
clear_cookies_per_iter=Clear cookies each iteration?
close=Close
+closeconnection=Close connection
column_delete_disallowed=Deleting this column is not permitted
column_number=Column number of CSV file | next | *alias
command_config_box_title=Command to Execute
@@ -251,6 +252,7 @@ endtime=End Time
entry_dn=Entry DN
entrydn=Entry DN
environment_panel_title=Environment Variables
+eolbyte=End of line(EOL) byte value:
error_indicator_tooltip=Show the number of errors in log, click to open Log Viewer panel
error_loading_help=Error loading help page
error_occurred=Error Occurred
@@ -966,6 +968,7 @@ soap_data_title=Soap/XML-RPC Data
soap_sampler_title=SOAP/XML-RPC Request
soap_send_action=Send SOAPAction:
soap_sampler_file_invalid=Filename references a missing or unreadable file\:
+solinger=SO_LINGER:
spline_visualizer_average=Average
spline_visualizer_incoming=Incoming
spline_visualizer_maximum=Maximum
Modified: jmeter/trunk/src/protocol/tcp/org/apache/jmeter/protocol/tcp/config/gui/TCPConfigGui.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/tcp/org/apache/jmeter/protocol/tcp/config/gui/TCPConfigGui.java?rev=1418365&r1=1418364&r2=1418365&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/tcp/org/apache/jmeter/protocol/tcp/config/gui/TCPConfigGui.java (original)
+++ jmeter/trunk/src/protocol/tcp/org/apache/jmeter/protocol/tcp/config/gui/TCPConfigGui.java Fri Dec 7 15:52:08 2012
@@ -19,11 +19,16 @@
package org.apache.jmeter.protocol.tcp.config.gui;
import java.awt.BorderLayout;
+import java.awt.Dimension;
+import java.awt.FlowLayout;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
import javax.swing.JCheckBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextArea;
+import javax.swing.JTextField;
import org.apache.jmeter.config.ConfigTestElement;
import org.apache.jmeter.config.gui.AbstractConfigGui;
@@ -49,6 +54,12 @@ public class TCPConfigGui extends Abstra
private JCheckBox setNoDelay;
+ private JCheckBox closeConnection;
+
+ private JTextField soLinger;
+
+ private JTextField eolByte;
+
private JTextArea requestData;
private boolean displayName = true;
@@ -81,6 +92,9 @@ public class TCPConfigGui extends Abstra
serverPanel.setConnectTimeout(element.getPropertyAsString(TCPSampler.TIMEOUT_CONNECT));
setNoDelay.setSelected(element.getPropertyAsBoolean(TCPSampler.NODELAY));
requestData.setText(element.getPropertyAsString(TCPSampler.REQUEST));
+ closeConnection.setSelected(element.getPropertyAsBoolean(TCPSampler.CLOSE_CONNECTION, TCPSampler.CLOSE_CONNECTION_DEFAULT));
+ soLinger.setText(element.getPropertyAsString(TCPSampler.SO_LINGER));
+ eolByte.setText(element.getPropertyAsString(TCPSampler.EOL_BYTE));
}
@Override
@@ -108,6 +122,9 @@ public class TCPConfigGui extends Abstra
element.setProperty(TCPSampler.TIMEOUT, serverPanel.getResponseTimeout());
element.setProperty(TCPSampler.TIMEOUT_CONNECT, serverPanel.getConnectTimeout(),"");
element.setProperty(TCPSampler.REQUEST, requestData.getText());
+ element.setProperty(TCPSampler.CLOSE_CONNECTION, closeConnection.isSelected(), TCPSampler.CLOSE_CONNECTION_DEFAULT);
+ element.setProperty(TCPSampler.SO_LINGER, soLinger.getText(), "");
+ element.setProperty(TCPSampler.EOL_BYTE, eolByte.getText(), "");
}
/**
@@ -122,6 +139,9 @@ public class TCPConfigGui extends Abstra
requestData.setText(""); //$NON-NLS-1$
reUseConnection.setSelected(true);
setNoDelay.setSelected(false);
+ closeConnection.setSelected(TCPSampler.CLOSE_CONNECTION_DEFAULT);
+ soLinger.setText(""); //$NON-NLS-1$
+ eolByte.setText(""); //$NON-NLS-1$
}
@@ -131,9 +151,9 @@ public class TCPConfigGui extends Abstra
setNoDelay = new JCheckBox();
label.setLabelFor(setNoDelay);
- JPanel nodelayPanel = new JPanel(new BorderLayout(5, 0));
- nodelayPanel.add(label, BorderLayout.WEST);
- nodelayPanel.add(setNoDelay, BorderLayout.CENTER);
+ JPanel nodelayPanel = new JPanel(new FlowLayout());
+ nodelayPanel.add(label);
+ nodelayPanel.add(setNoDelay);
return nodelayPanel;
}
@@ -141,14 +161,62 @@ public class TCPConfigGui extends Abstra
JLabel label = new JLabel(JMeterUtils.getResString("reuseconnection")); //$NON-NLS-1$
reUseConnection = new JCheckBox("", true);
+ reUseConnection.addItemListener(new ItemListener() {
+ @Override
+ public void itemStateChanged(final ItemEvent e) {
+ if (e.getStateChange() == ItemEvent.SELECTED) {
+ closeConnection.setEnabled(true);
+ } else {
+ closeConnection.setEnabled(false);
+ }
+ }
+ });
label.setLabelFor(reUseConnection);
- JPanel closePortPanel = new JPanel(new BorderLayout(5, 0));
- closePortPanel.add(label, BorderLayout.WEST);
- closePortPanel.add(reUseConnection, BorderLayout.CENTER);
+ JPanel closePortPanel = new JPanel(new FlowLayout());
+ closePortPanel.add(label);
+ closePortPanel.add(reUseConnection);
return closePortPanel;
}
+ private JPanel createCloseConnectionPanel() {
+ JLabel label = new JLabel(JMeterUtils.getResString("closeconnection")); // $NON-NLS-1$
+
+ closeConnection = new JCheckBox("", false);
+ label.setLabelFor(closeConnection);
+
+ JPanel closeConnectionPanel = new JPanel(new FlowLayout());
+ closeConnectionPanel.add(label);
+ closeConnectionPanel.add(closeConnection);
+ return closeConnectionPanel;
+ }
+
+ private JPanel createSoLingerOption() {
+ JLabel label = new JLabel(JMeterUtils.getResString("solinger")); //$NON-NLS-1$
+
+ soLinger = new JTextField(5); // 5 columns size
+ soLinger.setMaximumSize(new Dimension(soLinger.getPreferredSize()));
+ label.setLabelFor(soLinger);
+
+ JPanel soLingerPanel = new JPanel(new FlowLayout());
+ soLingerPanel.add(label);
+ soLingerPanel.add(soLinger);
+ return soLingerPanel;
+ }
+
+ private JPanel createEolBytePanel() {
+ JLabel label = new JLabel(JMeterUtils.getResString("eolbyte")); //$NON-NLS-1$
+
+ eolByte = new JTextField(3); // 3 columns size
+ eolByte.setMaximumSize(new Dimension(eolByte.getPreferredSize()));
+ label.setLabelFor(eolByte);
+
+ JPanel eolBytePanel = new JPanel(new FlowLayout());
+ eolBytePanel.add(label);
+ eolBytePanel.add(eolByte);
+ return eolBytePanel;
+ }
+
private JPanel createRequestPanel() {
JLabel reqLabel = new JLabel(JMeterUtils.getResString("tcp_request_data")); // $NON-NLS-1$
requestData = new JTextArea(3, 0);
@@ -193,7 +261,10 @@ public class TCPConfigGui extends Abstra
HorizontalPanel optionsPanel = new HorizontalPanel();
optionsPanel.add(createClosePortPanel());
+ optionsPanel.add(createCloseConnectionPanel());
optionsPanel.add(createNoDelayPanel());
+ optionsPanel.add(createSoLingerOption());
+ optionsPanel.add(createEolBytePanel());
mainPanel.add(optionsPanel);
mainPanel.add(createRequestPanel());
Modified: jmeter/trunk/src/protocol/tcp/org/apache/jmeter/protocol/tcp/sampler/TCPSampler.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/tcp/org/apache/jmeter/protocol/tcp/sampler/TCPSampler.java?rev=1418365&r1=1418364&r2=1418365&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/tcp/org/apache/jmeter/protocol/tcp/sampler/TCPSampler.java (original)
+++ jmeter/trunk/src/protocol/tcp/org/apache/jmeter/protocol/tcp/sampler/TCPSampler.java Fri Dec 7 15:52:08 2012
@@ -82,6 +82,14 @@ public class TCPSampler extends Abstract
public static final String REQUEST = "TCPSampler.request"; //$NON-NLS-1$
public static final String RE_USE_CONNECTION = "TCPSampler.reUseConnection"; //$NON-NLS-1$
+
+ public static final String CLOSE_CONNECTION = "TCPSampler.closeConnection"; //$NON-NLS-1$
+ public static final boolean CLOSE_CONNECTION_DEFAULT = false;
+
+ public static final String SO_LINGER = "TCPSampler.soLinger"; //$NON-NLS-1$
+
+ public static final String EOL_BYTE = "TCPSampler.EolByte"; //$NON-NLS-1$
+
//-- JMX file constants - do not change
private static final String TCPKEY = "TCP"; //$NON-NLS-1$ key for HashMap
@@ -168,6 +176,9 @@ public class TCPSampler extends Abstract
closeSocket(socketKey); // Bug 44910 - close previous socket (if any)
SocketAddress sockaddr = new InetSocketAddress(getServer(), getPort());
con = new Socket();
+ if (getPropertyAsString(SO_LINGER,"").length() > 0){
+ con.setSoLinger(true, getSoLinger());
+ }
con.connect(sockaddr, getConnectTimeout());
if(log.isDebugEnabled()) {
log.debug("Created new connection " + con); //$NON-NLS-1$
@@ -228,6 +239,31 @@ public class TCPSampler extends Abstract
return getPropertyAsBoolean(RE_USE_CONNECTION);
}
+ public void setCloseConnection(String close) {
+ this.setProperty(CLOSE_CONNECTION, close, "");
+ }
+
+ public boolean isCloseConnection() {
+ return getPropertyAsBoolean(CLOSE_CONNECTION, CLOSE_CONNECTION_DEFAULT);
+ }
+
+ public void setSoLinger(String soLinger) {
+ this.setProperty(SO_LINGER, soLinger, "");
+ }
+
+ public int getSoLinger() {
+ return getPropertyAsInt(SO_LINGER);
+ }
+
+ public void setEolByte(String eol) {
+ this.setProperty(EOL_BYTE, eol, "");
+ }
+
+ public int getEolByte() {
+ return getPropertyAsInt(EOL_BYTE);
+ }
+
+
public void setPort(String newFilename) {
this.setProperty(PORT, newFilename);
}
@@ -323,6 +359,11 @@ public class TCPSampler extends Abstract
}
try {
TCPClient = (TCPClient) javaClass.newInstance();
+ if (getPropertyAsString(EOL_BYTE, "").length()>0){
+ TCPClient.setEolByte(getEolByte());
+ log.info("Using eolByte=" + getEolByte());
+ }
+
if (log.isDebugEnabled()) {
log.debug(this + "Created: " + getClassname() + "@" + Integer.toHexString(TCPClient.hashCode())); //$NON-NLS-1$
}
@@ -381,7 +422,7 @@ public class TCPSampler extends Abstract
// Set if we were successful or not
res.setSuccessful(isSuccessful);
- if (!isReUseConnection()) {
+ if (!isReUseConnection() || isCloseConnection()) {
closeSocket(socketKey);
}
}
Modified: jmeter/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1418365&r1=1418364&r2=1418365&view=diff
==============================================================================
--- jmeter/trunk/xdocs/changes.xml (original)
+++ jmeter/trunk/xdocs/changes.xml Fri Dec 7 15:52:08 2012
@@ -172,6 +172,7 @@ and right angle bracket (>) in search
<li><bugzilla>54106</bugzilla> - JSR223TestElement should check for file existence when a filename is set instead of using Text Area content </li>
<li><bugzilla>54107</bugzilla> - JSR223TestElement : Enable compilation and caching of Script Text</li>
<li><bugzilla>54109</bugzilla> - JSR223TestElement : SampleResult properties should be set before entering script to allow user setting different code</li>
+<li><bugzilla>54230</bugzilla> - TCP Sampler, additions of "Close Connection", "SO_LINGER" and "End of line(EOL) byte value" options</li>
</ul>
<h3>Controllers</h3>
Modified: jmeter/trunk/xdocs/usermanual/component_reference.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/usermanual/component_reference.xml?rev=1418365&r1=1418364&r2=1418365&view=diff
==============================================================================
--- jmeter/trunk/xdocs/usermanual/component_reference.xml (original)
+++ jmeter/trunk/xdocs/usermanual/component_reference.xml Fri Dec 7 15:52:08 2012
@@ -1255,6 +1255,8 @@ e.g. props.get("START.HMS"); props.put("
If "Re-use connection" is selected, connections are shared between Samplers in the same thread,
provided that the exact same host name string and port are used.
Different hosts/port combinations will use different connections, as will different threads.
+ If both of "Re-use connection" and "Close connetion" are selected, the socket will be closed after running the sampler.
+ On the next sampler, another socket will be created. You may want to close a socket at the end of each thread loop.
<br></br>
If an error is detected - or "Re-use connection" is not selected - the socket is closed.
Another socket will be reopened on the next sample.
@@ -1329,6 +1331,9 @@ e.g. props.get("START.HMS"); props.put("
<property name="ServerName or IP" required="Yes">Name or IP of TCP server</property>
<property name="Port Number" required="Yes">Port to be used</property>
<property name="Re-use connection" required="Yes">If selected, the connection is kept open. Otherwise it is closed when the data has been read.</property>
+ <property name="Close connection" required="Yes">If selected, the connection will be closed after running the sampler.</property>
+ <property name="SO_LINGER" required="No">Enable/disable SO_LINGER with the specified linger time in seconds when a socket is created. If you set "SO_LINGER" value as 0, you may prevent large numbers of sockets sitting around with a TIME_WAIT status.</property>
+ <property name="End of line(EOL) byte value" required="No">Byte value for end of line, set this to a value outside the range -128 to +127 to skip eol checking. You may set this in jmeter.properties file as well with eolByte property. If you set this in TCP Sampler Config and in jmeter.properties file at the same time, the setting value in the TCP Sampler Config will be used.</property>
<property name="Connect Timeout" required="No">Connect Timeout (milliseconds, 0 disables).</property>
<property name="Response Timeout" required="No">Response Timeout (milliseconds, 0 disables).</property>
<property name="Set Nodelay" required="Yes">See java.net.Socket.setTcpNoDelay().
@@ -3740,6 +3745,9 @@ To make JMeter use more than one certifi
<property name="ServerName or IP" required="">Name or IP of TCP server</property>
<property name="Port Number" required="">Port to be used</property>
<property name="Re-use connection" required="Yes">If selected, the connection is kept open. Otherwise it is closed when the data has been read.</property>
+ <property name="Close connection" required="Yes">If selected, the connection will be closed after running the sampler.</property>
+ <property name="SO_LINGER" required="No">Enable/disable SO_LINGER with the specified linger time in seconds when a socket is created. If you set "SO_LINGER" value as 0, you may prevent large numbers of sockets sitting around with a TIME_WAIT status.</property>
+ <property name="End of line(EOL) byte value" required="No">Byte value for end of line, set this to a value outside the range -128 to +127 to skip eol checking. You may set this in jmeter.properties file as well with eolByte property. If you set this in TCP Sampler Config and in jmeter.properties file at the same time, the setting value in the TCP Sampler Config will be used.</property>
<property name="Connect Timeout" required="No">Connect Timeout (milliseconds, 0 disables).</property>
<property name="Response Timeout" required="No">Response Timeout (milliseconds, 0 disables).</property>
<property name="Set Nodelay" required="">Should the nodelay property be set?</property>