public class FileTailingAdaptor extends Object implements Adaptor
Modifier and Type | Field and Description |
---|---|
protected long |
adaptorID |
protected static org.apache.hadoop.conf.Configuration |
conf |
static int |
DEFAULT_MAX_READ_SIZE
This is the maximum amount we'll read from any one file before moving on to
the next.
|
protected long |
fileReadOffset
next PHYSICAL offset to read
|
static int |
GRACEFUL_PERIOD |
static int |
MAX_READ_SIZE |
static int |
MAX_RETRIES |
protected RandomAccessFile |
reader |
protected String |
type |
Constructor and Description |
---|
FileTailingAdaptor() |
Modifier and Type | Method and Description |
---|---|
protected int |
extractRecords(ChunkReceiver eq,
long buffOffsetInFile,
byte[] buf)
Extract records from a byte sequence
|
String |
getCurrentStatus()
Return the adaptor's state Should not include class name, datatype or byte
offset, which are written by caller.
|
String |
getStreamName()
Return the stream name
|
String |
getType() |
void |
hardStop()
Stop tailing the file, effective immediately.
|
long |
shutdown()
Do one last tail, and then stop
|
void |
start(long adaptorID,
String type,
String params,
long bytes,
ChunkReceiver dest)
Start this adaptor
|
boolean |
tailFile(ChunkReceiver eq)
Looks at the tail of the associated file, adds some of it to event queue
This method is not thread safe.
|
String |
toString() |
public static final int DEFAULT_MAX_READ_SIZE
public static int MAX_READ_SIZE
public static int MAX_RETRIES
public static int GRACEFUL_PERIOD
protected static org.apache.hadoop.conf.Configuration conf
protected long fileReadOffset
protected String type
protected RandomAccessFile reader
protected long adaptorID
public void start(long adaptorID, String type, String params, long bytes, ChunkReceiver dest)
Adaptor
public long shutdown() throws AdaptorException
shutdown
in interface Adaptor
AdaptorException
Adaptor.shutdown()
public void hardStop() throws AdaptorException
hardStop
in interface Adaptor
AdaptorException
public String getCurrentStatus()
Adaptor
getCurrentStatus
in interface Adaptor
Adaptor.getCurrentStatus()
public String getStreamName()
Adaptor
getStreamName
in interface Adaptor
public boolean tailFile(ChunkReceiver eq) throws InterruptedException
eq
- the queue to write Chunks intoInterruptedException
protected int extractRecords(ChunkReceiver eq, long buffOffsetInFile, byte[] buf) throws InterruptedException
eq
- the queue to stick the new chunk[s] inbuffOffsetInFile
- the byte offset in the stream at which buf[] beginsbuf
- the byte buffer to extract records fromInterruptedException
Copyright © ${year} The Apache Software Foundation