public static void main(String[] args) throws Exception {
    try {
      // check java version to be higher then 1.6
      String[] splittedJavaVersion = System.getProperty("java.version").split("\\.");
      float javaVersion = Float.parseFloat(splittedJavaVersion[0] + "." + splittedJavaVersion[1]);
      if (javaVersion < Configuration.JDK_MIN_VERSION) {
        LOG.error(String.format("Oracle JDK version is lower than %.1f It can cause problems during upgrade process. Please," +
                " use 'ambari-server setup' command to upgrade JDK!", Configuration.JDK_MIN_VERSION));
        System.exit(1);
      }

      Injector injector = Guice.createInjector(new UpgradeHelperModule(), new AuditLoggerModule(), new LdapModule());

      // Startup the JPA infrastructure, but do not indicate it is initialized since the underlying
      // database schema may not be updated to meet the expectations of the Entity instances.
      GuiceJpaInitializer jpaInitializer = injector.getInstance(GuiceJpaInitializer.class);

      SchemaUpgradeHelper schemaUpgradeHelper = injector.getInstance(SchemaUpgradeHelper.class);

      //Fail if MySQL database has tables with MyISAM engine
      List<String> myISAMTables = schemaUpgradeHelper.getMyISAMTables();
      if (!myISAMTables.isEmpty()) {
        String errorMessage = String.format("Unsupported MyISAM table %s detected. " +
            "For correct upgrade database should be migrated to InnoDB engine.", myISAMTables.get(0));
        LOG.error(errorMessage);
        throw new AmbariException(errorMessage);
      }

      String targetVersion = schemaUpgradeHelper.getAmbariServerVersion();
      LOG.info("Upgrading schema to target version = " + targetVersion);

      UpgradeCatalog targetUpgradeCatalog = AbstractUpgradeCatalog
        .getUpgradeCatalog(targetVersion);

      LOG.debug("Target upgrade catalog. {}", targetUpgradeCatalog);

      // Read source version from DB
      String sourceVersion = schemaUpgradeHelper.readSourceVersion();
      LOG.info("Upgrading schema from source version = " + sourceVersion);

      String minimalRequiredUpgradeVersion = schemaUpgradeHelper.getMinimalUpgradeCatalogVersion();

      if (!schemaUpgradeHelper.verifyUpgradePath(minimalRequiredUpgradeVersion, sourceVersion)){
        throw new AmbariException(String.format("Database version does not meet minimal upgrade requirements. Expected version should be not less than %s, current version is %s",
          minimalRequiredUpgradeVersion, sourceVersion));
      }

      List<UpgradeCatalog> upgradeCatalogs =
        schemaUpgradeHelper.getUpgradePath(sourceVersion, targetVersion);

      String date = new SimpleDateFormat("MM-dd-yyyy_HH:mm:ss").format(new Date());
      String ambariUpgradeConfigUpdatesFileName = "ambari_upgrade_config_changes_" + date + ".json";

      schemaUpgradeHelper.executeUpgrade(upgradeCatalogs);

      // The DDL is expected to be updated, now send the JPA initialized event so Entity
      // implementations can be created.
      jpaInitializer.setInitialized();

      schemaUpgradeHelper.executePreDMLUpdates(upgradeCatalogs);

      schemaUpgradeHelper.executeDMLUpdates(upgradeCatalogs, ambariUpgradeConfigUpdatesFileName);

      schemaUpgradeHelper.executeOnPostUpgrade(upgradeCatalogs);
      schemaUpgradeHelper.outputUpgradeJsonOutput(upgradeCatalogs);

      schemaUpgradeHelper.resetUIState();

      LOG.info("Upgrade successful.");

      schemaUpgradeHelper.cleanUpRCATables();

      schemaUpgradeHelper.stopPersistenceService();

      // Signal all threads that we are ready to exit...
      System.exit(0);
    } catch (Throwable e) {
      if (e instanceof AmbariException) {
        LOG.error("Exception occurred during upgrade, failed", e);
        throw (AmbariException)e;
      }else{
        LOG.error("Unexpected error, upgrade failed", e);
        throw new Exception("Unexpected error, upgrade failed", e);
      }
    }
  }
Upgrade Ambari DB schema to the target version passed in as the only
argument.
@param args args[0] = target version to upgrade to.
ambari-server/src/main/java/org/apache/ambari/server/upgrade/SchemaUpgradeHelper.java