org.rhq.core.pluginapi.util
Class ResponseTimeLogParser

java.lang.Object
  extended by org.rhq.core.pluginapi.util.ResponseTimeLogParser

public class ResponseTimeLogParser
extends Object

This is a very simple log parser that uses a StringTokenizer instead of a regular expression to parse a HTTP response-time log file. This should greatly improve the performance. It requires that lines in the log file have the following format (with one line per HTTP request):

URL date_in_milliseconds time_taken [status_code [IP_address]]

This is the output format used by the Apache RT module, as well as the servlet RT filter.


Nested Class Summary
 class ResponseTimeLogParser.LogEntry
           
 
Field Summary
static int DEFAULT_TIME_MULTIPLIER
           
protected  List<Pattern> excludes
           
protected  org.apache.commons.logging.Log log
           
protected  File logFile
           
protected  List<RegexSubstitution> transforms
           
 
Constructor Summary
ResponseTimeLogParser(File logFile)
           
ResponseTimeLogParser(File logFile, double timeMultiplier)
           
 
Method Summary
protected  String applyTransforms(String url)
           
 List<Pattern> getExcludes()
           
 File getLogFile()
           
 double getTimeMultiplier()
           
 List<RegexSubstitution> getTransforms()
           
protected  boolean isExcluded(String url)
           
protected  ResponseTimeLogParser.LogEntry parseLine(String line)
          Parses a line from a response time log and returns a LogEntry.
 void parseLog(CallTimeData callTimeData)
          Parse the log file, starting at the offset corresponding to the file's size after the last time this method was called.
 void setExcludes(List<Pattern> excludes)
           
 void setLogFile(File logFile)
           
 void setTransforms(List<RegexSubstitution> transforms)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_TIME_MULTIPLIER

public static final int DEFAULT_TIME_MULTIPLIER
See Also:
Constant Field Values

log

protected final org.apache.commons.logging.Log log

logFile

protected File logFile

excludes

protected List<Pattern> excludes

transforms

protected List<RegexSubstitution> transforms
Constructor Detail

ResponseTimeLogParser

public ResponseTimeLogParser(File logFile)

ResponseTimeLogParser

public ResponseTimeLogParser(File logFile,
                             double timeMultiplier)
Method Detail

parseLog

public void parseLog(CallTimeData callTimeData)
              throws IOException
Parse the log file, starting at the offset corresponding to the file's size after the last time this method was called. Immediately after parsing, the file will be truncated, permissions permitting. If the log file does not exist, a warning will be logged and the method will return. The parsed response-time data will be added to the passed-in CallTimeData object.

Parameters:
callTimeData - the parsed response-time data will be added to this object
Throws:
IOException - if an error occurs reading the log file

isExcluded

protected boolean isExcluded(String url)

applyTransforms

protected String applyTransforms(String url)

parseLine

@NotNull
protected ResponseTimeLogParser.LogEntry parseLine(String line)
                                            throws Exception
Parses a line from a response time log and returns a LogEntry.

Parameters:
line - the line to be parsed
Returns:
a LogEntry representing the line
Throws:
Exception - if parsing of the line fails

getLogFile

public File getLogFile()

setLogFile

public void setLogFile(File logFile)

getTimeMultiplier

public double getTimeMultiplier()

getExcludes

public List<Pattern> getExcludes()

setExcludes

public void setExcludes(List<Pattern> excludes)

getTransforms

public List<RegexSubstitution> getTransforms()

setTransforms

public void setTransforms(List<RegexSubstitution> transforms)


Copyright © 2008-2009 RHQ Project Advisory Board (Red Hat, Inc.). All Rights Reserved.