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

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

Introduction

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

Prototype

boolean assertsOn

To view the source code for org.apache.lucene.index CheckIndex assertsOn.

Click Source Link

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  w  w  w.ja  v  a 2  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);
    }
}