Apache JMeter
2.0.1.20050615

org.apache.jmeter.protocol.http.sampler
Class AccessLogSampler

java.lang.Object
  extended byorg.apache.jmeter.testelement.AbstractTestElement
      extended byorg.apache.jmeter.samplers.AbstractSampler
          extended byorg.apache.jmeter.protocol.http.sampler.HTTPSamplerBase
              extended byorg.apache.jmeter.protocol.http.sampler.HTTPSampler
                  extended byorg.apache.jmeter.protocol.http.sampler.AccessLogSampler
All Implemented Interfaces:
Cloneable, Sampler, Serializable, TestElement, TestListener

public class AccessLogSampler
extends HTTPSampler

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

Version:
$Revision: 1.8.2.1 $ last updated $Date: 2004/05/20 18:08:54 $
Author:
Peter Lin
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class org.apache.jmeter.protocol.http.sampler.HTTPSampler
HTTPSampler.Test
 
Field Summary
static String DEFAULT_CLASS
           
static String GENERATOR_CLASS_NAME
           
static String LOG_FILE
           
static String PARSER_CLASS_NAME
           
 
Fields inherited from class org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase
ARGUMENTS, AUTH_MANAGER, AUTO_REDIRECTS, CONTENT_TYPE, COOKIE_MANAGER, DEFAULT_HTTP_PORT, DEFAULT_HTTPS_PORT, DEFAULT_PROTOCOL, DOMAIN, FILE_DATA, FILE_FIELD, FILE_MIMETYPE, FILE_NAME, FOLLOW_REDIRECTS, GET, HEADER_MANAGER, IMAGE_PARSER, MAX_FRAME_DEPTH, MAX_REDIRECTS, METHOD, MIMETYPE, MONITOR, MULTIPART_FORM, NON_HTTP_RESPONSE_CODE, NON_HTTP_RESPONSE_MESSAGE, NORMAL_FORM, PATH, PORT, POST, PROTOCOL, UNSPECIFIED_PORT, URL, USE_KEEPALIVE
 
Fields inherited from interface org.apache.jmeter.testelement.TestElement
ENABLED, GUI_CLASS, NAME, TEST_CLASS
 
Constructor Summary
AccessLogSampler()
           
 
Method Summary
 void addEncodedArgument(String name, String value, String metaData)
          We override this to prevent the wrong encoding and provide no implementation.
 boolean checkGenerator()
          Method will instantiate the generator.
 boolean checkParser()
          Method will instantiate the log parser based on the class in the text field.
protected  long connect()
          We override this to prevent the wrong encoding and provide no implementation.
 Generator getGenerator()
          Return the generator
 String getGeneratorClassName()
          Return the name of the generator class to use.
 String getLogFile()
          Get the path where XML messages are stored. this is the directory where JMeter will randomly select a file.
 LogParser getParser()
          Return the parser
 String getParserClassName()
          Get the file location of the xml file.
 void instantiateGenerator()
          Method will instantiate the generator.
 void instantiateParser()
          Method will instantiate the log parser based on the class in the text field.
 SampleResult sample(Entry e)
          sample(Entry e) simply calls sample().
 SampleResult sampleWithGenerator()
          sample gets a new HTTPSampler from the generator and calls it's sample() method.
 void setGenerator(Generator gen)
          Set the generator for the Sampler to use
 void setGeneratorClassName(String classname)
          We give the user the choice of entering their own generator instead of the default generator.
 void setLogFile(String path)
          Set the path where XML messages are stored for random selection.
 void setParser(LogParser parser)
          Set the parser for the sampler to use
 void setParserClassName(String classname)
          it's kinda obvious, but we state it anyways.
protected  HttpURLConnection setupConnection(URL u, String method)
          We override this to prevent the wrong encoding and provide no implementation.
 
Methods inherited from class org.apache.jmeter.protocol.http.sampler.HTTPSampler
disconnect, getResponseHeaders, modifyHeaderValues, readResponse, sample, sendPostData, setPostHeaders, setupConnection
 
Methods inherited from class org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase
addArgument, addArgument, addTestElement, clone, downloadPageResources, encodeSpaces, errorResult, getArguments, getAuthManager, getCookieManager, getDomain, getFileField, getFilename, getFollowRedirects, getHeaderManager, getMethod, getMimetype, getMonitor, getPath, getPort, getProtocol, getQueryString, getUrl, getUseKeepAlive, isImageParser, isMonitor, parseArguments, sample, setArguments, setAuthManager, setCookieManager, setDomain, setFileField, setFilename, setFollowRedirects, setHeaderManager, setImageParser, setMethod, setMimetype, setMonitor, setPath, setPort, setProtocol, setUseKeepAlive, testEnded, testEnded, testIterationStart, testStarted, testStarted, toString
 
Methods inherited from class org.apache.jmeter.testelement.AbstractTestElement
addProperty, canRemove, clear, clearTemporary, emptyTemporary, equals, getName, getProperty, getPropertyAsBoolean, getPropertyAsBoolean, getPropertyAsDouble, getPropertyAsFloat, getPropertyAsInt, getPropertyAsLong, getPropertyAsString, getThreadContext, getThreadName, isRunningVersion, isTemporary, logProperties, mergeIn, nextIsNull, propertyIterator, recoverRunningVersion, removeProperty, setName, setProperty, setProperty, setRunningVersion, setTemporary, setThreadContext, setThreadName, threadFinished, threadStarted, traverse, traverseCollection, traverseMap, traverseProperty
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.apache.jmeter.testelement.TestElement
canRemove, clear, getProperty, getPropertyAsBoolean, getPropertyAsFloat, getPropertyAsInt, getPropertyAsLong, getPropertyAsString, getThreadContext, getThreadName, isRunningVersion, isTemporary, propertyIterator, recoverRunningVersion, removeProperty, setProperty, setProperty, setRunningVersion, setTemporary, setThreadContext, setThreadName, threadFinished, threadStarted, traverse
 

Field Detail

DEFAULT_CLASS

public static final String DEFAULT_CLASS
See Also:
Constant Field Values

LOG_FILE

public static final String LOG_FILE
See Also:
Constant Field Values

PARSER_CLASS_NAME

public static final String PARSER_CLASS_NAME
See Also:
Constant Field Values

GENERATOR_CLASS_NAME

public static final String GENERATOR_CLASS_NAME
See Also:
Constant Field Values
Constructor Detail

AccessLogSampler

public AccessLogSampler()
Method Detail

setLogFile

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


getLogFile

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


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

getParserClassName

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

Returns:
String file path.

setGeneratorClassName

public void setGeneratorClassName(String classname)
We give the user the choice of entering their own generator instead of the default generator. This also has the positive side effect that users can provide their own generators without providing a parser. Things like creating a test plan that randomly generates requests can be support in a simple way for programmers. Non programmers should use existing features to accomplish similar task.

Parameters:
classname -

getGeneratorClassName

public String getGeneratorClassName()
Return the name of the generator class to use.

Returns:
generator class name

setGenerator

public void setGenerator(Generator gen)
Set the generator for the Sampler to use

Parameters:
gen -

getGenerator

public Generator getGenerator()
Return the generator

Returns:
generator

setParser

public void setParser(LogParser parser)
Set the parser for the sampler to use

Parameters:
parser -

getParser

public LogParser getParser()
Return the parser

Returns:
parser

sampleWithGenerator

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


sample

public SampleResult sample(Entry e)
sample(Entry e) simply calls sample().

Specified by:
sample in interface Sampler
Overrides:
sample in class HTTPSamplerBase
Parameters:
e - - ignored
Returns:
the new sample

instantiateGenerator

public void instantiateGenerator()
Method will instantiate the generator. This is done to make it easier for users to extend and plugin their own generators.


checkGenerator

public boolean checkGenerator()
Method will instantiate the generator. This is done to make it easier for users to extend and plugin their own generators.


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.


checkParser

public boolean checkParser()
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.

Returns:
true if parser exists or was created

addEncodedArgument

public void addEncodedArgument(String name,
                               String value,
                               String metaData)
We override this to prevent the wrong encoding and provide no implementation. We want to reuse the other parts of HTTPSampler, but not the connection. The connection is handled by the Apache SOAP driver.

Overrides:
addEncodedArgument in class HTTPSamplerBase

setupConnection

protected HttpURLConnection setupConnection(URL u,
                                            String method)
                                     throws IOException
We override this to prevent the wrong encoding and provide no implementation. We want to reuse the other parts of HTTPSampler, but not the connection. The connection is handled by the Apache SOAP driver.

Throws:
IOException

connect

protected long connect()
                throws IOException
We override this to prevent the wrong encoding and provide no implementation. We want to reuse the other parts of HTTPSampler, but not the connection. The connection is handled by the Apache SOAP driver.

Throws:
IOException

Apache JMeter
2.0.1.20050615

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