|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.oozie.util.TimestampedMessageParser
public class TimestampedMessageParser
Encapsulates the parsing and filtering of the log messages from a BufferedReader. It makes sure not to read in the entire log into memory at the same time; at most, it will have two messages (which can be multi-line in the case of exception stack traces).
To use this class: Calling increment() will tell the parser to read the next message from the
Reader. It will return true if there are more messages and false if not. Calling
getLastMessage() and getLastTimestamp() will return the last
message and timestamp, respectively, that were parsed when increment() was called. Calling
processRemaining(java.io.Writer) will write the remaining log messages to the given Writer.
| Field Summary | |
|---|---|
int |
count
|
protected BufferedReader |
reader
|
| Constructor Summary | |
|---|---|
TimestampedMessageParser(BufferedReader reader,
XLogFilter filter)
Creates a TimestampedMessageParser with the given BufferedReader and filter. |
|
| Method Summary | |
|---|---|
void |
closeReader()
Closes the Reader. |
String |
getLastMessage()
Returns the message that was last parsed. |
String |
getLastTimestamp()
Returns the timestamp from the last message that was parsed. |
boolean |
increment()
Causes the next message and timestamp to be parsed from the BufferedReader. |
protected String |
parseNextLine()
Reads the next line from the Reader and checks if it matches the filter. |
void |
processRemaining(Writer writer)
Streams log messages to the passed in Writer, with default buffer len 4K and zero bytes already written |
void |
processRemaining(Writer writer,
int bufferLen)
Streams log messages to the passed in Writer, with zero bytes already written |
void |
processRemaining(Writer writer,
int bufferLen,
int bytesWritten)
Streams log messages to the passed in Writer. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected BufferedReader reader
public int count
| Constructor Detail |
|---|
public TimestampedMessageParser(BufferedReader reader,
XLogFilter filter)
reader - The BufferedReader to get the log messages fromfilter - The filter| Method Detail |
|---|
public boolean increment()
throws IOException
IOException - If there was a problem reading from the Readerpublic String getLastTimestamp()
public String getLastMessage()
public void closeReader()
throws IOException
IOException
protected String parseNextLine()
throws IOException
IOException
public void processRemaining(Writer writer,
int bufferLen,
int bytesWritten)
throws IOException
writer - bufferLen - maximum len of log bufferbytesWritten - num bytes already written to writer
IOException
public void processRemaining(Writer writer,
int bufferLen)
throws IOException
writer - bufferLen - maximum len of log buffer
IOException
public void processRemaining(Writer writer)
throws IOException
writer -
IOException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||