• Views
  • Iteration Report
  • My Iteration Report
  •  
OMERO.server
  • Login
  • Help/Guide
  • About Trac
  • Preferences
  • Wiki
  • Timeline
  • Roadmap
  • Browse Source
  • View Tickets
  • Search

Context Navigation

  • Last Change
  • Annotate
  • Revision Log

root/trunk/components/common/src/ome/api/JobHandle.java

Revision 2383, 2.8 kB (checked in by jmoore, 8 months ago)

JobHandle : revamped code for saving jobs (ticket:942)

  • Made Executor an interface, tests use new Executor.Impl()
  • Passing executor to ProcessManager
  • Renamed the JobDetails based on Threads to *-run
  • Simplifed calling of ProcessManager
    • Removed startProcess(id); just use run()
  • Improved ManagedContextFixture as replacement for AbstractManagedContextTest
Line 
1/*
2 *   $Id$
3 *
4 *   Copyright 2007 Glencoe Software, Inc. All rights reserved.
5 *   Use is subject to license terms supplied in LICENSE.txt
6 */
7package ome.api;
8
9import java.sql.Timestamp;
10
11import ome.annotations.NotNull;
12import ome.conditions.ApiUsageException;
13import ome.model.jobs.Job;
14import ome.model.jobs.JobStatus;
15
16/**
17 * Allows submission of asynchronous jobs.
18 * <p>
19 * NOTE: The calling order for the service is as follows:
20 * <ol>
21 * <li>submit({@link Job}) <em>or</em> attach(long)</li>
22 * <li>any of the other methods</li>
23 * <li>close()</li>
24 * </ol>
25 * </p>
26 * Calling <code>close()</code> does not cancel or otherwise change the Job
27 * state. See {@link #cancelJob()}.
28 *
29 * @author Josh Moore, josh at glencoesoftware.com
30 * @since 3.0-Beta2
31 */
32public interface JobHandle extends StatefulServiceInterface {
33
34    public final static String SUBMITTED = "Submitted";
35    public final static String RESUBMITTED = "Resubmitted";
36    public final static String QUEUED = "Queued";
37    public final static String REQUEUED = "Requeued";
38    public final static String RUNNING = "Running";
39    public final static String ERROR = "Error";
40    public final static String WAITING = "Waiting";
41    public final static String FINISHED = "Finished";
42    public final static String CANCELLED = "Cancelled";
43
44    /**
45     * Submits a {@link Job} and returns its database id. The only fields
46     * directly on status which are editable are <em>message</em>,
47     * <em>scheduledFor</em> and <em>status</em>. The latter two must be
48     * sensible.
49     *
50     * @param job
51     *            Not null
52     * @return id
53     */
54    long submit(@NotNull
55    Job job);
56
57    /**
58     * @return the current {@link JobStatus} for the {@link Job id}
59     * @throws ApiUsageException
60     *             if the {@link Job id} does not exist.
61     */
62    JobStatus attach(long jobId) throws ApiUsageException;
63
64    /**
65     * @return the current {@link Job}
66     */
67    Job getJob();
68
69    /**
70     * @return the current {@link JobStatus}. Will never return null.
71     */
72    JobStatus jobStatus();
73
74    /**
75     * @return null if the {@link Job} is not finished, otherwise the
76     *         {@link Timestamp} for when it completed.
77     */
78    Timestamp jobFinished();
79
80    /**
81     * @return current message for job. May be set during processing.
82     */
83    String jobMessage();
84
85    /**
86     * Returns true if the {@link Job} is running, i.e. has an attached
87     * {@link Process}.
88     */
89    boolean jobRunning();
90
91    /**
92     * Returns true if the {@link Job} has thrown an error.
93     */
94    boolean jobError();
95
96    /**
97     * Marks a job for cancellation. Not every processor will check for the
98     * cancelled flag for a running job, but no non-running job will start if it
99     * has been cancelled.
100     */
101    void cancelJob();
102
103}
Note: See TracBrowser for help on using the browser.

Download in other formats:

  • Plain Text
  • Original Format

Trac Powered

Powered by Trac 0.11
By Edgewall Software.

Visit the Trac open source project at
http://trac.edgewall.org/