Interface QJournalProtocol
- All Known Implementing Classes:
JournalNodeRpcServer,QJournalProtocolTranslatorPB
@Private
public interface QJournalProtocol
Protocol used to communicate between
QuorumJournalManager
and each JournalNode.
This is responsible for sending edits as well as coordinating
recovery of the nodes.-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionvoidacceptRecovery(RequestInfo reqInfo, QJournalProtocolProtos.SegmentStateProto stateToAccept, 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) getJournalCTime(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.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 requestInfo, long minTxIdToKeep) voidstartLogSegment(RequestInfo reqInfo, long txid, int layoutVersion) Start writing to a new log segment on the JournalNode.
-
Field Details
-
versionID
static final long versionID- See Also:
-
-
Method Details
-
isFormatted
- Returns:
- true if the given journal has been formatted and contains valid data.
- Throws:
IOException
-
getJournalState
QJournalProtocolProtos.GetJournalStateResponseProto getJournalState(String journalId, String nameServiceId) throws IOException Get the current state of the journal, including the most recent epoch number and the HTTP port.- Throws:
IOException
-
format
void format(String journalId, String nameServiceId, NamespaceInfo nsInfo, boolean force) throws IOException Format the underlying storage for the given namespace.- Throws:
IOException
-
newEpoch
QJournalProtocolProtos.NewEpochResponseProto newEpoch(String journalId, String nameServiceId, NamespaceInfo nsInfo, long epoch) throws IOException Begin a new epoch. See the HDFS-3077 design doc for details.- Throws:
IOException
-
journal
void journal(RequestInfo reqInfo, long segmentTxId, long firstTxnId, int numTxns, byte[] records) throws IOException Journal edit records. This message is sent by the active name-node to the JournalNodes to write edits to their local logs.- Throws:
IOException
-
heartbeat
Heartbeat. 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.- Throws:
IOException
-
startLogSegment
Start writing to a new log segment on the JournalNode. Before calling this, one should finalize the previous segment usingfinalizeLogSegment(RequestInfo, long, long).- Parameters:
txid- the first txid in the new loglayoutVersion- the LayoutVersion of the new log- Throws:
IOException
-
finalizeLogSegment
Finalize the given log segment on the JournalNode. The segment is expected to be in-progress and starting at the given startTxId.- Parameters:
startTxId- the starting transaction ID of the logendTxId- the expected last transaction in the given log- Throws:
IOException- if no such segment exists
-
purgeLogsOlderThan
- Throws:
IOException- See Also:
-
LogsPurgeable.purgeLogsOlderThan(long)
-
getEditLogManifest
QJournalProtocolProtos.GetEditLogManifestResponseProto getEditLogManifest(String jid, String nameServiceId, long sinceTxId, boolean inProgressOk) throws IOException - 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
-
getJournaledEdits
QJournalProtocolProtos.GetJournaledEditsResponseProto getJournaledEdits(String jid, String nameServiceId, long sinceTxId, int maxTxns) throws IOException Fetch 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.- 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 withgetEditLogManifest(String, String, long, boolean)).- See Also:
-
JournaledEditsCache
-
prepareRecovery
QJournalProtocolProtos.PrepareRecoveryResponseProto prepareRecovery(RequestInfo reqInfo, long segmentTxId) throws IOException Begin the recovery process for a given segment. See the HDFS-3077 design document for details.- Throws:
IOException
-
acceptRecovery
void acceptRecovery(RequestInfo reqInfo, QJournalProtocolProtos.SegmentStateProto stateToAccept, URL fromUrl) throws IOException Accept a proposed recovery for the given transaction ID.- Throws:
IOException
-
doPreUpgrade
- Throws:
IOException
-
doUpgrade
- Throws:
IOException
-
doFinalize
- Throws:
IOException
-
canRollBack
Boolean canRollBack(String journalId, String nameServiceid, StorageInfo storage, StorageInfo prevStorage, int targetLayoutVersion) throws IOException - Throws:
IOException
-
doRollback
- Throws:
IOException
-
discardSegments
Discard journal segments whose first TxId is greater than or equal to the given txid.- Throws:
IOException
-
getJournalCTime
- Throws:
IOException
-