public class RepImpl extends EnvironmentImpl implements RepEnvConfigObserver
EnvironmentImpl.MBeanRegistrarconfigManager, 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, wasCacheEverFullpublic RepImpl(java.io.File envHome,
EnvironmentConfig envConfig,
EnvironmentImpl sharedCacheEnv,
RepConfigProxy repConfigProxy)
throws EnvironmentNotFoundException,
EnvironmentLockedException
protected void initConfigParams(EnvironmentConfig envConfig, RepConfigProxy repConfigProxy)
initConfigParams in class EnvironmentImplprotected java.util.logging.Formatter initFormatter()
initFormatter in class EnvironmentImplpublic java.lang.String getMonitorClassName()
getMonitorClassName in class EnvironmentImplpublic java.lang.String getDiagnosticsClassName()
getDiagnosticsClassName in class EnvironmentImplprotected DbConfigManager initConfigManager(EnvironmentConfig envConfig, RepConfigProxy repConfigProxy)
EnvironmentImplinitConfigManager in class EnvironmentImplenvConfig - 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#initConfigManagerpublic boolean getAllowRepConvert()
EnvironmentImplgetAllowRepConvert in class EnvironmentImplprotected DbConfigManager resetConfigManager(EnvironmentConfig newConfig)
EnvironmentImplresetConfigManager in class EnvironmentImplsuper#resetConfigManagerpublic ReplicationConfig cloneRepConfig()
public ReplicatedEnvironment makeEnvironment()
public ReplicationMutableConfig cloneRepMutableConfig()
public void setRepMutableConfig(ReplicationMutableConfig config) throws DatabaseException
DatabaseExceptionpublic void repEnvConfigUpdate(RepConfigManager configMgr, ReplicationMutableConfig newConfig) throws DatabaseException
RepEnvConfigObserverrepEnvConfigUpdate in interface RepEnvConfigObserverDatabaseExceptionpublic void addRepConfigObserver(RepEnvConfigObserver o)
public void preRecoveryCheckpointInit(RecoveryInfo recoveryInfo)
preRecoveryCheckpointInit in class EnvironmentImplpublic ReplicatedEnvironment.State getState()
public StateChangeEvent getStateChangeEvent()
public ReplicatedEnvironment.State joinGroup(ReplicaConsistencyPolicy consistency, QuorumPolicy initialElectionPolicy) throws ReplicaConsistencyException, DatabaseException
protected Environment createInternalEnvironment()
EnvironmentImplcreateInternalEnvironment in class EnvironmentImplprotected void setupClose(java.io.PrintWriter errors)
throws DatabaseException
EnvironmentImplsetupClose in class EnvironmentImplDatabaseExceptionRelease 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 EnvironmentImplcheckpointed - if true, a checkpoint as issued before the closeDatabaseExceptionprotected void postRecoveryConversion()
EnvironmentImplpostRecoveryConversion in class EnvironmentImplNote: 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()
EnvironmentImpldoCloseAfterInvalid in class EnvironmentImplpublic void abnormalClose()
throws DatabaseException
abnormalClose in class EnvironmentImplDatabaseExceptionpublic void registerVLSN(LogItem logItem)
registerVLSN in class EnvironmentImplDatabaseExceptionpublic VLSN bumpVLSN()
bumpVLSN in class EnvironmentImplpublic void decrementVLSN()
decrementVLSN in class EnvironmentImplpublic void preCheckpointEndFlush()
throws DatabaseException
preCheckpointEndFlush in class EnvironmentImplDatabaseExceptionpublic boolean isMaster()
isMaster in class EnvironmentImplpublic 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 EnvironmentImplpublic Txn createRepUserTxn(TransactionConfig config) throws DatabaseException
createRepUserTxn in class EnvironmentImplconfig - the transaction configurationDatabaseExceptionpublic void txnBeginHook(MasterTxn txn) throws java.lang.InterruptedException, DatabaseException
txn - the master transaction being initiated.java.lang.InterruptedExceptionDatabaseException - if there were insufficient Replicas after the
timeout period.public void blockTxnCompletion(java.util.concurrent.CountDownLatch blocker)
throws java.lang.InterruptedException
java.lang.InterruptedExceptionupdateCBVLSN(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.EnvironmentFailureExceptionpublic 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.EnvironmentFailureExceptionpublic 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.EnvironmentFailureExceptionpublic 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 EnvironmentImplDatabaseException - from subclasses.public VLSNRecoveryProxy getVLSNProxy()
getVLSNProxy in class EnvironmentImplpublic java.util.UUID getUUID()
public static void setSkewMs(int skewMs)
public static int getClockSkewMs()
public void vlsnHeadTruncate(VLSN lastVLSN, long deleteFileNum)
vlsnHeadTruncate in class EnvironmentImpllastVLSN - 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 EnvironmentImplpublic ReplicaConsistencyPolicy getDefaultConsistencyPolicy()
getDefaultConsistencyPolicy in class EnvironmentImplpublic long getLsnForVLSN(VLSN vlsn, int readBufferSize)
getLsnForVLSN in class EnvironmentImplpublic long getEndOfLog()
getEndOfLog in class EnvironmentImplpublic VLSN getGroupDurableVLSN()
getGroupDurableVLSN in class EnvironmentImplpublic void freezeLocalCBVLSN()
freezeLocalCBVLSN in class EnvironmentImplpublic void unfreezeLocalCBVLSN()
unfreezeLocalCBVLSN in class EnvironmentImplpublic boolean getPreserveVLSN()
getPreserveVLSN in class EnvironmentImplpublic boolean getCacheVLSN()
getCacheVLSN in class EnvironmentImplpublic int getCachedVLSNMinLength()
getCachedVLSNMinLength in class EnvironmentImplpublic java.lang.String getName()
EnvironmentImplgetName in class EnvironmentImplEnvironmentImpl.getName()public boolean isReplicated()
isReplicated in class EnvironmentImplpublic void checkRulesForExistingEnv(boolean dbTreeReplicatedBit,
boolean dbTreePreserveVLSN)
throws java.lang.UnsupportedOperationException
checkRulesForExistingEnv in class EnvironmentImpljava.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
DatabaseExceptionpublic long getCleanerBarrierStartFile()
EnvironmentImplgetCleanerBarrierStartFile in class EnvironmentImplEnvironmentImpl.getCleanerBarrierStartFile()public DatabaseImpl getGroupDb() throws DatabaseNotFoundException, DatabaseException
public DatabaseImpl getGroupDb(ReplicaConsistencyPolicy policy) throws DatabaseNotFoundException, DatabaseException
public DatabaseImpl probeGroupDb() throws DatabaseException
DatabaseExceptionpublic boolean isDesignatedPrimary()
public boolean addDbBackup(DbBackup backup)
EnvironmentImpladdDbBackup in class EnvironmentImplpublic void removeDbBackup(DbBackup backup)
EnvironmentImplremoveDbBackup in class EnvironmentImplpublic void invalidateBackups(long fileNumber)
public void setBackupProhibited(boolean backupProhibited)
public LockPreemptedException createLockPreemptedException(Locker locker, java.lang.Throwable cause)
EnvironmentImplcreateLockPreemptedException in class EnvironmentImplpublic DatabasePreemptedException createDatabasePreemptedException(java.lang.String msg, java.lang.String dbName, Database db)
EnvironmentImplcreateDatabasePreemptedException in class EnvironmentImplpublic LogOverwriteException createLogOverwriteException(java.lang.String msg)
EnvironmentImplcreateLogOverwriteException in class EnvironmentImplmsg - 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 EnvironmentImplpublic void setSyncupProgress(SyncupProgress progress)
public void setSyncupProgress(SyncupProgress progress, long n, long total)
public void invalidate(EnvironmentFailureException e)
EnvironmentImplinvalidate in class EnvironmentImplCopyright (c) 2004-2012 Oracle. All rights reserved.