T - Type of event.P - Type of position object.@NotThreadSafe public abstract class LiveFileReader<T,P> extends Object implements FileReader<T,P>
FileReader that provides continuous event stream that never end.| Constructor and Description |
|---|
LiveFileReader() |
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
P |
getPosition()
Returns the position information.
|
void |
initialize()
Initialize the file reader.
|
int |
read(Collection<? super T> events,
int maxEvents,
long timeout,
TimeUnit unit)
Reads as much data as possible until maxEvents.
|
int |
read(Collection<? super T> events,
int maxEvents,
long timeout,
TimeUnit unit,
ReadFilter readFilter)
Reads as much data as possible that passes the given filter until maxEvents.
|
protected abstract FileReader<T,P> |
renewReader() |
public void initialize()
throws IOException
FileReaderinitialize in interface FileReader<T,P>IOException - If initialization failed.public int read(Collection<? super T> events, int maxEvents, long timeout, TimeUnit unit) throws IOException, InterruptedException
FileReaderread in interface FileReader<T,P>events - Collection for storing data read.maxEvents - Maximum number of events to read.timeout - Maximum of time to spend on trying to read eventsunit - Unit for the timeout.0. If -1 is returned, meaning it reached EOF and all
sub-sequence call to this method will also return -1.IOException - If failed to read.InterruptedException - If the reading is interrupted.public int read(Collection<? super T> events, int maxEvents, long timeout, TimeUnit unit, ReadFilter readFilter) throws IOException, InterruptedException
FileReaderread in interface FileReader<T,P>events - Collection for storing data read.maxEvents - Maximum number of events to read.timeout - Maximum of time to spend on trying to read eventsunit - Unit for the timeout.readFilter - Filter to apply during reading0. If -1 is returned, meaning it reached EOF and all
sub-sequence call to this method will also return -1.IOException - If failed to read.InterruptedException - If the reading is interrupted.public void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableIOExceptionpublic P getPosition()
PositionReportergetPosition in interface PositionReporter<P><P>@Nullable protected abstract FileReader<T,P> renewReader() throws IOException
null if no update.IOExceptionCopyright © 2016 Cask Data, Inc. Licensed under the Apache License, Version 2.0.