public interface Job
Modifier and Type | Method and Description |
---|---|
void |
cancel()
Makes a request to cancel this job and returns.
|
JobConfig |
getConfig()
Returns the configuration this job was submitted with.
|
CompletableFuture<Void> |
getFuture()
Gets the future associated with the job.
|
long |
getId()
Returns the ID of this job.
|
default String |
getName()
Returns the name of this job or
null if no name was supplied. |
JobStatus |
getStatus()
Returns the current status of this job.
|
long |
getSubmissionTime()
Returns the time when the job was submitted to the cluster.
|
default void |
join()
Waits for the job to complete and throws an exception if the job
completes with an error.
|
void |
restart()
Gracefully stops the current execution and schedules a new execution
with the current member list of the Jet cluster.
|
void |
resume()
Resumes a suspended job.
|
void |
suspend()
Gracefully suspends the current execution of the job.
|
long getId()
IllegalStateException
- if the job has not started yet, and thus has no id.@Nonnull JobConfig getConfig()
@Nullable default String getName()
null
if no name was supplied.
Jobs can be named through JobConfig.setName(String)
prior to submission.
long getSubmissionTime()
The time is assigned by reading System.currentTimeMillis()
of
the master member that executes the job for the first time. It doesn't
change on restart.
@Nonnull CompletableFuture<Void> getFuture()
cancel()
method
should be used.IllegalStateException
- if the job has not started yet.default void join()
Shorthand for job.getFuture().get()
.
void restart()
Conceptually this call is equivalent to suspend()
& resume()
.
IllegalStateException
- if the job is not running, for example it
has already completed, is not yet running, is already restarting,
suspended etc.void suspend()
JobStatus.SUSPENDED
. To resume the job, call resume()
.
You can suspend a job even if it's not configured for snapshotting. Such a job will resume with empty state, as if it has just been started.
This call just initiates the suspension process and doesn't wait for it to complete. Suspension starts with creating a terminal state snapshot. Should the terminal snapshot fail, the job will suspend anyway, but the previous snapshot (if there was one) won't be deleted. When the job resumes, its processing starts from the point of the last snapshot.
NOTE: if the cluster becomes unstable (a member leaves or
similar) while the job is in the process of being suspended, it may end up
getting immediately restarted. Call getStatus()
to find out and
possibly try to suspend again.
IllegalStateException
- if the job is not runningvoid resume()
If the job is not suspended, it does nothing.
void cancel()
NOTE: if the cluster becomes unstable (a member leaves or
similar) while the job is in the process of being cancelled, it may end up
getting restarted after the cluster has stabilized. Call getStatus()
to find out and possibly try to cancel again.
IllegalStateException
- if the cluster is not in a state to
restart the job, for example when coordinator member left and new
coordinator did not yet load job's metadata.Copyright © 2018 Hazelcast, Inc.. All rights reserved.