public class RepNode extends StoppableThread
Modifier and Type | Class and Description |
---|---|
static class |
RepNode.Clock |
Modifier and Type | Field and Description |
---|---|
(package private) LocalCBVLSNTracker |
cbvlsnTracker |
(package private) GlobalCBVLSN |
globalCBVLSN |
(package private) java.util.logging.Logger |
logger |
(package private) RepGroupDB |
repGroupDB |
envImpl
Constructor and Description |
---|
RepNode() |
RepNode(NameIdPair nameIdPair) |
RepNode(NameIdPair nameIdPair,
ServiceDispatcher serviceDispatcher) |
RepNode(RepImpl repImpl,
Replay replay,
NodeState nodeState) |
Modifier and Type | Method and Description |
---|---|
boolean |
checkDesignatedPrimary()
Checks whether we're in a 2-node group and configured as the Designated
Primary.
|
void |
configLogFlusher(DbConfigManager configMgr) |
void |
currentTxnEndVLSN(VLSN txnEndVLSN)
Notes the VLSN associated with the latest commit or abort.
|
java.lang.String |
dumpFeederState()
Dumps the state associated with all active Feeders.
|
java.lang.String |
dumpState()
Dumps the states associated with any active Feeders as well as
information pertaining to the group CBVLSN and the composition of the
group itself.
|
FeederManager |
feederManager() |
void |
forceMaster(boolean force) |
void |
freezeLocalCBVLSN() |
MasterTransfer |
getActiveTransfer() |
byte[] |
getAppState()
Return the application state that defined in user specified
AppStateMonitor.
|
(package private) LocalCBVLSNTracker |
getCBVLSNTracker() |
ChannelTimeoutTask |
getChannelTimeoutTask() |
long |
getCleanerBarrierFile()
Returns the file number that forms a barrier for the cleaner's file
deletion activities.
|
RepNode.Clock |
getClock() |
(package private) DbConfigManager |
getConfigManager() |
VLSN |
getCurrentTxnEndVLSN()
Returns the latest VLSN associated with a replicated commit.
|
(package private) int |
getDbTreeCacheClearingOpCount() |
QuorumPolicy |
getElectionPolicy() |
int |
getElectionPriority() |
int |
getElectionQuorumSize(QuorumPolicy quorumPolicy)
Returns the number of nodes needed to form a quorum for elections
|
Elections |
getElections() |
FeederTxns |
getFeederTxns() |
RepGroupImpl |
getGroup() |
VLSN |
getGroupCBVLSN()
May return NULL_VLSN
|
int |
getHeartbeatInterval() |
LogFlusher |
getLogFlusher() |
java.util.logging.Logger |
getLogger() |
LogManager |
getLogManager() |
RepNodeImpl[] |
getLogProviders()
Returns a list of nodes suitable for feeding log files for a network
restore.
|
int |
getLogVersion() |
java.lang.String |
getMasterName() |
MasterStatus |
getMasterStatus() |
MonitorEventManager |
getMonitorEventManager() |
NameIdPair |
getNameIdPair() |
int |
getNodeId()
Returns the nodeId associated with this replication node.
|
java.lang.String |
getNodeName()
Returns the nodeName associated with this replication node.
|
RepUtils.ExceptionAwareCountDownLatch |
getReadyLatch() |
RepGroupDB |
getRepGroupDB() |
RepImpl |
getRepImpl() |
Replica |
getReplica() |
(package private) long |
getReplicaCloseCatchupMs() |
ServiceDispatcher |
getServiceDispatcher() |
java.net.InetSocketAddress |
getSocket() |
ReplicatedEnvironmentStats |
getStats(StatsConfig config)
Returns the accumulated statistics for this node.
|
MasterSuggestionGenerator |
getSuggestionGenerator() |
int |
getThreadWaitInterval() |
java.util.Timer |
getTimer()
Returns the timer associated with this RepNode
|
java.util.UUID |
getUUID()
Returns the UUID associated with the replicated environment.
|
CommitFreezeLatch |
getVLSNFreezeLatch() |
VLSNIndex |
getVLSNIndex() |
protected int |
initiateSoftShutdown()
Soft shutdown for the RepNode thread.
|
boolean |
isActivePrimary()
Returns true if the node is a designated Primary that has been
activated.
|
boolean |
isAuthoritativeMaster()
Returns a definitive answer to whether this node is currently the master
by checking both its status as a master and that at least a simple
majority of nodes agrees that it's the master based on the number of
feeder connections to it.
|
boolean |
isMaster() |
ReplicatedEnvironment.State |
joinGroup(ReplicaConsistencyPolicy consistency,
QuorumPolicy initialElectionPolicy)
JoinGroup ensures that a RepNode is actively participating in a
replication group.
|
int |
minAckNodes(Durability.ReplicaAckPolicy ackPolicy)
Returns the minimum number of replication nodes required to
implement the ReplicaAckPolicy for a given group size.
|
int |
minAckNodes(Durability durability) |
void |
passivatePrimary() |
(package private) void |
recalculateGlobalCBVLSN()
Recalculate the Global CBVLSN, provoked by Replay, to ensure that the
replica's global CBVLSN is up to date.
|
RepGroupImpl |
refreshCachedGroup()
This method must be invoked when a RepNode is first initialized and
subsequently every time there is a change to the replication group.
|
void |
registerAppStateMonitor(AppStateMonitor stateMonitor)
Register an AppStateMonitor with this RepNode.
|
(package private) void |
reinitSelfElect()
Establishes this node as the master, after re-initializing the group
with this as the sole node in the group.
|
void |
removeMember(java.lang.String nodeName)
Removes a node so that it's no longer a member of the group.
|
Replica |
replica() |
void |
resetReadyLatch(java.lang.Exception exception) |
void |
resetStats() |
void |
restartNetworkBackup()
Restarts the network backup service *after* a rollback has been
completed and the log files are once again in a consistent state.
|
void |
run()
The top level Master/Feeder or Replica loop in support of replication.
|
void |
setElectableGroupSizeOverride(int override) |
void |
setVersion(int version) |
void |
shutdown()
Used to shutdown all activity associated with this replication stream.
|
void |
shutdownGroupOnClose(long timeoutMs)
Must be invoked on the Master via the last open handle.
|
void |
shutdownNetworkBackup()
Shuts down the Network backup service *before* a rollback is initiated
as part of syncup, thus ensuring that NetworkRestore does not see an
inconsistent set of log files.
|
void |
syncupEnded() |
void |
syncupStarted()
Returns the group wide CBVLSN.
|
void |
trackSyncableVLSN(VLSN syncableVLSN,
long lsn)
Should be called whenever a new VLSN is associated with a log entry
suitable for Replica/Feeder syncup.
|
java.lang.String |
transferMaster(java.util.Set<java.lang.String> replicas,
long timeout,
boolean force)
Transfer the master role to one of the specified replicas.
|
boolean |
tryActivatePrimary()
Tries to activate this node as a Primary, if it has been configured as
such and if the group size is two.
|
void |
unfreezeLocalCBVLSN() |
void |
updateAddress(java.lang.String nodeName,
java.lang.String newHostName,
int newPort)
Update the network address of a node.
|
void |
updateGroupInfo(NameIdPair updateNameIdPair,
RepGroupImpl.BarrierState barrierState)
Updates the cached group info for the node, avoiding a database read.
|
cleanup, getSavedShutdownException, getTotalCpuTime, getTotalUserTime, isShutdown, saveShutdownException, setExceptionListener, shutdownDone, shutdownThread
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
final RepGroupDB repGroupDB
final LocalCBVLSNTracker cbvlsnTracker
final GlobalCBVLSN globalCBVLSN
final java.util.logging.Logger logger
public RepNode(RepImpl repImpl, Replay replay, NodeState nodeState) throws java.io.IOException, DatabaseException
java.io.IOException
DatabaseException
public RepNode(NameIdPair nameIdPair)
public RepNode()
public RepNode(NameIdPair nameIdPair, ServiceDispatcher serviceDispatcher)
public java.util.logging.Logger getLogger()
getLogger
in class StoppableThread
public java.util.Timer getTimer()
public ServiceDispatcher getServiceDispatcher()
public ReplicatedEnvironmentStats getStats(StatsConfig config)
public void resetStats()
public RepUtils.ExceptionAwareCountDownLatch getReadyLatch()
public CommitFreezeLatch getVLSNFreezeLatch()
public void resetReadyLatch(java.lang.Exception exception)
public FeederManager feederManager()
public Replica replica()
public RepNode.Clock getClock()
public Replica getReplica()
public RepGroupDB getRepGroupDB()
public RepGroupImpl getGroup()
public java.util.UUID getUUID()
public java.lang.String getNodeName()
public int getNodeId()
public NameIdPair getNameIdPair()
public java.net.InetSocketAddress getSocket()
public MasterStatus getMasterStatus()
public boolean isAuthoritativeMaster()
public int getHeartbeatInterval()
public void setVersion(int version)
public int getLogVersion()
public int getElectionPriority()
public int getThreadWaitInterval()
int getDbTreeCacheClearingOpCount()
public RepImpl getRepImpl()
public LogManager getLogManager()
DbConfigManager getConfigManager()
public VLSNIndex getVLSNIndex()
public FeederTxns getFeederTxns()
public Elections getElections()
public MasterSuggestionGenerator getSuggestionGenerator()
public QuorumPolicy getElectionPolicy()
public RepNodeImpl[] getLogProviders()
public LogFlusher getLogFlusher()
public void configLogFlusher(DbConfigManager configMgr)
public ChannelTimeoutTask getChannelTimeoutTask()
public boolean isMaster()
public void currentTxnEndVLSN(VLSN txnEndVLSN)
txnEndVLSN
- the VLSN of a TxnAbort/TxnCommitpublic MonitorEventManager getMonitorEventManager()
public void registerAppStateMonitor(AppStateMonitor stateMonitor)
public byte[] getAppState()
public java.lang.String getMasterName()
public VLSN getCurrentTxnEndVLSN()
public void forceMaster(boolean force) throws java.lang.InterruptedException, DatabaseException
java.lang.InterruptedException
DatabaseException
public RepGroupImpl refreshCachedGroup() throws DatabaseException
The Master should invoke this method each time a member is added or removed, and a replica should invoke it each time it detects the commit of a transaction that modifies the membership database.
In addition, it must be invoked after a syncup operation, since it may revert changes made to the membership table.
DatabaseException
public void removeMember(java.lang.String nodeName)
nodeName
- identifies the node to be deleted.MemberNotFoundException
- if the node denoted by
memberName
is not a member of the replication group.MasterStateException
- if the member being removed is currently
the Masterpublic void updateAddress(java.lang.String nodeName, java.lang.String newHostName, int newPort)
nodeName
- identifies the node to be updatednewHostName
- the new host name of this nodenewPort
- the new port of this nodepublic java.lang.String transferMaster(java.util.Set<java.lang.String> replicas, long timeout, boolean force)
We delegate most of the real work to an instance of the MasterTransfer
class. Here, after some simple initial validity
checking, we're concerned with coordinating the potential for multiple
overlapping Master Transfer operation attempts. The possible outcomes
are:
done == true
)
setUpTransfer(java.util.Set<java.lang.String>, long, boolean)
)
replicas
- candidate targets for new master roletimeout
- time limit, in msecforce
- whether to replace any existing, in-progress
transfer operationpublic MasterTransfer getActiveTransfer()
public void updateGroupInfo(NameIdPair updateNameIdPair, RepGroupImpl.BarrierState barrierState)
updateNameIdPair
- the node whose localCBVLSN must be updated.barrierState
- the new node syncup statevoid recalculateGlobalCBVLSN()
LocalCBVLSNTracker getCBVLSNTracker()
public void freezeLocalCBVLSN()
public void unfreezeLocalCBVLSN()
void reinitSelfElect() throws java.io.IOException
java.io.IOException
public void run()
The thread is terminated via an orderly shutdown initiated as a result of an interrupt issued by the shutdown() method. Any exception that is not handled by the run method itself is caught by the thread's uncaught exception handler, and results in the RepImpl being made invalid. In that case, the application is responsible for closing the Replicated Environment, which will provoke the shutdown.
Note: This method currently runs either the feeder loop or the replica loop. With R to R support, it would be possible for a Replica to run both. This will be a future feature.
run
in interface java.lang.Runnable
run
in class java.lang.Thread
public void shutdown() throws java.lang.InterruptedException, DatabaseException
java.lang.InterruptedException
DatabaseException
protected int initiateSoftShutdown()
initiateSoftShutdown
in class StoppableThread
public void shutdownGroupOnClose(long timeoutMs) throws java.lang.IllegalStateException
java.lang.IllegalStateException
ReplicatedEnvironment.shutdownGroup(long, TimeUnit)
public ReplicatedEnvironment.State joinGroup(ReplicaConsistencyPolicy consistency, QuorumPolicy initialElectionPolicy) throws ReplicaConsistencyException, DatabaseException, java.io.IOException
UnknownMasterException
- If a master cannot be established within
ENV_SETUP_TIMEOUT, unless ENV_UNKNOWN_STATE_TIMEOUT has
been set to allow the creation of a handle while in the UNKNOWN state.ReplicaConsistencyException
DatabaseException
java.io.IOException
public void trackSyncableVLSN(VLSN syncableVLSN, long lsn)
public VLSN getGroupCBVLSN()
public int getElectionQuorumSize(QuorumPolicy quorumPolicy)
quorumPolicy
- public int minAckNodes(Durability.ReplicaAckPolicy ackPolicy)
public int minAckNodes(Durability durability)
public void syncupStarted()
DatabaseException
public void syncupEnded()
public long getCleanerBarrierFile() throws DatabaseException
DatabaseException
long getReplicaCloseCatchupMs()
public boolean isActivePrimary()
public boolean tryActivatePrimary()
public boolean checkDesignatedPrimary()
public final void passivatePrimary()
public final void shutdownNetworkBackup()
restarNetworkBackup() is then used to restart the service after it was shut down.
public final void restartNetworkBackup()
public java.lang.String dumpState()
public java.lang.String dumpFeederState()
public void setElectableGroupSizeOverride(int override)
Copyright (c) 2004-2012 Oracle. All rights reserved.