|
Apache JMeter 2.0.1.20050615 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.jmeter.protocol.http.util.accesslog.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.
Nested Class Summary | |
static class |
TCLogParser.Test
|
Field Summary | |
protected int |
COUNT
A counter used by the parser. |
protected String |
FILENAME
|
protected Filter |
FILTER
|
protected Generator |
GEN
Handles to supporting classes |
static String |
GET
|
protected int |
PARSECOUNT
the number of lines the user wishes to parse |
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)
Convert a single line into XML |
NVPair[] |
convertStringtoNVPair(String stringparams)
Parse the string parameters into NVPair[] array. |
File |
openFile(String filename)
Creates a new File object. |
boolean |
parse()
parse the entire file. |
protected void |
parse(BufferedReader breader)
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(int count)
parse a set number of lines from the access log. |
protected void |
parseLine(String line)
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 Vector |
parseParameters(String parameters)
Method uses StringTokenizer to convert the string into single pairs. |
void |
setFilter(Filter filter)
Use the filter to include/exclude files in the access logs. |
void |
setGenerator(Generator generator)
Set the Generator |
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)
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 |
public static final String GET
public static final String POST
protected String RMETHOD
protected String URL_PATH
protected int COUNT
protected int PARSECOUNT
protected boolean useFILE
protected File SOURCE
protected String FILENAME
protected BufferedReader READER
protected Generator GEN
protected Filter FILTER
Constructor Detail |
public TCLogParser()
public TCLogParser(String source)
source
- Method Detail |
public void setGenerator(Generator generator)
setGenerator
in interface LogParser
generator
- 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 File openFile(String filename)
filename
- public boolean parse()
public int parse(int count)
parse
in interface LogParser
count
-
protected void parse(BufferedReader breader)
breader
- protected void parseLine(String line)
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)
url
-
public boolean checkURL(String url)
url
-
public boolean checkParamFormat(String text)
text
-
public void convertStringToJMRequest(String text)
text
- public NVPair[] convertStringtoNVPair(String stringparams)
stringparams
- protected NVPair parseOneParameter(String parameter)
parameter
- to be parsed
protected Vector 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 2.0.1.20050615 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |