public void checkForFinishNow()

in taverna-server-webapp/src/main/java/org/apache/taverna/server/master/worker/RunDatabase.java [88:122]


	public void checkForFinishNow() {
		/*
		 * Get which runs are actually newly finished; this requires getting the
		 * candidates from the database and *then* doing the expensive requests
		 * to the back end to find out the status.
		 */
		Map<String, RemoteRunDelegate> notifiable = new HashMap<>();
		for (RemoteRunDelegate p : dao.getPotentiallyNotifiable())
			if (p.getStatus() == Status.Finished)
				notifiable.put(p.getId(), p);

		// Check if there's nothing more to do
		if (notifiable.isEmpty())
			return;

		/*
		 * Tell the database about the ones we've got.
		 */
		dao.markFinished(notifiable.keySet());

		/*
		 * Send out the notifications. The notification addresses are stored in
		 * the back-end engine, so this is *another* thing that can take time.
		 */
		for (RemoteRunDelegate rrd : notifiable.values())
			for (Listener l : rrd.getListeners())
				if (l.getName().equals("io")) {
					try {
						notifyFinished(rrd.id, l, rrd);
					} catch (Exception e) {
						log.warn("failed to do notification of completion", e);
					}
					break;
				}
	}