com.sleepycat.je.rep.impl
Class RepImpl

java.lang.Object
  extended by com.sleepycat.je.dbi.EnvironmentImpl
      extended by com.sleepycat.je.rep.impl.RepImpl
All Implemented Interfaces:
EnvConfigObserver, RepEnvConfigObserver

public class RepImpl
extends EnvironmentImpl
implements RepEnvConfigObserver


Nested Class Summary
 
Nested classes/interfaces inherited from class com.sleepycat.je.dbi.EnvironmentImpl
EnvironmentImpl.MBeanRegistrar
 
Field Summary
 
Fields inherited from class com.sleepycat.je.dbi.EnvironmentImpl
configManager, dbMapTree, envInternal, envLogger, formatter, IS_DALVIK, needRepConvert, SAVED_EFE, startupTracker, USE_JAVA5_ADLER32
 
Constructor Summary
RepImpl(File envHome, EnvironmentConfig envConfig, EnvironmentImpl sharedCacheEnv, RepConfigProxy repConfigProxy)
           
 
Method Summary
 void abnormalClose()
          Used by error handling to forcibly close an environment, and by tests to close an environment to simulate a crash.
 boolean addDbBackup(DbBackup backup)
          For replicated environments only; just return true for a standalone environment.
 void addRepConfigObserver(RepEnvConfigObserver o)
           
 void awaitVLSNConsistency()
          Ensure that the in-memory vlsn index encompasses all logged entries before it is flushed to disk.
 void blockTxnCompletion(CountDownLatch blocker)
          Installs the commit-blocking latch that is used to halt the commit/abort of transactions, in the final phase of a master transfer.
 VLSN bumpVLSN()
          Generate the next VLSN.
 void checkRulesForExistingEnv(boolean dbTreeReplicatedBit, boolean dbTreePreserveVLSN)
          Check whether this environment can be opened on an existing environment directory.
 ReplicationConfig cloneRepConfig()
           
 ReplicationMutableConfig cloneRepMutableConfig()
           
 DatabasePreemptedException createDatabasePreemptedException(String msg, String dbName, Database db)
          For replicated environments only; only the overridden method should ever be called.
 DatabaseImpl createGroupDb()
          Called when a node has identified itself as the master, which is when the RepNode.selfElect is called.
protected  Environment createInternalEnvironment()
          Is overridden in RepImpl to create a ReplicatedEnvironment.
 LockPreemptedException createLockPreemptedException(Locker locker, Throwable cause)
          For replicated environments only; only the overridden method should ever be called.
 LogOverwriteException createLogOverwriteException(String msg)
          For replicated environments only; only the overridden method should ever be called.
 Txn createReplayTxn(long txnId)
          Create a ReplayTxn for recovery processing.
 ThreadLocker createRepThreadLocker()
          Create an appropriate type of ThreadLocker.
 Txn createRepUserTxn(TransactionConfig config)
          Create an appropriate type of Replicated transaction.
 void decrementVLSN()
          If the log entry wasn't successfully logged, decrement the VLSN to reclaim the slot.
 void doCloseAfterInvalid()
          This method must be called while synchronized on DbEnvPool.
 String dumpFeederState()
          Dumps the state associated with all active Feeders alone with identifying information about the node and its current HA state.
 String dumpState()
          Dump interesting aspects of the node's state.
 void freezeLocalCBVLSN()
           
 boolean getAllowRepConvert()
          True if ReplicationConfig set allowConvert as true.
 int getCachedVLSNMinLength()
          Returns the number of initial bytes per VLSN in the VLSNCache.
 boolean getCacheVLSN()
          Returns true if the VLSN is both preserved and cached.
 StateChangeListener getChangeListener()
           
 long getCleanerBarrierStartFile()
          Returns the first protected file number.
static int getClockSkewMs()
           
 ReplicaConsistencyPolicy getDefaultConsistencyPolicy()
           
 String getDiagnosticsClassName()
           
 long getEndOfLog()
           
 FeederTxns getFeederTxns()
           
 DatabaseImpl getGroupDb()
          Open the group db, which should exist already.
 DatabaseImpl getGroupDb(ReplicaConsistencyPolicy policy)
           
 VLSN getGroupDurableVLSN()
           
 Set<InetSocketAddress> getHelperSockets()
          Returns the set of sockets associated with helper nodes.
 String getHostName()
          Returns the hostname associated with this node.
 long getLsnForVLSN(VLSN vlsn, int readBufferSize)
           
 String getMonitorClassName()
           
 String getName()
          Get an environment name, for tagging onto logging and debug message.
 NameIdPair getNameIdPair()
           
 int getNodeId()
           
 StatGroup getNodeStats()
           
 int getPort()
          Returns the port used by the replication node.
 boolean getPreserveVLSN()
          Returns true if the VLSN is preserved as the record version.
 Replay getReplay()
           
 long getReplayTxnTimeout()
           
 RepNode getRepNode()
           
 InetSocketAddress getSocket()
           
 ReplicatedEnvironment.State getState()
          Returns the current state associated with this ReplicatedEnvironment
 StateChangeEvent getStateChangeEvent()
          Returns the state change event that transitioned the ReplicatedEnviroment to its current state.
 ReplicatedEnvironmentStats getStats(StatsConfig config)
           
 UUID getUUID()
           
 VLSNIndex getVLSNIndex()
           
 VLSNRecoveryProxy getVLSNProxy()
          Used by environment recovery to get a tracker to collect VLSN-LSN mappings that are within the recovery part of the log.
protected  DbConfigManager initConfigManager(EnvironmentConfig envConfig, RepConfigProxy repConfigProxy)
          Create a config manager that holds the configuration properties that have been passed in.
protected  void initConfigParams(EnvironmentConfig envConfig, RepConfigProxy repConfigProxy)
          Called by the EnvironmentImpl constructor.
protected  Formatter initFormatter()
           
 void invalidate(EnvironmentFailureException e)
          Invalidate the environment.
 void invalidateBackups(long fileNumber)
           
 boolean isDesignatedPrimary()
          Returns true, if the node has been designated a Primary.
 boolean isMaster()
           
 boolean isReplicated()
          Return true if this environment is part of a replication group.
 ReplicatedEnvironment.State joinGroup(ReplicaConsistencyPolicy consistency, QuorumPolicy initialElectionPolicy)
          Wait for this node to join a replication group and return whether it is a MASTER or REPLICA.
 ReplicatedEnvironment makeEnvironment()
           
protected  void postCheckpointClose(boolean checkpointed)
          Close any resources that need to be closed after the closing checkpoint.
 void postLogAbortHook(MasterTxn txn)
          Releases the block latch lock, if held.
 void postLogCommitAbortHook(MasterTxn txn)
          Removes any pending acknowledgments that were registered by the preLogCommitHook.
 void postLogCommitHook(MasterTxn txn)
          It ensures that the feeder obtains the requisite number of acknowledgments required for a successful commit.
protected  void postRecoveryConversion()
          Called after recovery but before any other initialization.
 void preCheckpointEndFlush()
          Flush any information that needs to go out at checkpoint.
 void preLogAbortHook(MasterTxn txn)
          Invoked before aborting a MasterTxn, this happens when the master is going to be a replica because of mastership transfer.
 void preLogCommitHook(MasterTxn txn)
          This hook is used primarily to perform the final checks before allowing the commit operation to proceed.
 void preRecoveryCheckpointInit(RecoveryInfo recoveryInfo)
          The VLSNIndex must be created, merged and flushed before the recovery checkpoint.
 DatabaseImpl probeGroupDb()
          Open the group db, which should exist already.
 void registerVLSN(LogItem logItem)
          A replicated log entry has been written on this node.
 void removeDbBackup(DbBackup backup)
          For replicated environments only; do nothing for a standalone environment.
 void repEnvConfigUpdate(RepConfigManager configMgr, ReplicationMutableConfig newConfig)
          Notifies the observer that one or more mutable rep properties have been changed.
protected  DbConfigManager resetConfigManager(EnvironmentConfig newConfig)
          Make a new config manager that has all the properties needed.
 void setBackupProhibited(boolean backupProhibited)
           
 void setChangeListener(StateChangeListener listener)
           
 void setHardRecoveryInfo(RollbackException e)
          If this node was started with a hard recovery, preserve that information.
 void setRepMutableConfig(ReplicationMutableConfig config)
           
static void setSkewMs(int skewMs)
          Used during testing to introduce artificial clock skews.
 void setSyncupProgress(SyncupProgress progress)
           
 void setSyncupProgress(SyncupProgress progress, long n, long total)
           
protected  void setupClose(PrintWriter errors)
          Release any resources from a subclass that need to be released before close is called on regular environment components.
 void shutdownGroupSetup(long timeoutMs)
          Sets up the environment for group shutdown when the environment is closed.
 String transferMaster(Set<String> replicas, long timeout, boolean force)
           
 void txnBeginHook(MasterTxn txn)
          Ensure that a sufficient number of feeders are available before proceeding with a master transaction begin.
 void unblockTxnCompletion()
          Releases the transaction block latch.
 void unfreezeLocalCBVLSN()
           
 void updateCBVLSN(LocalCBVLSNUpdater updater)
          Updates the CBVLSN on behalf of a Feeder input thread (or FeederManager running in the RepNode thread), while avoiding the possibility that the resulting GroupDB update may get blocked behind the final phase of a master transfer.
 void vlsnHeadTruncate(VLSN lastVLSN, long deleteFileNum)
          Delete from the first VLSN in the range to lastVLSN, inclusive.
 
Methods inherited from class com.sleepycat.je.dbi.EnvironmentImpl
addConfigObserver, addToCompressorQueue, addToCompressorQueue, addToCompressorQueue, checkIfInvalid, checkImmutablePropsForEquality, checkNotClosed, cloneConfig, cloneMutableConfig, close, close, closeAfterInvalid, createRepTxn, criticalEviction, daemonEviction, envConfigUpdate, finishInit, flushLog, forceLogFileFlip, getAdler32ChunkSize, getAppOpenCount, getBackupCount, getCheckpointer, getClassLoader, getCleaner, getCompactMaxKeyLength, getConfigManager, getConfiguredHandler, getConsoleHandler, getDbEviction, getDbTree, getDefaultCacheMode, getDefaultCacheModeStrategy, getDupConvertPreloadConfig, getEnvironmentHome, getEvictor, getExceptionListener, getFileHandler, getFileManager, getINCompressor, getINCompressorQueueSize, getInMemoryINs, getInternalEnvHandle, getInvalidatingException, getLockTimeout, getLogger, getLogManager, getMemoryBudget, getNoComparators, getNodeName, getNodeSequence, getRecoveryProgressListener, getRootLsn, getSharedCache, getSharedLatches, getStartupTracker, getSyncCleanerBarrier, getThreadLocalReferenceCount, getTriggerLatch, getTxnManager, getTxnTimeout, getUtilizationProfile, getUtilizationTracker, incRelatchesRequired, invalidate, invokeCheckpoint, invokeCleaner, invokeCompressor, invokeEvictor, isCacheFull, isClosed, isClosing, isDbLoggingDisabled, isInInit, isInvalid, isMemOnly, isNoLocking, isReadOnly, isRepConverted, isTransactional, isValid, lazyCompress, loadEnvImplStats, loadStats, lockStat, logMapTreeRoot, logMapTreeRoot, maybeForceYield, mayNotWrite, needRepConvert, open, preload, readMapTreeFromLog, registerExceptionListenerUser, registerMBean, removeConfigObserver, requestShutdownDaemons, resetLoggingLevel, rewriteMapTreeRoot, setBackgroundSleepHook, setCleanerBarrierHook, setMutableConfig, shutdownCleaner, shutdownDaemons, sleepAfterBackgroundIO, specialEviction, stopDaemons, txnBegin, txnStat, unregisterExceptionListenerUser, updateBackgroundReads, updateBackgroundWrites, verify, verifyCursors, wasCacheEverFull
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RepImpl

public RepImpl(File envHome,
               EnvironmentConfig envConfig,
               EnvironmentImpl sharedCacheEnv,
               RepConfigProxy repConfigProxy)
        throws EnvironmentNotFoundException,
               EnvironmentLockedException
Throws:
EnvironmentNotFoundException
EnvironmentLockedException
Method Detail

initConfigParams

protected void initConfigParams(EnvironmentConfig envConfig,
                                RepConfigProxy repConfigProxy)
Called by the EnvironmentImpl constructor. Some rep params, preserveVLSN for example, are accessed by the EnvironmentImpl via methods (getPreserveVLSN for example), so they need to be initialized early.

Overrides:
initConfigParams in class EnvironmentImpl

initFormatter

protected Formatter initFormatter()
Overrides:
initFormatter in class EnvironmentImpl

getMonitorClassName

public String getMonitorClassName()
Overrides:
getMonitorClassName in class EnvironmentImpl

getDiagnosticsClassName

public String getDiagnosticsClassName()
Overrides:
getDiagnosticsClassName in class EnvironmentImpl

initConfigManager

protected DbConfigManager initConfigManager(EnvironmentConfig envConfig,
                                            RepConfigProxy repConfigProxy)
Description copied from class: EnvironmentImpl
Create a config manager that holds the configuration properties that have been passed in. These properties are already validated, and have had the proper order of precedence applied; that is, the je.properties file has been applied. The configuration properties need to be available before the rest of environment creation proceeds. This method is overridden by replication environments.

Overrides:
initConfigManager in class EnvironmentImpl
Parameters:
envConfig - is the environment configuration to use
repConfigProxy - are the replication configurations to use. In this case, the Properties bag has been extracted from the configuration instance, to avoid crossing the compilation firewall.
See Also:
super#initConfigManager

getAllowRepConvert

public boolean getAllowRepConvert()
Description copied from class: EnvironmentImpl
True if ReplicationConfig set allowConvert as true. Standalone environment is prohibited from doing a conversion, return false.

Overrides:
getAllowRepConvert in class EnvironmentImpl

resetConfigManager

protected DbConfigManager resetConfigManager(EnvironmentConfig newConfig)
Description copied from class: EnvironmentImpl
Make a new config manager that has all the properties needed. More complicated for subclasses.

Overrides:
resetConfigManager in class EnvironmentImpl
See Also:
super#resetConfigManager

cloneRepConfig

public ReplicationConfig cloneRepConfig()

makeEnvironment

public ReplicatedEnvironment makeEnvironment()

cloneRepMutableConfig

public ReplicationMutableConfig cloneRepMutableConfig()

setRepMutableConfig

public void setRepMutableConfig(ReplicationMutableConfig config)
                         throws DatabaseException
Throws:
DatabaseException

repEnvConfigUpdate

public void repEnvConfigUpdate(RepConfigManager configMgr,
                               ReplicationMutableConfig newConfig)
                        throws DatabaseException
Description copied from interface: RepEnvConfigObserver
Notifies the observer that one or more mutable rep properties have been changed.

Specified by:
repEnvConfigUpdate in interface RepEnvConfigObserver
Throws:
DatabaseException

addRepConfigObserver

public void addRepConfigObserver(RepEnvConfigObserver o)

preRecoveryCheckpointInit

public void preRecoveryCheckpointInit(RecoveryInfo recoveryInfo)
The VLSNIndex must be created, merged and flushed before the recovery checkpoint. This method should be called even if there is no recovery checkpoint, because it sets up needed data structures. On the face of it, it seems that one could flush the VLSNIndex cache after the recovery checkpoint, before the Replicator constructor returns and before any user level HA operations can start. That's not sufficient because the recovery checkpoint is shortening the recovery interval for future recoveries, and any information that has been garnered must be persisted. Here's an example of what might happen after a series of recoveries if we fail to flush VLSNIndex as part of the recovery checkpoint: Environment recovers for first time, brand new environment recovery did not find any VLSNs in log, because log is brand new recovery logs ckpt 1start recovery logs ckpt 1 end VLSN 1 logged VLSN 2 logged VLSN 3 logged crash .... Environment recovers recovery crawls log from ckpt 1 start onward, finds VLSNs 1-3 recovery logs ckpt 2 start recovery logs ckpt 2 end VLSN index instantiated, VLSNs 1-3 added in but not written too disk crash ... Environment recovers recovery crawls log from ckpt start 2 start onward, finds no VLSNs. Instead, the flushed VLSN has to be logged before the checkpoint end record that is used for the next recovery.

Overrides:
preRecoveryCheckpointInit in class EnvironmentImpl

getState

public ReplicatedEnvironment.State getState()
Returns the current state associated with this ReplicatedEnvironment

Returns:
the externally visible ReplicatedEnvironment state

getStateChangeEvent

public StateChangeEvent getStateChangeEvent()
Returns the state change event that transitioned the ReplicatedEnviroment to its current state.


joinGroup

public ReplicatedEnvironment.State joinGroup(ReplicaConsistencyPolicy consistency,
                                             QuorumPolicy initialElectionPolicy)
                                      throws ReplicaConsistencyException,
                                             DatabaseException
Wait for this node to join a replication group and return whether it is a MASTER or REPLICA. Note that any method that creates or clears the repNode field must be synchronized.

Throws:
ReplicaConsistencyException
DatabaseException

createInternalEnvironment

protected Environment createInternalEnvironment()
Description copied from class: EnvironmentImpl
Is overridden in RepImpl to create a ReplicatedEnvironment.

Overrides:
createInternalEnvironment in class EnvironmentImpl

setupClose

protected void setupClose(PrintWriter errors)
                   throws DatabaseException
Description copied from class: EnvironmentImpl
Release any resources from a subclass that need to be released before close is called on regular environment components.

Overrides:
setupClose in class EnvironmentImpl
Throws:
DatabaseException
See Also:
Release all replication resources that can be released before the checkpoint. Note that any method that creates or clears the repNode field must be called from a synchronized caller. Note that the vlsnIndex is closed as a callback, from postCheckpointPreEnvClose()

postCheckpointClose

protected void postCheckpointClose(boolean checkpointed)
                            throws DatabaseException
Close any resources that need to be closed after the closing checkpoint. Note that since Replay.close closes open transactions, it must be invoked after the checkpoint has been completed, so that the checkpoint operation can correctly account for the open transactions.

Overrides:
postCheckpointClose in class EnvironmentImpl
Parameters:
checkpointed - if true, a checkpoint as issued before the close
Throws:
DatabaseException

postRecoveryConversion

protected void postRecoveryConversion()
Description copied from class: EnvironmentImpl
Called after recovery but before any other initialization. Is overridden by ReplImpl to convert user defined databases to replicated after doing recovery.

Overrides:
postRecoveryConversion in class EnvironmentImpl
See Also:
Note: this conversion process will iterate over all user created databases in the environment, which could be potentially be a costly affair. However, let's opt for simplicity and defer any optimizations until we see whether this is an important use case.

doCloseAfterInvalid

public void doCloseAfterInvalid()
Description copied from class: EnvironmentImpl
This method must be called while synchronized on DbEnvPool.

Overrides:
doCloseAfterInvalid in class EnvironmentImpl

abnormalClose

public void abnormalClose()
                   throws DatabaseException
Used by error handling to forcibly close an environment, and by tests to close an environment to simulate a crash. Database handles do not have to be closed before calling this method. A checkpoint is not performed. The various thread pools will be shutdown abruptly.

Overrides:
abnormalClose in class EnvironmentImpl
Throws:
DatabaseException

registerVLSN

public void registerVLSN(LogItem logItem)
A replicated log entry has been written on this node. Update the VLSN->LSN mapping. Called outside the log write latch.

Overrides:
registerVLSN in class EnvironmentImpl
Throws:
DatabaseException

bumpVLSN

public VLSN bumpVLSN()
Generate the next VLSN.

Overrides:
bumpVLSN in class EnvironmentImpl

decrementVLSN

public void decrementVLSN()
If the log entry wasn't successfully logged, decrement the VLSN to reclaim the slot.

Overrides:
decrementVLSN in class EnvironmentImpl

preCheckpointEndFlush

public void preCheckpointEndFlush()
                           throws DatabaseException
Flush any information that needs to go out at checkpoint. Specifically, write any in-memory VLSN->LSN mappings to the VLSNIndex database so we are guaranteed that the VLSNIndex database will recover properly. This must be committed with noSync because - the ensuing checkpoint end record will be logged with an fsync and will effectively force this out - it's important to minmize lock contention on the vlsn index and any fsync done during a checkpoint will be expensive, as there may be quite a lot to push to disk. We don't want to incur that cost while holding locks on the vlsn index. [#20702]

Overrides:
preCheckpointEndFlush in class EnvironmentImpl
Throws:
DatabaseException

isMaster

public boolean isMaster()
Overrides:
isMaster in class EnvironmentImpl

setChangeListener

public void setChangeListener(StateChangeListener listener)

getChangeListener

public StateChangeListener getChangeListener()

getVLSNIndex

public VLSNIndex getVLSNIndex()

getFeederTxns

public FeederTxns getFeederTxns()

getStats

public ReplicatedEnvironmentStats getStats(StatsConfig config)

getReplay

public Replay getReplay()

getRepNode

public RepNode getRepNode()
Returns:
the repNode. May return null.

createRepThreadLocker

public ThreadLocker createRepThreadLocker()
Create an appropriate type of ThreadLocker. Specifically, it creates an MasterThreadLocker if the node is currently a Master, and a ReplicaThreadLocker otherwise, that is, if the node is a Replica, or it's currently in a DETACHED state.

Overrides:
createRepThreadLocker in class EnvironmentImpl
Returns:
an instance of MasterThreadLocker or ReplicaThreadLocker

createRepUserTxn

public Txn createRepUserTxn(TransactionConfig config)
                     throws DatabaseException
Create an appropriate type of Replicated transaction. Specifically, it creates a MasterTxn, if the node is currently a Master, a ReadonlyTxn otherwise, that is, if the node is a Replica, or it's currently in a DETACHED state. Note that a ReplicaTxn, used for transaction replay on a Replica is not created on this path. It's created explicitly in the Replay loop by a Replica.

Overrides:
createRepUserTxn in class EnvironmentImpl
Parameters:
config - the transaction configuration
Returns:
an instance of MasterTxn or ReadonlyTxn
Throws:
DatabaseException

txnBeginHook

public void txnBeginHook(MasterTxn txn)
                  throws InterruptedException,
                         DatabaseException
Ensure that a sufficient number of feeders are available before proceeding with a master transaction begin.

Parameters:
txn - the master transaction being initiated.
Throws:
InterruptedException
DatabaseException - if there were insufficient Replicas after the timeout period.

blockTxnCompletion

public void blockTxnCompletion(CountDownLatch blocker)
                        throws InterruptedException
Installs the commit-blocking latch that is used to halt the commit/abort of transactions, in the final phase of a master transfer.

Throws:
InterruptedException
See Also:
updateCBVLSN(LocalCBVLSNUpdater)

updateCBVLSN

public void updateCBVLSN(LocalCBVLSNUpdater updater)
Updates the CBVLSN on behalf of a Feeder input thread (or FeederManager running in the RepNode thread), while avoiding the possibility that the resulting GroupDB update may get blocked behind the final phase of a master transfer.

We skip the update if we're at the point of blocking new transactions for a master transfer. And we use a read/write lock in order to be able to examine that state safely.


unblockTxnCompletion

public void unblockTxnCompletion()
Releases the transaction block latch.


preLogCommitHook

public void preLogCommitHook(MasterTxn txn)
                      throws InsufficientReplicasException,
                             RestartRequiredException,
                             UnknownMasterException,
                             ReplicaWriteException,
                             EnvironmentFailureException
This hook is used primarily to perform the final checks before allowing the commit operation to proceed. The following checks are performed here: 1) Check for master 2) Check for sufficient Feeder connections to ensure that the commit policy could be implemented. There is no guarantee that they will all ack the commit request. The method also associates a latch with the transaction. The latch is used to delay the commit operation until a sufficient number of commits have been received. In addition, when mastership transfers are done, and this node is the original master, commits and aborts are blocked so as to avoid hard recovery after electing a new master, see [#18081].

Parameters:
txn - the master transaction being committed
Throws:
InsufficientReplicasException - if the feeder is not in contact with enough replicas.
RestartRequiredException - if the environment is invalid.
UnknownMasterException - if the current master is unknown.
ReplicaWriteException - if the node transitioned to a Replica after the transaction was initiated.
EnvironmentFailureException

postLogCommitHook

public void postLogCommitHook(MasterTxn txn)
                       throws InsufficientAcksException,
                              InterruptedException,
                              EnvironmentFailureException
It ensures that the feeder obtains the requisite number of acknowledgments required for a successful commit.

Parameters:
txn - The MasterTxn that was committed locally.
Throws:
InterruptedException - if the thread was interrupted while waiting for acknowledgments.
InsufficientAcksException - if the master received an insufficient number of commit acknowledgments within the replica commit timeout period.
EnvironmentFailureException

preLogAbortHook

public void preLogAbortHook(MasterTxn txn)
                     throws EnvironmentFailureException,
                            ReplicaWriteException,
                            UnknownMasterException
Invoked before aborting a MasterTxn, this happens when the master is going to be a replica because of mastership transfer. We do this to make sure that the replica going to be the master has the most recent log and no hard recovery would happen after its election, see SR [#18081].

Parameters:
txn - The MasterTxn that was aborted locally.
Throws:
ReplicaWriteException - if the node transitioned to a Replica after the transaction was initiated.
UnknownMasterException - if the current master is unknown.
EnvironmentFailureException

postLogAbortHook

public void postLogAbortHook(MasterTxn txn)
Releases the block latch lock, if held. This hook is called in the normal course of Txn.abort(), once the abort log record has been written and the associated VLSN stored.


postLogCommitAbortHook

public void postLogCommitAbortHook(MasterTxn txn)
Removes any pending acknowledgments that were registered by the preLogCommitHook. This hook is called only when a commit() fails and therefore must be aborted.


createReplayTxn

public Txn createReplayTxn(long txnId)
                    throws DatabaseException
Create a ReplayTxn for recovery processing.

Overrides:
createReplayTxn in class EnvironmentImpl
Throws:
DatabaseException - from subclasses.

getVLSNProxy

public VLSNRecoveryProxy getVLSNProxy()
Used by environment recovery to get a tracker to collect VLSN-LSN mappings that are within the recovery part of the log. These might not be reflected in the persistent mapping db.

Overrides:
getVLSNProxy in class EnvironmentImpl

getUUID

public UUID getUUID()

setSkewMs

public static void setSkewMs(int skewMs)
Used during testing to introduce artificial clock skews.


getClockSkewMs

public static int getClockSkewMs()

vlsnHeadTruncate

public void vlsnHeadTruncate(VLSN lastVLSN,
                             long deleteFileNum)
Delete from the first VLSN in the range to lastVLSN, inclusive. This will be fsynced to guarantee that the persistent vlsn index does not refer to any deleted files. [#20702]

Overrides:
vlsnHeadTruncate in class EnvironmentImpl
Parameters:
lastVLSN - was cleaned by the cleaner
deleteFileNum - was the file that was deleted by the cleaner.

getNodeId

public int getNodeId()

getNameIdPair

public NameIdPair getNameIdPair()

getReplayTxnTimeout

public long getReplayTxnTimeout()
Overrides:
getReplayTxnTimeout in class EnvironmentImpl

getDefaultConsistencyPolicy

public ReplicaConsistencyPolicy getDefaultConsistencyPolicy()
Overrides:
getDefaultConsistencyPolicy in class EnvironmentImpl

getLsnForVLSN

public long getLsnForVLSN(VLSN vlsn,
                          int readBufferSize)
Overrides:
getLsnForVLSN in class EnvironmentImpl

getEndOfLog

public long getEndOfLog()
Overrides:
getEndOfLog in class EnvironmentImpl

getGroupDurableVLSN

public VLSN getGroupDurableVLSN()
Overrides:
getGroupDurableVLSN in class EnvironmentImpl

freezeLocalCBVLSN

public void freezeLocalCBVLSN()
Overrides:
freezeLocalCBVLSN in class EnvironmentImpl

unfreezeLocalCBVLSN

public void unfreezeLocalCBVLSN()
Overrides:
unfreezeLocalCBVLSN in class EnvironmentImpl

getPreserveVLSN

public boolean getPreserveVLSN()
Returns true if the VLSN is preserved as the record version.

Overrides:
getPreserveVLSN in class EnvironmentImpl

getCacheVLSN

public boolean getCacheVLSN()
Returns true if the VLSN is both preserved and cached.

Overrides:
getCacheVLSN in class EnvironmentImpl

getCachedVLSNMinLength

public int getCachedVLSNMinLength()
Returns the number of initial bytes per VLSN in the VLSNCache.

Overrides:
getCachedVLSNMinLength in class EnvironmentImpl

getName

public String getName()
Description copied from class: EnvironmentImpl
Get an environment name, for tagging onto logging and debug message. Useful for multiple environments in a JVM, or for HA.

Overrides:
getName in class EnvironmentImpl
See Also:
EnvironmentImpl.getName()

isReplicated

public boolean isReplicated()
Return true if this environment is part of a replication group.

Overrides:
isReplicated in class EnvironmentImpl

checkRulesForExistingEnv

public void checkRulesForExistingEnv(boolean dbTreeReplicatedBit,
                                     boolean dbTreePreserveVLSN)
                              throws UnsupportedOperationException
Check whether this environment can be opened on an existing environment directory.

Overrides:
checkRulesForExistingEnv in class EnvironmentImpl
Throws:
UnsupportedOperationException - via Environment ctor.

getHostName

public String getHostName()
Returns the hostname associated with this node.

Returns:
the hostname

getPort

public int getPort()
Returns the port used by the replication node.

Returns:
the port number

getSocket

public InetSocketAddress getSocket()

getHelperSockets

public Set<InetSocketAddress> getHelperSockets()
Returns the set of sockets associated with helper nodes.

Returns:
the set of helper sockets, returns an empty set if there are no helpers.

createGroupDb

public DatabaseImpl createGroupDb()
                           throws DatabaseException
Called when a node has identified itself as the master, which is when the RepNode.selfElect is called. The database should not exist at this point. Lock hierarchy: GroupDbLock -> sync on EnvironmentImpl

Throws:
DatabaseException

getCleanerBarrierStartFile

public long getCleanerBarrierStartFile()
Description copied from class: EnvironmentImpl
Returns the first protected file number. All files from this file (inclusive) to the end of the log will be protected from deletion. For replicated environments, this method should be overridden to return the CBVLSN file. Returns -1 if all file deletion is prohibited. Requirement: This method may never return a file number less that (prior to) a file number returned earlier.

Overrides:
getCleanerBarrierStartFile in class EnvironmentImpl
See Also:
EnvironmentImpl.getCleanerBarrierStartFile()

getGroupDb

public DatabaseImpl getGroupDb()
                        throws DatabaseNotFoundException,
                               DatabaseException
Open the group db, which should exist already.

Throws:
DatabaseNotFoundException
DatabaseException

getGroupDb

public DatabaseImpl getGroupDb(ReplicaConsistencyPolicy policy)
                        throws DatabaseNotFoundException,
                               DatabaseException
Throws:
DatabaseNotFoundException
DatabaseException

probeGroupDb

public DatabaseImpl probeGroupDb()
                          throws DatabaseException
Open the group db, which should exist already. Do not wait on the group db lock, return null if the databaseImpl hasn't been created and we can't obtain it. Lock hierarchy: GroupDbLock -> sync on EnvironmentImpl

Throws:
DatabaseException

isDesignatedPrimary

public boolean isDesignatedPrimary()
Returns true, if the node has been designated a Primary.


addDbBackup

public boolean addDbBackup(DbBackup backup)
Description copied from class: EnvironmentImpl
For replicated environments only; just return true for a standalone environment.

Overrides:
addDbBackup in class EnvironmentImpl

removeDbBackup

public void removeDbBackup(DbBackup backup)
Description copied from class: EnvironmentImpl
For replicated environments only; do nothing for a standalone environment.

Overrides:
removeDbBackup in class EnvironmentImpl

invalidateBackups

public void invalidateBackups(long fileNumber)

setBackupProhibited

public void setBackupProhibited(boolean backupProhibited)

createLockPreemptedException

public LockPreemptedException createLockPreemptedException(Locker locker,
                                                           Throwable cause)
Description copied from class: EnvironmentImpl
For replicated environments only; only the overridden method should ever be called.

Overrides:
createLockPreemptedException in class EnvironmentImpl

createDatabasePreemptedException

public DatabasePreemptedException createDatabasePreemptedException(String msg,
                                                                   String dbName,
                                                                   Database db)
Description copied from class: EnvironmentImpl
For replicated environments only; only the overridden method should ever be called.

Overrides:
createDatabasePreemptedException in class EnvironmentImpl

createLogOverwriteException

public LogOverwriteException createLogOverwriteException(String msg)
Description copied from class: EnvironmentImpl
For replicated environments only; only the overridden method should ever be called.

Overrides:
createLogOverwriteException in class EnvironmentImpl
Parameters:
msg - unused

shutdownGroupSetup

public void shutdownGroupSetup(long timeoutMs)
Sets up the environment for group shutdown when the environment is closed.

See Also:
ReplicatedEnvironment.shutdownGroup(long, TimeUnit)

transferMaster

public String transferMaster(Set<String> replicas,
                             long timeout,
                             boolean force)

dumpState

public String dumpState()
Dump interesting aspects of the node's state. Currently for debugging use, possibly useful for field support.


dumpFeederState

public String dumpFeederState()
Dumps the state associated with all active Feeders alone with identifying information about the node and its current HA state.


setHardRecoveryInfo

public void setHardRecoveryInfo(RollbackException e)
If this node was started with a hard recovery, preserve that information.


getNodeStats

public StatGroup getNodeStats()

awaitVLSNConsistency

public void awaitVLSNConsistency()
Ensure that the in-memory vlsn index encompasses all logged entries before it is flushed to disk. A No-Op for non-replicated systems. [#19754]

Overrides:
awaitVLSNConsistency in class EnvironmentImpl

setSyncupProgress

public void setSyncupProgress(SyncupProgress progress)

setSyncupProgress

public void setSyncupProgress(SyncupProgress progress,
                              long n,
                              long total)

invalidate

public void invalidate(EnvironmentFailureException e)
Description copied from class: EnvironmentImpl
Invalidate the environment. Done when a fatal exception (EnvironmentFailureException) is thrown.

Overrides:
invalidate in class EnvironmentImpl


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