private void checkRootDir(final Path rd, final Configuration c, final FileSystem fs)
    throws IOException {
    int threadWakeFrequency = c.getInt(HConstants.THREAD_WAKE_FREQUENCY, 10 * 1000);
    // If FS is in safe mode wait till out of it.
    FSUtils.waitOnSafeMode(c, threadWakeFrequency);

    // Filesystem is good. Go ahead and check for hbase.rootdir.
    FileStatus status;
    try {
      status = fs.getFileStatus(rd);
    } catch (FileNotFoundException e) {
      status = null;
    }
    int versionFileWriteAttempts = c.getInt(HConstants.VERSION_FILE_WRITE_ATTEMPTS,
      HConstants.DEFAULT_VERSION_FILE_WRITE_ATTEMPTS);
    try {
      if (status == null) {
        if (!fs.mkdirs(rd)) {
          throw new IOException("Can not create configured '" + HConstants.HBASE_DIR + "' " + rd);
        }
        // DFS leaves safe mode with 0 DNs when there are 0 blocks.
        // We used to handle this by checking the current DN count and waiting until
        // it is nonzero. With security, the check for datanode count doesn't work --
        // it is a privileged op. So instead we adopt the strategy of the jobtracker
        // and simply retry file creation during bootstrap indefinitely. As soon as
        // there is one datanode it will succeed. Permission problems should have
        // already been caught by mkdirs above.
        FSUtils.setVersion(fs, rd, threadWakeFrequency, versionFileWriteAttempts);
      } else {
        if (!status.isDirectory()) {
          throw new IllegalArgumentException(
            "Configured '" + HConstants.HBASE_DIR + "' " + rd + " is not a directory.");
        }
        // as above
        FSUtils.checkVersion(fs, rd, true, threadWakeFrequency, versionFileWriteAttempts);
      }
    } catch (DeserializationException de) {
      LOG.error(HBaseMarkers.FATAL, "Please fix invalid configuration for '{}' {}",
        HConstants.HBASE_DIR, rd, de);
      throw new IOException(de);
    } catch (IllegalArgumentException iae) {
      LOG.error(HBaseMarkers.FATAL, "Please fix invalid configuration for '{}' {}",
        HConstants.HBASE_DIR, rd, iae);
      throw iae;
    }
    // Make sure cluster ID exists
    if (!FSUtils.checkClusterIdExists(fs, rd, threadWakeFrequency)) {
      FSUtils.setClusterId(fs, rd, new ClusterId(), threadWakeFrequency);
    }
    clusterId = FSUtils.getClusterId(fs, rd);
  }
Get the rootdir. Make sure its wholesome and exists before returning.
@return hbase.rootdir (after checks for existence and bootstrapping if needed populating the
        directory with necessary bootup files).
hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterFileSystem.java