org.apache.flume.serialization
Class DurablePositionTracker

java.lang.Object
  extended by org.apache.flume.serialization.DurablePositionTracker
All Implemented Interfaces:
Closeable, PositionTracker

@InterfaceAudience.Private
@InterfaceStability.Evolving
public class DurablePositionTracker
extends Object
implements PositionTracker

Class that stores object state in an avro container file. The file is only ever appended to. At construction time, the object reads data from the end of the file and caches that data for use by a client application. After construction, reads never go to disk. Writes always flush to disk.

Note: This class is not thread-safe.


Method Summary
 void close()
           
static DurablePositionTracker getInstance(File trackerFile, String target)
          If the file exists at startup, then read it, roll it, and open a new one.
 long getPosition()
           
 String getTarget()
           
 void storePosition(long position)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static DurablePositionTracker getInstance(File trackerFile,
                                                 String target)
                                          throws IOException
If the file exists at startup, then read it, roll it, and open a new one. We go through this to avoid issues with partial reads at the end of the file from a previous crash. If we append to a bad record, our writes may never be visible.

Parameters:
trackerFile -
target -
Returns:
Throws:
IOException

storePosition

public void storePosition(long position)
                   throws IOException
Specified by:
storePosition in interface PositionTracker
Throws:
IOException

getPosition

public long getPosition()
Specified by:
getPosition in interface PositionTracker

getTarget

public String getTarget()
Specified by:
getTarget in interface PositionTracker

close

public void close()
           throws IOException
Specified by:
close in interface Closeable
Specified by:
close in interface PositionTracker
Throws:
IOException


Copyright © 2009-2014 Apache Software Foundation. All Rights Reserved.