private UpgradePack findServiceUpgradePack(UpgradePack base, File upgradeStackDirectory) {
    if (!upgradeStackDirectory.exists() || !upgradeStackDirectory.isDirectory()) {
      return null;
    }

    File[] upgradeFiles = upgradeStackDirectory.listFiles(StackDirectory.XML_FILENAME_FILTER);
    if (0 == upgradeFiles.length) {
      return null;
    }

    for (File f : upgradeFiles) {
      try {
        UpgradePack upgradePack = unmarshaller.unmarshal(UpgradePack.class, f);

        // !!! if the type is the same and the target is "*", then it's good to merge
        if (upgradePack.isAllTarget() && upgradePack.getType() == base.getType()) {
          return upgradePack;
        }

      } catch (Exception e) {
        LOG.warn("File {} does not appear to be an upgrade pack and will be skipped ({})",
            f.getAbsolutePath(), e.getMessage());
      }
    }

    return null;
  }
Finds an upgrade pack that:
<ul>
  <li>Is found in the $SERVICENAME/upgrades/$STACKNAME folder</li>
  <li>Matches the same {@link UpgradeType} as the {@code base} upgrade pack</li>
  <li>Has the {@link UpgradePack#getTarget()} value equals to "*"</li>
  <li>Has the {@link UpgradePack#getTargetStack()} value equals to "*"</li>
</ul>
This method will not attempt to resolve the "most correct" upgrade pack.  For this
feature to work, there should be only one upgrade pack per type.  If more specificity
is required, then follow the convention of $SERVICENAME/upgrades/$STACKNAME/$STACKVERSION/$BASE_FILE_NAME.xml

@param base the base upgrade pack for a stack
@param upgradeStackDirectory service directory that contains stack upgrade files.
@return an upgrade pack that matches {@code base}
ambari-server/src/main/java/org/apache/ambari/server/stack/StackModule.java