Search in sources :

Example 1 with BatchProcessBuilder

use of org.apache.tika.batch.builders.BatchProcessBuilder in project tika by apache.

the class FSBatchTestBase method getNewBatchRunner.

BatchProcess getNewBatchRunner(String testConfig, Map<String, String> args) throws IOException {
    InputStream is = this.getClass().getResourceAsStream(testConfig);
    BatchProcessBuilder b = new BatchProcessBuilder();
    BatchProcess runner = b.build(is, args);
    IOUtils.closeQuietly(is);
    return runner;
}
Also used : BatchProcessBuilder(org.apache.tika.batch.builders.BatchProcessBuilder) InputStream(java.io.InputStream) BatchProcess(org.apache.tika.batch.BatchProcess)

Example 2 with BatchProcessBuilder

use of org.apache.tika.batch.builders.BatchProcessBuilder in project tika by apache.

the class FSBatchProcessCLI method execute.

private void execute(String[] args) throws Exception {
    CommandLineParser cliParser = new DefaultParser();
    CommandLine line = cliParser.parse(options, args);
    if (line.hasOption("help")) {
        usage();
        System.exit(BatchProcessDriverCLI.PROCESS_NO_RESTART_EXIT_CODE);
    }
    Map<String, String> mapArgs = new HashMap<String, String>();
    for (Option option : line.getOptions()) {
        String v = option.getValue();
        if (v == null || v.equals("")) {
            v = "true";
        }
        mapArgs.put(option.getOpt(), v);
    }
    BatchProcessBuilder b = new BatchProcessBuilder();
    TikaInputStream is = null;
    BatchProcess process = null;
    try {
        is = getConfigInputStream(args, false);
        process = b.build(is, mapArgs);
    } finally {
        IOUtils.closeQuietly(is);
    }
    final Thread mainThread = Thread.currentThread();
    ExecutorService executor = Executors.newSingleThreadExecutor();
    Future<ParallelFileProcessingResult> futureResult = executor.submit(process);
    ParallelFileProcessingResult result = futureResult.get();
    System.out.println(FINISHED_STRING);
    System.out.println("\n");
    System.out.println(result.toString());
    System.exit(result.getExitStatus());
}
Also used : HashMap(java.util.HashMap) BatchProcess(org.apache.tika.batch.BatchProcess) TikaInputStream(org.apache.tika.io.TikaInputStream) CommandLine(org.apache.commons.cli.CommandLine) ParallelFileProcessingResult(org.apache.tika.batch.ParallelFileProcessingResult) BatchProcessBuilder(org.apache.tika.batch.builders.BatchProcessBuilder) ExecutorService(java.util.concurrent.ExecutorService) Option(org.apache.commons.cli.Option) CommandLineParser(org.apache.commons.cli.CommandLineParser) DefaultParser(org.apache.commons.cli.DefaultParser)

Aggregations

BatchProcess (org.apache.tika.batch.BatchProcess)2 BatchProcessBuilder (org.apache.tika.batch.builders.BatchProcessBuilder)2 InputStream (java.io.InputStream)1 HashMap (java.util.HashMap)1 ExecutorService (java.util.concurrent.ExecutorService)1 CommandLine (org.apache.commons.cli.CommandLine)1 CommandLineParser (org.apache.commons.cli.CommandLineParser)1 DefaultParser (org.apache.commons.cli.DefaultParser)1 Option (org.apache.commons.cli.Option)1 ParallelFileProcessingResult (org.apache.tika.batch.ParallelFileProcessingResult)1 TikaInputStream (org.apache.tika.io.TikaInputStream)1