Interface HAContext
- All Known Implementing Classes:
NameNode.NameNodeHAContext
@Private
public interface HAContext
Context that is to be used by
HAState for getting/setting the
current state and performing required operations.-
Method Summary
Modifier and TypeMethodDescriptionbooleanvoidVerify that the given operation category is allowed in the current state.getState()Get the state from the contextvoidPrepare to exit the standby statevoidSet the state of the context to givenstatevoidStart the services required in active statevoidStart the services required in standby statevoidStop the services when exiting active statevoidStop the services when exiting standby statevoidTake a write-lock on the underlying namesystem so that no concurrent state transitions or edits can be made.voidUnlock the lock taken bywriteLock()
-
Method Details
-
setState
Set the state of the context to givenstate -
getState
HAState getState()Get the state from the context -
startActiveServices
Start the services required in active state- Throws:
IOException
-
stopActiveServices
Stop the services when exiting active state- Throws:
IOException
-
startStandbyServices
Start the services required in standby state- Throws:
IOException
-
prepareToStopStandbyServices
void prepareToStopStandbyServices() throws org.apache.hadoop.ha.ServiceFailedExceptionPrepare to exit the standby state- Throws:
org.apache.hadoop.ha.ServiceFailedException
-
stopStandbyServices
Stop the services when exiting standby state- Throws:
IOException
-
writeLock
void writeLock()Take a write-lock on the underlying namesystem so that no concurrent state transitions or edits can be made. -
writeUnlock
void writeUnlock()Unlock the lock taken bywriteLock() -
checkOperation
Verify that the given operation category is allowed in the current state. This is to allow NN implementations (eg BackupNode) to override it with node-specific handling. If the operation which is being checked will be taking the FSNS lock, it's advisable to check the operation category both immediately before and after taking the lock. This is because clients rely on the StandbyException thrown by this method in order to trigger client failover, and if a client first tries to contact the Standby NN, it could block for a long time if the Standby is holding the lock for a while, e.g. when performing a checkpoint. See HDFS-4591 for more details.- Throws:
org.apache.hadoop.ipc.StandbyException
-
allowStaleReads
boolean allowStaleReads()- Returns:
- true if the node should allow stale reads (ie reads while the namespace is not up to date)
-