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
BufferMode
s. 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.Temporary
bufferMode, 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, WARN
am
NULL
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 RuntimeException s) 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, useChecksums
getAddressManager, getByteCount, getOffset, getOffsetBits, getPhysicalAddress, toAddr, toString
getInputStream, getOutputStream
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
abort, getAddressManager, getBufferMode, getInitialExtent, getMaximumExtent, getMaxRecordSize, getMetaBitsAddr, getMetaStartAddr, getNextOffset, getOffsetBits, isDirty, requiresCommit, useChecksums
destroy, getResourceMetadata, getUUID, isOpen, isReadOnly, size
getByteCount, getOffset, getPhysicalAddress, toAddr, toString
getInputStream, getOutputStream
public void commit()
commit
in interface IBufferStrategy
commit
in class AbstractBufferStrategy
public final int getHeaderSize()
IDiskBasedStrategy
getHeaderSize
in interface IBufferStrategy
getHeaderSize
in interface IDiskBasedStrategy
public final File getFile()
IDiskBasedStrategy
getFile
in interface IDiskBasedStrategy
getFile
in interface IRawStore
public 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 IDiskBasedStrategy
public 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 IDiskBasedStrategy
public WORMStrategy.StoreCounters getStoreCounters()
public void setStoreCounters(WORMStrategy.StoreCounters storeCounters)
WORMStrategy.StoreCounters
object.storeCounters
- The new BTree.Counter
s.IllegalArgumentException
- if the argument is null
.public CounterSet getCounters()
getCounters
in interface ICounterSetAccess
getCounters
in interface IBufferStrategy
public final boolean isStable()
IRawStore
public boolean isFullyBuffered()
IRawStore
Note: This does not guarantee that the OS will not swap the buffer onto disk.
isFullyBuffered
in interface IRawStore
public void force(boolean metadata)
flushes
the writeCache
before syncing
the disk.public void close()
close
in interface IRawStore
close
in class AbstractBufferStrategy
public void deleteResources()
IRawStore
deleteResources
in interface IRawStore
public final long getExtent()
IBufferStrategy
Options.INITIAL_EXTENT
.getExtent
in interface IBufferStrategy
public 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 IBufferStrategy
public ByteBuffer read(long addr)
ClosedChannelException
and
AsynchronousCloseException
can get thrown out of this method
(wrapped as RuntimeException
s) if a reader task is interrupted.read
in interface IRawStore
addr
- 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)
IRawStore
write
in interface IRawStore
data
- 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)
IBufferStrategy
readRootBlock
in interface IBufferStrategy
public void writeRootBlock(IRootBlockView rootBlock, ForceEnum forceOnCommit)
IBufferStrategy
writeRootBlock
in interface IBufferStrategy
rootBlock
- The root block. Which root block is indicated by
IRootBlockView.isRootBlock0()
.public void truncate(long newExtent)
IBufferStrategy
Note: Implementations of this method MUST be synchronized so that the operation is atomic with respect to concurrent writers.
truncate
in interface IBufferStrategy
newExtent
- 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
IBufferStrategy
Note: Implementations of this method MUST be synchronized so that the operation is atomic with respect to concurrent writers.
transferTo
in interface IBufferStrategy
out
- The file to which the buffer contents will be transferred.IOException
public 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 IBufferStrategy
closeForWrites
in class AbstractBufferStrategy
public void delete(long addr)
AbstractBufferStrategy
delete
in interface IRawStore
delete
in class AbstractBufferStrategy
addr
- 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.