Package org.apache.bookkeeper.bookie
Class JournalChannel
- java.lang.Object
-
- org.apache.bookkeeper.bookie.JournalChannel
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable
class JournalChannel extends java.lang.Object implements java.io.CloseableSimple wrapper around FileChannel to add versioning information to the file.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) BufferedChannelbc(package private) BookieFileChannelchannel(package private) ServerConfigurationconfiguration(package private) static intCURRENT_JOURNAL_FORMAT_VERSION(package private) java.nio.channels.FileChannelfc(package private) intfd(package private) intformatVersion(package private) static intHEADER_SIZE(package private) byte[]magicWord(package private) static longMB(package private) static intMIN_COMPAT_JOURNAL_FORMAT_VERSION(package private) longnextPrealloc(package private) static intSECTOR_SIZE(package private) static intV1(package private) static intV2(package private) static intV3(package private) static intV4(package private) static intV5static intV6(package private) static intVERSION_HEADER_SIZEjava.nio.ByteBufferzeros
-
Constructor Summary
Constructors Constructor Description JournalChannel(java.io.File journalDirectory, long logId)JournalChannel(java.io.File journalDirectory, long logId, long preAllocSize, int writeBufferSize, int journalAlignSize, boolean fRemoveFromPageCache, int formatVersionToWrite, Journal.BufferedChannelBuilder bcBuilder, ServerConfiguration conf, FileChannelProvider provider, java.lang.Long toReplaceLogId)JournalChannel(java.io.File journalDirectory, long logId, long preAllocSize, int writeBufferSize, int journalAlignSize, boolean fRemoveFromPageCache, int formatVersionToWrite, ServerConfiguration conf, FileChannelProvider provider)JournalChannel(java.io.File journalDirectory, long logId, long preAllocSize, int writeBufferSize, long position, ServerConfiguration conf, FileChannelProvider provider)JournalChannel(java.io.File journalDirectory, long logId, long preAllocSize, int writeBufferSize, ServerConfiguration conf, FileChannelProvider provider)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()voidforceWrite(boolean forceMetadata)(package private) BufferedChannelgetBufferedChannel()(package private) intgetFormatVersion()(package private) voidpreAllocIfNeeded(long size)(package private) intread(java.nio.ByteBuffer dst)static voidrenameJournalFile(java.io.File source, java.io.File target)
-
-
-
Field Detail
-
MB
static final long MB
- See Also:
- Constant Field Values
-
channel
final BookieFileChannel channel
-
fd
final int fd
-
fc
final java.nio.channels.FileChannel fc
-
formatVersion
final int formatVersion
-
bc
BufferedChannel bc
-
nextPrealloc
long nextPrealloc
-
magicWord
final byte[] magicWord
-
SECTOR_SIZE
static final int SECTOR_SIZE
- See Also:
- Constant Field Values
-
V1
static final int V1
- See Also:
- Constant Field Values
-
V2
static final int V2
- See Also:
- Constant Field Values
-
V3
static final int V3
- See Also:
- Constant Field Values
-
V4
static final int V4
- See Also:
- Constant Field Values
-
V5
static final int V5
- See Also:
- Constant Field Values
-
V6
public static final int V6
- See Also:
- Constant Field Values
-
HEADER_SIZE
static final int HEADER_SIZE
- See Also:
- Constant Field Values
-
VERSION_HEADER_SIZE
static final int VERSION_HEADER_SIZE
- See Also:
- Constant Field Values
-
MIN_COMPAT_JOURNAL_FORMAT_VERSION
static final int MIN_COMPAT_JOURNAL_FORMAT_VERSION
- See Also:
- Constant Field Values
-
CURRENT_JOURNAL_FORMAT_VERSION
static final int CURRENT_JOURNAL_FORMAT_VERSION
- See Also:
- Constant Field Values
-
zeros
public final java.nio.ByteBuffer zeros
-
configuration
final ServerConfiguration configuration
-
-
Constructor Detail
-
JournalChannel
JournalChannel(java.io.File journalDirectory, long logId) throws java.io.IOException- Throws:
java.io.IOException
-
JournalChannel
JournalChannel(java.io.File journalDirectory, long logId, long preAllocSize, int writeBufferSize, ServerConfiguration conf, FileChannelProvider provider) throws java.io.IOException- Throws:
java.io.IOException
-
JournalChannel
JournalChannel(java.io.File journalDirectory, long logId, long preAllocSize, int writeBufferSize, long position, ServerConfiguration conf, FileChannelProvider provider) throws java.io.IOException- Throws:
java.io.IOException
-
JournalChannel
JournalChannel(java.io.File journalDirectory, long logId, long preAllocSize, int writeBufferSize, int journalAlignSize, boolean fRemoveFromPageCache, int formatVersionToWrite, ServerConfiguration conf, FileChannelProvider provider) throws java.io.IOException- Throws:
java.io.IOException
-
JournalChannel
JournalChannel(java.io.File journalDirectory, long logId, long preAllocSize, int writeBufferSize, int journalAlignSize, boolean fRemoveFromPageCache, int formatVersionToWrite, Journal.BufferedChannelBuilder bcBuilder, ServerConfiguration conf, FileChannelProvider provider, java.lang.Long toReplaceLogId) throws java.io.IOException- Throws:
java.io.IOException
-
-
Method Detail
-
renameJournalFile
public static void renameJournalFile(java.io.File source, java.io.File target) throws java.io.IOException- Throws:
java.io.IOException
-
getFormatVersion
int getFormatVersion()
-
getBufferedChannel
BufferedChannel getBufferedChannel() throws java.io.IOException
- Throws:
java.io.IOException
-
preAllocIfNeeded
void preAllocIfNeeded(long size) throws java.io.IOException- Throws:
java.io.IOException
-
read
int read(java.nio.ByteBuffer dst) throws java.io.IOException
- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Throws:
java.io.IOException
-
forceWrite
public void forceWrite(boolean forceMetadata) throws java.io.IOException- Throws:
java.io.IOException
-
-