/** * Processes a given Processing through the CallStack of this executor. Note that if a DocumentProcessor * returns a LaterProgress for this processing, it will be re-processed (after waiting the specified delay given * by the LaterProgress), until done or failed. * * @param processing the Processing to process. The CallStack of the Processing will be set to a clone of the CallStack of this executor, iff. it is currently null. * @return a Progress; this is never a LaterProgress. * @throws RuntimeException if a document processor throws an exception during processing, or this thread is interrupted while waiting. * @see com.yahoo.docproc.Processing * @see com.yahoo.docproc.DocumentProcessor.Progress * @see com.yahoo.docproc.DocumentProcessor.LaterProgress */ public DocumentProcessor.Progress processUntilDone(Processing processing) { DocumentProcessor.Progress progress; while (true) { progress = process(processing); if (!(progress instanceof DocumentProcessor.LaterProgress)) { break; } DocumentProcessor.LaterProgress later = (DocumentProcessor.LaterProgress) progress; try { Thread.sleep(later.getDelay()); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new RuntimeException(e); } } return progress; } }
/** * Processes the given Processing through the specified chain. Note that if one * {@link com.yahoo.docproc.DocumentProcessor DocumentProcessor} in the * chain returns a {@link com.yahoo.docproc.DocumentProcessor.LaterProgress DocumentProcessor.LaterProgress}, * it will be returned by this method. This method will hence return whenever a document processor returns any * {@link com.yahoo.docproc.DocumentProcessor.Progress DocumentProcessor.Progress}, or * throws an exception. * * @param chain the specification of the chain to execute * @param processing the Processing to process * @return any Progress * @throws RuntimeException if one of the document processors in the chain throws */ public DocumentProcessor.Progress processOnce(ComponentSpecification chain, com.yahoo.docproc.Processing processing) { DocprocExecutor executor = getExecutor(chain); processing.setDocprocServiceRegistry(handler.getDocprocServiceRegistry()); return executor.process(processing); }
progress = executor.process(processing); } catch (Exception e) { logProcessingFailure(processing, e);
progress = ex.process(processing); } catch (Exception e) { processingFailed(processing, processing + " failed", e);