| Class | Line # | Actions | |||
|---|---|---|---|---|---|
| JobStatus | 3 | 16 | 12 |
| 1 | package jalview.ws2.api; | |
| 2 | ||
| 3 | public enum JobStatus | |
| 4 | { | |
| 5 | /** Initial status before the job is started. */ | |
| 6 | CREATED, | |
| 7 | /** Job has invalid inputs and cannot be started. */ | |
| 8 | INVALID, | |
| 9 | /** Job is created and ready for submission. */ | |
| 10 | READY, | |
| 11 | /** Job has been submitted and awaits processing. */ | |
| 12 | SUBMITTED, | |
| 13 | /** Job has been queued for execution */ | |
| 14 | QUEUED, | |
| 15 | /** Job is running */ | |
| 16 | RUNNING, | |
| 17 | /** Job has completed successfully. */ | |
| 18 | COMPLETED, | |
| 19 | /** Job has finished with errors. */ | |
| 20 | FAILED, | |
| 21 | /** Job has been cancelled by the user. */ | |
| 22 | CANCELLED, | |
| 23 | /** Job cannot be processed due to server error. */ | |
| 24 | SERVER_ERROR, | |
| 25 | /** Job status cannot be determined. */ | |
| 26 | UNKNOWN; | |
| 27 | ||
| 28 | /** | |
| 29 | * Returns true if the status corresponds to the job completed due to normal | |
| 30 | * termination, error or cancellation. | |
| 31 | * | |
| 32 | * @return {@value true} if status corresponds to a finished job. | |
| 33 | */ | |
| 34 | 0 | public boolean isDone() |
| 35 | { | |
| 36 | 0 | switch (this) |
| 37 | { | |
| 38 | 0 | case INVALID: |
| 39 | 0 | case COMPLETED: |
| 40 | 0 | case FAILED: |
| 41 | 0 | case CANCELLED: |
| 42 | 0 | case SERVER_ERROR: |
| 43 | 0 | return true; |
| 44 | 0 | case CREATED: |
| 45 | 0 | case READY: |
| 46 | 0 | case SUBMITTED: |
| 47 | 0 | case QUEUED: |
| 48 | 0 | case RUNNING: |
| 49 | 0 | case UNKNOWN: |
| 50 | 0 | return false; |
| 51 | 0 | default: |
| 52 | 0 | throw new AssertionError("non-exhaustive switch statement"); |
| 53 | } | |
| 54 | } | |
| 55 | ||
| 56 | /** | |
| 57 | * A precedence order of job statuses used to compute the overall task status. | |
| 58 | */ | |
| 59 | public static final JobStatus[] statusPrecedence = { | |
| 60 | JobStatus.INVALID, // all must be invalid for task to be invalid | |
| 61 | JobStatus.COMPLETED, // all but invalid must be completed for task to be | |
| 62 | // completed | |
| 63 | JobStatus.UNKNOWN, // unknown prevents successful completion but not | |
| 64 | // running or failure | |
| 65 | JobStatus.READY, | |
| 66 | JobStatus.CREATED, | |
| 67 | JobStatus.SUBMITTED, | |
| 68 | JobStatus.QUEUED, | |
| 69 | JobStatus.RUNNING, | |
| 70 | JobStatus.CANCELLED, // if any is terminated unsuccessfully, the task is | |
| 71 | // failed | |
| 72 | JobStatus.FAILED, | |
| 73 | JobStatus.SERVER_ERROR | |
| 74 | }; | |
| 75 | } |