Class OmRatisSnapshotProvider

java.lang.Object
org.apache.hadoop.hdds.utils.RDBSnapshotProvider
org.apache.hadoop.ozone.om.ratis_snapshot.OmRatisSnapshotProvider
All Implemented Interfaces:
Closeable, AutoCloseable

public class OmRatisSnapshotProvider extends org.apache.hadoop.hdds.utils.RDBSnapshotProvider
OmRatisSnapshotProvider downloads the latest checkpoint from the leader OM and loads the checkpoint into State Machine. In addtion to the latest checkpoint, it also downloads any previous omSnapshots the leader has created. The term "snapshot" has two related but slightly different meanings in ozone. An "omSnapshot" is a copy of the om's metadata at a point in time. It is created by users through the "ozone sh snapshot create" cli. A "ratisSnapshot", (provided by this class), is used by om followers to bootstrap themselves to the current state of the om leader. ratisSnapshots will contain copies of all the individual "omSnapshot"s that exist on the leader at the time of the bootstrap. The follower needs these copies to respond the users snapshot requests when it becomes the leader.
  • Constructor Summary

    Constructors
    Constructor
    Description
    OmRatisSnapshotProvider(File snapshotDir, Map<String,org.apache.hadoop.ozone.om.helpers.OMNodeDetails> peerNodesMap, org.apache.hadoop.hdds.server.http.HttpConfig.Policy httpPolicy, boolean spnegoEnabled, org.apache.hadoop.hdfs.web.URLConnectionFactory connectionFactory)
     
    OmRatisSnapshotProvider(org.apache.hadoop.hdds.conf.MutableConfigurationSource conf, File omRatisSnapshotDir, Map<String,org.apache.hadoop.ozone.om.helpers.OMNodeDetails> peerNodeDetails)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addNewPeerNode(org.apache.hadoop.ozone.om.helpers.OMNodeDetails newOMNode)
    When a new OM is bootstrapped, add it to the peerNode map.
    void
     
    static void
    downloadFileWithProgress(InputStream inputStream, File targetFile)
    Writes data from the given InputStream to the target file while logging download progress every 30 seconds.
    void
    downloadSnapshot(String leaderNodeID, File targetFile)
     
    void
    When an OM is decommissioned, remove it from the peerNode map.
    static void
    writeFormData(HttpURLConnection connection, List<String> sstFiles)
    Writes form data to output stream as any HTTP client would for a multipart/form-data request.

    Methods inherited from class org.apache.hadoop.hdds.utils.RDBSnapshotProvider

    downloadDBSnapshotFromLeader, getCandidateDir, getCheckpointFromSnapshotFile, getInitCount, getInjector, getNumDownloaded, getSnapshotDir, getSnapshotFileName, init, setInjector

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • OmRatisSnapshotProvider

      public OmRatisSnapshotProvider(File snapshotDir, Map<String,org.apache.hadoop.ozone.om.helpers.OMNodeDetails> peerNodesMap, org.apache.hadoop.hdds.server.http.HttpConfig.Policy httpPolicy, boolean spnegoEnabled, org.apache.hadoop.hdfs.web.URLConnectionFactory connectionFactory)
    • OmRatisSnapshotProvider

      public OmRatisSnapshotProvider(org.apache.hadoop.hdds.conf.MutableConfigurationSource conf, File omRatisSnapshotDir, Map<String,org.apache.hadoop.ozone.om.helpers.OMNodeDetails> peerNodeDetails)
  • Method Details

    • addNewPeerNode

      public void addNewPeerNode(org.apache.hadoop.ozone.om.helpers.OMNodeDetails newOMNode)
      When a new OM is bootstrapped, add it to the peerNode map.
    • removeDecommissionedPeerNode

      public void removeDecommissionedPeerNode(String decommNodeId)
      When an OM is decommissioned, remove it from the peerNode map.
    • downloadSnapshot

      public void downloadSnapshot(String leaderNodeID, File targetFile) throws IOException
      Specified by:
      downloadSnapshot in class org.apache.hadoop.hdds.utils.RDBSnapshotProvider
      Throws:
      IOException
    • downloadFileWithProgress

      public static void downloadFileWithProgress(InputStream inputStream, File targetFile) throws IOException
      Writes data from the given InputStream to the target file while logging download progress every 30 seconds.
      Throws:
      IOException
    • writeFormData

      public static void writeFormData(HttpURLConnection connection, List<String> sstFiles) throws IOException
      Writes form data to output stream as any HTTP client would for a multipart/form-data request. Proper form data includes separator, content disposition and value separated by a new line. Example:
       -----XXX
       Content-Disposition: form-data; name="field1"
      
       value1
      Parameters:
      connection - HTTP URL connection which output stream is used.
      sstFiles - SST files for exclusion.
      Throws:
      IOException - if an exception occured during writing to output stream.
    • close

      public void close() throws IOException
      Throws:
      IOException