Class QuorumJournalManager

java.lang.Object
org.apache.hadoop.hdfs.qjournal.client.QuorumJournalManager
All Implemented Interfaces:
Closeable, AutoCloseable, Storage.FormatConfirmable, JournalManager

@Private public class QuorumJournalManager extends Object implements JournalManager
A JournalManager that writes to a set of remote JournalNodes, requiring a quorum of nodes to ack each write.
  • Field Details

  • Constructor Details

  • Method Details

    • createLoggers

      protected List<org.apache.hadoop.hdfs.qjournal.client.AsyncLogger> createLoggers(org.apache.hadoop.hdfs.qjournal.client.AsyncLogger.Factory factory) throws IOException
      Throws:
      IOException
    • checkJournalId

      public static void checkJournalId(String jid)
    • format

      public void format(NamespaceInfo nsInfo, boolean force) throws IOException
      Description copied from interface: JournalManager
      Format the underlying storage, removing any previously stored data.
      Specified by:
      format in interface JournalManager
      Throws:
      IOException
    • hasSomeData

      public boolean hasSomeData() throws IOException
      Specified by:
      hasSomeData in interface Storage.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

      public EditLogOutputStream startLogSegment(long txId, int layoutVersion) throws IOException
      Description copied from interface: JournalManager
      Begin writing to a new segment of the log stream, which starts at the given transaction ID.
      Specified by:
      startLogSegment in interface JournalManager
      Throws:
      IOException
    • finalizeLogSegment

      public void finalizeLogSegment(long firstTxId, long lastTxId) throws IOException
      Description copied from interface: JournalManager
      Mark the log segment that spans from firstTxId to lastTxId as finalized and complete.
      Specified by:
      finalizeLogSegment in interface JournalManager
      Throws:
      IOException
    • setOutputBufferCapacity

      public void setOutputBufferCapacity(int size)
      Description copied from interface: JournalManager
      Set the amount of memory that this stream should use to buffer edits
      Specified by:
      setOutputBufferCapacity in interface JournalManager
    • purgeLogsOlderThan

      public void purgeLogsOlderThan(long minTxIdToKeep) throws IOException
      Throws:
      IOException
    • recoverUnfinalizedSegments

      public void recoverUnfinalizedSegments() throws IOException
      Description copied from interface: JournalManager
      Recover segments which have not been finalized.
      Specified by:
      recoverUnfinalizedSegments in interface JournalManager
      Throws:
      IOException
    • close

      public void close() throws IOException
      Description copied from interface: JournalManager
      Close the journal manager, freeing any resources it may hold.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Specified by:
      close in interface JournalManager
      Throws:
      IOException
    • selectInputStreams

      public void selectInputStreams(Collection<EditLogInputStream> streams, long fromTxnId, boolean inProgressOk) throws IOException
      Throws:
      IOException
    • selectInputStreams

      public void selectInputStreams(Collection<EditLogInputStream> streams, long fromTxnId, boolean inProgressOk, boolean onlyDurableTxns) throws IOException
      Throws:
      IOException
    • toString

      public String toString()
      Specified by:
      toString in interface Storage.FormatConfirmable
      Overrides:
      toString in class Object
      Returns:
      a string representation of the formattable item, suitable for display to the user inside a prompt
    • doPreUpgrade

      public void doPreUpgrade() throws IOException
      Description copied from interface: JournalManager
      Perform 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:
      doPreUpgrade in interface JournalManager
      Throws:
      IOException
    • doUpgrade

      public void doUpgrade(Storage storage) throws IOException
      Description copied from interface: JournalManager
      Perform 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:
      doUpgrade in interface JournalManager
      Parameters:
      storage - info about the new upgraded versions.
      Throws:
      IOException
    • doFinalize

      public void doFinalize() throws IOException
      Description copied from interface: JournalManager
      Finalize 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:
      doFinalize in interface JournalManager
      Throws:
      IOException
    • canRollBack

      public boolean canRollBack(StorageInfo storage, StorageInfo prevStorage, int targetLayoutVersion) throws IOException
      Description copied from interface: JournalManager
      Return 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:
      canRollBack in interface JournalManager
      Parameters:
      storage - the storage info for the current state
      prevStorage - the storage info for the previous (unupgraded) state
      targetLayoutVersion - the layout version we intend to roll back to
      Returns:
      true if this JM can roll back, false otherwise.
      Throws:
      IOException
    • doRollback

      public void doRollback() throws IOException
      Description copied from interface: JournalManager
      Perform the rollback to the previous FS state. JMs which do not need to roll back their state should just return without error.
      Specified by:
      doRollback in interface JournalManager
      Throws:
      IOException
    • discardSegments

      public void discardSegments(long startTxId) throws IOException
      Description copied from interface: JournalManager
      Discard the segments whose first txid is >= the given txid.
      Specified by:
      discardSegments in interface JournalManager
      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

      public long getJournalCTime() throws IOException
      Specified by:
      getJournalCTime in interface JournalManager
      Returns:
      the CTime of the journal manager.
      Throws:
      IOException