public abstract class AbstractBufferStrategy extends AbstractRawWormStore implements IBufferStrategy
IBufferStrategy implementation.| Modifier and Type | Field and Description | 
|---|---|
| protected BufferMode | bufferModeThe buffer strategy implemented by this class. | 
| protected AtomicLong | commitOffsetThe WORM address of the last committed allocation. | 
| static String | ERR_ADDRESS_IS_NULLText of the error message used when a ZERO (0L) is passed as an address
 to  IRawStore.read(long)or similar methods. | 
| static String | ERR_ADDRESS_NOT_WRITTENText of the error message used when an address is given has never been
 written. | 
| static String | ERR_BAD_RECORD_SIZEError message used when the record size is invalid (e.g., negative). | 
| static String | ERR_BUFFER_EMPTYText of the error message used when a  ByteBufferwith zero bytesBuffer.remaining()is passed toIRawStore.write(ByteBuffer). | 
| static String | ERR_BUFFER_NULLText of the error message used when a  nullreference is
 provided for aByteBuffer. | 
| static String | ERR_BUFFER_OVERRUNError message used when an operation would write more data than would be
 permitted onto a buffer. | 
| static String | ERR_MAX_EXTENTText of the error message used when a write operation would exceed the
 maximum extent for a backing store. | 
| static String | ERR_NOT_OPENError message used when the store is closed but the operation requires
 that the store is open. | 
| static String | ERR_OPENError message used when the store is open by the operation requires that
 the store is closed. | 
| static String | ERR_READ_ONLYError message used when the writes are not allowed. | 
| static String | ERR_RECORD_LENGTH_ZEROText of the error message used when an address provided to
  IRawStore.read(long)or a similar method encodes a record length
 of zero (0). | 
| static String | ERR_TRUNCATEText of the error message used when
  IBufferStrategy.truncate(long)would truncate data that has
 already been written. | 
| protected long | initialExtent | 
| protected static org.apache.log4j.Logger | logLog for buffer operations. | 
| protected long | maximumExtent | 
| protected AtomicLong | nextOffsetThe next offset at which a data item would be written on the store as an
 offset into the user extent (offset zero(0) addresses the first
 byte after the root blocks). | 
| protected static boolean | WARN | 
amNULL| Modifier and Type | Method and Description | 
|---|---|
| void | abort()A method that requires the implementation to discard its buffered write
 set (if any). | 
| protected void | assertOpen() | 
| void | close()Manages the  openflag state. | 
| void | closeForWrites()Sets the  readOnlyflag. | 
| void | commit()A method that removes assumptions of how a specific strategy commits
 data. | 
| void | delete(long addr)The default is a NOP. | 
| void | destroy()Closes the store immediately (if open) and deletes its persistent
 resources. | 
| BufferMode | getBufferMode()The buffer mode supported by the implementation | 
| long | getInitialExtent()The initial extent. | 
| long | getMaximumExtent()The maximum extent allowable before a buffer overflow operation will be
 rejected. | 
| int | getMaxRecordSize()The maximum size of a record for the address manager less 4 bytes iff
 checksums are enabled. | 
| long | getMetaBitsAddr()The RWStrategy requires meta allocation info in the root block, this
 method is the hook to enable access. | 
| long | getMetaStartAddr()The RWStrategy requires meta allocation info in the root block, this
 method is the hook to enable access. | 
| protected long | getMinimumExtension()The minimum amount to extend the backing storage when it overflows. | 
| long | getNextOffset()The next offset at which a data item would be written on the store as an
 offset into the user extent. | 
| IResourceMetadata | getResourceMetadata()Not supported - this is available on the  AbstractJournal. | 
| UUID | getUUID()Not supported - this is available on the  AbstractJournal. | 
| boolean | isDirty()Return  trueif the store has been modified since the lastIBufferStrategy.commit()orIBufferStrategy.abort(). | 
| boolean | isOpen()trueiff the store is open. | 
| boolean | isReadOnly()trueiff the store does not allow writes. | 
| boolean | overflow(long needed)Invoked if the store would exceed its current extent by
  IRawStore.write(ByteBuffer). | 
| boolean | requiresCommit(IRootBlockView block)A method that removes assumptions of how a specific strategy determines
 whether a transaction commit is required. | 
| long | size()The #of application data bytes written on the store (does not count any
 headers or root blocks that may exist for the store). | 
| protected static long | transferFromDiskTo(IDiskBasedStrategy src,
                  RandomAccessFile out)Helper method used by  DiskBackedBufferStrategyandDiskOnlyStrategyto implementIBufferStrategy.transferTo(RandomAccessFile)using aFileChanneltoFileChanneltransfer. | 
| boolean | useChecksums() | 
getAddressManager, getByteCount, getOffset, getOffsetBits, getPhysicalAddress, toAddr, toStringgetInputStream, getOutputStreamclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetAddressManager, getCounters, getExtent, getHeaderSize, getOffsetBits, getUserExtent, readRootBlock, transferTo, truncate, writeRootBlockdeleteResources, force, getFile, isFullyBuffered, isStable, read, writegetByteCount, getOffset, getPhysicalAddress, toAddr, toStringgetInputStream, getOutputStreamprotected static final org.apache.log4j.Logger log
protected static final boolean WARN
public static final String ERR_BUFFER_EMPTY
ByteBuffer with zero bytes
 Buffer.remaining() is passed to IRawStore.write(ByteBuffer).public static final String ERR_BUFFER_NULL
null reference is
 provided for a ByteBuffer.public static final String ERR_ADDRESS_NOT_WRITTEN
nextOffset on which data
 would be written may be easily detected.public static final String ERR_ADDRESS_IS_NULL
IRawStore.read(long) or similar methods. This value 0L is
 reserved to indicate a persistent null reference and may never be read.public static final String ERR_RECORD_LENGTH_ZERO
IRawStore.read(long) or a similar method encodes a record length
 of zero (0). Empty records are not permitted on write and addresses with
 a zero length are rejected on read.public static final String ERR_MAX_EXTENT
public static final String ERR_TRUNCATE
IBufferStrategy.truncate(long) would truncate data that has
 already been written.public static final String ERR_READ_ONLY
public static final String ERR_BAD_RECORD_SIZE
public static final String ERR_NOT_OPEN
public static final String ERR_OPEN
public static final String ERR_BUFFER_OVERRUN
protected final long initialExtent
protected final long maximumExtent
protected final BufferMode bufferMode
protected final AtomicLong nextOffset
 Note: It is NOT safe to reload the current root block and therefore reset
 this to an earlier offset unless all transactions are discarded. The
 reason is that transactions may use objects (btrees) to provide
 isolation. Those objects write on the store but do not register as
 ICommitters and therefore never make themselves restart safe.
 However, you can not discard the writes of those objects unless the
 entire store is being restarted, e.g., after a shutdown or a crash.
 
 Note: An AtomicLong is used to provide an object on which we can
 lock when assigning the next record's address and synchronously updating
 the counter value. It also ensures that threads can not see a stale value
 for the counter.
protected final AtomicLong commitOffset
public final long getInitialExtent()
IBufferStrategygetInitialExtent in interface IBufferStrategypublic final long getMaximumExtent()
IBufferStrategy
 Note: The semantics here differ from those defined by
 Options.MAXIMUM_EXTENT. The latter specifies the threshold at
 which a journal will overflow (onto another journal) while this specifies
 the maximum size to which a buffer is allowed to grow.
 
 Note: This is normally zero (0L), which basically means that
 the maximum extent is ignored by the IBufferStrategy but
 respected by the AbstractJournal, resulting in a soft limit
 on journal overflow.
getMaximumExtent in interface IBufferStrategy0L
         iff no limit is imposed.protected long getMinimumExtension()
public final BufferMode getBufferMode()
IBufferStrategygetBufferMode in interface IBufferStrategypublic final long getNextOffset()
IBufferStrategygetNextOffset in interface IBufferStrategypublic final long size()
IRawStoreprotected final void assertOpen()
public boolean isOpen()
IRawStoretrue iff the store is open.public boolean isReadOnly()
IRawStoretrue iff the store does not allow writes.isReadOnly in interface IRawStorepublic final void destroy()
IRawStoreIllegalStateException if the store
 is already closed, but still deletes the backing resources.destroy in interface IRawStoreIRawStore.deleteResources()public final boolean overflow(long needed)
IRawStore.write(ByteBuffer). The default behavior extends the capacity of
 the buffer by the at least the requested amount and a maximum of 32M or
 the Options.INITIAL_EXTENT.
 If the data are fully buffered, then the maximum store size is limited to int32 bytes which is the maximum #of bytes that can be addressed in RAM (the pragmatic maximum is slightly less than 2G due to the limits of the JVM to address system memory).
protected static long transferFromDiskTo(IDiskBasedStrategy src, RandomAccessFile out) throws IOException
DiskBackedBufferStrategy and
 DiskOnlyStrategy to implement
 IBufferStrategy.transferTo(RandomAccessFile) using a
 FileChannel to FileChannel transfer.src - The source.out - The output file.IOExceptionpublic UUID getUUID()
AbstractJournal.getUUID in interface IRawStoreUnsupportedOperationException - alwayspublic IResourceMetadata getResourceMetadata()
AbstractJournal.getResourceMetadata in interface IRawStoreUnsupportedOperationException - alwayspublic void closeForWrites()
readOnly flag.
 Note: This method SHOULD be extended to release write caches, etc.
closeForWrites in interface IBufferStrategypublic void delete(long addr)
delete in interface IRawStoredelete in class AbstractRawStoreaddr - 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 boolean isDirty()
true if the store has been modified since the last
 IBufferStrategy.commit() or IBufferStrategy.abort().
 This implementation checks the current allocation offset with that in the rootBlock
isDirty in interface IBufferStrategypublic void commit()
IBufferStrategycommit in interface IBufferStrategypublic void abort()
IBufferStrategyabort in interface IBufferStrategypublic long getMetaBitsAddr()
IBufferStrategygetMetaBitsAddr in interface IBufferStrategypublic long getMetaStartAddr()
IBufferStrategygetMetaStartAddr in interface IBufferStrategypublic boolean requiresCommit(IRootBlockView block)
IBufferStrategyrequiresCommit in interface IBufferStrategyblock - The root block held by the client, can be checked against the
            state of the Buffer Strategypublic int getMaxRecordSize()
getMaxRecordSize in interface IBufferStrategypublic boolean useChecksums()
useChecksums in interface IBufferStrategyCopyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.