com.sleepycat.je.rep.impl.node
Class Replay

java.lang.Object
  extended by com.sleepycat.je.rep.impl.node.Replay

public class Replay
extends Object

Replays log records from the replication stream, and manages the transactions for those records. The Replay module has a lifetime equivalent to the environment owned by this replicator. Its lifetime is longer than the feeder/replica stream. For example, suppose this is nodeX: t1 - Node X is a replica, node A is master. Replay X is alive t2 - Node X is a replica, node B takes over as master. X's Replay module is still alive and has the same set of active txns. It doesn't matter to X that the master has changed. t3 - Node X becomes the master. Now its Replay unit is cleared, because anything managed by the Replay is defunct.


Nested Class Summary
static class Replay.TxnInfo
          Simple helper class to package a Txn vlsn and its associated commit time.
 
Constructor Summary
Replay(RepImpl repImpl, NameIdPair nameIdPair)
           
 
Method Summary
 void abortOldTxns()
          When mastership changes, all inflight replay transactions are aborted.
 void close()
          Release all transactions, database handles, etc held by the replay unit.
 String dumpState()
           
 Map<Long,ReplayTxn> getActiveTxns()
           
 Replay.TxnInfo getLastReplayedTxn()
           
 VLSN getLastReplayedVLSN()
           
 StatGroup getStats(StatsConfig config)
          Returns a copy of the statistics associated with Replay
 void preRecoveryCheckpointInit(RecoveryInfo recoveryInfo)
          Actions that must be taken before the recovery checkpoint, whether the environment is read/write or read/only.
 void replayEntry(NamedChannel namedChannel, Protocol protocol, Protocol.Entry entry)
          Apply the operation represented by this log entry on this replica node.
 void resetStats()
           
 void rollback(VLSN matchpointVLSN, long matchpointLsn)
          Go through all active txns and rollback up to but not including the log entry represented by the matchpoint VLSN.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Replay

public Replay(RepImpl repImpl,
              NameIdPair nameIdPair)
Method Detail

preRecoveryCheckpointInit

public void preRecoveryCheckpointInit(RecoveryInfo recoveryInfo)
Actions that must be taken before the recovery checkpoint, whether the environment is read/write or read/only.


getLastReplayedTxn

public Replay.TxnInfo getLastReplayedTxn()

getLastReplayedVLSN

public VLSN getLastReplayedVLSN()

abortOldTxns

public void abortOldTxns()
                  throws DatabaseException
When mastership changes, all inflight replay transactions are aborted. Replay transactions are only aborted by the new master (who was previously a Replica); the replay transactions on the other replicas are resolved by the abort record issued by said new master.

Throws:
DatabaseException

replayEntry

public void replayEntry(NamedChannel namedChannel,
                        Protocol protocol,
                        Protocol.Entry entry)
                 throws DatabaseException,
                        IOException,
                        InterruptedException,
                        MasterStatus.MasterSyncException
Apply the operation represented by this log entry on this replica node.

Throws:
InterruptedException
MasterStatus.MasterSyncException
DatabaseException
IOException

rollback

public void rollback(VLSN matchpointVLSN,
                     long matchpointLsn)
Go through all active txns and rollback up to but not including the log entry represented by the matchpoint VLSN. Effectively truncate these rolled back log entries by making them invisible. Flush the log first, to make sure these log entries are out of the log buffers and are on disk, so we can reliably find them through the FileManager. Rollback steps are described in https://sleepycat.oracle.com/trac/wiki/Logging#Recoverysteps. In summary, 1. Log and fsync a new RollbackStart record 2. Do the rollback in memory. There is no need to explicitly log INs made dirty by the rollback operation. 3. Do invisibility masking by overwriting LNs. 4. Fsync all overwritten log files at this point. 5. Write a RollbackEnd record, for ease of debugging Note that application read txns can continue to run during syncup. Reader txns cannot access records that are being rolled back, because they are in txns that are not committed, i.e, they are write locked. The rollback interval never includes committed txns, and we do a hard recovery if it would include them.


close

public void close()
Release all transactions, database handles, etc held by the replay unit. The Replicator is closing down and Replay will not be invoked again.


getStats

public StatGroup getStats(StatsConfig config)
Returns a copy of the statistics associated with Replay


resetStats

public void resetStats()

getActiveTxns

public Map<Long,ReplayTxn> getActiveTxns()

dumpState

public String dumpState()


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