/**
 *
 */
package org.jmist.framework.services;

import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.util.UUID;

import org.jmist.framework.IJob;
import org.jmist.framework.IParallelizableJob;
import org.jmist.framework.IProgressMonitor;

/**
 * @author bkimmel
 *
 */
public final class ServiceSubmitJob implements IJob {

	/* (non-Javadoc)
	 * @see org.jmist.framework.IJob#go(org.jmist.framework.IProgressMonitor)
	 */
	@Override
	public void go(IProgressMonitor monitor) {

		try {

			monitor.notifyStatusChanged("Submitting job...");

			Registry registry = LocateRegistry.getRegistry(this.masterHost);
			IJobMasterService service = (IJobMasterService) registry.lookup("IJobMasterService");
			UUID jobId = service.submitJob(this.job, this.priority);

			if (jobId.compareTo(new UUID(0, 0)) != 0) {

				monitor.notifyStatusChanged(String.format("Submitted, ID=%s.", jobId.toString()));
				monitor.notifyComplete();

			} else {

				monitor.notifyStatusChanged("Failed to submit job.");
				monitor.notifyCancelled();

			}

		} catch (Exception e) {

			System.err.println("Client exception: " + e.toString());
			e.printStackTrace();

		}

	}

	private String masterHost;
	private IParallelizableJob job;
	private int priority;

}

@@ -1176,16 +1176,137 @@
 ace();%0A%0A
+%09%09%09monitor.notifyStatusChanged(String.format(%22Failed to submit job: %25s.%22, e.toString()));%0A%09%09%09monitor.notifyCancelled();%0A%0A
 %09%09%7D%0A%0A%09%7D%0A

Update progress monitor when exception raised during ServiceSubmitJob.