Class Journal
- java.lang.Object
-
- org.apache.activemq.store.kahadb.disk.journal.Journal
-
- Direct Known Subclasses:
ReadOnlyJournal
public class Journal extends Object
Manages DataFiles
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
Journal.DataFileRemovedListener
static class
Journal.JournalDiskSyncStrategy
static class
Journal.PreallocationScope
static class
Journal.PreallocationStrategy
static class
Journal.WriteCommand
static class
Journal.WriteKey
-
Field Summary
-
Constructor Summary
Constructors Constructor Description Journal()
-
Method Summary
-
-
-
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
-
EMPTY_BATCH_CONTROL_RECORD
public static final byte[] EMPTY_BATCH_CONTROL_RECORD
-
EOF_INT
public static final int EOF_INT
-
EOF_EOT
public static final byte EOF_EOT
- See Also:
- Constant Field Values
-
EOF_RECORD
public static final byte[] EOF_RECORD
-
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
-
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
-
writeBatchSize
protected int writeBatchSize
-
appender
protected FileAppender appender
-
accessorPool
protected DataFileAccessorPool accessorPool
-
dataFiles
protected LinkedNodeList<DataFile> dataFiles
-
lastAppendLocation
protected final AtomicReference<Location> lastAppendLocation
-
cleanupTask
protected ScheduledFuture cleanupTask
-
totalLength
protected AtomicLong totalLength
-
archiveDataLogs
protected boolean archiveDataLogs
-
checksum
protected boolean checksum
-
checkForCorruptionOnStartup
protected boolean checkForCorruptionOnStartup
-
enableAsyncDiskSync
protected boolean enableAsyncDiskSync
-
preallocationScope
protected Journal.PreallocationScope preallocationScope
-
preallocationStrategy
protected Journal.PreallocationStrategy preallocationStrategy
-
journalDiskSyncStrategy
protected Journal.JournalDiskSyncStrategy journalDiskSyncStrategy
-
-
Method Detail
-
corruptRecoveryLocation
public void corruptRecoveryLocation(Location recoveryPosition) throws IOException
- Throws:
IOException
-
getAccessorPool
public DataFileAccessorPool getAccessorPool()
-
allowIOResumption
public void allowIOResumption()
-
setCleanupInterval
public void setCleanupInterval(long cleanupInterval)
-
getCleanupInterval
public long getCleanupInterval()
-
start
public void start() throws IOException
- Throws:
IOException
-
preallocateEntireJournalDataFile
public void preallocateEntireJournalDataFile(RecoverableRandomAccessFile file)
-
isUnusedPreallocated
public boolean isUnusedPreallocated(DataFile dataFile) throws IOException
- Throws:
IOException
-
recoveryCheck
protected Location recoveryCheck(DataFile dataFile) throws IOException
- Throws:
IOException
-
length
public long length()
-
rotateWriteFile
public void rotateWriteFile() throws IOException
- Throws:
IOException
-
reserveDataFile
public DataFile reserveDataFile()
-
getFile
public File getFile(int nextNum)
-
close
public void close() throws IOException
- Throws:
IOException
-
cleanup
public 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
-
getNextLocation
public Location getNextLocation(Location location) throws IOException, IllegalStateException
- Throws:
IOException
IllegalStateException
-
getNextLocation
public Location getNextLocation(Location location, Location limit) 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
-
getPreallocationStrategy
public Journal.PreallocationStrategy getPreallocationStrategy()
-
setPreallocationStrategy
public void setPreallocationStrategy(Journal.PreallocationStrategy preallocationStrategy)
-
getPreallocationScope
public Journal.PreallocationScope getPreallocationScope()
-
setPreallocationScope
public void setPreallocationScope(Journal.PreallocationScope preallocationScope)
-
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)
-
getDataFileById
public DataFile getDataFileById(int dataFileId)
-
getCurrentDataFile
public DataFile getCurrentDataFile(int capacity) throws IOException
- Throws:
IOException
-
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()
-
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()
-
getJournalDiskSyncStrategy
public Journal.JournalDiskSyncStrategy getJournalDiskSyncStrategy()
-
setJournalDiskSyncStrategy
public void setJournalDiskSyncStrategy(Journal.JournalDiskSyncStrategy journalDiskSyncStrategy)
-
isJournalDiskSyncPeriodic
public boolean isJournalDiskSyncPeriodic()
-
setDataFileRemovedListener
public void setDataFileRemovedListener(Journal.DataFileRemovedListener dataFileRemovedListener)
-
-