@InterfaceAudience.Private @InterfaceStability.Evolving public class ReliableSpoolingFileEventReader extends Object implements ReliableEventReader
A ReliableEventReader
which reads log data from files stored
in a spooling directory and renames each file once all of its data has been
read (through EventDeserializer.readEvent()
calls). The user must
commit()
each read, to indicate that the lines have been fully
processed.
Read calls will return no data if there are no files left to read. This class, in general, is not thread safe.
This reader assumes that files with unique file names are left in the spooling directory and not modified once they are placed there. Any user behavior which violates these assumptions, when detected, will result in a FlumeException being thrown.
This class makes the following guarantees, if above assumptions are met:
completedSuffix
,
all of its records have been read through the
EventDeserializer.readEvent()
function and
commit()
ed at least once.
readEvents(int)
caller.
Modifier and Type | Class and Description |
---|---|
static class |
ReliableSpoolingFileEventReader.Builder
Special builder class for ReliableSpoolingFileEventReader
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Clean-up any state associated with this reader.
|
void |
commit()
Commit the last lines which were read.
|
String |
getLastFileRead()
Return the filename which generated the data from the last successful
readEvents(int) call. |
Event |
readEvent()
Get the next line associated with the input stream.
|
List<Event> |
readEvents(int numEvents)
Get up to
n lines associated with the input stream. |
public String getLastFileRead()
readEvents(int)
call. Returns null if called before any file
contents are read.public Event readEvent() throws IOException
EventReader
null
, the input underlying input source is considered finished.
Note that this is allowed to block for indefinite amounts of time waiting
to generate a new line.readEvent
in interface EventReader
IOException
public List<Event> readEvents(int numEvents) throws IOException
EventReader
n
lines associated with the input stream. If this returns
less than n lines, the input underlying input source is considered
finished. Note that this is allowed to block for indefinite amounts of
time waiting to generate a new line.readEvents
in interface EventReader
IOException
public void close() throws IOException
EventReader
close
in interface Closeable
close
in interface AutoCloseable
close
in interface EventReader
IOException
public void commit() throws IOException
commit
in interface ReliableEventReader
IOException
Copyright © 2009-2017 Apache Software Foundation. All Rights Reserved.