private static CleanupContext processArguments(String... args) {
    CommandLineParser cmdLineParser = new DefaultParser();
    HelpFormatter formatter = new HelpFormatter();
    DateFormat df = new SimpleDateFormat(DATE_PATTERN);
    CleanupContext ctx = null;

    try {
      CommandLine line = cmdLineParser.parse(getOptions(), args);
      String clusterName = (String) line.getParsedOptionValue(CLUSTER_NAME_ARG);
      Date fromDate = df.parse(line.getOptionValue(FROM_DATE_ARG));
      ctx = new CleanupContext(clusterName, fromDate.getTime());
    } catch (Exception exp) {
      System.err.println("Parsing failed.  Reason: " + exp.getMessage());
      LOGGER.error("Parsing failed.  Reason: ", exp);
      formatter.printHelp("db-purge-history", getOptions());
      System.exit(1);
    }
    return ctx;
  }
Class in charge for driving the cleanup process.
ambari-server/src/main/java/org/apache/ambari/server/cleanup/CleanupDriver.java