public class RepNode extends StoppableThread
Thread.State, Thread.UncaughtExceptionHandler| Modifier and Type | Field and Description |
|---|---|
static TestHook<String> |
beforeFindRestoreSupplierHook
If not null, a test hook that is called with the name of the current
node before attempting to contact each network restore supplier, for
unit testing.
|
static TestHook<String> |
queryGroupForMembershipBeforeQueryForMaster
If not null, called by queryGroupForMembership with the name of the
current node before querying learners for the master -- for unit
testing.
|
static TestHook<String> |
queryGroupForMembershipBeforeSleepHook
If not null, a test hook that is called with the name of the current
node during the query for group membership before the node sleeps after
failing to obtain information about the group master -- for unit
testing.
|
envImplMAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY| 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 |
|---|---|
void |
addTransientIdNode(RepNodeImpl node)
Adds a transient ID node to the group.
|
void |
clearActiveTransfer()
Called by the RepNode when a transition to replica status has completely
finished.
|
void |
clearedCachedFileChecksum(String fileName)
Clears the cached checksum for a file when it may be overwritten
(e.g., entries may be erased).
|
String |
dumpAckFeederState()
Dumps the state associated with all active Feeders that supply
acknowledgments.
|
String |
dumpState()
Dumps the states associated with any active Feeders as well as
the composition of the group itself.
|
FeederManager |
feederManager() |
void |
findRestoreSuppliers(Set<InetSocketAddress> helpers)
Sets up a Network Restore, as part of the process of restoring an entire
group from backup, by producing an appropriate
InsufficientLogException if possible. |
void |
forceMaster(boolean force) |
MasterTransfer |
getActiveTransfer() |
long |
getAnyDTVLSN()
Returns a DTVLSN (possibly null) for logging/debugging purposes.
|
byte[] |
getAppState()
Return the application state that defined in user specified
AppStateMonitor.
|
Arbiter |
getArbiter() |
ChannelTimeoutTask |
getChannelTimeoutTask() |
RepUtils.Clock |
getClock() |
VLSN |
getCurrentTxnEndVLSN()
Returns the latest VLSN associated with a replicated commit.
|
long |
getDTVLSN()
Returns the instantaneous non-null DTVLSN value.
|
DurabilityQuorum |
getDurabilityQuorum() |
QuorumPolicy |
getElectionPolicy() |
int |
getElectionPriority() |
ElectionQuorum |
getElectionQuorum() |
Elections |
getElections() |
FeederTxns |
getFeederTxns() |
VLSN |
getGlobalCBVLSN()
Returns the global CBVLSN if it is not defunct, and otherwise a null
VLSN.
|
RepGroupImpl |
getGroup()
Retrieves the node's current snapshot image of the group definition.
|
int |
getHeartbeatInterval() |
String |
getHostName() |
Logger |
getLogger() |
LogManager |
getLogManager() |
RepNodeImpl[] |
getLogProviders()
Returns an array of nodes suitable for feeding log files for a network
restore.
|
int |
getLogVersion() |
String |
getMasterName() |
MasterStatus |
getMasterStatus() |
JEVersion |
getMinJEVersion()
Get the group minimum JE version.
|
MonitorEventManager |
getMonitorEventManager() |
NameIdPair |
getNameIdPair() |
int |
getNodeId()
Returns the nodeId associated with this replication node.
|
String |
getNodeName()
Returns the nodeName associated with this replication node.
|
NodeType |
getNodeType()
Returns the node type of this node.
|
int |
getPort() |
RepUtils.ExceptionAwareCountDownLatch |
getReadyLatch() |
RepGroupDB |
getRepGroupDB() |
RepImpl |
getRepImpl() |
Replica |
getReplica() |
VLSN |
getRestoreResponseVLSN(VLSNRange range)
Returns a VLSN appropriate for the RestoreResponse.cbvlsn field when the
GlobalCBVLSN is not defunct, and otherwise a null VLSN.
|
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 |
isAuthoritativeMaster()
Returns a definitive answer to whether this node is currently the master
by checking both its status as a master and whether the group agrees
that it is the master.
|
boolean |
isGlobalCBVLSNDefunct()
Returns whether the GlobalCBVLSN is defunct -- see
GlobalCBVLSN. |
boolean |
isMaster() |
boolean |
isNeedsAcks()
Returns true if acks are needed by the group for durability.
|
boolean |
isShutdownOrInvalid()
Returns true if the node has been shutdown or if the underlying
environment has been invalidated.
|
ReplicatedEnvironment.State |
joinGroup(ReplicaConsistencyPolicy consistency,
QuorumPolicy initialElectionPolicy)
JoinGroup ensures that a RepNode is actively participating in a
replication group.
|
void |
recalculateGlobalCBVLSN()
When the GlobalVLSN is not defunct, recalculates it.
|
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.
|
void |
removeMember(String nodeName)
Removes a node so that it's no longer a member of the group.
|
void |
removeMember(String nodeName,
boolean delete)
Remove or delete a node from the group.
|
void |
removeTransientNode(RepNodeImpl node)
Removes a node with transient id from 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 |
setConvertHook(TestHook<Integer> hook) |
long |
setDTVLSN(long newDTVLSN)
Sets the DTVLSN to a specific value.
|
void |
setGroup(RepGroupImpl repGroupImpl)
Sets the group metadata associated with the RepNode and updates any
local derived data.
|
void |
setMinJEVersion(JEVersion newMinJEVersion)
Checks if all data nodes in the replication group support the specified
JE version.
|
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(FileProtector.ProtectedFileSet fileSet) |
FileProtector.ProtectedFileSet |
syncupStarted(NameIdPair syncupNode)
Marks the start of the search for a matchpoint that happens during a
syncup.
|
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.
|
void |
updateAddress(String nodeName,
String newHostName,
int newPort)
Update the network address of a node.
|
long |
updateDTVLSN(long candidateDTVLSN)
Updates the DTVLSN with a potentially new DTVLSN value.
|
void |
updateGroupInfo(NameIdPair updateNameIdPair,
CleanerBarrierState barrierState)
Updates the cached group info for the node, avoiding a database read,
if the global CBVLSN is not defunct.
|
cleanup, getSavedShutdownException, getTotalCpuTime, getTotalUserTime, handleUncaughtException, isShutdown, saveShutdownException, shutdownDone, shutdownThreadactiveCount, 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, yieldpublic static volatile TestHook<String> queryGroupForMembershipBeforeSleepHook
public static volatile TestHook<String> queryGroupForMembershipBeforeQueryForMaster
public RepNode(RepImpl repImpl, Replay replay, NodeState nodeState) throws IOException, DatabaseException
IOExceptionDatabaseExceptionpublic RepNode(NameIdPair nameIdPair)
public RepNode()
public RepNode(NameIdPair nameIdPair, ServiceDispatcher serviceDispatcher)
public Logger getLogger()
getLogger in class StoppableThreadpublic NodeType getNodeType()
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 RepUtils.Clock getClock()
public Replica getReplica()
public RepGroupDB getRepGroupDB()
public RepGroupImpl getGroup()
There is a very brief period of time, during node start-up, where this
can be null. But after that it should always return a
valid object.
public UUID getUUID()
public String getNodeName()
public int getNodeId()
public NameIdPair getNameIdPair()
public InetSocketAddress getSocket()
public String getHostName()
public int getPort()
public MasterStatus getMasterStatus()
public boolean isAuthoritativeMaster()
public int getHeartbeatInterval()
public void setVersion(int version)
public int getLogVersion()
public int getElectionPriority()
public int getThreadWaitInterval()
public RepImpl getRepImpl()
public LogManager getLogManager()
public VLSNIndex getVLSNIndex()
public FeederTxns getFeederTxns()
public Elections getElections()
public MasterSuggestionGenerator getSuggestionGenerator()
public QuorumPolicy getElectionPolicy()
public RepNodeImpl[] getLogProviders()
public ChannelTimeoutTask getChannelTimeoutTask()
public boolean isMaster()
public MonitorEventManager getMonitorEventManager()
public void registerAppStateMonitor(AppStateMonitor stateMonitor)
public byte[] getAppState()
public String getMasterName()
public VLSN getCurrentTxnEndVLSN()
public long getDTVLSN()
public long getAnyDTVLSN()
public long updateDTVLSN(long candidateDTVLSN)
candidateDTVLSN - the new candidate DTVLSNpublic long setDTVLSN(long newDTVLSN)
public void setGroup(RepGroupImpl repGroupImpl)
public void forceMaster(boolean force)
throws 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.
DatabaseExceptionpublic void removeMember(String nodeName)
nodeName - identifies the node to be removedMemberNotFoundException - 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 removeMember(String nodeName, boolean delete)
Note that names referring to removed nodes cannot be reused, but names for deleted nodes can be.
nodeName - identifies the node to be removed or deleteddelete - whether to delete the node rather than just remove itMemberActiveException - if delete is true and
the node is currently activeMemberNotFoundException - if the node denoted by
memberName is not a member of the replication group.MasterStateException - if the member being removed or deleted 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<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 clearActiveTransfer()
public void updateGroupInfo(NameIdPair updateNameIdPair, CleanerBarrierState barrierState)
updateNameIdPair - the node whose localCBVLSN must be updated.barrierState - the new node syncup statepublic void recalculateGlobalCBVLSN()
public void findRestoreSuppliers(Set<InetSocketAddress> helpers) throws InterruptedException
InsufficientLogException if possible.
Queries each of the supplied helper hosts for their notion of the group make-up. If any of them consider us to be already in the group, then instead of joining the group as a new node we ought to try a Network Restore; and the node(s) that do already know of us are the suitable suppliers for it.
InsufficientLogException - in the successful case, if one or more
suitable suppliers for a Network Restore can be found; otherwise just
returns.InterruptedException - if the node was shutdown or invalidated
while we were looking for a network restore supplierpublic 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.
public boolean isShutdownOrInvalid()
public void shutdown()
throws InterruptedException,
DatabaseException
protected int initiateSoftShutdown()
initiateSoftShutdown in class StoppableThreadpublic void shutdownGroupOnClose(long timeoutMs)
throws IllegalStateException
IllegalStateExceptionReplicatedEnvironment.shutdownGroup(long, TimeUnit)public ReplicatedEnvironment.State joinGroup(ReplicaConsistencyPolicy consistency, QuorumPolicy initialElectionPolicy) throws ReplicaConsistencyException, DatabaseException
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.ReplicaConsistencyExceptionDatabaseExceptionpublic void trackSyncableVLSN(VLSN syncableVLSN, long lsn)
public VLSN getGlobalCBVLSN()
GlobalCBVLSN.getCBVLSN()public boolean isGlobalCBVLSNDefunct()
GlobalCBVLSN.public VLSN getRestoreResponseVLSN(VLSNRange range)
public FileProtector.ProtectedFileSet syncupStarted(NameIdPair syncupNode)
A feeder may have multiple syncups in action. The caller
should call syncupEnded(com.sleepycat.je.cleaner.FileProtector.ProtectedFileSet) when the syncup is done, passing the
value returned by this method.
syncupNode - identifies the other node involved in the the syncup,
and is the name to be used in LogSizeStats.public void syncupEnded(FileProtector.ProtectedFileSet fileSet)
public Arbiter getArbiter()
public final void shutdownNetworkBackup()
restartNetworkBackup() is then used to restart the service after it was shut down.
public final void restartNetworkBackup()
public void clearedCachedFileChecksum(String fileName)
public String dumpState()
public String dumpAckFeederState()
public ElectionQuorum getElectionQuorum()
public DurabilityQuorum getDurabilityQuorum()
public JEVersion getMinJEVersion()
Returns the minimum JE version that is required for all nodes that join this node's replication group. The version returned is supported by all current and future group members. The minimum JE version is guaranteed to only increase over time, so long as the data for the environment is not rolled back or lost.
public void setMinJEVersion(JEVersion newMinJEVersion) throws MinJEVersionUnsupportedException
This method should only be called on the master, because attempts to update the rep group DB on an replica will fail.
newMinJEVersion - the new minimum JE versionDatabaseException - if an error occurs when accessing the
replication group databaseMinJEVersionUnsupportedException - if the version is not supported
by one or more current group memberspublic boolean isNeedsAcks()
public void addTransientIdNode(RepNodeImpl node)
node - the nodeIllegalStateException - if the store does not currently support
secondary nodes or the node doesn't meet the current minimum JE
versionRepGroupImpl.NodeConflictException - if the node conflicts with an existing
persistent nodepublic void removeTransientNode(RepNodeImpl node)
node - the nodeCopyright © 2024. All rights reserved.