/**
  * Start the ingest procedure.
  *
  * @param iterator the iterator to iterate on
  * @return the pid of the root object, or null of something odd failed
  */
 @Override
 public String ingest(TreeIterator iterator) {
   this.iterator = iterator;
   ForkJoinPool forkJoinPool = new ForkJoinPool(concurrency);
   ForkJoinTask<String> result;
   result = forkJoinPool.submit(this);
   forkJoinPool.shutdown();
   try {
     return result.get();
   } catch (CancellationException | ExecutionException | InterruptedException e) {
     log.warn("Shutting down pool {}", forkJoinPool);
     result.cancel(true);
     forkJoinPool.shutdownNow();
     boolean shutdown;
     try {
       shutdown = forkJoinPool.awaitTermination(3, TimeUnit.MINUTES);
     } catch (InterruptedException e1) {
       shutdown = false;
     }
     if (!shutdown) {
       log.error("Failed to shut down forkjoinpool {}", forkJoinPool);
       System.exit(1);
     }
     log.debug("Pool shot down {}", forkJoinPool);
     throw new IngesterShutdownException(e);
   }
 }
Пример #2
0
 protected void cancelTasks(ForkJoinTask<?>... tasks) {
   for (ForkJoinTask<?> task : tasks) {
     if (task != null) {
       task.cancel(true);
       //				task.completeExceptionally(null);
     }
   }
 }