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.Closeable
Simple wrapper around FileChannel to add versioning information to the file.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) BufferedChannel
bc
(package private) BookieFileChannel
channel
(package private) ServerConfiguration
configuration
(package private) static int
CURRENT_JOURNAL_FORMAT_VERSION
(package private) java.nio.channels.FileChannel
fc
(package private) int
fd
(package private) int
formatVersion
(package private) static int
HEADER_SIZE
(package private) byte[]
magicWord
(package private) static long
MB
(package private) static int
MIN_COMPAT_JOURNAL_FORMAT_VERSION
(package private) long
nextPrealloc
(package private) static int
SECTOR_SIZE
(package private) static int
V1
(package private) static int
V2
(package private) static int
V3
(package private) static int
V4
(package private) static int
V5
static int
V6
(package private) static int
VERSION_HEADER_SIZE
java.nio.ByteBuffer
zeros
-
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 void
close()
void
forceWrite(boolean forceMetadata)
(package private) BufferedChannel
getBufferedChannel()
(package private) int
getFormatVersion()
(package private) void
preAllocIfNeeded(long size)
(package private) int
read(java.nio.ByteBuffer dst)
static void
renameJournalFile(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:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Throws:
java.io.IOException
-
forceWrite
public void forceWrite(boolean forceMetadata) throws java.io.IOException
- Throws:
java.io.IOException
-
-