private boolean writeResultToFile(MsckInfo msckInfo, CheckResult result, List<String> repairOutput,
      long partitionExpirySeconds) {
    boolean success = true;
    try {
      Path resFile = new Path(msckInfo.getResFile());
      FileSystem fs = resFile.getFileSystem(getConf());

      try (BufferedWriter resultOut = new BufferedWriter(new OutputStreamWriter(fs.create(resFile)))) {

        boolean firstWritten = false;
        firstWritten |= writeMsckResult(result.getTablesNotInMs(), TABLES_NOT_IN_METASTORE, resultOut, firstWritten);
        firstWritten |=
            writeMsckResult(result.getTablesNotOnFs(), TABLES_MISSING_ON_FILESYSTEM, resultOut, firstWritten);
        firstWritten |=
            writeMsckResult(result.getPartitionsNotInMs(), PARTITIONS_NOT_IN_METASTORE, resultOut, firstWritten);
        firstWritten |= writeMsckResult(result.getPartitionsNotOnFs(), PARTITIONS_MISSING_FROM_FILESYSTEM, resultOut,
            firstWritten);
        firstWritten |= writeMsckResult(result.getExpiredPartitions(),
            String.format(EXPIRED_PARTITIONS_RETENTION, partitionExpirySeconds), resultOut, firstWritten);

        for (String rout : repairOutput) {
          if (firstWritten) {
            resultOut.write(terminator);
          } else {
            firstWritten = true;
          }
          resultOut.write(rout);
        }
      }
    } catch (IOException e) {
      LOG.error("Failed to save metacheck output: ", e);
      success = false;
    }
    return success;
  }
MetastoreCheck, see if the data in the metastore matches what is on the
dfs. Current version checks for tables and partitions that are either
missing on disk on in the metastore.

@param msckInfo Information about the tables and partitions we want to check for.
@return Returns 0 when execution succeeds and above 0 if it fails.
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/Msck.java