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

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

public class FileAdaptor
extends AbstractAdaptor

File Adaptor push small size file in one chunk to collector


Field Summary
protected  long fileReadOffset
           
protected  boolean finished
           
protected  RandomAccessFile reader
           
protected  boolean shutdownCalled
           
 
Fields inherited from class org.apache.hadoop.chukwa.datacollection.adaptor.AbstractAdaptor
adaptorID, control, dest, 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 or byte offset, which are written by caller.
 void hardStop()
          Deprecated. 
 String parseArgs(String params)
          Parse args, return stream name.
 long shutdown()
          Deprecated. 
 long shutdown(AdaptorShutdownPolicy shutdownPolicy)
          Signals this adaptor to come to an orderly stop.
 void start(long bytes)
           
 
Methods inherited from class org.apache.hadoop.chukwa.datacollection.adaptor.AbstractAdaptor
deregisterAndStop, getType, start
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

finished

protected volatile boolean finished

reader

protected RandomAccessFile reader

fileReadOffset

protected long fileReadOffset

shutdownCalled

protected boolean shutdownCalled
Constructor Detail

FileAdaptor

public FileAdaptor()
Method Detail

start

public void start(long bytes)
Specified by:
start in class AbstractAdaptor

shutdown

@Deprecated
public long shutdown()
              throws AdaptorException
Deprecated. 

We want to keep trying

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

hardStop

@Deprecated
public void hardStop()
              throws AdaptorException
Deprecated. 

Stop tailing the file, effective immediately.

Throws:
AdaptorException

shutdown

public long shutdown(AdaptorShutdownPolicy shutdownPolicy)
Description copied from interface: Adaptor
Signals this adaptor to come to an orderly stop. The adaptor ought to push out all the data it can before exiting depending of the shutdown policy

Returns:
the logical offset at which the adaptor was when the method return

parseArgs

public String parseArgs(String params)
Description copied from interface: Adaptor
Parse args, return stream name. Do not start running. Return the stream name, given params. The stream name is the part of the Adaptor status that's used to determine uniqueness.

Returns:
Stream name as a string, null if params are malformed

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

getCurrentStatus

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

Returns:
the adaptor state as a string


Copyright © ${year} The Apache Software Foundation