|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.lang.Thread
com.sleepycat.je.utilint.StoppableThread
com.sleepycat.je.rep.impl.node.RepNode
public class RepNode
Represents a replication node. This class is the locus of operations that manage the state of the node, master, replica, etc. Once the state of a node has been established the thread of control passes over to the Replica or FeederManager instances. Note that both Feeders and the Replica instance may be active in future when we support r2r replication, in addition to m2r replication. For now however, either the FeederManager is active, or the Replica is and the same common thread control can be shared between the two.
Nested Class Summary | |
---|---|
static class |
RepNode.Clock
|
Nested classes/interfaces inherited from class java.lang.Thread |
---|
Thread.State, Thread.UncaughtExceptionHandler |
Field Summary | |
---|---|
(package private) LocalCBVLSNTracker |
cbvlsnTracker
|
(package private) GlobalCBVLSN |
globalCBVLSN
|
(package private) Logger |
logger
|
(package private) RepGroupDB |
repGroupDB
|
Fields inherited from class com.sleepycat.je.utilint.StoppableThread |
---|
envImpl |
Fields inherited from class java.lang.Thread |
---|
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Constructor Summary | |
---|---|
RepNode()
|
|
RepNode(NameIdPair nameIdPair)
|
|
RepNode(NameIdPair nameIdPair,
ServiceDispatcher serviceDispatcher)
|
|
RepNode(RepImpl repImpl,
Replay replay,
NodeState nodeState)
|
Method Summary | |
---|---|
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. |
String |
dumpFeederState()
Dumps the state associated with all active Feeders. |
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()
|
Logger |
getLogger()
|
LogManager |
getLogManager()
|
RepNodeImpl[] |
getLogProviders()
Returns a list of nodes suitable for feeding log files for a network restore. |
int |
getLogVersion()
|
String |
getMasterName()
|
MasterStatus |
getMasterStatus()
|
MonitorEventManager |
getMonitorEventManager()
|
NameIdPair |
getNameIdPair()
|
int |
getNodeId()
Returns the nodeId associated with this replication node. |
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()
|
InetSocketAddress |
getSocket()
|
ReplicatedEnvironmentStats |
getStats(StatsConfig config)
Returns the accumulated statistics for this node. |
MasterSuggestionGenerator |
getSuggestionGenerator()
|
int |
getThreadWaitInterval()
|
Timer |
getTimer()
Returns the timer associated with this RepNode |
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(String nodeName)
Removes a node so that it's no longer a member of the group. |
Replica |
replica()
|
void |
resetReadyLatch(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. |
String |
transferMaster(Set<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(String nodeName,
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. |
Methods inherited from class com.sleepycat.je.utilint.StoppableThread |
---|
cleanup, getSavedShutdownException, getTotalCpuTime, getTotalUserTime, isShutdown, saveShutdownException, setExceptionListener, shutdownDone, shutdownThread |
Methods inherited from class java.lang.Thread |
---|
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 |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
final RepGroupDB repGroupDB
final LocalCBVLSNTracker cbvlsnTracker
final GlobalCBVLSN globalCBVLSN
final Logger logger
Constructor Detail |
---|
public RepNode(RepImpl repImpl, Replay replay, NodeState nodeState) throws IOException, DatabaseException
IOException
DatabaseException
public RepNode(NameIdPair nameIdPair)
public RepNode()
public RepNode(NameIdPair nameIdPair, ServiceDispatcher serviceDispatcher)
Method Detail |
---|
public Logger getLogger()
getLogger
in class StoppableThread
public Timer getTimer()
public ServiceDispatcher getServiceDispatcher()
public ReplicatedEnvironmentStats getStats(StatsConfig config)
public void resetStats()
public RepUtils.ExceptionAwareCountDownLatch getReadyLatch()
public CommitFreezeLatch getVLSNFreezeLatch()
public void resetReadyLatch(Exception exception)
public FeederManager feederManager()
public Replica replica()
public RepNode.Clock getClock()
public Replica getReplica()
public RepGroupDB getRepGroupDB()
public RepGroupImpl getGroup()
public UUID getUUID()
public String getNodeName()
public int getNodeId()
public NameIdPair getNameIdPair()
public 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 String getMasterName()
public VLSN getCurrentTxnEndVLSN()
public void forceMaster(boolean force) throws InterruptedException, DatabaseException
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(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(String nodeName, String newHostName, int newPort)
nodeName
- identifies the node to be updatednewHostName
- the new host name of this nodenewPort
- the new port of this nodepublic String transferMaster(Set<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, 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 IOException
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 Runnable
run
in class Thread
public void shutdown() throws InterruptedException, DatabaseException
InterruptedException
DatabaseException
protected int initiateSoftShutdown()
initiateSoftShutdown
in class StoppableThread
public void shutdownGroupOnClose(long timeoutMs) throws IllegalStateException
IllegalStateException
ReplicatedEnvironment.shutdownGroup(long, TimeUnit)
public ReplicatedEnvironment.State joinGroup(ReplicaConsistencyPolicy consistency, QuorumPolicy initialElectionPolicy) throws ReplicaConsistencyException, DatabaseException, 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
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 String dumpState()
public String dumpFeederState()
public void setElectableGroupSizeOverride(int override)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |