Example usage for org.apache.lucene.index CheckIndex parseOptions

List of usage examples for org.apache.lucene.index CheckIndex parseOptions

Introduction

In this page you can find the example usage for org.apache.lucene.index CheckIndex parseOptions.

Prototype

@SuppressForbidden(reason = "System.err required: command line tool")
public static Options parseOptions(String[] args) 

Source Link

Document

Parse command line args into fields

Usage

From source file:org.apache.solr.index.hdfs.CheckHdfsIndex.java

License:Apache License

@SuppressForbidden(reason = "System.out required: command line tool")
protected static int doMain(String[] args) throws IOException, InterruptedException {
    CheckIndex.Options opts;/*from   www  .  j av a2  s  .co m*/
    try {
        opts = CheckIndex.parseOptions(args);
    } catch (IllegalArgumentException e) {
        System.out.println(e.getMessage());
        return 1;
    }

    if (!CheckIndex.assertsOn()) {
        System.out.println(
                "\nNOTE: testing will be more thorough if you run java with '-ea:org.apache.lucene...', so assertions are enabled");
    }

    if (opts.getDirImpl() != null) {
        System.out.println(
                "\nIgnoring specified -dir-impl, instead using " + HdfsDirectory.class.getSimpleName());
    }

    System.out.println("\nOpening index @ " + opts.getIndexPath() + "\n");

    Directory directory;
    try {
        directory = new HdfsDirectory(new Path(opts.getIndexPath()), getConf());
    } catch (IOException e) {
        System.out.println("ERROR: could not open hdfs directory \"" + opts.getIndexPath() + "\"; exiting");
        e.printStackTrace(System.out);
        return 1;
    }

    try (Directory dir = directory; CheckIndex checker = new CheckIndex(dir)) {
        opts.setOut(System.out);
        return checker.doCheck(opts);
    }
}