org.apache.activemq.kaha.impl.async
Class AsyncDataManager

java.lang.Object
  extended by org.apache.activemq.kaha.impl.async.AsyncDataManager
Direct Known Subclasses:
ReadOnlyAsyncDataManager

public class AsyncDataManager
extends Object

Manages DataFiles


Field Summary
protected  DataFileAccessorPool accessorPool
           
protected  org.apache.activemq.kaha.impl.async.DataFileAppender appender
           
protected  boolean archiveDataLogs
           
protected  Runnable cleanupTask
           
static int CONTROL_RECORD_MAX_LENGTH
           
protected  ControlFile controlFile
           
protected  DataFile currentWriteFile
           
static byte DATA_ITEM_TYPE
           
static String DEFAULT_ARCHIVE_DIRECTORY
           
static int DEFAULT_CLEANUP_INTERVAL
           
static String DEFAULT_DIRECTORY
           
static String DEFAULT_FILE_PREFIX
           
static int DEFAULT_MAX_FILE_LENGTH
           
protected  File directory
           
protected  File directoryArchive
           
protected  Map<File,DataFile> fileByFileMap
           
protected  Map<Integer,DataFile> fileMap
           
protected  String filePrefix
           
protected  Map<DataFileAppender.WriteKey,DataFileAppender.WriteCommand> inflightWrites
           
static int ITEM_FOOT_SPACE
           
static byte[] ITEM_HEAD_EOR
           
static int ITEM_HEAD_FOOT_SPACE
           
static int ITEM_HEAD_OFFSET_TO_SOR
           
static int ITEM_HEAD_RESERVED_SPACE
           
static byte[] ITEM_HEAD_SOR
           
static int ITEM_HEAD_SPACE
           
protected  AtomicReference<Location> lastAppendLocation
           
protected  Location mark
           
protected  int maxFileLength
           
static int PREFERED_DIFF
           
protected  int preferedFileLength
           
static byte REDO_ITEM_TYPE
           
protected  Scheduler scheduler
           
protected  boolean started
           
protected  AtomicLong storeSize
           
protected  boolean useNio
           
 
Constructor Summary
AsyncDataManager()
           
AsyncDataManager(AtomicLong storeSize)
           
 
Method Summary
 void addInterestInFile(int file)
           
 void close()
           
 void consolidateDataFiles()
           
 void consolidateDataFilesNotIn(Set<Integer> inUse, Integer lastFile)
           
 void consolidateDataFilesNotIn(Set<Integer> inUse, Set<Integer> inProgress)
           
 boolean delete()
           
 Integer getCurrentDataFileId()
           
 File getDirectory()
           
 File getDirectoryArchive()
           
 long getDiskSize()
           
 long getDiskSizeUntil(Location startPosition)
           
 String getFilePrefix()
           
 Set<File> getFiles()
          Get a set of files - only valid after start()
 Map<DataFileAppender.WriteKey,DataFileAppender.WriteCommand> getInflightWrites()
           
 Location getLastAppendLocation()
           
 Location getMark()
           
 int getMaxFileLength()
           
 Location getNextLocation(DataFile dataFile, Location lastLocation, boolean thisFileOnly)
           
 Location getNextLocation(File file, Location lastLocation, boolean thisFileOnly)
           
 Location getNextLocation(Location location)
           
 boolean isArchiveDataLogs()
           
 boolean isUseNio()
           
 void lock()
           
 ByteSequence read(Location location)
           
protected  Location recoveryCheck(DataFile dataFile, Location location)
           
 void removeInterestInFile(int file)
           
 void removeLocation(Location location)
           
 void setArchiveDataLogs(boolean archiveDataLogs)
           
 void setDirectory(File directory)
           
 void setDirectoryArchive(File directoryArchive)
           
 void setFilePrefix(String filePrefix)
           
 void setLastAppendLocation(Location lastSyncedLocation)
           
 void setMark(Location location, boolean sync)
           
 void setMaxFileLength(int maxFileLength)
           
 void setUseNio(boolean useNio)
           
 void start()
           
protected  void storeState(boolean sync)
           
 String toString()
           
protected  void unmarshallState(ByteSequence sequence)
           
 void update(Location location, ByteSequence data, boolean sync)
           
 Location write(ByteSequence data, boolean sync)
           
 Location write(ByteSequence data, byte type, boolean sync)
           
 Location write(ByteSequence data, Runnable onComplete)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CONTROL_RECORD_MAX_LENGTH

public static final int CONTROL_RECORD_MAX_LENGTH
See Also:
Constant Field Values

ITEM_HEAD_RESERVED_SPACE

public static final int ITEM_HEAD_RESERVED_SPACE
See Also:
Constant Field Values

ITEM_HEAD_SPACE

public static final int ITEM_HEAD_SPACE
See Also:
Constant Field Values

ITEM_HEAD_OFFSET_TO_SOR

public static final int ITEM_HEAD_OFFSET_TO_SOR
See Also:
Constant Field Values

ITEM_FOOT_SPACE

public static final int ITEM_FOOT_SPACE
See Also:
Constant Field Values

ITEM_HEAD_FOOT_SPACE

public static final int ITEM_HEAD_FOOT_SPACE
See Also:
Constant Field Values

ITEM_HEAD_SOR

public static final byte[] ITEM_HEAD_SOR

ITEM_HEAD_EOR

public static final byte[] ITEM_HEAD_EOR

DATA_ITEM_TYPE

public static final byte DATA_ITEM_TYPE
See Also:
Constant Field Values

REDO_ITEM_TYPE

public static final byte REDO_ITEM_TYPE
See Also:
Constant Field Values

DEFAULT_DIRECTORY

public static final String DEFAULT_DIRECTORY
See Also:
Constant Field Values

DEFAULT_ARCHIVE_DIRECTORY

public static final String DEFAULT_ARCHIVE_DIRECTORY
See Also:
Constant Field Values

DEFAULT_FILE_PREFIX

public static final String DEFAULT_FILE_PREFIX
See Also:
Constant Field Values

DEFAULT_MAX_FILE_LENGTH

public static final int DEFAULT_MAX_FILE_LENGTH
See Also:
Constant Field Values

DEFAULT_CLEANUP_INTERVAL

public static final int DEFAULT_CLEANUP_INTERVAL
See Also:
Constant Field Values

PREFERED_DIFF

public static final int PREFERED_DIFF
See Also:
Constant Field Values

scheduler

protected Scheduler scheduler

inflightWrites

protected final Map<DataFileAppender.WriteKey,DataFileAppender.WriteCommand> inflightWrites

directory

protected File directory

directoryArchive

protected File directoryArchive

filePrefix

protected String filePrefix

controlFile

protected ControlFile controlFile

started

protected boolean started

useNio

protected boolean useNio

maxFileLength

protected int maxFileLength

preferedFileLength

protected int preferedFileLength

appender

protected org.apache.activemq.kaha.impl.async.DataFileAppender appender

accessorPool

protected DataFileAccessorPool accessorPool

fileMap

protected Map<Integer,DataFile> fileMap

fileByFileMap

protected Map<File,DataFile> fileByFileMap

currentWriteFile

protected DataFile currentWriteFile

mark

protected Location mark

lastAppendLocation

protected final AtomicReference<Location> lastAppendLocation

cleanupTask

protected Runnable cleanupTask

storeSize

protected final AtomicLong storeSize

archiveDataLogs

protected boolean archiveDataLogs
Constructor Detail

AsyncDataManager

public AsyncDataManager(AtomicLong storeSize)

AsyncDataManager

public AsyncDataManager()
Method Detail

start

public void start()
           throws IOException
Throws:
IOException

lock

public void lock()
          throws IOException
Throws:
IOException

recoveryCheck

protected Location recoveryCheck(DataFile dataFile,
                                 Location location)
                          throws IOException
Throws:
IOException

unmarshallState

protected void unmarshallState(ByteSequence sequence)
                        throws IOException
Throws:
IOException

removeLocation

public void removeLocation(Location location)
                    throws IOException
Throws:
IOException

close

public void close()
           throws IOException
Throws:
IOException

delete

public boolean delete()
               throws IOException
Throws:
IOException

addInterestInFile

public void addInterestInFile(int file)
                       throws IOException
Throws:
IOException

removeInterestInFile

public void removeInterestInFile(int file)
                          throws IOException
Throws:
IOException

consolidateDataFilesNotIn

public void consolidateDataFilesNotIn(Set<Integer> inUse,
                                      Set<Integer> inProgress)
                               throws IOException
Throws:
IOException

consolidateDataFilesNotIn

public void consolidateDataFilesNotIn(Set<Integer> inUse,
                                      Integer lastFile)
                               throws IOException
Throws:
IOException

consolidateDataFiles

public void consolidateDataFiles()
                          throws IOException
Throws:
IOException

getMaxFileLength

public int getMaxFileLength()
Returns:
the maxFileLength

setMaxFileLength

public void setMaxFileLength(int maxFileLength)
Parameters:
maxFileLength - the maxFileLength to set

toString

public String toString()
Overrides:
toString in class Object

getMark

public Location getMark()
                 throws IllegalStateException
Throws:
IllegalStateException

getNextLocation

public Location getNextLocation(Location location)
                         throws IOException,
                                IllegalStateException
Throws:
IOException
IllegalStateException

getNextLocation

public Location getNextLocation(File file,
                                Location lastLocation,
                                boolean thisFileOnly)
                         throws IllegalStateException,
                                IOException
Throws:
IllegalStateException
IOException

getNextLocation

public Location getNextLocation(DataFile dataFile,
                                Location lastLocation,
                                boolean thisFileOnly)
                         throws IOException,
                                IllegalStateException
Throws:
IOException
IllegalStateException

read

public ByteSequence read(Location location)
                  throws IOException,
                         IllegalStateException
Throws:
IOException
IllegalStateException

setMark

public void setMark(Location location,
                    boolean sync)
             throws IOException,
                    IllegalStateException
Throws:
IOException
IllegalStateException

storeState

protected void storeState(boolean sync)
                   throws IOException
Throws:
IOException

write

public Location write(ByteSequence data,
                      boolean sync)
               throws IOException,
                      IllegalStateException
Throws:
IOException
IllegalStateException

write

public Location write(ByteSequence data,
                      Runnable onComplete)
               throws IOException,
                      IllegalStateException
Throws:
IOException
IllegalStateException

write

public Location write(ByteSequence data,
                      byte type,
                      boolean sync)
               throws IOException,
                      IllegalStateException
Throws:
IOException
IllegalStateException

update

public void update(Location location,
                   ByteSequence data,
                   boolean sync)
            throws IOException
Throws:
IOException

getDirectory

public File getDirectory()

setDirectory

public void setDirectory(File directory)

getFilePrefix

public String getFilePrefix()

setFilePrefix

public void setFilePrefix(String filePrefix)

getInflightWrites

public Map<DataFileAppender.WriteKey,DataFileAppender.WriteCommand> getInflightWrites()

getLastAppendLocation

public Location getLastAppendLocation()

setLastAppendLocation

public void setLastAppendLocation(Location lastSyncedLocation)

isUseNio

public boolean isUseNio()

setUseNio

public void setUseNio(boolean useNio)

getDirectoryArchive

public File getDirectoryArchive()

setDirectoryArchive

public void setDirectoryArchive(File directoryArchive)

isArchiveDataLogs

public boolean isArchiveDataLogs()

setArchiveDataLogs

public void setArchiveDataLogs(boolean archiveDataLogs)

getCurrentDataFileId

public Integer getCurrentDataFileId()

getFiles

public Set<File> getFiles()
Get a set of files - only valid after start()

Returns:
files currently being used

getDiskSize

public long getDiskSize()

getDiskSizeUntil

public long getDiskSizeUntil(Location startPosition)


Copyright © 2005-2013 The Apache Software Foundation. All Rights Reserved.