private void executeBean(U bean) throws EventException, InterruptedException { // We record the bean in the status queue if (overrideMap != null && overrideMap.containsKey(bean.getUniqueId())) { U o = overrideMap.remove(bean.getUniqueId()); bean.setStatus(o.getStatus()); } logger.trace("Moving " + bean + " to " + mover.getSubmitQueueName()); mover.submit(bean); // Run the process if (runner == null) { bean.setStatus(Status.FAILED); bean.setMessage("No runner set for consumer " + getName() + ". Nothing run"); status.broadcast(bean); throw new EventException("You must set the runner before executing beans from the queue!"); } if (processes.containsKey(bean.getUniqueId())) { throw new EventException( "The bean with unique id '" + bean.getUniqueId() + "' has already been used. Cannot run the same uuid twice!"); } // We peal off the most recent bean from the submission queue if (bean.getStatus() == Status.REQUEST_TERMINATE) { bean.setStatus(Status.TERMINATED); bean.setMessage("Run aborted before started"); status.broadcast(bean); return; } if (bean.getStatus().isFinal()) return; // This is not the bean you are looking for. IConsumerProcess<U> process = runner.createProcess(bean, status); processes.put(bean.getUniqueId(), new WeakReference<IConsumerProcess<U>>(process)); process.start(); // Depending on the process may run in a separate thread (default is not to) }
private void rerun(StatusBean bean) { try { final DateFormat format = DateFormat.getDateTimeInstance(); boolean ok = MessageDialog.openQuestion( getViewSite().getShell(), "Confirm resubmission " + bean.getName(), "Are you sure you want to rerun " + bean.getName() + " submitted on " + format.format(new Date(bean.getSubmissionTime())) + "?"); if (!ok) return; final StatusBean copy = bean.getClass().newInstance(); copy.merge(bean); copy.setUniqueId(UUID.randomUUID().toString()); copy.setMessage("Rerun of " + bean.getName()); copy.setStatus(org.eclipse.scanning.api.event.status.Status.SUBMITTED); copy.setPercentComplete(0.0); copy.setSubmissionTime(System.currentTimeMillis()); queueConnection.submit(copy, true); reconnect(); } catch (Exception e) { ErrorDialog.openError( getViewSite().getShell(), "Cannot rerun " + bean.getName(), "Cannot rerun " + bean.getName() + "\n\nPlease contact your support representative.", new Status(IStatus.ERROR, "org.eclipse.scanning.event.ui", e.getMessage())); } }