org.apache.jmeter.protocol.http.sampler

Class AccessLogSampler

Implemented Interfaces:
Cloneable, HTTPConstantsInterface, Interruptible, Sampler, Serializable, TestBean, TestElement, TestListener, ThreadListener

public class AccessLogSampler
extends HTTPSampler
implements TestBean, ThreadListener

Description:

AccessLogSampler is responsible for a couple of things:

The intent of this sampler is it uses the generator and parser to create a HTTPSampler when it is needed. It does not contain logic about how to parse the logs. It also doesn't care how Generator is implemented, as long as it implements the interface. This means a person could simply implement a dummy parser to generate random parameters and the generator consumes the results. This wasn't the original intent of the sampler. I originaly wanted to write this sampler, so that I can take production logs to simulate production traffic in a test environment. Doing so is desirable to study odd or unusual behavior. It's also good to compare a new system against an existing system to get near apples- to-apples comparison. I've been asked if benchmarks are really fair comparisons just about every single time, so this helps me accomplish that task.

Some bugs only appear under production traffic, so it is useful to generate traffic using production logs. This way, JMeter can record when problems occur and provide a way to match the server logs.

Created on: Jun 26, 2003

Field Summary

static String
DEFAULT_CLASS

Fields inherited from class org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase

ARGUMENTS, AUTH_MANAGER, AUTO_REDIRECTS, CACHE_MANAGER, CLIENT, CONNECT_TIMEOUT, CONTENT_ENCODING, CONTENT_TYPE, COOKIE_MANAGER, DEFAULT_METHOD, DOMAIN, DO_MULTIPART_POST, EMBEDDED_URL_RE, FOLLOW_REDIRECTS, HEADER_MANAGER, IMAGE_PARSER, IMPLEMENTATION, MAX_FRAME_DEPTH, MAX_REDIRECTS, METHOD, MONITOR, NON_HTTP_RESPONSE_CODE, NON_HTTP_RESPONSE_MESSAGE, PATH, PORT, PROTOCOL, RESPONSE_TIMEOUT, UNSPECIFIED_PORT, UNSPECIFIED_PORT_AS_STRING, URL, URL_UNSPECIFIED_PORT, URL_UNSPECIFIED_PORT_AS_STRING, USE_KEEPALIVE

Fields inherited from interface org.apache.jmeter.protocol.http.util.HTTPConstantsInterface

APPLICATION_X_WWW_FORM_URLENCODED, CONNECTION_CLOSE, DEFAULT_HTTPS_PORT, DEFAULT_HTTPS_PORT_STRING, DEFAULT_HTTP_PORT, DEFAULT_HTTP_PORT_STRING, DELETE, ENCODING_GZIP, ETAG, GET, HEAD, HEADER_AUTHORIZATION, HEADER_CONNECTION, HEADER_CONTENT_DISPOSITION, HEADER_CONTENT_ENCODING, HEADER_CONTENT_LENGTH, HEADER_CONTENT_TYPE, HEADER_COOKIE, HEADER_LOCATION, HEADER_SET_COOKIE, HTTP_1_1, IF_MODIFIED_SINCE, IF_NONE_MATCH, KEEP_ALIVE, LAST_MODIFIED, MULTIPART_FORM_DATA, OPTIONS, POST, PROTOCOL_HTTP, PROTOCOL_HTTPS, PUT, TRACE, TRANSFER_ENCODING

Fields inherited from interface org.apache.jmeter.testelement.TestElement

COMMENTS, ENABLED, GUI_CLASS, NAME, TEST_CLASS

Constructor Summary

AccessLogSampler()

Method Summary

Object
clone()
String
getDomain()
String
getFilterClassName()
String
getLogFile()
Get the path where XML messages are stored. this is the directory where JMeter will randomly select a file.
String
getParserClassName()
Get the file location of the xml file.
String
getPortString()
protected void
initFilter()
void
instantiateParser()
Method will instantiate the log parser based on the class in the text field.
boolean
isImageParsing()
SampleResult
sample(Entry e)
sample(Entry e) simply calls sample().
SampleResult
sampleWithParser()
sample gets a new HTTPSampler from the generator and calls it's sample() method.
void
setDomain(String domain)
void
setFilterClassName(String filterClassName)
void
setImageParsing(boolean imageParsing)
void
setLogFile(String path)
Set the path where XML messages are stored for random selection.
void
setParserClassName(String classname)
it's kinda obvious, but we state it anyways.
void
setPortString(String port)
void
testEnded()
void
testStarted()
void
threadFinished()
Called once for each thread at the end of a test

Methods inherited from class org.apache.jmeter.protocol.http.sampler.HTTPSampler

disconnect, getResponseHeaders, interrupt, readResponse, sample, sendPostData, setPostHeaders, setupConnection

Methods inherited from class org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase

addArgument, addArgument, addEncodedArgument, addEncodedArgument, addEncodedArgument, addNonEncodedArgument, addTestElement, clone, downloadPageResources, encodeBackSlashes, encodeSpaces, errorResult, followRedirects, getArguments, getAuthManager, getAutoRedirects, getCacheManager, getClient, getConnectTimeout, getContentEncoding, getCookieManager, getDefaultPort, getDoMultipartPost, getDomain, getEmbeddedUrlRE, getFileField, getFilename, getFollowRedirects, getHTTPFileCount, getHTTPFiles, getHeaderManager, getImplementation, getMethod, getMimetype, getMonitor, getPath, getPort, getPortIfSpecified, getProtocol, getQueryString, getQueryString, getResponseTimeout, getSendFileAsPostBody, getSendParameterValuesAsPostBody, getUrl, getUseKeepAlive, getUseMultipartForPost, getValidMethodsAsArray, hasArguments, isImageParser, isMonitor, isProtocolDefaultPort, isSecure, isSecure, isSuccessCode, parseArguments, parseArguments, readResponse, resultProcessing, sample, sample, sample, setArguments, setAuthManager, setAutoRedirects, setCacheManager, setClient, setConnectTimeout, setContentEncoding, setCookieManager, setDoMultipartPost, setDomain, setEmbeddedUrlRE, setFileField, setFilename, setFollowRedirects, setHTTPFiles, setHeaderManager, setImageParser, setImplementation, setMD5, setMethod, setMimetype, setMonitor, setMonitor, setPath, setPath, setPort, setProtocol, setResponseTimeout, setUseKeepAlive, testEnded, testEnded, testIterationStart, testStarted, testStarted, threadFinished, threadStarted, toString, useMD5

Methods inherited from class org.apache.jmeter.testelement.AbstractTestElement

addProperty, addTestElement, canRemove, clear, clearTemporary, clone, emptyTemporary, equals, getComment, getName, getProperty, getPropertyAsBoolean, getPropertyAsBoolean, getPropertyAsDouble, getPropertyAsFloat, getPropertyAsInt, getPropertyAsInt, getPropertyAsLong, getPropertyAsString, getPropertyAsString, getThreadContext, getThreadName, hashCode, isEnabled, isRunningVersion, isTemporary, logProperties, mergeIn, propertyIterator, recoverRunningVersion, removeProperty, setComment, setName, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setRunningVersion, setTemporary, setThreadContext, setThreadName, traverse, traverseCollection, traverseMap, traverseProperty

Field Details

DEFAULT_CLASS

public static final String DEFAULT_CLASS

Constructor Details

AccessLogSampler

public AccessLogSampler()

Method Details

clone

public Object clone()
Specified by:
clone in interface TestElement
Overrides:
clone in interface HTTPSamplerBase

getDomain

public String getDomain()
Overrides:
getDomain in interface HTTPSamplerBase
Returns:
Returns the domain.

getFilterClassName

public String getFilterClassName()
Returns:
Returns the filterClassName.

getLogFile

public String getLogFile()
Get the path where XML messages are stored. this is the directory where JMeter will randomly select a file.

getParserClassName

public String getParserClassName()
Get the file location of the xml file.
Returns:
String file path.

getPortString

public String getPortString()
Returns:
Returns the port.

initFilter

protected void initFilter()

instantiateParser

public void instantiateParser()
Method will instantiate the log parser based on the class in the text field. This was done to make it easier for people to plugin their own log parser and use different log parser.

isImageParsing

public boolean isImageParsing()
Returns:
Returns the imageParsing.

sample

public SampleResult sample(Entry e)
sample(Entry e) simply calls sample().
Specified by:
sample in interface Sampler
Overrides:
sample in interface HTTPSamplerBase
Parameters:
e - - ignored
Returns:
the new sample

sampleWithParser

public SampleResult sampleWithParser()
sample gets a new HTTPSampler from the generator and calls it's sample() method.

setDomain

public void setDomain(String domain)
Overrides:
setDomain in interface HTTPSamplerBase
Parameters:
domain - The domain to set.

setFilterClassName

public void setFilterClassName(String filterClassName)
Parameters:
filterClassName - The filterClassName to set.

setImageParsing

public void setImageParsing(boolean imageParsing)
Parameters:
imageParsing - The imageParsing to set.

setLogFile

public void setLogFile(String path)
Set the path where XML messages are stored for random selection.

setParserClassName

public void setParserClassName(String classname)
it's kinda obvious, but we state it anyways. Set the xml file with a string path.
Parameters:
classname - - parser class name

setPortString

public void setPortString(String port)
Parameters:
port - The port to set.

testEnded

public void testEnded()
Specified by:
testEnded in interface TestListener
Overrides:
testEnded in interface HTTPSamplerBase

testStarted

public void testStarted()
Specified by:
testStarted in interface TestListener
Overrides:
testStarted in interface HTTPSamplerBase

threadFinished

public void threadFinished()
Called once for each thread at the end of a test
Specified by:
threadFinished in interface ThreadListener
Overrides:
threadFinished in interface HTTPSamplerBase
See Also:
org.apache.jmeter.threads.JMeterThread.threadFinished()

Copyright © 1998-2010 Apache Software Foundation. All Rights Reserved.