java.io.Closeable, java.lang.AutoCloseable, Storage.FormatConfirmable, JournalManager@Private public class FileJournalManager extends java.lang.Object implements JournalManager
| Modifier and Type | Class | Description |
|---|---|---|
static class |
FileJournalManager.EditLogFile |
Record of an edit log that has been located and had its filename parsed.
|
JournalManager.CorruptionException| Constructor | Description |
|---|---|
FileJournalManager(org.apache.hadoop.conf.Configuration conf,
Storage.StorageDirectory sd,
StorageErrorReporter errorReporter) |
| Modifier and Type | Method | Description |
|---|---|---|
boolean |
canRollBack(StorageInfo storage,
StorageInfo prevStorage,
int targetLayoutVersion) |
Return true if this JM can roll back to the previous storage state, false
otherwise.
|
void |
close() |
Close the journal manager, freeing any resources it may hold.
|
void |
discardSegments(long startTxid) |
Discard the segments whose first txid is >= the given txid.
|
void |
doFinalize() |
Finalize the upgrade.
|
void |
doPreUpgrade() |
Perform any steps that must succeed across all JournalManagers involved in
an upgrade before proceeding onto the actual upgrade stage.
|
void |
doRollback() |
Perform the rollback to the previous FS state.
|
void |
doUpgrade(Storage storage) |
This method assumes that the fields of the
Storage object have
already been updated to the appropriate new values for the upgrade. |
void |
finalizeLogSegment(long firstTxId,
long lastTxId) |
Mark the log segment that spans from firstTxId to lastTxId
as finalized and complete.
|
void |
format(NamespaceInfo ns,
boolean force) |
Format the underlying storage, removing any previously
stored data.
|
long |
getJournalCTime() |
|
long |
getLastReadableTxId() |
|
FileJournalManager.EditLogFile |
getLogFile(long startTxId) |
|
FileJournalManager.EditLogFile |
getLogFile(long startTxId,
boolean inProgressOk) |
|
static FileJournalManager.EditLogFile |
getLogFile(java.io.File dir,
long startTxId) |
|
static FileJournalManager.EditLogFile |
getLogFile(java.io.File dir,
long startTxId,
boolean inProgressOk) |
|
java.util.List<FileJournalManager.EditLogFile> |
getLogFiles(long fromTxId) |
|
java.util.List<RemoteEditLog> |
getRemoteEditLogs(long firstTxId,
boolean inProgressOk) |
Find all editlog segments starting at or above the given txid.
|
Storage.StorageDirectory |
getStorageDirectory() |
|
boolean |
hasSomeData() |
|
static java.util.List<FileJournalManager.EditLogFile> |
matchEditLogs(java.io.File logDir) |
returns matching edit logs via the log directory.
|
void |
purgeLogsOlderThan(long minTxIdToKeep) |
Purges the unnecessary edits and edits_inprogress files.
|
void |
recoverUnfinalizedSegments() |
Recover segments which have not been finalized.
|
void |
selectInputStreams(java.util.Collection<EditLogInputStream> streams,
long fromTxnId,
boolean inProgressOk) |
|
void |
selectInputStreams(java.util.Collection<EditLogInputStream> streams,
long fromTxId,
boolean inProgressOk,
boolean onlyDurableTxns) |
|
void |
setLastReadableTxId(long id) |
|
void |
setOutputBufferCapacity(int size) |
Set the amount of memory that this stream should use to buffer edits
|
EditLogOutputStream |
startLogSegment(long txid,
int layoutVersion) |
Begin writing to a new segment of the log stream, which starts at
the given transaction ID.
|
java.lang.String |
toString() |
public FileJournalManager(org.apache.hadoop.conf.Configuration conf,
Storage.StorageDirectory sd,
StorageErrorReporter errorReporter)
public void close()
throws java.io.IOException
JournalManagerclose in interface java.lang.AutoCloseableclose in interface java.io.Closeableclose in interface JournalManagerjava.io.IOExceptionpublic void format(NamespaceInfo ns, boolean force) throws java.io.IOException
JournalManagerformat in interface JournalManagerjava.io.IOExceptionpublic boolean hasSomeData()
hasSomeData in interface Storage.FormatConfirmablepublic EditLogOutputStream startLogSegment(long txid, int layoutVersion) throws java.io.IOException
JournalManagerstartLogSegment in interface JournalManagerjava.io.IOExceptionpublic void finalizeLogSegment(long firstTxId,
long lastTxId)
throws java.io.IOException
JournalManagerfinalizeLogSegment in interface JournalManagerjava.io.IOException@VisibleForTesting public Storage.StorageDirectory getStorageDirectory()
public void setOutputBufferCapacity(int size)
JournalManagersetOutputBufferCapacity in interface JournalManagerpublic long getLastReadableTxId()
public void setLastReadableTxId(long id)
public void purgeLogsOlderThan(long minTxIdToKeep)
throws java.io.IOException
minTxIdToKeep - the lowest transaction ID that should be retainedjava.io.IOException - if listing the storage directory fails.public java.util.List<RemoteEditLog> getRemoteEditLogs(long firstTxId, boolean inProgressOk) throws java.io.IOException
firstTxId - the txnid which to start lookinginProgressOk - whether or not to include the in-progress edit log
segmentjava.io.IOException - if edit logs cannot be listed.public static java.util.List<FileJournalManager.EditLogFile> matchEditLogs(java.io.File logDir) throws java.io.IOException
logDir - directory to match edit logs injava.io.IOException - IOException thrown for invalid logDirpublic void selectInputStreams(java.util.Collection<EditLogInputStream> streams, long fromTxnId, boolean inProgressOk) throws java.io.IOException
java.io.IOExceptionpublic void selectInputStreams(java.util.Collection<EditLogInputStream> streams, long fromTxId, boolean inProgressOk, boolean onlyDurableTxns) throws java.io.IOException
java.io.IOExceptionpublic void recoverUnfinalizedSegments()
throws java.io.IOException
JournalManagerrecoverUnfinalizedSegments in interface JournalManagerjava.io.IOExceptionpublic java.util.List<FileJournalManager.EditLogFile> getLogFiles(long fromTxId) throws java.io.IOException
java.io.IOExceptionpublic FileJournalManager.EditLogFile getLogFile(long startTxId) throws java.io.IOException
java.io.IOExceptionpublic FileJournalManager.EditLogFile getLogFile(long startTxId, boolean inProgressOk) throws java.io.IOException
java.io.IOExceptionpublic static FileJournalManager.EditLogFile getLogFile(java.io.File dir, long startTxId) throws java.io.IOException
java.io.IOExceptionpublic static FileJournalManager.EditLogFile getLogFile(java.io.File dir, long startTxId, boolean inProgressOk) throws java.io.IOException
java.io.IOExceptionpublic java.lang.String toString()
toString in interface Storage.FormatConfirmabletoString in class java.lang.Objectpublic void doPreUpgrade()
throws java.io.IOException
JournalManagerdoPreUpgrade in interface JournalManagerjava.io.IOExceptionpublic void doUpgrade(Storage storage) throws java.io.IOException
Storage object have
already been updated to the appropriate new values for the upgrade.doUpgrade in interface JournalManagerstorage - info about the new upgraded versions.java.io.IOExceptionpublic void doFinalize()
throws java.io.IOException
JournalManagerdoFinalize in interface JournalManagerjava.io.IOExceptionpublic boolean canRollBack(StorageInfo storage, StorageInfo prevStorage, int targetLayoutVersion) throws java.io.IOException
JournalManagercanRollBack in interface JournalManagerstorage - the storage info for the current stateprevStorage - the storage info for the previous (unupgraded) statetargetLayoutVersion - the layout version we intend to roll back tojava.io.IOExceptionpublic void doRollback()
throws java.io.IOException
JournalManagerdoRollback in interface JournalManagerjava.io.IOExceptionpublic void discardSegments(long startTxid)
throws java.io.IOException
JournalManagerdiscardSegments in interface JournalManagerstartTxid - 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.java.io.IOExceptionpublic long getJournalCTime()
throws java.io.IOException
getJournalCTime in interface JournalManagerjava.io.IOExceptionCopyright © 2008–2025 Apache Software Foundation. All rights reserved.