Search in sources :

Example 1 with FileBasedAuditLogger

use of org.apache.helix.rest.server.auditlog.auditloggers.FileBasedAuditLogger in project helix by apache.

the class HelixRestMain method processCommandLineArgs.

private static void processCommandLineArgs(String[] cliArgs) throws Exception {
    CommandLineParser cliParser = new GnuParser();
    Options cliOptions = constructCommandLineOptions();
    CommandLine cmd = null;
    try {
        cmd = cliParser.parse(cliOptions, cliArgs);
    } catch (ParseException pe) {
        LOG.error("RestAdminApplication: failed to parse command-line options: " + pe.toString());
        printUsage(cliOptions);
        System.exit(1);
    }
    int port = DEFAULT_PORT;
    String zkAddr;
    List<HelixRestNamespace> namespaces = new ArrayList<>();
    if (cmd.hasOption(HELP)) {
        printUsage(cliOptions);
        return;
    } else {
        if (cmd.hasOption(PORT)) {
            port = Integer.parseInt(cmd.getOptionValue(PORT));
        }
        zkAddr = String.valueOf(cmd.getOptionValue(ZKSERVERADDRESS));
        namespaces.add(new HelixRestNamespace(zkAddr));
        if (cmd.hasOption(NAMESPACE_MANIFEST_FILE)) {
            constructNamespaceFromConfigFile(String.valueOf(cmd.getOptionValue(NAMESPACE_MANIFEST_FILE)), namespaces);
        }
    }
    final HelixRestServer restServer = new HelixRestServer(namespaces, port, URI_PREFIX, Arrays.<AuditLogger>asList(new FileBasedAuditLogger()));
    try {
        restServer.start();
        restServer.join();
    } catch (HelixException ex) {
        LOG.error("Failed to start Helix rest server, " + ex);
    } finally {
        restServer.shutdown();
    }
}
Also used : Options(org.apache.commons.cli.Options) FileBasedAuditLogger(org.apache.helix.rest.server.auditlog.auditloggers.FileBasedAuditLogger) GnuParser(org.apache.commons.cli.GnuParser) ArrayList(java.util.ArrayList) HelixException(org.apache.helix.HelixException) CommandLine(org.apache.commons.cli.CommandLine) CommandLineParser(org.apache.commons.cli.CommandLineParser) ParseException(org.apache.commons.cli.ParseException) HelixRestNamespace(org.apache.helix.rest.common.HelixRestNamespace)

Aggregations

ArrayList (java.util.ArrayList)1 CommandLine (org.apache.commons.cli.CommandLine)1 CommandLineParser (org.apache.commons.cli.CommandLineParser)1 GnuParser (org.apache.commons.cli.GnuParser)1 Options (org.apache.commons.cli.Options)1 ParseException (org.apache.commons.cli.ParseException)1 HelixException (org.apache.helix.HelixException)1 HelixRestNamespace (org.apache.helix.rest.common.HelixRestNamespace)1 FileBasedAuditLogger (org.apache.helix.rest.server.auditlog.auditloggers.FileBasedAuditLogger)1