code: void doImportCheckpoint() throws IOException {
      Collection<URI> checkpointDirs =
        NNStorageConfiguration.getCheckpointDirs(conf, null);
      Collection<URI> checkpointEditsDirs =
          NNStorageConfiguration.getCheckpointEditsDirs(conf, null);
  
      if (checkpointDirs == null || checkpointDirs.isEmpty()) {
        throw new IOException("Cannot import image from a checkpoint. "
                              + "\"dfs.namenode.checkpoint.dir\" is not set." );
      }
      
      if (checkpointEditsDirs == null || checkpointEditsDirs.isEmpty()) {
        throw new IOException("Cannot import image from a checkpoint. "
                              + "\"dfs.namenode.checkpoint.dir\" is not set." );
      }
  
      // replace real image with the checkpoint image
      FSImage realImage = namesystem.getFSImage();
      assert realImage == this;
      FSImage ckptImage = new FSImage(conf,
                                      checkpointDirs, checkpointEditsDirs, null);
      ckptImage.setFSNamesystem(namesystem);
      namesystem.dir.fsImage = ckptImage;
      // load from the checkpoint dirs
      try {
        ckptImage.recoverTransitionRead(StartupOption.REGULAR);
      } finally {
        ckptImage.close();
      }
      // return back the real image
      realImage.storage.setStorageInfo(ckptImage.storage);
      realImage.getEditLog().setLastWrittenTxId(ckptImage.getEditLog().getLastWrittenTxId() + 1);
  
      namesystem.dir.fsImage = realImage;
  
      // and save it but keep the same checkpointTime
      // parameters
      saveNamespace();
    }
docs: Load image from a checkpoint directory and save it into the current one.
  @param target the NameSystem to import into
  @throws IOException