void checkTempDir(final Path tmpdir, final Configuration c, final FileSystem fs)
    throws IOException {
    // If the temp directory exists, clear the content (left over, from the previous run)
    if (fs.exists(tmpdir)) {
      // Archive table in temp, maybe left over from failed deletion,
      // if not the cleaner will take care of them.
      for (Path tableDir : FSUtils.getTableDirs(fs, tmpdir)) {
        HFileArchiver.archiveRegions(c, fs, this.rootdir, tableDir,
          FSUtils.getRegionDirs(fs, tableDir));
        if (!FSUtils.getRegionDirs(fs, tableDir).isEmpty()) {
          LOG.warn("Found regions in tmp dir after archiving table regions, {}", tableDir);
        }
      }
      // if acl sync to hdfs is enabled, then skip delete tmp dir because ACLs are set
      if (!SnapshotScannerHDFSAclHelper.isAclSyncToHdfsEnabled(c) && !fs.delete(tmpdir, true)) {
        throw new IOException("Unable to clean the temp directory: " + tmpdir);
      }
    }

    // Create the temp directory
    if (!fs.exists(tmpdir)) {
      if (isSecurityEnabled) {
        if (!fs.mkdirs(tmpdir, secureRootSubDirPerms)) {
          throw new IOException("HBase temp directory '" + tmpdir + "' creation failure.");
        }
      } else {
        if (!fs.mkdirs(tmpdir)) {
          throw new IOException("HBase temp directory '" + tmpdir + "' creation failure.");
        }
      }
    }
  }
Make sure the hbase temp directory exists and is empty. NOTE that this method is only executed
once just after the master becomes the active one.
hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterFileSystem.java