com.sleepycat.je.rep.vlsn
Class VLSNTracker

java.lang.Object
  extended by com.sleepycat.je.rep.vlsn.VLSNTracker
Direct Known Subclasses:
VLSNRecoveryTracker

 class VLSNTracker
extends Object

See @link{VLSNIndex} for an overview of the mapping system. The VLSNTracker packages the VLSNRange and the cached, in-memory VLSNBuckets. The tracker has a notion of the "currentBucket", which is the one receiving updates. All other cached buckets are finished and are awaiting a write to the database. Those finished buckets will only be updated in special circumstances, such as log cleaning or replication stream truncation, when we can assume that there will no readers viewing the buckets.


Field Summary
(package private)  SortedMap<Long,VLSNBucket> bucketCache
           
protected  VLSNRange range
           
 
Constructor Summary
VLSNTracker(EnvironmentImpl envImpl, DatabaseImpl mappingDbImpl, int stride, int maxMappings, int maxDistance)
           
VLSNTracker(EnvironmentImpl envImpl, int stride, int maxMappings, int maxDistance)
           
 
Method Summary
(package private)  void append(VLSNRecoveryTracker recoveryTracker)
           
(package private)  void flushToDatabase(DatabaseImpl mappingDbImpl, Txn txn)
          Flush the tracker cache to disk.
(package private)  VLSN getFirstTracked()
           
(package private)  VLSNBucket getGTEBucket(VLSN vlsn)
          Return a bucket for reading a mapping for this VLSN.
(package private)  VLSN getLastOnDisk()
           
(package private)  VLSNBucket getLTEBucket(VLSN vlsn)
          Get the bucket which holds a mapping for this VLSN.
(package private)  VLSNRange getRange()
           
(package private)  void initEmpty()
           
(package private)  boolean isFlushedToDisk()
           
(package private)  void merge(VLSN prunedLastOnDiskVLSN, VLSNRecoveryTracker recoveryTracker)
          Attempt to replace the mappings in this vlsnIndex for deleteStart->lastVLSN with those from the recovery mapper.
 String toString()
           
(package private)  void track(VLSN vlsn, long lsn, byte entryTypeNum)
          Record a new VLSN->LSN mapping.
(package private)  void truncateFromHead(VLSN deleteEnd, long deleteFileNum)
           
(package private)  void truncateFromTail(VLSN deleteStart, long prevLsn)
          Remove the mappings for VLSNs >= deleteStart.
(package private)  boolean verify(boolean verbose)
          For unit test support.
(package private) static boolean verifyBucketBoundaries(ArrayList<VLSN> firstVLSN, ArrayList<VLSN> lastVLSN)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

bucketCache

SortedMap<Long,VLSNBucket> bucketCache

range

protected volatile VLSNRange range
Constructor Detail

VLSNTracker

VLSNTracker(EnvironmentImpl envImpl,
            DatabaseImpl mappingDbImpl,
            int stride,
            int maxMappings,
            int maxDistance)
      throws DatabaseException
Throws:
DatabaseException

VLSNTracker

VLSNTracker(EnvironmentImpl envImpl,
            int stride,
            int maxMappings,
            int maxDistance)
Method Detail

initEmpty

void initEmpty()

getGTEBucket

VLSNBucket getGTEBucket(VLSN vlsn)
Return a bucket for reading a mapping for this VLSN. If vlsn is > lastOnDisk, a bucket is guaranteed to be returned.


getLTEBucket

VLSNBucket getLTEBucket(VLSN vlsn)
Get the bucket which holds a mapping for this VLSN. If there is no such bucket, get the one directly preceeding it. If this VLSN is >= firstTrackedVLSN, then we should be able to guarantee that a bucket is returned.


track

void track(VLSN vlsn,
           long lsn,
           byte entryTypeNum)
Record a new VLSN->LSN mapping. We guarantee that the first and last VLSNs in the range have a mapping. If a VLSN comes out of order, we will discard it, and will not update the range.


flushToDatabase

void flushToDatabase(DatabaseImpl mappingDbImpl,
                     Txn txn)
Flush the tracker cache to disk. Ideally, we'd allow concurent VLSN put() calls while a flush to database is happening. To do that, we need a more sophisticated synchronization scheme that defines the immutable vs. mutable portion of the tracker cache. See SR [#17689]


truncateFromHead

void truncateFromHead(VLSN deleteEnd,
                      long deleteFileNum)

truncateFromTail

void truncateFromTail(VLSN deleteStart,
                      long prevLsn)
Remove the mappings for VLSNs >= deleteStart. This should only be used at syncup, or recovery. We cannot assume that the VLSNIndex is quiescent; checkpoints continue to happen during rollbacks. Since syncup is always at a sync-able log entry, and snce we don't roll back past a commit, we can assume that the lastSync can be changed to deleteStart.getPrev(), and lastTxnEnd is unchanged. The VLSNRange itself is updated by the VLSNIndex, after any on-disk buckets are updated.


merge

void merge(VLSN prunedLastOnDiskVLSN,
           VLSNRecoveryTracker recoveryTracker)
Attempt to replace the mappings in this vlsnIndex for deleteStart->lastVLSN with those from the recovery mapper. Since we do not supply a prevLsn argument, we may not be able to "cap" the truncated vlsn bucket the same what that we can in truncateFromTail. Because of that, we may need to remove mappings that are < deleteStart. For example, suppose a bucket holds mappings 10 -> 101 15 -> 201 18 -> 301 If deleteStart == 17, we will have to delete all the way to vlsn 15. The maintenance of VLSNRange.lastSync and lastTxnEnd are simplified because of assumptions we can make because we are about to append mappings found by the recovery tracke that begin at deleteStart. If lastSync and lastTxnEnd are <= deleteStart, we know that they will either stay the same, or be replaced by lastSync and lastTxnEnd from the recoveryTracker. Even we delete mappings that are < deleteStart, we know that we did not roll back past an abort or commit, so that we do not have to updated the lastSync or lastTxnEnd value.


append

void append(VLSNRecoveryTracker recoveryTracker)

getRange

VLSNRange getRange()

toString

public String toString()
Overrides:
toString in class Object

verify

boolean verify(boolean verbose)
For unit test support.


verifyBucketBoundaries

static boolean verifyBucketBoundaries(ArrayList<VLSN> firstVLSN,
                                      ArrayList<VLSN> lastVLSN)

getFirstTracked

VLSN getFirstTracked()

getLastOnDisk

VLSN getLastOnDisk()

isFlushedToDisk

boolean isFlushedToDisk()


Copyright (c) 2004-2010 Oracle. All rights reserved.