public static class WriteCache.FileChannelScatteredWriteCache extends WriteCache
RWStore
since the writes
can be made to any part of the file assigned for data allocation.
The writeonChannel must therefore utilize the WriteCache.RecordMetadata
to
write each update separately.
To support HA, we prefix each write with the file position and buffer length in the cache. This enables the cache buffer to be sent as a single stream and the RecordMap rebuilt downstream.
WriteCache.FileChannelScatteredWriteCache, WriteCache.FileChannelWriteCache, WriteCache.HAPackage, WriteCache.ReadCache, WriteCache.RecordMetadata
counters, log, recordMap
Constructor and Description |
---|
WriteCache.FileChannelScatteredWriteCache(IBufferAccess buf,
boolean useChecksum,
boolean isHighlyAvailable,
boolean bufferHasData,
IReopenChannel<FileChannel> opener,
long fileExtent,
BufferedWrite bufferedWrite) |
Modifier and Type | Method and Description |
---|---|
protected void |
addAddress(int latchedAddr,
int size)
A record add has been decoded.
|
protected void |
removeAddress(int latchedAddr)
A record delete has been decoded.
|
void |
resetRecordMapFromBuffer(ByteBuffer buf,
Map<Long,WriteCache.RecordMetadata> recordMap)
Hook to rebuild
WriteCache.RecordMetadata after buffer has been
transferred. |
protected boolean |
writeOnChannel(ByteBuffer data,
long firstOffsetIgnored,
Map<Long,WriteCache.RecordMetadata> recordMap,
long nanos)
Called by WriteCacheService to process a direct write for large
blocks and also to flush data from dirty caches.
|
allocate, bytesWritten, capacity, close, closeForWrites, contains, decrementReferenceCount, flush, flush, getCompressorKey, getCounters, getFileExtent, getLastOffset, getReferenceCount, incrementReferenceCount, isClosedForWrites, read, registerWriteStatus, reset, resetRecordMapFromBuffer, setFileExtent, setFirstOffset, setRecordMap, toString, write
public WriteCache.FileChannelScatteredWriteCache(IBufferAccess buf, boolean useChecksum, boolean isHighlyAvailable, boolean bufferHasData, IReopenChannel<FileChannel> opener, long fileExtent, BufferedWrite bufferedWrite) throws InterruptedException
baseOffset
- An offsetbuf
- opener
- InterruptedException
protected boolean writeOnChannel(ByteBuffer data, long firstOffsetIgnored, Map<Long,WriteCache.RecordMetadata> recordMap, long nanos) throws InterruptedException, IOException
writeOnChannel
in class WriteCache
data
- The data to be written. Only the dirty bytes are visible in
this view. The implementation should write all bytes from the
current position to the limit.firstOffsetIgnored
- The offset of the first record in the recordMap into the file
(may be relative to a base offset within the file). This is
provided as an optimization for the WORM which writes its
records contiguously on the backing store.recordMap
- The mapping of record offsets onto metadata about those
records.nanos
- The timeout for the operation in nanoseconds.true
if the operation was completed successfully
within the time alloted.InterruptedException
- if the thread was interrupted.IOException
- if there was an IO problem.public void resetRecordMapFromBuffer(ByteBuffer buf, Map<Long,WriteCache.RecordMetadata> recordMap)
WriteCache.RecordMetadata
after buffer has been
transferred. For the WriteCache.FileChannelScatteredWriteCache
this
means hopping trough the buffer marking offsets and data size into
the WriteCache.RecordMetadata
map, and ignoring any zero address entries
that indicate a "freed" allocation.
Update: This has now been changed to avoid problems with incremental checksums by indicating removal by appending a new prefix where the data length is zero.
resetRecordMapFromBuffer
in class WriteCache
InterruptedException
protected void addAddress(int latchedAddr, int size)
latchedAddr
- The latched address.size
- The size of the allocation in bytes.protected void removeAddress(int latchedAddr)
latchedAddr
- The latched address.Copyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.