Search in sources :

Example 31 with CmdLineParser

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

the class Groupby 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;
    long start = System.currentTimeMillis();
    job = createJob(parseFileSplits(options.inFileSplits), parseFileSplits(options.outFileSplits), options.htSize, options.fileSize, options.frameLimit, options.frameSize, options.algo, options.outPlain);
    if (job != null) {
        System.out.print("CreateJobTime:" + (System.currentTimeMillis() - start));
        start = System.currentTimeMillis();
        JobId jobId = hcc.startJob(job);
        hcc.waitForCompletion(jobId);
        System.out.println("JobExecuteTime:" + (System.currentTimeMillis() - 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 32 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 33 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 34 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 35 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)

Aggregations

CmdLineParser (org.kohsuke.args4j.CmdLineParser)208 CmdLineException (org.kohsuke.args4j.CmdLineException)165 IOException (java.io.IOException)45 File (java.io.File)27 Test (org.junit.Test)14 KeeperException (org.apache.zookeeper.KeeperException)12 ArrayList (java.util.ArrayList)11 HyracksConnection (org.apache.hyracks.api.client.HyracksConnection)10 IHyracksClientConnection (org.apache.hyracks.api.client.IHyracksClientConnection)10 Directory (org.apache.lucene.store.Directory)10 FSDirectory (org.apache.lucene.store.FSDirectory)10 JobId (org.apache.hyracks.api.job.JobId)9 JobSpecification (org.apache.hyracks.api.job.JobSpecification)9 ClientException (com.ms.silverking.cloud.dht.client.ClientException)8 PutException (com.ms.silverking.cloud.dht.client.PutException)8 SKGridConfiguration (com.ms.silverking.cloud.dht.gridconfig.SKGridConfiguration)8 PrintStream (java.io.PrintStream)8 List (java.util.List)8 RetrievalException (com.ms.silverking.cloud.dht.client.RetrievalException)7 IndexArgs (io.anserini.index.IndexArgs)7