|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.flume.client.avro.SpoolingFileLineReader
public class SpoolingFileLineReader
A LineReader
which reads log data from files stored in a
spooling directory and renames each file once all of its data has been
read (through readLine()
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:
1) Once a log file has been renamed with the completedSuffix
,
all of its records have been read through the readLine()
function and commit()
'd exactly once.
2) All files in the spooling directory will eventually be opened
and delivered to a readLine()
caller.
NOTE: This class is for internal Flume components, this is not an extension
point for developers customizing Flume.
Field Summary | |
---|---|
String |
completedSuffix
|
Constructor Summary | |
---|---|
SpoolingFileLineReader(File directory,
String completedSuffix,
int bufferMaxLines,
int bufferMaxLineLength)
Create a SpoolingFileLineReader to watch the given directory. |
Method Summary | |
---|---|
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 #readLines() call. |
String |
readLine()
Get the next line associated with the input stream. |
List<String> |
readLines(int n)
Get up to n lines associated with the input stream. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public String completedSuffix
Constructor Detail |
---|
public SpoolingFileLineReader(File directory, String completedSuffix, int bufferMaxLines, int bufferMaxLineLength)
directory
- The directory to watchcompletedSuffix
- The suffix to append to completed filesbufferMaxLines
- The maximum number of lines to keep in a pre-commit
bufferbufferMaxLineLength
- The maximum line length for lines in the pre-commit
buffer, in charactersMethod Detail |
---|
public String getLastFileRead()
#readLines()
call. Returns null if called before any file
contents are read.
public String readLine() throws IOException
LineReader
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.
readLine
in interface LineReader
IOException
public void commit() throws IOException
IOException
public List<String> readLines(int n) throws IOException
LineReader
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.
readLines
in interface LineReader
IOException
public void close() throws IOException
LineReader
close
in interface LineReader
IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |