Class JournalSet
java.lang.Object
org.apache.hadoop.hdfs.server.namenode.JournalSet
- All Implemented Interfaces:
Closeable,AutoCloseable,Storage.FormatConfirmable,JournalManager
Manages a collection of Journals. None of the methods are synchronized, it is
assumed that FSEditLog methods, that use this class, use proper
synchronization.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.hadoop.hdfs.server.namenode.JournalManager
JournalManager.CorruptionException -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionbooleancanRollBack(StorageInfo storage, StorageInfo prevStorage, int targetLayoutVersion) Return true if this JM can roll back to the previous storage state, false otherwise.static voidchainAndMakeRedundantStreams(Collection<EditLogInputStream> outStreams, PriorityQueue<EditLogInputStream> allStreams, long fromTxId) voidclose()Close the journal manager, freeing any resources it may hold.voiddiscardSegments(long startTxId) Discard the segments whose first txid is >= the given txid.voidFinalize the upgrade.voidPerform any steps that must succeed across all JournalManagers involved in an upgrade before proceeding onto the actual upgrade stage.voidPerform the rollback to the previous FS state.voidPerform the actual upgrade of the JM.voidfinalizeLogSegment(long firstTxId, long lastTxId) Mark the log segment that spans from firstTxId to lastTxId as finalized and complete.voidformat(NamespaceInfo nsInfo, boolean force) Format the underlying storage, removing any previously stored data.getEditLogManifest(long fromTxId) Return a manifest of what finalized edit logs are available.longbooleanbooleanisEmpty()Returns true if there are no journals, all redundant journals are disabled, or any required journals are disabled.booleanisOpen()voidpurgeLogsOlderThan(long minTxIdToKeep) voidRecover segments which have not been finalized.voidselectInputStreams(Collection<EditLogInputStream> streams, long fromTxId, boolean inProgressOk, boolean onlyDurableTxns) In this function, we get a bunch of streams from all of our JournalManager objects.voidsetOutputBufferCapacity(int size) Set the amount of memory that this stream should use to buffer editsstartLogSegment(long txId, int layoutVersion) Begin writing to a new segment of the log stream, which starts at the given transaction ID.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.hadoop.hdfs.server.common.Storage.FormatConfirmable
toString
-
Field Details
-
EDIT_LOG_INPUT_STREAM_COMPARATOR
-
-
Method Details
-
format
Description copied from interface:JournalManagerFormat the underlying storage, removing any previously stored data.- Specified by:
formatin interfaceJournalManager- Throws:
IOException
-
hasSomeData
- Specified by:
hasSomeDatain interfaceStorage.FormatConfirmable- Returns:
- true if the storage seems to have some valid data in it, and the user should be required to confirm the format. Otherwise, false.
- Throws:
IOException- if the storage cannot be accessed at all.
-
startLogSegment
Description copied from interface:JournalManagerBegin writing to a new segment of the log stream, which starts at the given transaction ID.- Specified by:
startLogSegmentin interfaceJournalManager- Throws:
IOException
-
finalizeLogSegment
Description copied from interface:JournalManagerMark the log segment that spans from firstTxId to lastTxId as finalized and complete.- Specified by:
finalizeLogSegmentin interfaceJournalManager- Throws:
IOException
-
close
Description copied from interface:JournalManagerClose the journal manager, freeing any resources it may hold.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceJournalManager- Throws:
IOException
-
isOpen
public boolean isOpen() -
selectInputStreams
public void selectInputStreams(Collection<EditLogInputStream> streams, long fromTxId, boolean inProgressOk, boolean onlyDurableTxns) In this function, we get a bunch of streams from all of our JournalManager objects. Then we add these to the collection one by one.- Parameters:
streams- The collection to add the streams to. It may or may not be sorted-- this is up to the caller.fromTxId- The transaction ID to start looking for streams atinProgressOk- Should we consider unfinalized streams?onlyDurableTxns- Set to true if streams are bounded by the durable TxId. A durable TxId is the committed txid in QJM or the largest txid written into file in FJM
-
chainAndMakeRedundantStreams
public static void chainAndMakeRedundantStreams(Collection<EditLogInputStream> outStreams, PriorityQueue<EditLogInputStream> allStreams, long fromTxId) -
isEmpty
public boolean isEmpty()Returns true if there are no journals, all redundant journals are disabled, or any required journals are disabled.- Returns:
- True if there no journals, all redundant journals are disabled, or any required journals are disabled.
-
setOutputBufferCapacity
public void setOutputBufferCapacity(int size) Description copied from interface:JournalManagerSet the amount of memory that this stream should use to buffer edits- Specified by:
setOutputBufferCapacityin interfaceJournalManager
-
purgeLogsOlderThan
- Throws:
IOException
-
recoverUnfinalizedSegments
Description copied from interface:JournalManagerRecover segments which have not been finalized.- Specified by:
recoverUnfinalizedSegmentsin interfaceJournalManager- Throws:
IOException
-
getEditLogManifest
Return a manifest of what finalized edit logs are available. All available edit logs are returned starting from the transaction id passed. If 'fromTxId' falls in the middle of a log, that log is returned as well.- Parameters:
fromTxId- Starting transaction id to read the logs.- Returns:
- RemoteEditLogManifest object.
-
doPreUpgrade
Description copied from interface:JournalManagerPerform any steps that must succeed across all JournalManagers involved in an upgrade before proceeding onto the actual upgrade stage. If a call to any JM's doPreUpgrade method fails, then doUpgrade will not be called for any JM.- Specified by:
doPreUpgradein interfaceJournalManager- Throws:
IOException
-
doUpgrade
Description copied from interface:JournalManagerPerform the actual upgrade of the JM. After this is completed, the NN can begin to use the new upgraded metadata. This metadata may later be either finalized or rolled back to the previous state.- Specified by:
doUpgradein interfaceJournalManager- Parameters:
storage- info about the new upgraded versions.- Throws:
IOException
-
doFinalize
Description copied from interface:JournalManagerFinalize the upgrade. JMs should purge any state that they had been keeping around during the upgrade process. After this is completed, rollback is no longer allowed.- Specified by:
doFinalizein interfaceJournalManager- Throws:
IOException
-
canRollBack
public boolean canRollBack(StorageInfo storage, StorageInfo prevStorage, int targetLayoutVersion) throws IOException Description copied from interface:JournalManagerReturn true if this JM can roll back to the previous storage state, false otherwise. The NN will refuse to run the rollback operation unless at least one JM or fsimage storage directory can roll back.- Specified by:
canRollBackin interfaceJournalManager- Parameters:
storage- the storage info for the current stateprevStorage- the storage info for the previous (unupgraded) statetargetLayoutVersion- the layout version we intend to roll back to- Returns:
- true if this JM can roll back, false otherwise.
- Throws:
IOException
-
doRollback
Description copied from interface:JournalManagerPerform the rollback to the previous FS state. JMs which do not need to roll back their state should just return without error.- Specified by:
doRollbackin interfaceJournalManager- Throws:
IOException
-
discardSegments
Description copied from interface:JournalManagerDiscard the segments whose first txid is >= the given txid.- Specified by:
discardSegmentsin interfaceJournalManager- Parameters:
startTxId- The given txid should be right at the segment boundary, i.e., it should be the first txid of some segment, if segment corresponding to the txid exists.- Throws:
IOException
-
getJournalCTime
- Specified by:
getJournalCTimein interfaceJournalManager- Returns:
- the CTime of the journal manager.
- Throws:
IOException
-