/** * Applies all modifications to the index in parallel using the workers executor * * @throws ExecutionException * @throws InterruptedException */ private void applyUpdates() throws InterruptedException, ExecutionException { AbstractWorkspaceImpl workspace = resources.getWorkspace(); ErrorContextBuilder errorContextBuilder = new ErrorContextBuilder(); errorContextBuilder.allWorkToBeDone(workList); IndexWriter indexWriter = workspace.getIndexWriter(errorContextBuilder); if (indexWriter == null) { log.cannotOpenIndexWriterCausePreviousError(); return; } boolean taskExecutionSuccessful = true; try { if (workList.size() == 1) { taskExecutionSuccessful = runSingleTask(workList.get(0), indexWriter, errorContextBuilder); } else { taskExecutionSuccessful = runMultipleTasks(indexWriter, errorContextBuilder); } if (!taskExecutionSuccessful) { resources.getErrorHandler().handle(errorContextBuilder.createErrorContext()); } else { workspace.optimizerPhase(); } } finally { workspace.afterTransactionApplied(!taskExecutionSuccessful, false); } }
private void handleException(Exception e) { ErrorContextBuilder builder = new ErrorContextBuilder(); builder.allWorkToBeDone(workList); builder.errorThatOccurred(e); resources.getErrorHandler().handle(builder.createErrorContext()); }