public class Job<T extends Keyed> extends Keyed
Jobs are Keyed
, because they need to Key to control e.g. atomic updates.
Jobs produce a Keyed
result, such as a Frame (from Parsing), or a Model.
NOTE: the Job class is parametrized on the type of its _dest field.
Modifier and Type | Class and Description |
---|---|
static class |
Job.JobCancelledException
Simple named exception class
|
static class |
Job.JobState
Possible job states.
|
static class |
Job.Progress
Helper class to store the job progress in the DKV
|
static class |
Job.ProgressUpdate
Helper class to atomically update the job progress in the DKV
|
static class |
Job.ValidationMessage
The result of an abnormal Model.Parameter check.
|
Keyed.BinarySerializer<X extends Keyed>
Modifier and Type | Field and Description |
---|---|
java.lang.String |
_description
User description
|
Key<T> |
_dest
Jobs produce a single DKV result into Key _dest
|
long |
_end_time
Job end_time using Sys.CTM, or 0 if not ended
|
java.lang.String |
_exception
Any exception thrown by this Job, or null if none
|
Job.ValidationMessage[] |
_messages
A list of field validation issues.
|
protected Key<Job.Progress> |
_progressKey |
long |
_start_time
Job start_time using Sys.CTM
|
Job.JobState |
_state |
static Key<Job> |
LIST
A system key for global list of Job keys.
|
_key, EMPTY_KEY_LIST
Constructor and Description |
---|
Job(Key<T> dest,
java.lang.String desc)
Create a Job
|
Modifier and Type | Method and Description |
---|---|
void |
block()
Blocks for job completion, but do not return anything as the destination object might not yet be finished
|
protected boolean |
canBeDone()
Allow ModelBuilders to override this to conditionally mark the job as finished
|
void |
cancel()
Signal cancellation of this job.
|
void |
cancel(java.lang.String msg)
Signal exceptional cancellation of this job.
|
protected long |
checksum_impl()
Default checksum; not really used by Jobs.
|
void |
clearValidationErrors() |
protected Key |
createProgressKey() |
protected boolean |
deleteProgressKey() |
Key<T> |
dest()
Since _dest is public final, not sure why we have a getter but some
people like 'em.
|
void |
done()
Marks job as finished and records job end time.
|
protected void |
done(boolean force)
Conditionally mark the job as finished and record job end time
|
int |
error_count_or_uninitialized() |
int |
error_count() |
void |
error(java.lang.String field_name,
java.lang.String message) |
void |
failed(java.lang.Throwable ex)
Signal exceptional cancellation of this job.
|
T |
get()
Blocks and get result of this job.
|
void |
hide(java.lang.String field_name,
java.lang.String message) |
void |
info(java.lang.String field_name,
java.lang.String message) |
boolean |
isCancelledOrCrashed()
Returns true if the job was cancelled by the user or crashed.
|
boolean |
isDone()
Returns true if this job is done
|
boolean |
isRunning()
Returns true if this job is running
|
static boolean |
isRunning(Key<Job> job_key)
Check if given job is running.
|
boolean |
isStopped()
Returns true if this job was started and is now stopped
|
Key<Job> |
jobKey() |
static Job[] |
jobs()
The list of all Jobs, past and present.
|
void |
message(Job.ValidationMessage.MessageType message_type,
java.lang.String field_name,
java.lang.String message) |
long |
msec()
Current runtime; zero if not started
|
java.lang.String |
progress_msg()
Returns last progress message.
|
float |
progress()
Returns a float from 0 to 1 representing progress.
|
protected Futures |
remove_impl(Futures fs)
Override to remove subparts, but not self, of composite Keyed objects.
|
protected Job<T> |
start(H2O.H2OCountedCompleter fjtask,
long work,
boolean restartTimer)
Start this task based on given top-level fork-join task representing job computation.
|
void |
update(long newworked)
Report new work done for this job
|
static void |
update(long newworked,
Key<Job> jobkey) |
void |
update(long newworked,
java.lang.String msg) |
static void |
update(long newworked,
java.lang.String msg,
Key<Job> jobkey) |
void |
updateValidationMessages()
init(expensive) is called inside a DTask, not from the http request thread.
|
java.lang.String |
validationErrors()
Get a string representation of only the ERROR ValidationMessages (e.g., to use in an exception throw).
|
void |
warn(java.lang.String field_name,
java.lang.String message) |
checksum, getBinarySerializer, getPublishedKeys, remove, remove, remove, remove
clone, frozenType, read_impl, read, readExternal, readJSON_impl, readJSON, toJsonString, write_impl, write, writeExternal, writeJSON_impl, writeJSON
public Job.ValidationMessage[] _messages
public java.lang.String _description
public long _start_time
public long _end_time
public java.lang.String _exception
public Job.JobState _state
protected Key<Job.Progress> _progressKey
public void updateValidationMessages()
NOTE: this should only be called when no other threads are updating the job, for example from init() or after the DTask is stopped and is getting cleaned up.
public int error_count()
public int error_count_or_uninitialized()
public void hide(java.lang.String field_name, java.lang.String message)
public void info(java.lang.String field_name, java.lang.String message)
public void warn(java.lang.String field_name, java.lang.String message)
public void error(java.lang.String field_name, java.lang.String message)
public void clearValidationErrors()
public void message(Job.ValidationMessage.MessageType message_type, java.lang.String field_name, java.lang.String message)
public java.lang.String validationErrors()
public static Job[] jobs()
public final Key<T> dest()
public boolean isCancelledOrCrashed()
Job.JobState.CANCELLED
or Job.JobState.FAILED
public boolean isRunning()
public boolean isDone()
Job.JobState.DONE
public boolean isStopped()
public static boolean isRunning(Key<Job> job_key)
job_key
- job keypublic final long msec()
protected Job<T> start(H2O.H2OCountedCompleter fjtask, long work, boolean restartTimer)
fjtask
- top-level job computation task.work
- Units of work to be completedrestartTimer
- Job.JobState.RUNNING
stateJob.JobState
,
H2O.H2OCountedCompleter
protected Key createProgressKey()
protected boolean deleteProgressKey()
public T get()
This call blocks on working task which was passed via start(water.H2O.H2OCountedCompleter, long, boolean)
method and returns the result which is fetched from DKV based on job
destination key.
start(water.H2O.H2OCountedCompleter, long, boolean)
,
DKV
public void block()
public void done()
protected void done(boolean force)
force
- If set to false, then ask canBeDone() whether to mark the job as finishedprotected boolean canBeDone()
public void cancel()
The job will be switched to state Job.JobState.CANCELLED
which signals that
the job was cancelled by a user.
public void failed(java.lang.Throwable ex)
ex
- exception causing the termination of job.public void cancel(java.lang.String msg)
msg
- cancellation message explaining reason for cancellationpublic float progress()
public java.lang.String progress_msg()
public final void update(long newworked)
public final void update(long newworked, java.lang.String msg)
protected Futures remove_impl(Futures fs)
Keyed
Vec
(removing associated Chunk
keys)
and Frame
(removing associated Vec
keys.)remove_impl
in class Keyed
protected long checksum_impl()
checksum_impl
in class Keyed