org.apache.hadoop.contrib.failmon
Class LogParser

java.lang.Object
  extended by org.apache.hadoop.contrib.failmon.LogParser
All Implemented Interfaces:
Monitored
Direct Known Subclasses:
HadoopLogParser, SystemLogParser

public abstract class LogParser
extends Object
implements Monitored

This class represents objects that provide log parsing functionality. Typically, such objects read log files line by line and for each log entry they identify, they create a corresponding EventRecord. In this way, disparate log files can be merged using the uniform format of EventRecords and can, thus, be processed in a uniform way.


Constructor Summary
LogParser(String fname)
          Create a parser that will read from the specified log file.
 
Method Summary
 void checkForRotation()
          Check whether the log file has been rotated.
 EventRecord getNext()
          Continue parsing the log file until a valid log entry is identified.
 BufferedReader getReader()
          Return the BufferedReader, that reads the log file
 EventRecord[] monitor()
          Get an array of all EventRecords that can be extracted for the represented hardware component.
 void monitor(LocalStore ls)
          Insert all EventRecords that can be extracted for the represented hardware component into a LocalStore.
protected abstract  Calendar parseDate(String strDate, String strTime)
          Parse a date found in Hadoop log file.
abstract  EventRecord parseLine(String line)
          Parses one line of the log.
protected  void setNetworkProperties()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.hadoop.contrib.failmon.Monitored
getInfo
 

Constructor Detail

LogParser

public LogParser(String fname)
Create a parser that will read from the specified log file.

Parameters:
fname - the filename of the log file to be read
Method Detail

setNetworkProperties

protected void setNetworkProperties()

monitor

public void monitor(LocalStore ls)
Insert all EventRecords that can be extracted for the represented hardware component into a LocalStore.

Specified by:
monitor in interface Monitored
Parameters:
ls - the LocalStore into which the EventRecords are to be stored.

monitor

public EventRecord[] monitor()
Get an array of all EventRecords that can be extracted for the represented hardware component.

Specified by:
monitor in interface Monitored
Returns:
The array of EventRecords

getNext

public EventRecord getNext()
Continue parsing the log file until a valid log entry is identified. When one such entry is found, parse it and return a corresponding EventRecord.

Returns:
The EventRecord corresponding to the next log entry

getReader

public BufferedReader getReader()
Return the BufferedReader, that reads the log file

Returns:
The BufferedReader that reads the log file

checkForRotation

public void checkForRotation()
Check whether the log file has been rotated. If so, start reading the file from the beginning.


parseLine

public abstract EventRecord parseLine(String line)
                               throws IOException
Parses one line of the log. If the line contains a valid log entry, then an appropriate EventRecord is returned, after all relevant fields have been parsed.

Parameters:
line - the log line to be parsed
Returns:
the EventRecord representing the log entry of the line. If the line does not contain a valid log entry, then the EventRecord returned has isValid() = false. When the end-of-file has been reached, null is returned to the caller.
Throws:
IOException

parseDate

protected abstract Calendar parseDate(String strDate,
                                      String strTime)
Parse a date found in Hadoop log file.

Returns:
a Calendar representing the date


Copyright © 2009 The Apache Software Foundation