public interface IRootBlockView
The commit counter is a store local strictly increasing non-negative long integer (commit counters are distinct for each store regardless of whether they are part of the same distributed database). The commit counters MUST be strictly increasing (a) so that they place the commit records into a total ordering; (b) so that the more current root block may be choose by comparing the value of the field in each of the two root blocks; and (c) so that a partial write of a root block may be detected by the presence of different values for the field at the head and tail of a given root block. The commit counter is also used as the field written at the head and tail of each root block according to the Challis algorithm. If those fields are the same then the root block is assumed to have been completely written.
Note that random data may still result in an identical value during a partial write. This possibility is guarded against by storing the checksum of the root block.
The first and last commit times are persisted in each root block in order to
support both unisolated commits and transactions, whether in a local or a
distributed database. These "times" are generated by the appropriate
ITransactionManagerService
service, which is responsible both for assigning
transaction start times (which are in fact the transaction identifier) and
transaction commit times, which are stored in root blocks of the various
stored that participate in a given database and reported via
getFirstCommitTime()
and getLastCommitTime()
. While these
do not strictly speaking have to be "times" they do have to be assigned using
the same measure as the transaction identifiers, so either a coordinated time
server or a strictly increasing counter. Regardless, we need to know "when" a
transaction commits as well as "when" it starts whether we measure "when"
using a counter or a clock. Also note that we need to assign "commit times"
even when the operation is unisolated. This means that we have to coordinate
an unisolated commit on a store that is part of a distributed database with
the centralized transaction manager. This should be done as part of the group
commit since we are waiting at that point anyway to optimize IO by minimizing
syncs to disk.
Note that some file systems or disks can re-order writes of by the
application and write the data in a more efficient order. This can cause the
root blocks to be written before the application data is stable on disk. The
Options.DOUBLE_SYNC
option exists to defeat this behavior and ensure
restart-safety for such systems.
Modifier and Type | Field and Description |
---|---|
static long |
NO_BLOCK_SEQUENCE
The value used for
getBlockSequence() for both historical stores
and for stores that do not support this concept. |
Modifier and Type | Method and Description |
---|---|
ByteBuffer |
asReadOnlyBuffer()
A read-only buffer whose contents are the root block.
|
IRootBlockView |
asRootBlock(boolean rootBlock0)
Return a version of the caller's root block that is flagged as either
rootBlock0 or rootBlock1 as indicated by the argument.
|
long |
getBlockSequence()
Return the #of
WriteCache blocks that have been written out as
part of the current write set. |
long |
getCloseTime()
The timestamp assigned as the time at which writes were disallowed for
the journal.
|
long |
getCommitCounter()
The commit counter is a positive long integer that is strictly local to
the store.
|
long |
getCommitRecordAddr()
Return the address at which the
ICommitRecord for this root block
is stored. |
long |
getCommitRecordIndexAddr()
The address of the root of the
CommitRecordIndex . |
long |
getCreateTime()
The timestamp assigned as the creation time for the journal.
|
long |
getFirstCommitTime()
The database wide timestamp of first commit on the store -or- 0L if there
have been no commits.
|
long |
getLastCommitTime()
The database wide timestamp of the most recent commit on the store or 0L
iff there have been no commits.
|
long |
getMetaBitsAddr()
For the
StoreTypeEnum.RW store, where we will read the metadata
bits from. |
long |
getMetaStartAddr()
For the
StoreTypeEnum.RW store, the start of the area of the file
where the allocation blocks are allocated. |
long |
getNextOffset()
The next offset at which a data item would be written on the store.
|
int |
getOffsetBits()
The #of bits in a 64-bit long integer address that are dedicated to the
byte offset into the store.
|
long |
getQuorumToken()
The
Quorum token associated with this commit point or
Quorum.NO_QUORUM if there was no quorum. |
StoreTypeEnum |
getStoreType()
A byte value which specifies whether the backing store is a journal
(log-structured store or WORM) or a read-write store.
|
UUID |
getUUID()
The unique journal identifier
|
int |
getVersion()
The root block version number.
|
boolean |
isRootBlock0()
There are two root blocks and they are written in an alternating order.
|
void |
valid()
Assertion throws exception unless the root block is valid.
|
static final long NO_BLOCK_SEQUENCE
getBlockSequence()
for both historical stores
and for stores that do not support this concept.void valid() throws RootBlockException
RootBlockException
boolean isRootBlock0()
int getVersion()
long getNextOffset()
AbstractJournal
so we can directly decide
how many bytes were "written" (for the WORM) or were "allocated" (for the
RWStore, in which case it should probably be the net of the bytes
allocated and released). Update all the locations in the code which rely
on getNextOffset()
to compute the #of bytes written onto the
store.long getFirstCommitTime()
long getLastCommitTime()
long getCommitCounter()
Challis field
).long getCommitRecordAddr()
ICommitRecord
for this root block
is stored. The ICommitRecord
s are stored separately from the
root block so that they may be indexed by the commit timestamps. This is
necessary in order to be able to quickly recover the root addresses for a
given commit timestamp, which is a featured used to support transactional
isolation.
Note: When a logical journal may overflow onto more than one physical
journal then the address of the ICommitRecord
MAY refer to a
historical physical journal and care MUST be exercised to resolve the
address against the appropriate journal file. [This paragraph is probably
not valid. Verify and remove if it is not true.]
ICommitRecord
for this root
block is stored.long getCommitRecordIndexAddr()
CommitRecordIndex
. The
CommitRecordIndex
contains the ordered addresses of the
historical ICommitRecord
s on the Journal
. The address
of the CommitRecordIndex
is stored directly in the root block
rather than the ICommitRecord
since we can not obtain this
address until after we have formatted and written the
ICommitRecord
.UUID getUUID()
int getOffsetBits()
WormAddressManager
long getCreateTime()
long getCloseTime()
StoreTypeEnum getStoreType()
long getMetaBitsAddr()
StoreTypeEnum.RW
store, where we will read the metadata
bits from. When we start the store up we need to retrieve the metabits
from this address. This is a byte offset into the file and is stored as a
long integer. Normal addresses are calculated with reference to the
allocation blocks. The value for a WORM store is ZERO (0).long getMetaStartAddr()
StoreTypeEnum.RW
store, the start of the area of the file
where the allocation blocks are allocated. This is also a byte offset
into the file and is stored as a 64-bit integer. It is called
metaStartAddr because that is the offset that is used with the
metaBitsAddr to determine how to find the allocation blocks. The value
for a WORM store is ZERO (0).long getQuorumToken()
Quorum
token associated with this commit point or
Quorum.NO_QUORUM
if there was no quorum.
Note: If commit points are part of the resynchronization protocol, they MUST NOT use the current quorum token unless the service is synchronized with the quorum at that commit point.
long getBlockSequence()
WriteCache
blocks that have been written out as
part of the current write set. This value is origin ZERO (0) and is reset
to ZERO (0) after each commit or abort.ByteBuffer asReadOnlyBuffer()
ByteBuffer
that is
returned by this method.IRootBlockView asRootBlock(boolean rootBlock0)
IRootBlockView
in which the sense of the isRootBlock0()
flag is now correct.rootBlock0
- Whether you want rootBlock0 or rootBlock1.Copyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.