org.apache.activemq.store.kahadb.disk.journal
Class Journal

java.lang.Object
  extended by org.apache.activemq.store.kahadb.disk.journal.Journal
Direct Known Subclasses:
ReadOnlyJournal

public class Journal
extends Object

Manages DataFiles


Nested Class Summary
static class Journal.WriteCommand
           
static class Journal.WriteKey
           
 
Field Summary
protected  DataFileAccessorPool accessorPool
           
protected  FileAppender appender
           
protected  boolean archiveDataLogs
           
static byte[] BATCH_CONTROL_RECORD_HEADER
           
static byte[] BATCH_CONTROL_RECORD_MAGIC
           
static int BATCH_CONTROL_RECORD_SIZE
           
static byte BATCH_CONTROL_RECORD_TYPE
           
static String CALLER_BUFFER_APPENDER
           
static boolean callerBufferAppender
           
protected  boolean checkForCorruptionOnStartup
           
protected  boolean checksum
           
protected  Runnable cleanupTask
           
protected  LinkedNodeList<DataFile> dataFiles
           
static String DEFAULT_ARCHIVE_DIRECTORY
           
static int DEFAULT_CLEANUP_INTERVAL
           
static String DEFAULT_DIRECTORY
           
static String DEFAULT_FILE_PREFIX
           
static String DEFAULT_FILE_SUFFIX
           
static int DEFAULT_MAX_FILE_LENGTH
           
static int DEFAULT_MAX_WRITE_BATCH_SIZE
           
protected  File directory
           
protected  File directoryArchive
           
protected  boolean enableAsyncDiskSync
           
protected  Map<File,DataFile> fileByFileMap
           
protected  Map<Integer,DataFile> fileMap
           
protected  String filePrefix
           
protected  String fileSuffix
           
protected  Map<Journal.WriteKey,Journal.WriteCommand> inflightWrites
           
protected  AtomicReference<Location> lastAppendLocation
           
protected  int maxFileLength
           
static int PREFERED_DIFF
           
protected  int preferedFileLength
           
static int RECORD_HEAD_SPACE
           
protected  boolean started
           
protected  AtomicLong totalLength
           
static byte USER_RECORD_TYPE
           
protected  int writeBatchSize
           
 
Constructor Summary
Journal()
           
 
Method Summary
 void appendedExternally(Location loc, int length)
           
 int checkBatchRecord(org.apache.activemq.store.kahadb.disk.journal.DataFileAccessor reader, int offset)
           
protected  void cleanup()
           
 void close()
           
 boolean delete()
           
 Integer getCurrentDataFileId()
           
 File getDirectory()
           
 File getDirectoryArchive()
           
 long getDiskSize()
           
 File getFile(int nextNum)
           
 Map<Integer,DataFile> getFileMap()
           
 String getFilePrefix()
           
 Set<File> getFiles()
          Get a set of files - only valid after start()
 String getFileSuffix()
           
 Map<Journal.WriteKey,Journal.WriteCommand> getInflightWrites()
           
 Location getLastAppendLocation()
           
 int getMaxFileLength()
           
 Location getNextLocation(DataFile dataFile, Location lastLocation, boolean thisFileOnly)
           
 Location getNextLocation(File file, Location lastLocation, boolean thisFileOnly)
           
 Location getNextLocation(Location location)
           
 ReplicationTarget getReplicationTarget()
           
 int getWriteBatchSize()
           
 boolean isArchiveDataLogs()
           
 boolean isCheckForCorruptionOnStartup()
           
 boolean isChecksum()
           
 boolean isEnableAsyncDiskSync()
           
 long length()
           
 ByteSequence read(Location location)
           
protected  Location recoveryCheck(DataFile dataFile)
           
 void removeDataFiles(Set<Integer> files)
           
 void setArchiveDataLogs(boolean archiveDataLogs)
           
 void setCheckForCorruptionOnStartup(boolean checkForCorruptionOnStartup)
           
 void setChecksum(boolean checksumWrites)
           
 void setDirectory(File directory)
           
 void setDirectoryArchive(File directoryArchive)
           
 void setEnableAsyncDiskSync(boolean val)
           
 void setFilePrefix(String filePrefix)
           
 void setFileSuffix(String fileSuffix)
           
 void setLastAppendLocation(Location lastSyncedLocation)
           
 void setMaxFileLength(int maxFileLength)
           
 void setReplicationTarget(ReplicationTarget replicationTarget)
           
 void setSizeAccumulator(AtomicLong storeSizeAccumulator)
           
 void setWriteBatchSize(int writeBatchSize)
           
 void start()
           
 String toString()
           
 void update(Location location, ByteSequence data, boolean sync)
           
 Location write(ByteSequence data, 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

CALLER_BUFFER_APPENDER

public static final String CALLER_BUFFER_APPENDER
See Also:
Constant Field Values

callerBufferAppender

public static final boolean callerBufferAppender

RECORD_HEAD_SPACE

public static final int RECORD_HEAD_SPACE
See Also:
Constant Field Values

USER_RECORD_TYPE

public static final byte USER_RECORD_TYPE
See Also:
Constant Field Values

BATCH_CONTROL_RECORD_TYPE

public static final byte BATCH_CONTROL_RECORD_TYPE
See Also:
Constant Field Values

BATCH_CONTROL_RECORD_MAGIC

public static final byte[] BATCH_CONTROL_RECORD_MAGIC

BATCH_CONTROL_RECORD_SIZE

public static final int BATCH_CONTROL_RECORD_SIZE

BATCH_CONTROL_RECORD_HEADER

public static final byte[] BATCH_CONTROL_RECORD_HEADER

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_FILE_SUFFIX

public static final String DEFAULT_FILE_SUFFIX
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

DEFAULT_MAX_WRITE_BATCH_SIZE

public static final int DEFAULT_MAX_WRITE_BATCH_SIZE
See Also:
Constant Field Values

inflightWrites

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

directory

protected File directory

directoryArchive

protected File directoryArchive

filePrefix

protected String filePrefix

fileSuffix

protected String fileSuffix

started

protected boolean started

maxFileLength

protected int maxFileLength

preferedFileLength

protected int preferedFileLength

writeBatchSize

protected int writeBatchSize

appender

protected FileAppender appender

accessorPool

protected DataFileAccessorPool accessorPool

fileMap

protected Map<Integer,DataFile> fileMap

fileByFileMap

protected Map<File,DataFile> fileByFileMap

dataFiles

protected LinkedNodeList<DataFile> dataFiles

lastAppendLocation

protected final AtomicReference<Location> lastAppendLocation

cleanupTask

protected Runnable cleanupTask

totalLength

protected AtomicLong totalLength

archiveDataLogs

protected boolean archiveDataLogs

checksum

protected boolean checksum

checkForCorruptionOnStartup

protected boolean checkForCorruptionOnStartup

enableAsyncDiskSync

protected boolean enableAsyncDiskSync
Constructor Detail

Journal

public Journal()
Method Detail

start

public void start()
           throws IOException
Throws:
IOException

recoveryCheck

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

checkBatchRecord

public int checkBatchRecord(org.apache.activemq.store.kahadb.disk.journal.DataFileAccessor reader,
                            int offset)
                     throws IOException
Throws:
IOException

length

public long length()

getFile

public File getFile(int nextNum)

close

public void close()
           throws IOException
Throws:
IOException

cleanup

protected void cleanup()

delete

public boolean delete()
               throws IOException
Throws:
IOException

removeDataFiles

public void removeDataFiles(Set<Integer> files)
                     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

appendedExternally

public void appendedExternally(Location loc,
                               int length)
                        throws IOException
Throws:
IOException

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

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

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<Journal.WriteKey,Journal.WriteCommand> getInflightWrites()

getLastAppendLocation

public Location getLastAppendLocation()

setLastAppendLocation

public void setLastAppendLocation(Location lastSyncedLocation)

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

getFileMap

public Map<Integer,DataFile> getFileMap()

getDiskSize

public long getDiskSize()

setReplicationTarget

public void setReplicationTarget(ReplicationTarget replicationTarget)

getReplicationTarget

public ReplicationTarget getReplicationTarget()

getFileSuffix

public String getFileSuffix()

setFileSuffix

public void setFileSuffix(String fileSuffix)

isChecksum

public boolean isChecksum()

setChecksum

public void setChecksum(boolean checksumWrites)

isCheckForCorruptionOnStartup

public boolean isCheckForCorruptionOnStartup()

setCheckForCorruptionOnStartup

public void setCheckForCorruptionOnStartup(boolean checkForCorruptionOnStartup)

setWriteBatchSize

public void setWriteBatchSize(int writeBatchSize)

getWriteBatchSize

public int getWriteBatchSize()

setSizeAccumulator

public void setSizeAccumulator(AtomicLong storeSizeAccumulator)

setEnableAsyncDiskSync

public void setEnableAsyncDiskSync(boolean val)

isEnableAsyncDiskSync

public boolean isEnableAsyncDiskSync()


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