com.bigdata.journal
Class RootBlockView

java.lang.Object
  extended by com.bigdata.journal.RootBlockView
All Implemented Interfaces:
IRootBlockView

public class RootBlockView
extends Object
implements IRootBlockView

A view onto a root block of the Journal.

Version:
$Id: RootBlockView.java 2265 2009-10-26 12:51:06Z thompsonbry $
Author:
Bryan Thompson

Field Summary
static org.apache.log4j.Logger log
          Logger.
 
Method Summary
 ByteBuffer asReadOnlyBuffer()
          A read-only buffer whose contents are the root block.
 int calcChecksum(ChecksumUtility checker)
          Compute the checksum of the root block (excluding only the field including the checksum value itself).
 long getChallisField()
          The "Challis field" is written at both the head and the tail of each root block and is a strictly increasing value positive long integer.
 int getChecksum(ChecksumUtility checker)
          Return the checksum store in the root block (excluding only the field including the checksum value itself).
 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 getLocalTime()
          A purely informative field whose value is the system local timestamp of the last commit as reported by System.currentTimeMillis() or the time at which the store was created iff there have been no commits.
 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.
 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.
 String toString()
           
 void valid()
          Assertion throws exception unless the root block is valid.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

log

public static final org.apache.log4j.Logger log
Logger.

Method Detail

isRootBlock0

public boolean isRootBlock0()
Description copied from interface: IRootBlockView
There are two root blocks and they are written in an alternating order. For the sake of distinction, the first one is referred to as "rootBlock0" while the 2nd one is referred to as "rootBlock1". This method indicates which root block is represented by this view based on metadata supplied to the constructor (the distinction is not persistent on disk).

Specified by:
isRootBlock0 in interface IRootBlockView
Returns:
True iff the root block view was constructed from "rootBlock0".

asReadOnlyBuffer

public ByteBuffer asReadOnlyBuffer()
Description copied from interface: IRootBlockView
A read-only buffer whose contents are the root block. The position, limit, and mark will be independent for each ByteBuffer that is returned by this method.

Specified by:
asReadOnlyBuffer in interface IRootBlockView

getVersion

public int getVersion()
Description copied from interface: IRootBlockView
The root block version number.

Specified by:
getVersion in interface IRootBlockView

getOffsetBits

public int getOffsetBits()
Description copied from interface: IRootBlockView
The #of bits in a 64-bit long integer address that are dedicated to the byte offset into the store.

Specified by:
getOffsetBits in interface IRootBlockView
See Also:
WormAddressManager

getNextOffset

public long getNextOffset()
Description copied from interface: IRootBlockView
The next offset at which a data item would be written on the store.

Specified by:
getNextOffset in interface IRootBlockView

getLocalTime

public long getLocalTime()
A purely informative field whose value is the system local timestamp of the last commit as reported by System.currentTimeMillis() or the time at which the store was created iff there have been no commits. Unlike getFirstCommitTime() and getLastCommitTime() this field does NOT provide a guarentee that time is strictly increasing.

Note: This field is stored for post-mortem purposes and is NOT used internally.

Returns:
A purely informative field whose value is the system local timestamp of the last commit.

getFirstCommitTime

public long getFirstCommitTime()
Description copied from interface: IRootBlockView
The database wide timestamp of first commit on the store -or- 0L if there have been no commits. In a local database, this timestamp is generated by a local timestamp service. In a distributed database, this timestamp is generated by a shared timestamp service. The timestamps returned by this method are strictly increasing for a given store and for a given database.

Specified by:
getFirstCommitTime in interface IRootBlockView
Returns:
The timestamp of the first commit on the store or 0L iff there have been no commits.

getLastCommitTime

public long getLastCommitTime()
Description copied from interface: IRootBlockView
The database wide timestamp of the most recent commit on the store or 0L iff there have been no commits. In a local database, this timestamp is generated by a local timestamp service. In a distributed database, this timestamp is generated by a shared timestamp service. The timestamps returned by this method are strictly increasing for a given store and for a given database.

Specified by:
getLastCommitTime in interface IRootBlockView
Returns:
The timestamp of the most recent commit on the store or 0L iff there have been no commits.

getChallisField

public long getChallisField()
                     throws RootBlockException
The "Challis field" is written at both the head and the tail of each root block and is a strictly increasing value positive long integer. This field is used to detect partial writes of the root blocks (the values of the field in a given root block will not agree). This field is also used to identify which of the two root blocks is more recent (it will have the larger value for this field).

Returns:
The value of the "Challis" field.
Throws:
RootBlockException - if the values on the root block do not agree.

getCommitCounter

public long getCommitCounter()
Description copied from interface: IRootBlockView
The commit counter is a positive long integer that is strictly local to the store. The commit counter is used to avoid problems with timestamps generated by different machines or when time goes backwards or other nasty stuff. The correct root block is choosen by selecting the valid root block with the larger commit counter (the value of the commit counter is reused by the Challis field).

Specified by:
getCommitCounter in interface IRootBlockView
Returns:
The commit counter.

getCommitRecordAddr

public long getCommitRecordAddr()
Description copied from interface: IRootBlockView
Return the address at which the ICommitRecord for this root block is stored. The ICommitRecords 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.

Specified by:
getCommitRecordAddr in interface IRootBlockView
Returns:
The address at which the ICommitRecord for this root block is stored.

getCommitRecordIndexAddr

public long getCommitRecordIndexAddr()
Description copied from interface: IRootBlockView
The address of the root of the CommitRecordIndex. The CommitRecordIndex contains the ordered addresses of the historical ICommitRecords 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.

Specified by:
getCommitRecordIndexAddr in interface IRootBlockView

valid

public void valid()
Description copied from interface: IRootBlockView
Assertion throws exception unless the root block is valid. Conditions tested include the root block MAGIC and the root block timestamps (there are two and they must agree).

Specified by:
valid in interface IRootBlockView

getUUID

public UUID getUUID()
Description copied from interface: IRootBlockView
The unique journal identifier

Specified by:
getUUID in interface IRootBlockView

getCreateTime

public long getCreateTime()
Description copied from interface: IRootBlockView
The timestamp assigned as the creation time for the journal.

Specified by:
getCreateTime in interface IRootBlockView

getCloseTime

public long getCloseTime()
Description copied from interface: IRootBlockView
The timestamp assigned as the time at which writes were disallowed for the journal.

Specified by:
getCloseTime in interface IRootBlockView

getChecksum

public int getChecksum(ChecksumUtility checker)
                throws RootBlockException
Return the checksum store in the root block (excluding only the field including the checksum value itself).

Parameters:
checker - An object used to compute the checksum. Note that you can disable the checksum test by passing in a null value here.
Returns:
The checksum stored in the root block.
Throws:
RootBlockException - if the checksum stored in the root block does not agree with the checksum computed by calcChecksum(ChecksumUtility).

calcChecksum

public int calcChecksum(ChecksumUtility checker)
Compute the checksum of the root block (excluding only the field including the checksum value itself).


toString

public String toString()
Overrides:
toString in class Object


Copyright © 2006-2009 SYSTAP, LLC. All Rights Reserved.