WORMStrategy.public class DiskOnlyStrategy extends AbstractBufferStrategy implements IDiskBasedStrategy
Writes are buffered in a write cache. The cache is flushed when it would overflow. As a result only large sequential writes are performed on the store. Reads read through the write cache for consistency.
Note: This is used to realize both the BufferMode.Disk and the
BufferMode.Temporary BufferModes. When configured for the
BufferMode.Temporary mode: the root blocks will not be written onto
the disk, writes will not be forced, and the backing file will be created the
first time the DiskOnlyStrategy attempts to write through to the
disk. For many scenarios, the backing file will never be created unless the
write cache overflows. This provides very low latency on start-up, the same
MRMW capability, and allows very large temporary stores.
FIXME Examine behavior when write caching is enabled/disabled for the OS.
This has a profound impact. Asynchronous writes of multiple buffers, and the
use of smaller buffers, may be absolutely when the write cache is disabled.
It may be that swapping sets in because the Windows write cache is being
overworked, in which case doing incremental and async IO would help. Compare
with behavior on server platforms. See
http://support.microsoft.com/kb/259716,
http://www.accucadd.com/TechNotes/Cache/WriteBehindCache.htm,
http://msdn2.microsoft.com/en-us/library/aa365165.aspx,
http://www.jasonbrome.com/blog/archives/2004/04/03/writecache_enabled.html,
http://support.microsoft.com/kb/811392,
http://mail-archives.apache.org/mod_mbox/db-derby-dev/200609.mbox/%3C44F820A8.6000000@sun.com%3E
/sbin/hdparm -W 0 /dev/hda 0 Disable write caching
/sbin/hdparm -W 1 /dev/hda 1 Enable write caching
BufferMode.Disk,
BufferMode.TemporarybufferMode, commitOffset, ERR_ADDRESS_IS_NULL, ERR_ADDRESS_NOT_WRITTEN, ERR_BAD_RECORD_SIZE, ERR_BUFFER_EMPTY, ERR_BUFFER_NULL, ERR_BUFFER_OVERRUN, ERR_MAX_EXTENT, ERR_NOT_OPEN, ERR_OPEN, ERR_READ_ONLY, ERR_RECORD_LENGTH_ZERO, ERR_TRUNCATE, initialExtent, log, maximumExtent, nextOffset, WARNamNULL| Modifier and Type | Method and Description |
|---|---|
void |
close()
Deprecated.
Closes the file immediately (without flushing any pending writes).
|
void |
closeForWrites()
Deprecated.
Extended to discard the write cache.
|
void |
commit()
Deprecated.
Need to override commit to ensure the writeCache is flushed prior to
writing the root block.
|
void |
delete(long addr)
Deprecated.
The default is a NOP.
|
void |
deleteResources()
Deprecated.
Deletes the backing file(s) (if any).
|
void |
force(boolean metadata)
Deprecated.
flushes the writeCache before syncing
the disk. |
FileChannel |
getChannel()
Deprecated.
Note: This MAY be
null. |
CounterSet |
getCounters()
Deprecated.
Return interesting information about the write cache and file operations.
|
long |
getExtent()
Deprecated.
The current size of the journal in bytes.
|
File |
getFile()
Deprecated.
The backing file.
|
int |
getHeaderSize()
Deprecated.
The size of the file header in bytes.
|
RandomAccessFile |
getRandomAccessFile()
Deprecated.
Note: This MAY be
null. |
WORMStrategy.StoreCounters |
getStoreCounters()
Deprecated.
Returns the performance counters for the store.
|
long |
getUserExtent()
Deprecated.
The size of the user data extent in bytes.
|
boolean |
isFullyBuffered()
Deprecated.
True iff the store is fully buffered (all reads are against memory).
|
boolean |
isStable()
Deprecated.
True iff backed by stable storage.
|
ByteBuffer |
read(long addr)
Deprecated.
Note:
ClosedChannelException and
AsynchronousCloseException can get thrown out of this method
(wrapped as RuntimeExceptions) if a reader task is interrupted. |
ByteBuffer |
readRootBlock(boolean rootBlock0)
Deprecated.
Read the specified root block from the backing file.
|
void |
setCommitRecordIndex(CommitRecordIndex commitRecordIndex)
Deprecated.
|
void |
setNextOffset(long lastOffset)
Deprecated.
|
void |
setStoreCounters(WORMStrategy.StoreCounters storeCounters)
Deprecated.
Replaces the
WORMStrategy.StoreCounters object. |
long |
transferTo(RandomAccessFile out)
Deprecated.
A block operation that transfers the serialized records (aka the written
on portion of the user extent) en mass from the buffer onto an output
file.
|
void |
truncate(long newExtent)
Deprecated.
Either truncates or extends the journal.
|
long |
write(ByteBuffer data)
Deprecated.
Write the data (unisolated).
|
void |
writeRootBlock(IRootBlockView rootBlock,
ForceEnum forceOnCommit)
Deprecated.
Write the root block onto stable storage (ie, flush it through to disk).
|
abort, assertOpen, destroy, getBufferMode, getInitialExtent, getMaximumExtent, getMaxRecordSize, getMetaBitsAddr, getMetaStartAddr, getMinimumExtension, getNextOffset, getResourceMetadata, getUUID, isDirty, isOpen, isReadOnly, overflow, requiresCommit, size, transferFromDiskTo, useChecksumsgetAddressManager, getByteCount, getOffset, getOffsetBits, getPhysicalAddress, toAddr, toStringgetInputStream, getOutputStreamclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitabort, getAddressManager, getBufferMode, getInitialExtent, getMaximumExtent, getMaxRecordSize, getMetaBitsAddr, getMetaStartAddr, getNextOffset, getOffsetBits, isDirty, requiresCommit, useChecksumsdestroy, getResourceMetadata, getUUID, isOpen, isReadOnly, sizegetByteCount, getOffset, getPhysicalAddress, toAddr, toStringgetInputStream, getOutputStreampublic void commit()
commit in interface IBufferStrategycommit in class AbstractBufferStrategypublic final int getHeaderSize()
IDiskBasedStrategygetHeaderSize in interface IBufferStrategygetHeaderSize in interface IDiskBasedStrategypublic final File getFile()
IDiskBasedStrategygetFile in interface IDiskBasedStrategygetFile in interface IRawStorepublic final RandomAccessFile getRandomAccessFile()
null. If BufferMode.Temporary
is used then it WILL be null until the writeCache
is flushed to disk for the first time.getRandomAccessFile in interface IDiskBasedStrategypublic final FileChannel getChannel()
null. If BufferMode.Temporary
is used then it WILL be null until the writeCache
is flushed to disk for the first time.getChannel in interface IDiskBasedStrategypublic WORMStrategy.StoreCounters getStoreCounters()
public void setStoreCounters(WORMStrategy.StoreCounters storeCounters)
WORMStrategy.StoreCounters object.storeCounters - The new BTree.Counters.IllegalArgumentException - if the argument is null.public CounterSet getCounters()
getCounters in interface ICounterSetAccessgetCounters in interface IBufferStrategypublic final boolean isStable()
IRawStorepublic boolean isFullyBuffered()
IRawStoreNote: This does not guarantee that the OS will not swap the buffer onto disk.
isFullyBuffered in interface IRawStorepublic void force(boolean metadata)
flushes the writeCache before syncing
the disk.public void close()
close in interface IRawStoreclose in class AbstractBufferStrategypublic void deleteResources()
IRawStoredeleteResources in interface IRawStorepublic final long getExtent()
IBufferStrategyOptions.INITIAL_EXTENT.getExtent in interface IBufferStrategypublic final long getUserExtent()
IBufferStrategy
Note: The size of the user extent is always generally smaller than the
value reported by IBufferStrategy.getExtent() since the latter also reports the
space allocated to the journal header and root blocks.
getUserExtent in interface IBufferStrategypublic ByteBuffer read(long addr)
ClosedChannelException and
AsynchronousCloseException can get thrown out of this method
(wrapped as RuntimeExceptions) if a reader task is interrupted.read in interface IRawStoreaddr - A long integer that encodes both the offset from which the
data will be read and the #of bytes to be read. See
IAddressManager.toAddr(int, long).public long write(ByteBuffer data)
IRawStorewrite in interface IRawStoredata - The data. The bytes from the current
Buffer.position() to the
Buffer.limit() will be written and the
Buffer.position() will be advanced to the
Buffer.limit() . The caller may subsequently
modify the contents of the buffer without changing the state
of the store (i.e., the data are copied into the store).IAddressManager.public ByteBuffer readRootBlock(boolean rootBlock0)
IBufferStrategyreadRootBlock in interface IBufferStrategypublic void writeRootBlock(IRootBlockView rootBlock, ForceEnum forceOnCommit)
IBufferStrategywriteRootBlock in interface IBufferStrategyrootBlock - The root block. Which root block is indicated by
IRootBlockView.isRootBlock0().public void truncate(long newExtent)
IBufferStrategyNote: Implementations of this method MUST be synchronized so that the operation is atomic with respect to concurrent writers.
truncate in interface IBufferStrategynewExtent - The new extent of the journal. This value represent the total
extent of the journal, including any root blocks together with
the user extent.public long transferTo(RandomAccessFile out) throws IOException
IBufferStrategyNote: Implementations of this method MUST be synchronized so that the operation is atomic with respect to concurrent writers.
transferTo in interface IBufferStrategyout - The file to which the buffer contents will be transferred.IOExceptionpublic void closeForWrites()
Note: The file is NOT closed and re-opened in a read-only mode in order to avoid causing difficulties for concurrent readers.
closeForWrites in interface IBufferStrategycloseForWrites in class AbstractBufferStrategypublic void delete(long addr)
AbstractBufferStrategydelete in interface IRawStoredelete in class AbstractBufferStrategyaddr - A long integer formed using Addr that encodes both the
offset at which the data was written and the #of bytes that
were written.public void setNextOffset(long lastOffset)
public void setCommitRecordIndex(CommitRecordIndex commitRecordIndex)
Copyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.