public class RepImpl extends EnvironmentImpl implements RepEnvConfigObserver
EnvironmentImpl.MBeanRegistrar
configManager, dbMapTree, envInternal, envLogger, formatter, IS_DALVIK, needRepConvert, SAVED_EFE, startupTracker, USE_JAVA5_ADLER32
Constructor and Description |
---|
RepImpl(java.io.File envHome,
EnvironmentConfig envConfig,
EnvironmentImpl sharedCacheEnv,
RepConfigProxy repConfigProxy) |
Modifier and Type | Method and Description |
---|---|
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(java.util.concurrent.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(java.lang.String msg,
java.lang.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,
java.lang.Throwable cause)
For replicated environments only; only the overridden method should
ever be called.
|
LogOverwriteException |
createLogOverwriteException(java.lang.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.
|
java.lang.String |
dumpFeederState()
Dumps the state associated with all active Feeders alone with
identifying information about the node and its current HA state.
|
java.lang.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() |
java.lang.String |
getDiagnosticsClassName() |
long |
getEndOfLog() |
FeederTxns |
getFeederTxns() |
DatabaseImpl |
getGroupDb()
Open the group db, which should exist already.
|
DatabaseImpl |
getGroupDb(ReplicaConsistencyPolicy policy) |
VLSN |
getGroupDurableVLSN() |
java.util.Set<java.net.InetSocketAddress> |
getHelperSockets()
Returns the set of sockets associated with helper nodes.
|
java.lang.String |
getHostName()
Returns the hostname associated with this node.
|
long |
getLsnForVLSN(VLSN vlsn,
int readBufferSize) |
java.lang.String |
getMonitorClassName() |
java.lang.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() |
java.net.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) |
java.util.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 java.util.logging.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(java.io.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.
|
java.lang.String |
transferMaster(java.util.Set<java.lang.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.
|
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
public RepImpl(java.io.File envHome, EnvironmentConfig envConfig, EnvironmentImpl sharedCacheEnv, RepConfigProxy repConfigProxy) throws EnvironmentNotFoundException, EnvironmentLockedException
protected void initConfigParams(EnvironmentConfig envConfig, RepConfigProxy repConfigProxy)
initConfigParams
in class EnvironmentImpl
protected java.util.logging.Formatter initFormatter()
initFormatter
in class EnvironmentImpl
public java.lang.String getMonitorClassName()
getMonitorClassName
in class EnvironmentImpl
public java.lang.String getDiagnosticsClassName()
getDiagnosticsClassName
in class EnvironmentImpl
protected DbConfigManager initConfigManager(EnvironmentConfig envConfig, RepConfigProxy repConfigProxy)
EnvironmentImpl
initConfigManager
in class EnvironmentImpl
envConfig
- is the environment configuration to userepConfigProxy
- 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.super#initConfigManager
public boolean getAllowRepConvert()
EnvironmentImpl
getAllowRepConvert
in class EnvironmentImpl
protected DbConfigManager resetConfigManager(EnvironmentConfig newConfig)
EnvironmentImpl
resetConfigManager
in class EnvironmentImpl
super#resetConfigManager
public ReplicationConfig cloneRepConfig()
public ReplicatedEnvironment makeEnvironment()
public ReplicationMutableConfig cloneRepMutableConfig()
public void setRepMutableConfig(ReplicationMutableConfig config) throws DatabaseException
DatabaseException
public void repEnvConfigUpdate(RepConfigManager configMgr, ReplicationMutableConfig newConfig) throws DatabaseException
RepEnvConfigObserver
repEnvConfigUpdate
in interface RepEnvConfigObserver
DatabaseException
public void addRepConfigObserver(RepEnvConfigObserver o)
public void preRecoveryCheckpointInit(RecoveryInfo recoveryInfo)
preRecoveryCheckpointInit
in class EnvironmentImpl
public ReplicatedEnvironment.State getState()
public StateChangeEvent getStateChangeEvent()
public ReplicatedEnvironment.State joinGroup(ReplicaConsistencyPolicy consistency, QuorumPolicy initialElectionPolicy) throws ReplicaConsistencyException, DatabaseException
protected Environment createInternalEnvironment()
EnvironmentImpl
createInternalEnvironment
in class EnvironmentImpl
protected void setupClose(java.io.PrintWriter errors) throws DatabaseException
EnvironmentImpl
setupClose
in class EnvironmentImpl
DatabaseException
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()
protected void postCheckpointClose(boolean checkpointed) throws DatabaseException
postCheckpointClose
in class EnvironmentImpl
checkpointed
- if true, a checkpoint as issued before the closeDatabaseException
protected void postRecoveryConversion()
EnvironmentImpl
postRecoveryConversion
in class EnvironmentImpl
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.
public void doCloseAfterInvalid()
EnvironmentImpl
doCloseAfterInvalid
in class EnvironmentImpl
public void abnormalClose() throws DatabaseException
abnormalClose
in class EnvironmentImpl
DatabaseException
public void registerVLSN(LogItem logItem)
registerVLSN
in class EnvironmentImpl
DatabaseException
public VLSN bumpVLSN()
bumpVLSN
in class EnvironmentImpl
public void decrementVLSN()
decrementVLSN
in class EnvironmentImpl
public void preCheckpointEndFlush() throws DatabaseException
preCheckpointEndFlush
in class EnvironmentImpl
DatabaseException
public boolean isMaster()
isMaster
in class EnvironmentImpl
public void setChangeListener(StateChangeListener listener)
public StateChangeListener getChangeListener()
public VLSNIndex getVLSNIndex()
public FeederTxns getFeederTxns()
public ReplicatedEnvironmentStats getStats(StatsConfig config)
public Replay getReplay()
public RepNode getRepNode()
public ThreadLocker createRepThreadLocker()
createRepThreadLocker
in class EnvironmentImpl
public Txn createRepUserTxn(TransactionConfig config) throws DatabaseException
createRepUserTxn
in class EnvironmentImpl
config
- the transaction configurationDatabaseException
public void txnBeginHook(MasterTxn txn) throws java.lang.InterruptedException, DatabaseException
txn
- the master transaction being initiated.java.lang.InterruptedException
DatabaseException
- if there were insufficient Replicas after the
timeout period.public void blockTxnCompletion(java.util.concurrent.CountDownLatch blocker) throws java.lang.InterruptedException
java.lang.InterruptedException
updateCBVLSN(LocalCBVLSNUpdater)
public void updateCBVLSN(LocalCBVLSNUpdater updater)
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.
public void unblockTxnCompletion()
public void preLogCommitHook(MasterTxn txn) throws InsufficientReplicasException, RestartRequiredException, UnknownMasterException, ReplicaWriteException, EnvironmentFailureException
txn
- the master transaction being committedInsufficientReplicasException
- 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
public void postLogCommitHook(MasterTxn txn) throws InsufficientAcksException, java.lang.InterruptedException, EnvironmentFailureException
txn
- The MasterTxn that was committed locally.java.lang.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
public void preLogAbortHook(MasterTxn txn) throws EnvironmentFailureException, ReplicaWriteException, UnknownMasterException
txn
- The MasterTxn that was aborted locally.ReplicaWriteException
- if the node transitioned to a Replica
after the transaction was initiated.UnknownMasterException
- if the current master is unknown.EnvironmentFailureException
public void postLogAbortHook(MasterTxn txn)
public void postLogCommitAbortHook(MasterTxn txn)
commit()
fails and therefore must be aborted.public Txn createReplayTxn(long txnId) throws DatabaseException
createReplayTxn
in class EnvironmentImpl
DatabaseException
- from subclasses.public VLSNRecoveryProxy getVLSNProxy()
getVLSNProxy
in class EnvironmentImpl
public java.util.UUID getUUID()
public static void setSkewMs(int skewMs)
public static int getClockSkewMs()
public void vlsnHeadTruncate(VLSN lastVLSN, long deleteFileNum)
vlsnHeadTruncate
in class EnvironmentImpl
lastVLSN
- was cleaned by the cleanerdeleteFileNum
- was the file that was deleted by the cleaner.public int getNodeId()
public NameIdPair getNameIdPair()
public long getReplayTxnTimeout()
getReplayTxnTimeout
in class EnvironmentImpl
public ReplicaConsistencyPolicy getDefaultConsistencyPolicy()
getDefaultConsistencyPolicy
in class EnvironmentImpl
public long getLsnForVLSN(VLSN vlsn, int readBufferSize)
getLsnForVLSN
in class EnvironmentImpl
public long getEndOfLog()
getEndOfLog
in class EnvironmentImpl
public VLSN getGroupDurableVLSN()
getGroupDurableVLSN
in class EnvironmentImpl
public void freezeLocalCBVLSN()
freezeLocalCBVLSN
in class EnvironmentImpl
public void unfreezeLocalCBVLSN()
unfreezeLocalCBVLSN
in class EnvironmentImpl
public boolean getPreserveVLSN()
getPreserveVLSN
in class EnvironmentImpl
public boolean getCacheVLSN()
getCacheVLSN
in class EnvironmentImpl
public int getCachedVLSNMinLength()
getCachedVLSNMinLength
in class EnvironmentImpl
public java.lang.String getName()
EnvironmentImpl
getName
in class EnvironmentImpl
EnvironmentImpl.getName()
public boolean isReplicated()
isReplicated
in class EnvironmentImpl
public void checkRulesForExistingEnv(boolean dbTreeReplicatedBit, boolean dbTreePreserveVLSN) throws java.lang.UnsupportedOperationException
checkRulesForExistingEnv
in class EnvironmentImpl
java.lang.UnsupportedOperationException
- via Environment ctor.public java.lang.String getHostName()
public int getPort()
public java.net.InetSocketAddress getSocket()
public java.util.Set<java.net.InetSocketAddress> getHelperSockets()
public DatabaseImpl createGroupDb() throws DatabaseException
DatabaseException
public long getCleanerBarrierStartFile()
EnvironmentImpl
getCleanerBarrierStartFile
in class EnvironmentImpl
EnvironmentImpl.getCleanerBarrierStartFile()
public DatabaseImpl getGroupDb() throws DatabaseNotFoundException, DatabaseException
public DatabaseImpl getGroupDb(ReplicaConsistencyPolicy policy) throws DatabaseNotFoundException, DatabaseException
public DatabaseImpl probeGroupDb() throws DatabaseException
DatabaseException
public boolean isDesignatedPrimary()
public boolean addDbBackup(DbBackup backup)
EnvironmentImpl
addDbBackup
in class EnvironmentImpl
public void removeDbBackup(DbBackup backup)
EnvironmentImpl
removeDbBackup
in class EnvironmentImpl
public void invalidateBackups(long fileNumber)
public void setBackupProhibited(boolean backupProhibited)
public LockPreemptedException createLockPreemptedException(Locker locker, java.lang.Throwable cause)
EnvironmentImpl
createLockPreemptedException
in class EnvironmentImpl
public DatabasePreemptedException createDatabasePreemptedException(java.lang.String msg, java.lang.String dbName, Database db)
EnvironmentImpl
createDatabasePreemptedException
in class EnvironmentImpl
public LogOverwriteException createLogOverwriteException(java.lang.String msg)
EnvironmentImpl
createLogOverwriteException
in class EnvironmentImpl
msg
- unusedpublic void shutdownGroupSetup(long timeoutMs)
public java.lang.String transferMaster(java.util.Set<java.lang.String> replicas, long timeout, boolean force)
public java.lang.String dumpState()
public java.lang.String dumpFeederState()
public void setHardRecoveryInfo(RollbackException e)
public StatGroup getNodeStats()
public void awaitVLSNConsistency()
awaitVLSNConsistency
in class EnvironmentImpl
public void setSyncupProgress(SyncupProgress progress)
public void setSyncupProgress(SyncupProgress progress, long n, long total)
public void invalidate(EnvironmentFailureException e)
EnvironmentImpl
invalidate
in class EnvironmentImpl
Copyright (c) 2004-2012 Oracle. All rights reserved.