org.apache.hadoop.chukwa.datacollection.adaptor
Class FileAdaptor

java.lang.Object
  extended by org.apache.hadoop.chukwa.datacollection.adaptor.FileAdaptor
All Implemented Interfaces:
Adaptor

public class FileAdaptor
extends Object
implements Adaptor

File Adaptor push small size file in one chunk to collector


Field Summary
protected  long adaptorID
           
protected  ChunkReceiver dest
           
protected  long fileReadOffset
           
protected  RandomAccessFile reader
           
protected  boolean shutdownCalled
           
protected  File toWatch
           
protected  String type
           
 
Constructor Summary
FileAdaptor()
           
 
Method Summary
protected  int extractRecords(ChunkReceiver eq, long buffOffsetInFile, byte[] buf, long fileTime)
          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()
          We want to keep trying
 void start(long adaptorID, String type, String params, long bytes, ChunkReceiver dest)
          Start this adaptor
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

toWatch

protected File toWatch

reader

protected RandomAccessFile reader

fileReadOffset

protected long fileReadOffset

type

protected String type

dest

protected ChunkReceiver dest

adaptorID

protected long adaptorID

shutdownCalled

protected boolean shutdownCalled
Constructor Detail

FileAdaptor

public FileAdaptor()
Method Detail

start

public void start(long adaptorID,
                  String type,
                  String params,
                  long bytes,
                  ChunkReceiver dest)
Description copied from interface: Adaptor
Start this adaptor

Specified by:
start in interface Adaptor
type - the application type, who is starting this adaptor
params - the status string to use for configuration.
bytes - the stream offset of the first byte sent by this adaptor

shutdown

public long shutdown()
              throws AdaptorException
We want to keep trying

Specified by:
shutdown in interface Adaptor
Returns:
the logical offset at which the adaptor stops
Throws:
AdaptorException
See Also:
Adaptor.shutdown()

hardStop

public void hardStop()
              throws AdaptorException
Stop tailing the file, effective immediately.

Specified by:
hardStop in interface Adaptor
Throws:
AdaptorException

getStreamName

public String getStreamName()
Description copied from interface: Adaptor
Return the stream name

Specified by:
getStreamName in interface Adaptor
Returns:
Stream name as a string

extractRecords

protected int extractRecords(ChunkReceiver eq,
                             long buffOffsetInFile,
                             byte[] buf,
                             long fileTime)
                      throws InterruptedException
Extract records from a byte sequence

Parameters:
eq - the queue to stick the new chunk[s] in
buffOffsetInFile - the byte offset in the stream at which buf[] begins
buf - the byte buffer to extract records from
Returns:
the number of bytes processed
Throws:
InterruptedException

getType

public String getType()
Specified by:
getType in interface Adaptor

getCurrentStatus

public String getCurrentStatus()
                        throws AdaptorException
Description copied from interface: Adaptor
Return the adaptor's state Should not include class name, datatype or byte offset, which are written by caller.

Specified by:
getCurrentStatus in interface Adaptor
Returns:
the adaptor state as a string
Throws:
AdaptorException


Copyright © ${year} The Apache Software Foundation