use of org.apache.lucene.util.SuppressForbidden in project lucene-solr by apache.
the class IndexSplitter method main.
@SuppressForbidden(reason = "System.out required: command line tool")
public static void main(String[] args) throws Exception {
if (args.length < 2) {
System.err.println("Usage: IndexSplitter <srcDir> -l (list the segments and their sizes)");
System.err.println("IndexSplitter <srcDir> <destDir> <segments>+");
System.err.println("IndexSplitter <srcDir> -d (delete the following segments)");
return;
}
Path srcDir = Paths.get(args[0]);
IndexSplitter is = new IndexSplitter(srcDir);
if (!Files.exists(srcDir)) {
throw new Exception("srcdir:" + srcDir.toAbsolutePath() + " doesn't exist");
}
if (args[1].equals("-l")) {
is.listSegments();
} else if (args[1].equals("-d")) {
List<String> segs = new ArrayList<>();
for (int x = 2; x < args.length; x++) {
segs.add(args[x]);
}
is.remove(segs.toArray(new String[0]));
} else {
Path targetDir = Paths.get(args[1]);
List<String> segs = new ArrayList<>();
for (int x = 2; x < args.length; x++) {
segs.add(args[x]);
}
is.split(targetDir, segs.toArray(new String[0]));
}
}
use of org.apache.lucene.util.SuppressForbidden in project lucene-solr by apache.
the class TestIndexWriterOnJRECrash method forkTest.
/** fork ourselves in a new jvm. sets -Dtests.crashmode=true */
@SuppressForbidden(reason = "ProcessBuilder requires java.io.File for CWD")
public void forkTest() throws Exception {
List<String> cmd = new ArrayList<>();
cmd.add(Paths.get(System.getProperty("java.home"), "bin", "java").toString());
cmd.add("-Xmx512m");
cmd.add("-Dtests.crashmode=true");
// passing NIGHTLY to this test makes it run for much longer, easier to catch it in the act...
cmd.add("-Dtests.nightly=true");
cmd.add("-DtempDir=" + tempDir);
cmd.add("-Dtests.seed=" + SeedUtils.formatSeed(random().nextLong()));
cmd.add("-ea");
cmd.add("-cp");
cmd.add(System.getProperty("java.class.path"));
cmd.add("org.junit.runner.JUnitCore");
cmd.add(getClass().getName());
ProcessBuilder pb = new ProcessBuilder(cmd).directory(tempDir.toFile()).redirectInput(Redirect.INHERIT).redirectErrorStream(true);
Process p = pb.start();
// We pump everything to stderr.
PrintStream childOut = System.err;
Thread stdoutPumper = ThreadPumper.start(p.getInputStream(), childOut);
if (VERBOSE)
childOut.println(">>> Begin subprocess output");
p.waitFor();
stdoutPumper.join();
if (VERBOSE)
childOut.println("<<< End subprocess output");
}
Aggregations