private void validateStackDirectory(File stackRoot) throws AmbariException {
    LOG.info("Validating stack directory {} ...", stackRoot);

    String stackRootAbsPath = stackRoot.getAbsolutePath();
    if (LOG.isDebugEnabled()) {
      LOG.debug("Loading stack information, stackRoot = {}", stackRootAbsPath);
    }

    if (!stackRoot.isDirectory() && !stackRoot.exists()) {
      throw new AmbariException("" + Configuration.METADATA_DIR_PATH
          + " should be a directory with stack"
          + ", stackRoot = " + stackRootAbsPath);
    }
    Validator validator = getPropertySchemaValidator();

    validateAllPropertyXmlsInFolderRecursively(stackRoot, validator);
  }
Validate that the specified stack root is a valid directory.

@param stackRoot  the stack root directory to validate
@throws AmbariException if the specified stack root directory is invalid
ambari-server/src/main/java/org/apache/ambari/server/stack/StackManager.java