Author: sebb
Date: Sun Nov 11 12:22:05 2007
New Revision: 593947
URL: http://svn.apache.org/viewvc?rev=593947&view=rev
Log:
Allow hostname to be saved/restored from CSV files
Modified:
jakarta/jmeter/trunk/bin/jmeter.properties
jakarta/jmeter/trunk/src/core/org/apache/jmeter/reporters/ResultCollector.java
jakarta/jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties
jakarta/jmeter/trunk/src/core/org/apache/jmeter/samplers/SampleSaveConfiguration.java
jakarta/jmeter/trunk/src/core/org/apache/jmeter/save/OldSaveService.java
jakarta/jmeter/trunk/src/core/org/apache/jmeter/save/converters/SampleSaveConfigurationConverter.java
Modified: jakarta/jmeter/trunk/bin/jmeter.properties
URL:
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/bin/jmeter.properties?rev=593947&r1=593946&r2=593947&view=diff
==============================================================================
--- jakarta/jmeter/trunk/bin/jmeter.properties (original)
+++ jakarta/jmeter/trunk/bin/jmeter.properties Sun Nov 11 12:22:05 2007
@@ -285,6 +285,7 @@
#jmeter.save.saveservice.bytes=true
#jmeter.save.saveservice.url=false
#jmeter.save.saveservice.filename=false
+#jmeter.save.saveservice.hostname=false
#jmeter.save.saveservice.thread_counts=false
#jmeter.save.saveservice.sample_count=false
Modified:
jakarta/jmeter/trunk/src/core/org/apache/jmeter/reporters/ResultCollector.java
URL:
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/core/org/apache/jmeter/reporters/ResultCollector.java?rev=593947&r1=593946&r2=593947&view=diff
==============================================================================
---
jakarta/jmeter/trunk/src/core/org/apache/jmeter/reporters/ResultCollector.java
(original)
+++
jakarta/jmeter/trunk/src/core/org/apache/jmeter/reporters/ResultCollector.java
Sun Nov 11 12:22:05 2007
@@ -206,8 +206,8 @@
lineNumber++;
}
while (line != null) { // Already read 1st line
- SampleResult result =
OldSaveService.makeResultFromDelimitedString(line,saveConfig,lineNumber);
- if (result != null) sendToVisualizer(result);
+ SampleEvent event =
OldSaveService.makeResultFromDelimitedString(line,saveConfig,lineNumber);
+ if (event != null) sendToVisualizer(event);
line = dataReader.readLine();
lineNumber++;
}
@@ -418,6 +418,12 @@
protected void sendToVisualizer(SampleResult r) {
if (getVisualizer() != null) {
getVisualizer().add(r);
+ }
+ }
+
+ private void sendToVisualizer(SampleEvent e) {
+ if (getVisualizer() != null) {
+ getVisualizer().add(e.getResult());
}
}
Modified:
jakarta/jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties
URL:
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties?rev=593947&r1=593946&r2=593947&view=diff
==============================================================================
---
jakarta/jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties
(original)
+++
jakarta/jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties
Sun Nov 11 12:22:05 2007
@@ -632,6 +632,7 @@
save_fieldnames=Save Field Names
save_filename=Save Response Filename
save_graphics=Save Graph
+save_hostname=Save Hostname
save_label=Save Label
save_latency=Save Latency
save_message=Save Response Message
Modified:
jakarta/jmeter/trunk/src/core/org/apache/jmeter/samplers/SampleSaveConfiguration.java
URL:
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/core/org/apache/jmeter/samplers/SampleSaveConfiguration.java?rev=593947&r1=593946&r2=593947&view=diff
==============================================================================
---
jakarta/jmeter/trunk/src/core/org/apache/jmeter/samplers/SampleSaveConfiguration.java
(original)
+++
jakarta/jmeter/trunk/src/core/org/apache/jmeter/samplers/SampleSaveConfiguration.java
Sun Nov 11 12:22:05 2007
@@ -172,6 +172,9 @@
// Save fileName for ResultSaver
private static final String SAVE_FILENAME_PROP =
"jmeter.save.saveservice.filename"; // $NON_NLS-1$
+ // Save hostname for ResultSaver
+ private static final String SAVE_HOSTNAME_PROP =
"jmeter.save.saveservice.hostname"; // $NON_NLS-1$
+
/***************************************************************************
* The name of the property indicating whether the time should be saved.
**************************************************************************/
@@ -212,6 +215,8 @@
private boolean url = _url, bytes = _bytes , fileName = _fileName;
+ private boolean hostname = _hostname;
+
private boolean threadCounts = _threadCounts;
private boolean sampleCount = _sampleCount;
@@ -258,6 +263,8 @@
private static final boolean _fileName;
+ private static final boolean _hostname;
+
private static final boolean _threadCounts;
private static final boolean _sampleCount;
@@ -316,6 +323,8 @@
_fileName =
TRUE.equalsIgnoreCase(props.getProperty(SAVE_FILENAME_PROP, FALSE));
+ _hostname =
TRUE.equalsIgnoreCase(props.getProperty(SAVE_HOSTNAME_PROP, FALSE));
+
_time = TRUE.equalsIgnoreCase(props.getProperty(SAVE_TIME_PROP,
TRUE));
_timeStampFormat = props.getProperty(TIME_STAMP_FORMAT_PROP,
MILLISECONDS);
@@ -381,6 +390,7 @@
encoding = value;
fieldNames = value;
fileName = value;
+ hostname = value;
label = value;
latency = value;
message = value;
@@ -455,6 +465,7 @@
s.url == url &&
s.bytes == bytes &&
s.fileName == fileName &&
+ s.hostname == hostname &&
s.sampleCount == sampleCount &&
s.threadCounts == threadCounts;
@@ -497,6 +508,7 @@
hash = 31 * hash + (url ? 1 : 0);
hash = 31 * hash + (bytes ? 1 : 0);
hash = 31 * hash + (fileName ? 1 : 0);
+ hash = 31 * hash + (hostname ? 1 : 0);
hash = 31 * hash + (threadCounts ? 1 : 0);
hash = 31 * hash + (delimiter != null ? delimiter.hashCode() : 0);
hash = 31 * hash + (formatter != null ? formatter.hashCode() : 0);
@@ -754,5 +766,13 @@
public void setDefaultTimeStampFormat() {
printMilliseconds=_printMilliseconds;
formatter=_formatter;
+ }
+
+ public boolean saveHostname(){
+ return hostname;
+ }
+
+ public void setHostname(boolean save){
+ hostname = save;
}
}
Modified:
jakarta/jmeter/trunk/src/core/org/apache/jmeter/save/OldSaveService.java
URL:
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/core/org/apache/jmeter/save/OldSaveService.java?rev=593947&r1=593946&r2=593947&view=diff
==============================================================================
--- jakarta/jmeter/trunk/src/core/org/apache/jmeter/save/OldSaveService.java
(original)
+++ jakarta/jmeter/trunk/src/core/org/apache/jmeter/save/OldSaveService.java
Sun Nov 11 12:22:05 2007
@@ -109,6 +109,7 @@
private static final String CSV_FILENAME = "Filename"; // $NON-NLS-1$
private static final String CSV_LATENCY = "Latency"; // $NON-NLS-1$
private static final String CSV_ENCODING = "Encoding"; // $NON-NLS-1$
+ private static final String CSV_HOSTNAME = "Hostname"; // $NON-NLS-1$
// Initial config from properties
static private final SampleSaveConfiguration _saveConfig =
SampleSaveConfiguration.staticConfig();
@@ -129,8 +130,6 @@
//////////////////////////////////////////////////////////////////////////////
// Start of CSV methods
- // TODO - move to separate file? If so, remember that some of the
-
/**
* Make a SampleResult given a delimited string.
*
@@ -141,12 +140,13 @@
*
* @throws JMeterError
*/
- public static SampleResult makeResultFromDelimitedString(
+ public static SampleEvent makeResultFromDelimitedString(
final String inputLine,
final SampleSaveConfiguration saveConfig, // may be updated
final long lineNumber) {
SampleResult result = null;
+ String hostname = "";// $NON-NLS-1$
long timeStamp = 0;
long elapsed = 0;
/*
@@ -282,6 +282,10 @@
result.setErrorCount(Integer.parseInt(text));
}
+ if (saveConfig.saveHostname()) {
+ field = CSV_HOSTNAME;
+ hostname = parts[i++];
+ }
} catch (NumberFormatException e) {
log.warn("Error parsing field '" + field + "' at line "
+ lineNumber + " " + e);
@@ -293,7 +297,7 @@
log.warn("Insufficient columns to parse field '" +
field + "' at line " + lineNumber);
throw new JMeterError(e);
}
- return result;
+ return new SampleEvent(result,"",hostname);
}
/**
@@ -398,7 +402,12 @@
text.append(delim);
}
- String resultString = null;
+ if (saveConfig.saveHostname()) {
+ text.append(CSV_HOSTNAME);
+ text.append(delim);
+ }
+
+ String resultString = null;
int size = text.length();
int delSize = delim.length();
@@ -437,6 +446,7 @@
// Both these are needed in the list even though they set the same
variable
headerLabelMethods.put(CSV_SAMPLE_COUNT, new
Functor("setSampleCount"));
headerLabelMethods.put(CSV_ERROR_COUNT, new
Functor("setSampleCount"));
+ headerLabelMethods.put(CSV_HOSTNAME, new Functor("setHostname"));
}
/**
@@ -656,6 +666,11 @@
text.append(delimiter);
}
+ if (saveConfig.saveHostname()) {
+ text.append(event.getHostname());
+ text.append(delimiter);
+ }
+
String resultString = null;
int size = text.length();
int delSize = delimiter.length();
@@ -686,7 +701,14 @@
throw new IOException("Problem using Avalon
Configuration tools");
}
}
-
+
+ /**
+ * Read sampleResult from Avalon XML file.
+ *
+ * @param config Avalon configuration
+ * @return sample result
+ */
+ // Probably no point in converting this to return a SampleEvent
public static SampleResult getSampleResult(Configuration config) {
SampleResult result = new
SampleResult(config.getAttributeAsLong(TIME_STAMP, 0L),
config.getAttributeAsLong(
TIME, 0L));
@@ -775,18 +797,16 @@
return config;
}
- /*
- * TODO - I think this is used for the original test plan format
- * It seems to be rather out of date, as many attributes are missing?
- */
/**
* This method determines the content of the result data that will be
- * stored.
+ * stored for the Avalon XML format.
*
* @param result
* the object containing all of the data that has been
collected.
* @param saveConfig
* the configuration giving the data items to be saved.
+ * N.B. It is rather out of date, as many fields are not saved.
+ * However it is probably not worth updating, as no-one should be using
the format.
*/
public static Configuration getConfiguration(SampleResult result,
SampleSaveConfiguration saveConfig) {
DefaultConfiguration config = new
DefaultConfiguration(SAMPLE_RESULT_TAG_NAME, "JMeter Save Service"); //
$NON-NLS-1$
Modified:
jakarta/jmeter/trunk/src/core/org/apache/jmeter/save/converters/SampleSaveConfigurationConverter.java
URL:
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/core/org/apache/jmeter/save/converters/SampleSaveConfigurationConverter.java?rev=593947&r1=593946&r2=593947&view=diff
==============================================================================
---
jakarta/jmeter/trunk/src/core/org/apache/jmeter/save/converters/SampleSaveConfigurationConverter.java
(original)
+++
jakarta/jmeter/trunk/src/core/org/apache/jmeter/save/converters/SampleSaveConfigurationConverter.java
Sun Nov 11 12:22:05 2007
@@ -44,6 +44,7 @@
// N.B. These must agree with the new member names in
SampleSaveConfiguration
private static final String NODE_FILENAME = "fileName"; // $NON-NLS-1$
+ private static final String NODE_HOSTNAME = "hostname"; // $NON-NLS-1$
private static final String NODE_URL = "url"; // $NON-NLS-1$
private static final String NODE_BYTES = "bytes"; // $NON-NLS-1$
private static final String NODE_THREAD_COUNT = "threadCounts"; //
$NON-NLS-1$
@@ -66,6 +67,7 @@
if (fieldName.equals(NODE_BYTES)) return false;
if (fieldName.equals(NODE_URL)) return false;
if (fieldName.equals(NODE_FILENAME)) return false;
+ if (fieldName.equals(NODE_HOSTNAME)) return false;
if (fieldName.equals(NODE_THREAD_COUNT)) return false;
if (fieldName.equals(NODE_SAMPLE_COUNT)) return false;
@@ -112,6 +114,7 @@
createNode(writer,prop.saveBytes(),NODE_BYTES);
createNode(writer,prop.saveUrl(),NODE_URL);
createNode(writer,prop.saveFileName(),NODE_FILENAME);
+ createNode(writer,prop.saveHostname(),NODE_HOSTNAME);
createNode(writer,prop.saveThreadCounts(),NODE_THREAD_COUNT);
createNode(writer,prop.saveSampleCount(),NODE_SAMPLE_COUNT);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]