/** * Called when the Jiffle task has been completed successfully. * * @param ev the event containing the task results */ private void onCompletion(JiffleEvent ev) { JiffleExecutorResult result = ev.getResult(); RenderedImage img = result.getImages().get("result"); ImageFrame frame = new ImageFrame(img, "Jiffle image demo"); frame.setVisible(true); }
public void run() { try { Future<JiffleExecutorResult> future = completionService.poll(); if (future != null) { JiffleExecutorResult result = future.get(); numTasksRunning-- ; if (result.isCompleted()) { if (LOGGER.isLoggable(Level.INFO)) { LOGGER.log(Level.INFO, TASK_SUCCESS_MSG, result.getTaskID()); } notifySuccess(result); } else { if (LOGGER.isLoggable(Level.INFO)) { LOGGER.log(Level.INFO, TASK_FAILURE_MSG, result.getTaskID()); } notifyFailure(result); } } } catch (Exception ex) { throw new RuntimeException(ex); } }
/** * Called by the system to execute this task on a thread provided by the * {@link JiffleExecutor}. * * @return a result object with references to the {@code Jiffle} object, * the images, and the job completion status */ public JiffleExecutorResult call() { boolean gotEx = false; try { runtime.evaluateAll(progressListener); } catch (Exception ex) { gotEx = true; } completed = !gotEx; return new JiffleExecutorResult(id, runtime, completed); }
@Test public void taskCompletedOnShutdown() throws Exception { System.out.println(" task completed after shutdown request"); WaitingListener listener = new WaitingListener(); executor.addEventListener(listener); listener.setNumTasks(1); executor.submit(new MockJiffleRuntime(100, 5), null); executor.shutdown(); if (!listener.await(2, TimeUnit.SECONDS)) { fail("Listener time-out period elapsed"); } List<JiffleExecutorResult> results = listener.getResults(); assertEquals(1, results.size()); assertTrue(results.get(0).isCompleted()); }
public void run() { try { Future<JiffleExecutorResult> future = completionService.poll(); if (future != null) { JiffleExecutorResult result = future.get(); numTasksRunning-- ; if (result.isCompleted()) { if (LOGGER.isLoggable(Level.INFO)) { LOGGER.log(Level.INFO, TASK_SUCCESS_MSG, result.getTaskID()); } notifySuccess(result); } else { if (LOGGER.isLoggable(Level.INFO)) { LOGGER.log(Level.INFO, TASK_FAILURE_MSG, result.getTaskID()); } notifyFailure(result); } } } catch (Exception ex) { throw new RuntimeException(ex); } }
assertNotNull(result); RenderedImage dest = result.getImages().get("dest"); assertNotNull(dest);
/** * Called by the system to execute this task on a thread provided by the * {@link JiffleExecutor}. * * @return a result object with references to the {@code Jiffle} object, * the images, and the job completion status */ public JiffleExecutorResult call() { boolean gotEx = false; try { runtime.evaluateAll(progressListener); } catch (Exception ex) { gotEx = true; } completed = !gotEx; return new JiffleExecutorResult(id, runtime, completed); }