public class WriteAheadLog
extends java.lang.Object
StoreWAL
Modifier and Type | Class and Description |
---|---|
static interface |
WriteAheadLog.WALReplay |
Modifier and Type | Field and Description |
---|---|
protected Volume |
curVol |
protected long |
featureBitMap |
protected boolean |
fileDeleteAfterOpen |
protected long |
fileNum |
protected long |
fileOffset |
protected java.util.concurrent.locks.ReentrantLock |
fileOffsetLock |
protected static int |
I_BYTE_ARRAY |
protected static int |
I_COMMIT |
protected static int |
I_EOF |
protected static int |
I_LONG |
protected static int |
I_PREALLOCATE |
protected static int |
I_RECORD |
protected static int |
I_ROLLBACK |
protected static int |
I_SKIP_MANY |
protected static int |
I_SKIP_SINGLE |
protected static int |
I_TOMBSTONE |
protected int |
lastChecksum |
protected long |
lastChecksumOffset |
protected static long |
MAX_FILE_RESERVE |
protected static long |
MAX_FILE_SIZE |
static WriteAheadLog.WALReplay |
NOREPLAY
does nothing
|
protected int |
pointerFileBites |
protected long |
pointerFileMask |
protected int |
pointerOffsetBites |
protected long |
pointerOffsetMask |
protected int |
pointerSizeBites |
protected long |
pointerSizeMask |
protected java.util.List<Volume> |
volumes |
protected static int |
WAL_HEADER
4 byte file header
|
protected static long |
WAL_SEAL |
protected java.util.List<Volume> |
walRec
record WALs, store recid-record pairs.
|
Constructor and Description |
---|
WriteAheadLog(java.lang.String fileName) |
WriteAheadLog(java.lang.String fileName,
VolumeFactory volumeFactory,
long featureBitMap,
boolean fileDeleteAfterOpen) |
Modifier and Type | Method and Description |
---|---|
protected long |
allocate(int reqSize,
int optSize)
Allocate space in WAL
|
protected int |
checksum(Volume vol,
long startOffset,
long endOffset) |
void |
close() |
void |
commit() |
void |
destroyWalFiles() |
protected void |
ensureFileReady(boolean addressable) |
boolean |
fileLoad() |
protected void |
fileOffsetSet(long fileOffset) |
java.lang.Iterable<java.lang.String> |
getAllFiles() |
long |
getNumberOfFiles() |
protected java.lang.String |
getWalFileName(java.lang.String ext) |
void |
initFailedCloseFiles() |
void |
replayWAL(WriteAheadLog.WALReplay replay) |
void |
rollback() |
void |
seal() |
void |
startNextFile() |
void |
sync() |
DataInput2 |
walGetByteArray(long walPointer)
Retrieve
DataInput from WAL. |
byte[] |
walGetByteArray2(long walPointer)
Retrieve
byte[] from WAL. |
byte[] |
walGetRecord(long walPointer,
long expectedRecid) |
protected long |
walPointer(long size,
long fileNum,
long offset) |
protected long |
walPointerToFileNum(long walPointer) |
protected long |
walPointerToOffset(long walPointer) |
protected int |
walPointerToSize(long walPointer) |
long |
walPutByteArray(long offset,
byte[] buf,
int bufPos,
int size)
Puts instruction into WAL.
|
void |
walPutLong(long offset,
long value)
Put 8 byte long into WAL.
|
void |
walPutPreallocate(long recid) |
long |
walPutRecord(long recid,
byte[] buf,
int bufPos,
int size) |
void |
walPutTombstone(long recid) |
protected static final int WAL_HEADER
protected static final long WAL_SEAL
protected static final int I_EOF
protected static final int I_LONG
protected static final int I_BYTE_ARRAY
protected static final int I_SKIP_MANY
protected static final int I_SKIP_SINGLE
protected static final int I_RECORD
protected static final int I_TOMBSTONE
protected static final int I_PREALLOCATE
protected static final int I_COMMIT
protected static final int I_ROLLBACK
protected static final long MAX_FILE_SIZE
protected static final long MAX_FILE_RESERVE
protected final long featureBitMap
protected final int pointerOffsetBites
protected final long pointerOffsetMask
protected final int pointerSizeBites
protected final long pointerSizeMask
protected final int pointerFileBites
protected final long pointerFileMask
protected final boolean fileDeleteAfterOpen
protected int lastChecksum
protected long lastChecksumOffset
public static final WriteAheadLog.WALReplay NOREPLAY
protected volatile long fileOffset
protected java.util.concurrent.locks.ReentrantLock fileOffsetLock
protected final java.util.List<Volume> volumes
protected final java.util.List<Volume> walRec
protected Volume curVol
protected long fileNum
public WriteAheadLog(java.lang.String fileName, VolumeFactory volumeFactory, long featureBitMap, boolean fileDeleteAfterOpen)
public WriteAheadLog(java.lang.String fileName)
public void initFailedCloseFiles()
public void close()
public void seal()
public void startNextFile()
public void rollback()
public void commit()
protected int checksum(Volume vol, long startOffset, long endOffset)
public boolean fileLoad()
public void sync()
@NotNull public java.lang.Iterable<java.lang.String> getAllFiles()
protected long allocate(int reqSize, int optSize)
reqSize
- space which can not cross page boundariesoptSize
- space which can cross page boundariesprotected void fileOffsetSet(long fileOffset)
public void replayWAL(WriteAheadLog.WALReplay replay)
public void destroyWalFiles()
protected java.lang.String getWalFileName(java.lang.String ext)
public long getNumberOfFiles()
public DataInput2 walGetByteArray(long walPointer)
DataInput
from WAL. This data were written by walPutByteArray(long, byte[], int, int)
walPointer
- pointer returned by walPutByteArray(long, byte[], int, int)
public byte[] walGetByteArray2(long walPointer)
byte[]
from WAL. This data were written by walPutByteArray(long, byte[], int, int)
walPointer
- pointer returned by walPutByteArray(long, byte[], int, int)
protected long walPointerToOffset(long walPointer)
protected long walPointerToFileNum(long walPointer)
protected int walPointerToSize(long walPointer)
public byte[] walGetRecord(long walPointer, long expectedRecid)
public long walPutByteArray(long offset, byte[] buf, int bufPos, int size)
byte[]
at given offset.
This value returns pointer to WAL, which can be used to retrieve data back with walGetByteArray(long)
.
Pointer is composed of file number, and offset in WAL file.offset
- where data will be written in main store, after WAL replay (6 bytes)buf
- byte array of databufPos
- starting position within byte arraysize
- number of bytes to take from byte arrayprotected long walPointer(long size, long fileNum, long offset)
public long walPutRecord(long recid, byte[] buf, int bufPos, int size)
public void walPutLong(long offset, long value)
offset
- where data will be written in main store, after WAL replay (6 bytes)value
- protected void ensureFileReady(boolean addressable)
public void walPutTombstone(long recid)
public void walPutPreallocate(long recid)
Copyright © 2018. All Rights Reserved.