|
Apache JMeter | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.jmeter.protocol.http.util.accesslog.TCLogParser
public class TCLogParser
Description:
Currently the parser only handles GET/POST requests. It's easy enough to add
support for other request methods by changing checkMethod. The is a complete
rewrite of a tool I wrote for myself earlier. The older algorithm was basic
and did not provide the same level of flexibility I want, so I wrote a new
one using a totally new algorithm. This implementation reads one line at a
time using BufferedReader. When it gets to the end of the file and the
sampler needs to get more requests, the parser will re-initialize the
BufferedReader. The implementation uses StringTokenizer to create tokens.
The parse algorithm is the following:
Extending this class is fairly simple. Most access logs use the same format starting from the request method. Therefore, changing the implementation of cleanURL(string) method should be sufficient to support new log formats. Tomcat uses common log format, so any webserver that uses the format should work with this parser. Servers that are known to use non standard formats are IIS and Netscape.
Field Summary | |
---|---|
protected boolean |
decode
by default, we probably should decode the parameter values |
protected String |
FILENAME
|
protected Filter |
FILTER
Handles to supporting classes |
static String |
GET
|
static String |
HEAD
|
protected static org.apache.log.Logger |
log
|
static String |
POST
|
protected BufferedReader |
READER
|
protected String |
RMETHOD
protected members * |
protected File |
SOURCE
|
protected String |
URL_PATH
The path to the access log file |
protected boolean |
useFILE
|
Constructor Summary | |
---|---|
TCLogParser()
|
|
TCLogParser(String source)
|
Method Summary | |
---|---|
boolean |
checkMethod(String text)
The method checks for POST and GET methods currently. |
boolean |
checkParamFormat(String text)
Checks the string to see if it contains "&" and "=". |
boolean |
checkURL(String url)
Checks the string to make sure it has /path/file? |
String |
cleanURL(String entry)
The method cleans the URL using the following algorithm. |
void |
close()
close the any streams or readers. |
void |
convertStringToJMRequest(String text,
TestElement el)
Convert a single line into XML |
NVPair[] |
convertStringtoNVPair(String stringparams)
Parse the string parameters into NVPair[] array. |
boolean |
decodeParameterValue()
decode the parameter values is to true by default |
protected int |
parse(BufferedReader breader,
TestElement el,
int parseCount)
The method is responsible for reading each line, and breaking out of the while loop if a set number of lines is given. |
int |
parse(TestElement el,
int parseCount)
parse the entire file. |
int |
parseAndConfigure(int count,
TestElement el)
parse a set number of lines from the access log. |
protected int |
parseLine(String line,
TestElement el)
parseLine calls the other parse methods to parse the given text. |
protected NVPair |
parseOneParameter(String parameter)
Method expects name and value to be separated by an equal sign "=". |
protected List<String> |
parseParameters(String parameters)
Method uses StringTokenizer to convert the string into single pairs. |
void |
setDecodeParameterValues(boolean decodeparams)
by default decode is set to true. if the parameters shouldn't be decoded, call the method with false |
void |
setFilter(Filter filter)
Use the filter to include/exclude files in the access logs. |
void |
setSourceFile(String source)
Sets the source file. |
void |
setUseParsedFile(boolean file)
Calls this method to set whether or not to use the path in the log. |
String |
stripFile(String url,
TestElement el)
Tokenize the URL into two tokens. |
StringTokenizer |
tokenize(String line,
String delim)
Parses the line using java.util.StringTokenizer. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final org.apache.log.Logger log
public static final String GET
public static final String POST
public static final String HEAD
protected String RMETHOD
protected String URL_PATH
protected boolean useFILE
protected File SOURCE
protected String FILENAME
protected BufferedReader READER
protected Filter FILTER
protected boolean decode
Constructor Detail |
---|
public TCLogParser()
public TCLogParser(String source)
source
- Method Detail |
---|
public void setDecodeParameterValues(boolean decodeparams)
decodeparams
- public boolean decodeParameterValue()
public void setUseParsedFile(boolean file)
file
- public void setFilter(Filter filter)
setFilter
in interface LogParser
filter
- public void setSourceFile(String source)
setSourceFile
in interface LogParser
source
- public int parse(TestElement el, int parseCount)
public int parseAndConfigure(int count, TestElement el)
parseAndConfigure
in interface LogParser
count
-
protected int parse(BufferedReader breader, TestElement el, int parseCount)
breader
- protected int parseLine(String line, TestElement el)
line
- public String cleanURL(String entry)
127.0.0.1 - - [08/Jan/2003:07:03:54 -0500] "GET /addrbook/ HTTP/1.1" 200 1981
entry
-
public boolean checkMethod(String text)
text
-
public String stripFile(String url, TestElement el)
url
-
public boolean checkURL(String url)
url
-
public boolean checkParamFormat(String text)
text
-
public void convertStringToJMRequest(String text, TestElement el)
text
- public NVPair[] convertStringtoNVPair(String stringparams)
stringparams
- protected NVPair parseOneParameter(String parameter)
parameter
- to be parsed
protected List<String> parseParameters(String parameters)
parameters
-
public StringTokenizer tokenize(String line, String delim)
line
- line to be parseddelim
- delimiter
public void close()
LogParser
close
in interface LogParser
|
Apache JMeter | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |