Class JournalNodeRpcServer
java.lang.Object
org.apache.hadoop.hdfs.qjournal.server.JournalNodeRpcServer
- All Implemented Interfaces:
InterQJournalProtocol,QJournalProtocol
@Private
@VisibleForTesting
public class JournalNodeRpcServer
extends Object
implements QJournalProtocol, InterQJournalProtocol
-
Field Summary
Fields inherited from interface org.apache.hadoop.hdfs.qjournal.protocol.InterQJournalProtocol
versionIDFields inherited from interface org.apache.hadoop.hdfs.qjournal.protocol.QJournalProtocol
versionID -
Method Summary
Modifier and TypeMethodDescriptionvoidacceptRecovery(RequestInfo reqInfo, QJournalProtocolProtos.SegmentStateProto log, URL fromUrl) Accept a proposed recovery for the given transaction ID.canRollBack(String journalId, String nameServiceId, StorageInfo storage, StorageInfo prevStorage, int targetLayoutVersion) voiddiscardSegments(String journalId, String nameServiceId, long startTxId) Discard journal segments whose first TxId is greater than or equal to the given txid.voiddoFinalize(String journalId, String nameServiceId) voiddoPreUpgrade(String journalId) voiddoRollback(String journalId, String nameServiceId) voiddoUpgrade(String journalId, StorageInfo sInfo) voidfinalizeLogSegment(RequestInfo reqInfo, long startTxId, long endTxId) Finalize the given log segment on the JournalNode.voidformat(String journalId, String nameServiceId, NamespaceInfo nsInfo, boolean force) Format the underlying storage for the given namespace.getEditLogManifest(String jid, String nameServiceId, long sinceTxId, boolean inProgressOk) getEditLogManifestFromJournal(String jid, String nameServiceId, long sinceTxId, boolean inProgressOk) protected intgetJournalCTime(String journalId, String nameServiceId) getJournaledEdits(String jid, String nameServiceId, long sinceTxId, int maxTxns) Fetch edit logs present in the Journal's in-memory cache of edits (JournaledEditsCache).getJournalState(String journalId, String nameServiceId) Get the current state of the journal, including the most recent epoch number and the HTTP port.org.apache.hadoop.hdfs.protocol.proto.HdfsServerProtos.StorageInfoProtogetStorageInfo(String jid, String nameServiceId) Get the storage info for the specified journal.voidheartbeat(RequestInfo reqInfo) Heartbeat.booleanisFormatted(String journalId, String nameServiceId) voidjournal(RequestInfo reqInfo, long segmentTxId, long firstTxnId, int numTxns, byte[] records) Journal edit records.newEpoch(String journalId, String nameServiceId, NamespaceInfo nsInfo, long epoch) Begin a new epoch.prepareRecovery(RequestInfo reqInfo, long segmentTxId) Begin the recovery process for a given segment.voidpurgeLogsOlderThan(RequestInfo reqInfo, long minTxIdToKeep) voidstartLogSegment(RequestInfo reqInfo, long txid, int layoutVersion) Start writing to a new log segment on the JournalNode.
-
Method Details
-
getHandlerCount
@VisibleForTesting protected int getHandlerCount() -
getAddress
-
isFormatted
- Specified by:
isFormattedin interfaceQJournalProtocol- Returns:
- true if the given journal has been formatted and contains valid data.
- Throws:
IOException
-
getJournalState
public QJournalProtocolProtos.GetJournalStateResponseProto getJournalState(String journalId, String nameServiceId) throws IOException Description copied from interface:QJournalProtocolGet the current state of the journal, including the most recent epoch number and the HTTP port.- Specified by:
getJournalStatein interfaceQJournalProtocol- Throws:
IOException
-
newEpoch
public QJournalProtocolProtos.NewEpochResponseProto newEpoch(String journalId, String nameServiceId, NamespaceInfo nsInfo, long epoch) throws IOException Description copied from interface:QJournalProtocolBegin a new epoch. See the HDFS-3077 design doc for details.- Specified by:
newEpochin interfaceQJournalProtocol- Throws:
IOException
-
format
public void format(String journalId, String nameServiceId, NamespaceInfo nsInfo, boolean force) throws IOException Description copied from interface:QJournalProtocolFormat the underlying storage for the given namespace.- Specified by:
formatin interfaceQJournalProtocol- Throws:
IOException
-
journal
public void journal(RequestInfo reqInfo, long segmentTxId, long firstTxnId, int numTxns, byte[] records) throws IOException Description copied from interface:QJournalProtocolJournal edit records. This message is sent by the active name-node to the JournalNodes to write edits to their local logs.- Specified by:
journalin interfaceQJournalProtocol- Throws:
IOException
-
heartbeat
Description copied from interface:QJournalProtocolHeartbeat. This is a no-op on the server, except that it verifies that the caller is in fact still the active writer, and provides up-to-date information on the most recently committed txid.- Specified by:
heartbeatin interfaceQJournalProtocol- Throws:
IOException
-
startLogSegment
Description copied from interface:QJournalProtocolStart writing to a new log segment on the JournalNode. Before calling this, one should finalize the previous segment usingQJournalProtocol.finalizeLogSegment(RequestInfo, long, long).- Specified by:
startLogSegmentin interfaceQJournalProtocoltxid- the first txid in the new loglayoutVersion- the LayoutVersion of the new log- Throws:
IOException
-
finalizeLogSegment
public void finalizeLogSegment(RequestInfo reqInfo, long startTxId, long endTxId) throws IOException Description copied from interface:QJournalProtocolFinalize the given log segment on the JournalNode. The segment is expected to be in-progress and starting at the given startTxId.- Specified by:
finalizeLogSegmentin interfaceQJournalProtocolstartTxId- the starting transaction ID of the logendTxId- the expected last transaction in the given log- Throws:
IOException- if no such segment exists
-
purgeLogsOlderThan
- Specified by:
purgeLogsOlderThanin interfaceQJournalProtocol- Throws:
IOException- See Also:
-
LogsPurgeable.purgeLogsOlderThan(long)
-
getEditLogManifest
public QJournalProtocolProtos.GetEditLogManifestResponseProto getEditLogManifest(String jid, String nameServiceId, long sinceTxId, boolean inProgressOk) throws IOException - Specified by:
getEditLogManifestin interfaceQJournalProtocol- Parameters:
jid- the journal from which to enumerate editssinceTxId- the first transaction which the client cares aboutinProgressOk- whether or not to check the in-progress edit log segment- Returns:
- a list of edit log segments since the given transaction ID.
- Throws:
IOException
-
getStorageInfo
public org.apache.hadoop.hdfs.protocol.proto.HdfsServerProtos.StorageInfoProto getStorageInfo(String jid, String nameServiceId) throws IOException Description copied from interface:InterQJournalProtocolGet the storage info for the specified journal.- Specified by:
getStorageInfoin interfaceInterQJournalProtocol- Parameters:
jid- the journal identifiernameServiceId- the name service id- Returns:
- the storage info object
- Throws:
IOException
-
getJournaledEdits
public QJournalProtocolProtos.GetJournaledEditsResponseProto getJournaledEdits(String jid, String nameServiceId, long sinceTxId, int maxTxns) throws IOException Description copied from interface:QJournalProtocolFetch edit logs present in the Journal's in-memory cache of edits (JournaledEditsCache). To enable this cache, in-progress edit log tailing must be enabled via the "dfs.ha.tail-edits.in-progress" configuration key.- Specified by:
getJournaledEditsin interfaceQJournalProtocol- Parameters:
jid- The ID of the journal from which to fetch edits.nameServiceId- The ID of the namespace for which to fetch edits.sinceTxId- Fetch edits starting at this transaction IDmaxTxns- Request at most this many transactions to be returned- Returns:
- Response containing serialized edits to be loaded
- Throws:
IOException- If there was an issue encountered while fetching edits from the cache, including a cache miss (cache does not contain the requested edits). The caller should then attempt to fetch the edits via the streaming mechanism (starting withQJournalProtocol.getEditLogManifest(String, String, long, boolean)).- See Also:
-
JournaledEditsCache
-
prepareRecovery
public QJournalProtocolProtos.PrepareRecoveryResponseProto prepareRecovery(RequestInfo reqInfo, long segmentTxId) throws IOException Description copied from interface:QJournalProtocolBegin the recovery process for a given segment. See the HDFS-3077 design document for details.- Specified by:
prepareRecoveryin interfaceQJournalProtocol- Throws:
IOException
-
acceptRecovery
public void acceptRecovery(RequestInfo reqInfo, QJournalProtocolProtos.SegmentStateProto log, URL fromUrl) throws IOException Description copied from interface:QJournalProtocolAccept a proposed recovery for the given transaction ID.- Specified by:
acceptRecoveryin interfaceQJournalProtocol- Throws:
IOException
-
doPreUpgrade
- Specified by:
doPreUpgradein interfaceQJournalProtocol- Throws:
IOException
-
doUpgrade
- Specified by:
doUpgradein interfaceQJournalProtocol- Throws:
IOException
-
doFinalize
- Specified by:
doFinalizein interfaceQJournalProtocol- Throws:
IOException
-
canRollBack
public Boolean canRollBack(String journalId, String nameServiceId, StorageInfo storage, StorageInfo prevStorage, int targetLayoutVersion) throws IOException - Specified by:
canRollBackin interfaceQJournalProtocol- Throws:
IOException
-
doRollback
- Specified by:
doRollbackin interfaceQJournalProtocol- Throws:
IOException
-
discardSegments
public void discardSegments(String journalId, String nameServiceId, long startTxId) throws IOException Description copied from interface:QJournalProtocolDiscard journal segments whose first TxId is greater than or equal to the given txid.- Specified by:
discardSegmentsin interfaceQJournalProtocol- Throws:
IOException
-
getJournalCTime
- Specified by:
getJournalCTimein interfaceQJournalProtocol- Throws:
IOException
-
getEditLogManifestFromJournal
public QJournalProtocolProtos.GetEditLogManifestResponseProto getEditLogManifestFromJournal(String jid, String nameServiceId, long sinceTxId, boolean inProgressOk) throws IOException - Specified by:
getEditLogManifestFromJournalin interfaceInterQJournalProtocol- Parameters:
jid- the journal from which to enumerate editssinceTxId- the first transaction which the client cares aboutinProgressOk- whether or not to check the in-progress edit log segment- Returns:
- a list of edit log segments since the given transaction ID.
- Throws:
IOException
-