Esempio n. 1
0
 /**
  * Creates an executor that queues the passed tasks for execution by one single additional thread.
  * The executor will start to block further executions as soon as more than the configured write
  * tasks are waiting for execution.
  */
 private static ExecutorService newAsyncWriteExecutor() {
   return new ThreadPoolExecutor(
       CORE_POOL_SIZE,
       MAXIMUM_POOL_SIZE,
       KEEP_ALIVE_TIME,
       TimeUnit.SECONDS,
       new LinkedBlockingQueue<Runnable>(
           ScenarioDocuGeneratorConfiguration.INSTANCE.getAsyncWriteBufferSize()));
 }
Esempio n. 2
0
 @Override
 public void flush() {
   final int timeoutInSeconds =
       ScenarioDocuGeneratorConfiguration.INSTANCE.getTimeoutWaitingForWritingFinishedInSeconds();
   asyncWriteExecutor.shutdown();
   try {
     final boolean terminated =
         asyncWriteExecutor.awaitTermination(timeoutInSeconds, TimeUnit.SECONDS);
     if (!terminated) {
       asyncWriteExecutor.shutdownNow();
       throw new ScenarioDocuTimeoutException(
           "Timeout occured while waiting for diff files to be written. Writing of files took too long.");
     }
   } catch (final InterruptedException e) {
     throw new RuntimeException("Async writing of scenarioo docu files was interrupted", e);
   }
   if (!caughtExceptions.isEmpty()) {
     throw new ScenarioDocuSaveException(caughtExceptions);
   }
 }