public class TimestampedMessageParser extends Object
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,org.apache.oozie.util.XLogStreamer)
will write the
remaining log messages to the given Writer.
Modifier and Type | Field and Description |
---|---|
int |
count |
protected BufferedReader |
reader |
Constructor and Description |
---|
TimestampedMessageParser(BufferedReader reader,
XLogFilter filter)
Creates a TimestampedMessageParser with the given BufferedReader and filter.
|
Modifier and Type | Method and Description |
---|---|
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 LogLine |
parseNextLogLine()
Reads the next line from the Reader and checks if it matches the filter.
|
void |
processRemaining(Writer writer,
XLogStreamer logStreamer)
Streams log messages to the passed in Writer, with zero bytes already
written
|
protected ArrayList<String> |
splitLogMessage(String line)
Splits the log message into parts
|
protected BufferedReader reader
public int count
public TimestampedMessageParser(BufferedReader reader, XLogFilter filter)
reader
- The BufferedReader to get the log messages fromfilter
- The filterpublic 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
- if the reader can't be closedprotected LogLine parseNextLogLine() throws IOException
IOException
- in case of an error in the Readerpublic void processRemaining(Writer writer, XLogStreamer logStreamer) throws IOException
writer
- the target writerlogStreamer
- the log streamerIOException
- in case of IO errorprotected ArrayList<String> splitLogMessage(String line)
line
- the line to splitCopyright © 2018 Apache Software Foundation. All rights reserved.