Search in sources :

Example 46 with CmdLineParser

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

the class Join method main.

public static void main(String[] args) throws Exception {
    Options options = new Options();
    CmdLineParser parser = new CmdLineParser(options);
    if (args.length == 0) {
        parser.printUsage(System.err);
        return;
    }
    parser.parseArgument(args);
    IHyracksClientConnection hcc = new HyracksConnection(options.host, options.port);
    JobSpecification job = createJob(parseFileSplits(options.inFileCustomerSplits), parseFileSplits(options.inFileOrderSplits), parseFileSplits(options.outFileSplits), options.numJoinPartitions, options.algo, options.graceInputSize, options.graceRecordsPerFrame, options.graceFactor, options.memSize, options.tableSize, options.hasGroupBy, options.frameSize);
    if (job == null) {
        return;
    }
    long start = System.currentTimeMillis();
    JobId jobId = hcc.startJob(job, options.profile ? EnumSet.of(JobFlag.PROFILE_RUNTIME) : EnumSet.noneOf(JobFlag.class));
    hcc.waitForCompletion(jobId);
    long end = System.currentTimeMillis();
    System.err.println(start + " " + end + " " + (end - start));
}
Also used : IHyracksClientConnection(org.apache.hyracks.api.client.IHyracksClientConnection) CmdLineParser(org.kohsuke.args4j.CmdLineParser) JobSpecification(org.apache.hyracks.api.job.JobSpecification) HyracksConnection(org.apache.hyracks.api.client.HyracksConnection) JobId(org.apache.hyracks.api.job.JobId)

Example 47 with CmdLineParser

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

the class WordCountMain method main.

public static void main(String[] args) throws Exception {
    Options options = new Options();
    CmdLineParser parser = new CmdLineParser(options);
    parser.parseArgument(args);
    IHyracksClientConnection hcc = new HyracksConnection(options.host, options.port);
    JobSpecification job = createJob(parseFileSplits(options.inFileSplits), parseFileSplits(options.outFileSplits), options.algo, options.htSize, options.memFrameLimit, options.format, options.frameSize);
    long start = System.currentTimeMillis();
    JobId jobId = hcc.startJob(job, options.runtimeProfiling ? EnumSet.of(JobFlag.PROFILE_RUNTIME) : EnumSet.noneOf(JobFlag.class));
    hcc.waitForCompletion(jobId);
    long end = System.currentTimeMillis();
    System.err.println(start + " " + end + " " + (end - start));
}
Also used : IHyracksClientConnection(org.apache.hyracks.api.client.IHyracksClientConnection) CmdLineParser(org.kohsuke.args4j.CmdLineParser) JobSpecification(org.apache.hyracks.api.job.JobSpecification) HyracksConnection(org.apache.hyracks.api.client.HyracksConnection) JobId(org.apache.hyracks.api.job.JobId)

Example 48 with CmdLineParser

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

the class NCService method main.

public static void main(String[] args) throws Exception {
    // Register a shutdown hook which will kill the NC if the NC Service is killed.
    Runtime.getRuntime().addShutdownHook(new Thread() {

        @Override
        public void run() {
            if (proc != null) {
                proc.destroy();
            }
        }
    });
    config = new NCServiceConfig();
    CmdLineParser cp = new CmdLineParser(config);
    try {
        cp.parseArgument(args);
    } catch (Exception e) {
        e.printStackTrace();
        cp.printUsage(System.err);
        System.exit(1);
    }
    config.loadConfigAndApplyDefaults();
    // Initializes the oxMXBean.
    osMXBean = ManagementFactory.getOperatingSystemMXBean();
    // For now we implement a trivial listener which just
    // accepts an IP/port combination from the CC. This could
    // be made more advanced in several ways depending on whether
    // we want to expand the functionality of this service.
    // For now this gets the job done, without radically changing
    // the NC itself so that Managix can continue to function.
    InetAddress addr = config.address == null ? null : InetAddress.getByName(config.address);
    int port = config.port;
    // when the child NC terminates for any reason.
    while (true) {
        try (ServerSocket listener = new ServerSocket(port, 5, addr)) {
            boolean launched = false;
            while (!launched) {
                LOGGER.info("Waiting for connection from CC on " + (addr == null ? "*" : addr) + ":" + port);
                try (Socket socket = listener.accept()) {
                    // QQQ Because acceptConnection() doesn't return if the
                    // service is started appropriately, the socket remains
                    // open but non-responsive.
                    launched = acceptConnection(socket.getInputStream());
                }
            }
        }
    }
}
Also used : CmdLineParser(org.kohsuke.args4j.CmdLineParser) ServerSocket(java.net.ServerSocket) InetAddress(java.net.InetAddress) IOException(java.io.IOException) Socket(java.net.Socket) ServerSocket(java.net.ServerSocket)

Example 49 with CmdLineParser

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

the class EventDriver method main.

public static void main(String[] args) throws Exception {
    String eventsHome = System.getenv("EVENT_HOME");
    if (eventsHome == null) {
        throw new IllegalStateException("EVENT_HOME is not set");
    }
    eventsDir = eventsHome + File.separator + EventUtil.EVENTS_DIR;
    EventConfig eventConfig = new EventConfig();
    CmdLineParser parser = new CmdLineParser(eventConfig);
    try {
        parser.parseArgument(args);
        if (eventConfig.help) {
            parser.printUsage(System.out);
        }
        if (eventConfig.seed > 0) {
            Randomizer.getInstance(eventConfig.seed);
        }
        Cluster cluster = initializeCluster(eventConfig.clusterPath);
        if (!eventConfig.dryRun) {
            prepare(cluster);
        }
        if (!eventConfig.dryRun) {
            cleanup(cluster);
        }
    } catch (Exception e) {
        e.printStackTrace();
        parser.printUsage(System.err);
    }
}
Also used : CmdLineParser(org.kohsuke.args4j.CmdLineParser) Cluster(org.apache.asterix.event.schema.cluster.Cluster) IOException(java.io.IOException) JAXBException(javax.xml.bind.JAXBException)

Example 50 with CmdLineParser

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

the class AbstractCommand method execute.

public void execute(String[] args) throws Exception {
    String[] cmdArgs = new String[args.length - 1];
    System.arraycopy(args, 1, cmdArgs, 0, cmdArgs.length);
    config = getCommandConfig();
    CmdLineParser parser = new CmdLineParser(config);
    parser.parseArgument(cmdArgs);
    execCommand();
}
Also used : CmdLineParser(org.kohsuke.args4j.CmdLineParser)

Aggregations

CmdLineParser (org.kohsuke.args4j.CmdLineParser)119 CmdLineException (org.kohsuke.args4j.CmdLineException)80 File (java.io.File)16 Test (org.junit.Test)14 IOException (java.io.IOException)11 HyracksConnection (org.apache.hyracks.api.client.HyracksConnection)10 IHyracksClientConnection (org.apache.hyracks.api.client.IHyracksClientConnection)10 ArrayList (java.util.ArrayList)9 JobId (org.apache.hyracks.api.job.JobId)9 JobSpecification (org.apache.hyracks.api.job.JobSpecification)9 PrintStream (java.io.PrintStream)6 FileOutputStream (java.io.FileOutputStream)4 List (java.util.List)4 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 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2