| Index: appengine/cmd/dm/enums/execution/state.go
|
| diff --git a/appengine/cmd/dm/enums/execution/state.go b/appengine/cmd/dm/enums/execution/state.go
|
| index e4b00e66313a22185c7f37b6879128e3e440e3a7..be1564f677ff97ddcc4e9599e1272f33aca31d59 100644
|
| --- a/appengine/cmd/dm/enums/execution/state.go
|
| +++ b/appengine/cmd/dm/enums/execution/state.go
|
| @@ -15,26 +15,76 @@ type State int8
|
|
|
| // State values
|
| const (
|
| - UnknownState State = iota
|
| + Unknown State = iota
|
|
|
| + // The execution has been accepted by the distributor, but is not running yet
|
| Scheduled
|
| - Running
|
|
|
| + // The execution is running
|
| + Started
|
| +
|
| + // The execution was unable to be accepted by the distributor
|
| Rejected
|
| +
|
| + // The execution was accepted by the distributor, but couldn't run in time.
|
| + TimedOut
|
| +
|
| + // The execution ran and completed
|
| Finished
|
| - Crashed
|
| +
|
| + // The execution ran, but the distributor claims it did not complete
|
| + Failed
|
| +
|
| + // The distributor claims to not know anything about this execution
|
| + Missing
|
| +
|
| + // Some entity (DM, Human, Distributor) requested that this execution not run.
|
| + Cancelled
|
| )
|
|
|
| // validStateEvolution defines all valid {From -> []To} state transitions. The
|
| // identity transition (X -> X) is implied, as long as X has an entry in this
|
| // mapping.
|
| var validStateEvolution = map[State][]State{
|
| - Scheduled: {Running, Rejected, Crashed, Finished},
|
| - Running: {Crashed, Finished, Rejected},
|
| + Scheduled: {Started, Finished, Missing, Cancelled, TimedOut},
|
| + Started: {Finished, Failed, Missing, Cancelled},
|
| +
|
| + Cancelled: {},
|
| + Finished: {},
|
| + Failed: {},
|
| + Missing: {},
|
| + Rejected: {},
|
| + TimedOut: {},
|
| +}
|
| +
|
| +// FromString returns the State for it's equivalent string representation.
|
| +//
|
| +// All unknown state vals are converted to Unknown.
|
| +func FromString(val string) State {
|
| + switch val {
|
| + case "Scheduled":
|
| + return Scheduled
|
| + case "Started":
|
| + return Started
|
| + case "Rejected":
|
| + return Rejected
|
| + case "TimedOut":
|
| + return TimedOut
|
| + case "Finished":
|
| + return Finished
|
| + case "Failed":
|
| + return Failed
|
| + case "Missing":
|
| + return Missing
|
| + case "Cancelled":
|
| + return Cancelled
|
| + }
|
| + return Unknown
|
| +}
|
|
|
| - Crashed: {},
|
| - Finished: {},
|
| - Rejected: {},
|
| +// IsTerminal returns True if State has no more valid evolutions.
|
| +func (s State) IsTerminal() bool {
|
| + return len(validStateEvolution[s]) == 0
|
| }
|
|
|
| // Evolve attempts to evolve the state of this Attempt. If the state
|
|
|