public class Journal extends Object
Modifier and Type | Class and Description |
---|---|
static class |
Journal.WriteCommand |
static class |
Journal.WriteKey |
Constructor and Description |
---|
Journal() |
public static final String CALLER_BUFFER_APPENDER
public static final boolean callerBufferAppender
public static final int RECORD_HEAD_SPACE
public static final byte USER_RECORD_TYPE
public static final byte BATCH_CONTROL_RECORD_TYPE
public static final byte[] BATCH_CONTROL_RECORD_MAGIC
public static final int BATCH_CONTROL_RECORD_SIZE
public static final byte[] BATCH_CONTROL_RECORD_HEADER
public static final String DEFAULT_DIRECTORY
public static final String DEFAULT_ARCHIVE_DIRECTORY
public static final String DEFAULT_FILE_PREFIX
public static final String DEFAULT_FILE_SUFFIX
public static final int DEFAULT_MAX_FILE_LENGTH
public static final int DEFAULT_CLEANUP_INTERVAL
public static final int PREFERED_DIFF
public static final int DEFAULT_MAX_WRITE_BATCH_SIZE
protected final Map<Journal.WriteKey,Journal.WriteCommand> inflightWrites
protected File directoryArchive
protected String filePrefix
protected String fileSuffix
protected boolean started
protected int maxFileLength
protected int preferedFileLength
protected int writeBatchSize
protected FileAppender appender
protected DataFileAccessorPool accessorPool
protected Map<File,DataFile> fileByFileMap
protected LinkedNodeList<DataFile> dataFiles
protected final AtomicReference<Location> lastAppendLocation
protected Runnable cleanupTask
protected AtomicLong totalLength
protected boolean archiveDataLogs
protected boolean checksum
protected boolean checkForCorruptionOnStartup
protected boolean enableAsyncDiskSync
public Journal()
public void start() throws IOException
IOException
protected Location recoveryCheck(DataFile dataFile) throws IOException
IOException
public int checkBatchRecord(org.apache.kahadb.journal.DataFileAccessor reader, int offset) throws IOException
IOException
public long length()
public void close() throws IOException
IOException
protected void cleanup()
public boolean delete() throws IOException
IOException
public void removeDataFiles(Set<Integer> files) throws IOException
IOException
public int getMaxFileLength()
public void setMaxFileLength(int maxFileLength)
maxFileLength
- the maxFileLength to setpublic void appendedExternally(Location loc, int length) throws IOException
IOException
public Location getNextLocation(Location location) throws IOException, IllegalStateException
IOException
IllegalStateException
public Location getNextLocation(File file, Location lastLocation, boolean thisFileOnly) throws IllegalStateException, IOException
IllegalStateException
IOException
public Location getNextLocation(DataFile dataFile, Location lastLocation, boolean thisFileOnly) throws IOException, IllegalStateException
IOException
IllegalStateException
public ByteSequence read(Location location) throws IOException, IllegalStateException
IOException
IllegalStateException
public Location write(ByteSequence data, boolean sync) throws IOException, IllegalStateException
IOException
IllegalStateException
public Location write(ByteSequence data, Runnable onComplete) throws IOException, IllegalStateException
IOException
IllegalStateException
public void update(Location location, ByteSequence data, boolean sync) throws IOException
IOException
public File getDirectory()
public void setDirectory(File directory)
public String getFilePrefix()
public void setFilePrefix(String filePrefix)
public Map<Journal.WriteKey,Journal.WriteCommand> getInflightWrites()
public Location getLastAppendLocation()
public void setLastAppendLocation(Location lastSyncedLocation)
public File getDirectoryArchive()
public void setDirectoryArchive(File directoryArchive)
public boolean isArchiveDataLogs()
public void setArchiveDataLogs(boolean archiveDataLogs)
public Integer getCurrentDataFileId()
public Set<File> getFiles()
public Map<Integer,DataFile> getFileMap()
public long getDiskSize()
public void setReplicationTarget(ReplicationTarget replicationTarget)
public ReplicationTarget getReplicationTarget()
public String getFileSuffix()
public void setFileSuffix(String fileSuffix)
public boolean isChecksum()
public void setChecksum(boolean checksumWrites)
public boolean isCheckForCorruptionOnStartup()
public void setCheckForCorruptionOnStartup(boolean checkForCorruptionOnStartup)
public void setWriteBatchSize(int writeBatchSize)
public int getWriteBatchSize()
public void setSizeAccumulator(AtomicLong storeSizeAccumulator)
public void setEnableAsyncDiskSync(boolean val)
public boolean isEnableAsyncDiskSync()
Copyright © 2005–2017. All rights reserved.