org.apache.kahadb.journal
Class Journal
java.lang.Object
org.apache.kahadb.journal.Journal
- Direct Known Subclasses:
- ReadOnlyJournal
public class Journal
- extends Object
Manages DataFiles
- Version:
- $Revision: 813467 $
Method Summary |
void |
appendedExternally(Location loc,
int length)
|
int |
checkBatchRecord(org.apache.kahadb.journal.DataFileAccessor reader,
int offset)
|
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<DataFileAppender.WriteKey,DataFileAppender.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()
|
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 |
setFilePrefix(String filePrefix)
|
void |
setFileSuffix(String fileSuffix)
|
void |
setLastAppendLocation(Location lastSyncedLocation)
|
void |
setMaxFileLength(int maxFileLength)
|
void |
setReplicationTarget(ReplicationTarget replicationTarget)
|
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)
|
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<DataFileAppender.WriteKey,DataFileAppender.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 org.apache.kahadb.journal.DataFileAppender 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 final AtomicLong totalLength
archiveDataLogs
protected boolean archiveDataLogs
checksum
protected boolean checksum
checkForCorruptionOnStartup
protected boolean checkForCorruptionOnStartup
Journal
public Journal()
start
public void start()
throws IOException
- Throws:
IOException
recoveryCheck
protected Location recoveryCheck(DataFile dataFile)
throws IOException
- Throws:
IOException
checkBatchRecord
public int checkBatchRecord(org.apache.kahadb.journal.DataFileAccessor reader,
int offset)
throws IOException
- Throws:
IOException
getFile
public File getFile(int nextNum)
close
public void close()
throws IOException
- Throws:
IOException
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<DataFileAppender.WriteKey,DataFileAppender.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()
Copyright © 2005-2011 Apache Software Foundation. All Rights Reserved.