public static void main(String... args) throws Exception {
    LOGGER.info("DB-PURGE - Starting the database purge process ...");

    CleanupContext cleanupContext = processArguments(args);

    // set up the guice context
    Injector injector = Guice.createInjector(new ControllerModule(), new AuditLoggerModule(), new CleanupModule(), new LdapModule());

    // explicitly starting the persist service
    injector.getInstance(AmbariJpaPersistService.class).start();

    CleanupServiceImpl cleanupService = injector.getInstance(CleanupServiceImpl.class);
    CleanupService.CleanupResult result = cleanupService.cleanup(new TimeBasedCleanupPolicy(cleanupContext.getClusterName(), cleanupContext.getFromDayTimestamp()));

    // explicitly stopping the persist service
    injector.getInstance(AmbariJpaPersistService.class).stop();

    if (result.getErrorCount() > 0) {
      LOGGER.warn("DB-PURGE - completed with error, check Ambari Server log for details ! Number of affected records [{}]", result.getAffectedRows());
      System.exit(2);
    }

    LOGGER.info("DB-PURGE - completed. Number of affected records [{}]", result.getAffectedRows());
  }
Class in charge for driving the cleanup process.
ambari-server/src/main/java/org/apache/ambari/server/cleanup/CleanupDriver.java