Search in sources :

Example 36 with CmdLineException

use of org.kohsuke.args4j.CmdLineException in project gerrit by GerritCodeReview.

the class ChangeIdHandler method parseArguments.

@Override
public final int parseArguments(final Parameters params) throws CmdLineException {
    final String token = params.getParameter(0);
    final String[] tokens = token.split(",");
    if (tokens.length != 3) {
        throw new CmdLineException(owner, "change should be specified as <project>,<branch>,<change-id>");
    }
    try {
        final Change.Key key = Change.Key.parse(tokens[2]);
        final Project.NameKey project = new Project.NameKey(tokens[0]);
        final Branch.NameKey branch = new Branch.NameKey(project, tokens[1]);
        for (final ChangeData cd : queryProvider.get().byBranchKey(branch, key)) {
            setter.addValue(cd.getId());
            return 1;
        }
    } catch (IllegalArgumentException e) {
        throw new CmdLineException(owner, "Change-Id is not valid");
    } catch (OrmException e) {
        throw new CmdLineException(owner, "Database error: " + e.getMessage());
    }
    throw new CmdLineException(owner, "\"" + token + "\": change not found");
}
Also used : Change(com.google.gerrit.reviewdb.client.Change) ChangeData(com.google.gerrit.server.query.change.ChangeData) Project(com.google.gerrit.reviewdb.client.Project) OrmException(com.google.gwtorm.server.OrmException) Branch(com.google.gerrit.reviewdb.client.Branch) CmdLineException(org.kohsuke.args4j.CmdLineException)

Example 37 with CmdLineException

use of org.kohsuke.args4j.CmdLineException in project gerrit by GerritCodeReview.

the class PatchSetIdHandler method parseArguments.

@Override
public final int parseArguments(final Parameters params) throws CmdLineException {
    final String token = params.getParameter(0);
    final PatchSet.Id id;
    try {
        id = PatchSet.Id.parse(token);
    } catch (IllegalArgumentException e) {
        throw new CmdLineException(owner, "\"" + token + "\" is not a valid patch set");
    }
    setter.addValue(id);
    return 1;
}
Also used : PatchSet(com.google.gerrit.reviewdb.client.PatchSet) CmdLineException(org.kohsuke.args4j.CmdLineException)

Example 38 with CmdLineException

use of org.kohsuke.args4j.CmdLineException in project asterixdb by apache.

the class CCDriver method main.

public static void main(String[] args) throws Exception {
    try {
        final ConfigManager configManager = new ConfigManager(args);
        ICCApplication application = getApplication(args);
        application.registerConfig(configManager);
        CCConfig ccConfig = new CCConfig(configManager);
        ClusterControllerService ccService = new ClusterControllerService(ccConfig, application);
        ccService.start();
        while (true) {
            Thread.sleep(100000);
        }
    } catch (CmdLineException e) {
        LOGGER.log(Level.FINE, "Exception parsing command line: " + Arrays.toString(args), e);
        System.exit(2);
    } catch (Exception e) {
        LOGGER.log(Level.SEVERE, "Exiting CCDriver due to exception", e);
        System.exit(1);
    }
}
Also used : ICCApplication(org.apache.hyracks.api.application.ICCApplication) CCConfig(org.apache.hyracks.control.common.controllers.CCConfig) ConfigManager(org.apache.hyracks.control.common.config.ConfigManager) CmdLineException(org.kohsuke.args4j.CmdLineException) CmdLineException(org.kohsuke.args4j.CmdLineException) IOException(java.io.IOException)

Example 39 with CmdLineException

use of org.kohsuke.args4j.CmdLineException in project asterixdb by apache.

the class LSMExperimentSetRunner method main.

public static void main(String[] args) throws Exception {
    //        LogManager.getRootLogger().setLevel(org.apache.log4j.Level.OFF);
    LSMExperimentSetRunnerConfig config = new LSMExperimentSetRunnerConfig(String.valueOf(System.currentTimeMillis()), 3);
    CmdLineParser clp = new CmdLineParser(config);
    try {
        clp.parseArgument(args);
    } catch (CmdLineException e) {
        System.err.println(e.getMessage());
        clp.printUsage(System.err);
        System.exit(1);
    }
    Collection<AbstractExperimentBuilder> suite = new ArrayList<>();
    /*
                suite.add(new Experiment7BBuilder(config));
                suite.add(new Experiment7DBuilder(config));
                suite.add(new Experiment7ABuilder(config));
                suite.add(new Experiment8DBuilder(config));
                suite.add(new Experiment8ABuilder(config));
                suite.add(new Experiment8BBuilder(config));
                suite.add(new Experiment9ABuilder(config));
                suite.add(new Experiment9DBuilder(config));
                suite.add(new Experiment9BBuilder(config));
                suite.add(new Experiment6ABuilder(config));
                suite.add(new Experiment6BBuilder(config));
                suite.add(new Experiment6CBuilder(config));
                suite.add(new Experiment2D1Builder(config));
                suite.add(new Experiment2D2Builder(config));
                suite.add(new Experiment2D4Builder(config));
                suite.add(new Experiment2D8Builder(config));
                suite.add(new Experiment2C1Builder(config));
                suite.add(new Experiment2C2Builder(config));
                suite.add(new Experiment2C4Builder(config));
                suite.add(new Experiment2C8Builder(config));
                suite.add(new Experiment2A1Builder(config));
                suite.add(new Experiment2A2Builder(config));
                suite.add(new Experiment2A4Builder(config));
                suite.add(new Experiment2A8Builder(config));
                suite.add(new Experiment2B1Builder(config));
                suite.add(new Experiment2B2Builder(config));
                suite.add(new Experiment2B4Builder(config));
                suite.add(new Experiment2B8Builder(config));
                suite.add(new Experiment1ABuilder(config));
                suite.add(new Experiment1BBuilder(config));
                suite.add(new Experiment1CBuilder(config));
                suite.add(new Experiment1DBuilder(config));
                suite.add(new Experiment1EBuilder(config));
                suite.add(new Experiment4ABuilder(config));
                suite.add(new Experiment4BBuilder(config));
                suite.add(new Experiment4CBuilder(config));
                suite.add(new Experiment4DBuilder(config));
                suite.add(new Experiment3ABuilder(config));
                suite.add(new Experiment3BBuilder(config));
                suite.add(new Experiment3CBuilder(config));
                suite.add(new Experiment3DBuilder(config));
                suite.add(new Experiment5ABuilder(config));
                suite.add(new Experiment5BBuilder(config));
                suite.add(new Experiment5CBuilder(config));
                suite.add(new Experiment5DBuilder(config));
        */
    suite.add(new PerfTestAggBuilder(config));
    suite.add(new PresetClusterPerfBuilder(config));
    Pattern p = config.getRegex() == null ? null : Pattern.compile(config.getRegex());
    SequentialActionList exps = new SequentialActionList();
    for (AbstractExperimentBuilder eb : suite) {
        if (p == null || p.matcher(eb.getName()).matches()) {
            exps.add(eb.build());
            if (LOGGER.isLoggable(Level.INFO)) {
                LOGGER.info("Added " + eb.getName() + " to run list...");
            }
        }
    }
    exps.perform();
}
Also used : Pattern(java.util.regex.Pattern) AbstractExperimentBuilder(org.apache.asterix.experiment.builder.AbstractExperimentBuilder) PerfTestAggBuilder(org.apache.asterix.experiment.builder.PerfTestAggBuilder) CmdLineParser(org.kohsuke.args4j.CmdLineParser) SequentialActionList(org.apache.asterix.experiment.action.base.SequentialActionList) ArrayList(java.util.ArrayList) CmdLineException(org.kohsuke.args4j.CmdLineException) PresetClusterPerfBuilder(org.apache.asterix.experiment.builder.PresetClusterPerfBuilder)

Example 40 with CmdLineException

use of org.kohsuke.args4j.CmdLineException in project asterixdb by apache.

the class SocketTweetGeneratorDriver method main.

public static void main(String[] args) throws Exception {
    SocketTweetGeneratorConfig clientConfig = new SocketTweetGeneratorConfig();
    CmdLineParser clp = new CmdLineParser(clientConfig);
    try {
        clp.parseArgument(args);
    } catch (CmdLineException e) {
        System.err.println(e.getMessage());
        clp.printUsage(System.err);
        System.exit(1);
    }
    if ((clientConfig.getDataInterval() == -1 && clientConfig.getDataGenDuration() == -1) || (clientConfig.getDataInterval() > 0 && clientConfig.getDataGenDuration() > 0)) {
        System.err.println("Must use exactly one of -d or -di");
        clp.printUsage(System.err);
        System.exit(1);
    }
    SocketTweetGenerator client = new SocketTweetGenerator(clientConfig);
    client.start();
}
Also used : CmdLineParser(org.kohsuke.args4j.CmdLineParser) CmdLineException(org.kohsuke.args4j.CmdLineException)

Aggregations

CmdLineException (org.kohsuke.args4j.CmdLineException)105 CmdLineParser (org.kohsuke.args4j.CmdLineParser)80 IOException (java.io.IOException)16 File (java.io.File)14 ArrayList (java.util.ArrayList)11 PrintStream (java.io.PrintStream)7 StringWriter (java.io.StringWriter)6 List (java.util.List)5 FileOutputStream (java.io.FileOutputStream)4 Path (java.nio.file.Path)4 CmdLineParser (com.google.gerrit.util.cli.CmdLineParser)3 FeatureExtractors (io.anserini.ltr.feature.FeatureExtractors)3 Qrels (io.anserini.util.Qrels)3 Directory (org.apache.lucene.store.Directory)3 FSDirectory (org.apache.lucene.store.FSDirectory)3 ConsoleReporter (com.codahale.metrics.ConsoleReporter)2 MetricRegistry (com.codahale.metrics.MetricRegistry)2 Project (com.google.gerrit.reviewdb.client.Project)2 OrmException (com.google.gwtorm.server.OrmException)2 Hudson (hudson.model.Hudson)2