Class QJournalProtocolTranslatorPB
java.lang.Object
org.apache.hadoop.hdfs.qjournal.protocolPB.QJournalProtocolTranslatorPB
- All Implemented Interfaces:
Closeable,AutoCloseable,QJournalProtocol,org.apache.hadoop.ipc.ProtocolMetaInterface
@Private
@Stable
public class QJournalProtocolTranslatorPB
extends Object
implements org.apache.hadoop.ipc.ProtocolMetaInterface, QJournalProtocol, Closeable
This class is the client side translator to translate the requests made on
JournalProtocol interfaces to the RPC server implementing
JournalProtocolPB.-
Field Summary
Fields inherited from interface org.apache.hadoop.hdfs.qjournal.protocol.QJournalProtocol
versionID -
Constructor Summary
Constructors -
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) voidclose()voiddiscardSegments(String journalId, String nameServiceId, long startTxId) Discard journal segments whose first TxId is greater than or equal to the given txid.voiddoFinalize(String jid, String nameServiceId) voiddoPreUpgrade(String jid) 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 jid, 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 jid, 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) booleanisMethodSupported(String methodName) voidjournal(RequestInfo reqInfo, long segmentTxId, long firstTxnId, int numTxns, byte[] records) Journal edit records.newEpoch(String jid, 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.
-
Constructor Details
-
QJournalProtocolTranslatorPB
-
-
Method Details
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
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 jid, 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
-
format
public void format(String jid, 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
-
newEpoch
public QJournalProtocolProtos.NewEpochResponseProto newEpoch(String jid, 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
-
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
-
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 stateToAccept, URL fromUrl) throws IOException Description copied from interface:QJournalProtocolAccept a proposed recovery for the given transaction ID.- Specified by:
acceptRecoveryin interfaceQJournalProtocol- Throws:
IOException
-
isMethodSupported
- Specified by:
isMethodSupportedin interfaceorg.apache.hadoop.ipc.ProtocolMetaInterface- 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
-