Interface IJob

All Superinterfaces:
Runnable
All Known Implementing Classes:
AbstractJob, Job, RunnableJobAdapter

public interface IJob extends Runnable
A unit of work that can be run synchronously or asynchronously, paused, resumed, cancelled and monitored.
  • Method Summary

    Modifier and Type
    Method
    Description
    Interrupts the run thread and cancels the child job; does nothing unless this job is running and not yet cancelled.
    Returns the time this job instance was cancelled.
    Returns the thread-local child job of this one while this job is running.
    Returns the time this job instance was created.
    Returns the last exception thrown while running.
    Returns the time this job finished running.
    Returns the name assigned to this job or its default name if one was not assigned.
    Returns the thread-local job that ran this one while this job is running.
    Returns the time this job was paused or null if this job is not currently paused.
    long
    Returns the number of milliseconds this job was (or has been) running for or zero (0) if it hasn't yet started running.
    Returns the time this job was (or has been) running in long form as a human readable string (2 Years, 1 Second, 12 Millisecond) or null if it hasn't yet started running.
    getRunningTimeAsString(boolean shortForm)
    Returns the time this job was (or has been) running as a human readable string in long form (2 Years, 1 Second, 12 Millisecond) or short form (2y 1s 12ms) or null if it hasn't yet started running.
    Returns the thread currently executing this job or null if the job is not running.
    Returns the time this job instance started running.
    Returns the universally unique identifier (UUID) for this job.
    boolean
    Returns true if this job was cancelled.
    boolean
    Returns true if this job has completed unsuccessfully.
    boolean
    Returns true if this job has finished running.
    boolean
    Returns true if this job is currently paused.
    boolean
    Returns true if this job is currently running.
    Asks this job to pause at its next pause check (between records for a Job) until resume() is called.
    Lets a paused job continue; does nothing if it is not paused.
    void
    run()
    Executes this job in the current thread.
    Executes this job in a new thread.
    Assigns a new name to this job.
    Waits for this job to complete.
    waitUntilFinished(long timeout)
    Waits up to timeout milliseconds for this job to complete or throws InterruptedException.
    Waits for this job to start.
    waitUntilStarted(long timeout)
    Waits up to timeout milliseconds for this job to start or throws InterruptedException.
  • Method Details

    • getParent

      IJob getParent()
      Returns the thread-local job that ran this one while this job is running.
    • getChild

      IJob getChild()
      Returns the thread-local child job of this one while this job is running.
    • getUuid

      UUID getUuid()
      Returns the universally unique identifier (UUID) for this job.
    • getName

      String getName()
      Returns the name assigned to this job or its default name if one was not assigned.
    • setName

      IJob setName(String name)
      Assigns a new name to this job.
    • getCreatedOn

      Date getCreatedOn()
      Returns the time this job instance was created.
    • getStartedOn

      Date getStartedOn()
      Returns the time this job instance started running.
    • getCancelledOn

      Date getCancelledOn()
      Returns the time this job instance was cancelled.
    • isCancelled

      boolean isCancelled()
      Returns true if this job was cancelled.
    • getPausedOn

      Date getPausedOn()
      Returns the time this job was paused or null if this job is not currently paused.
    • isPaused

      boolean isPaused()
      Returns true if this job is currently paused.
    • getFinishedOn

      Date getFinishedOn()
      Returns the time this job finished running.
    • isFinished

      boolean isFinished()
      Returns true if this job has finished running.
    • getException

      DataException getException()
      Returns the last exception thrown while running.
    • isFailed

      boolean isFailed()
      Returns true if this job has completed unsuccessfully.
    • getRunThread

      Thread getRunThread()
      Returns the thread currently executing this job or null if the job is not running.
    • isRunning

      boolean isRunning()
      Returns true if this job is currently running.
    • getRunningTime

      long getRunningTime()
      Returns the number of milliseconds this job was (or has been) running for or zero (0) if it hasn't yet started running.
    • getRunningTimeAsString

      String getRunningTimeAsString()
      Returns the time this job was (or has been) running in long form as a human readable string (2 Years, 1 Second, 12 Millisecond) or null if it hasn't yet started running.
    • getRunningTimeAsString

      String getRunningTimeAsString(boolean shortForm)
      Returns the time this job was (or has been) running as a human readable string in long form (2 Years, 1 Second, 12 Millisecond) or short form (2y 1s 12ms) or null if it hasn't yet started running.
    • pause

      IJob pause()
      Asks this job to pause at its next pause check (between records for a Job) until resume() is called.
    • resume

      IJob resume()
      Lets a paused job continue; does nothing if it is not paused.
    • cancel

      IJob cancel()
      Interrupts the run thread and cancels the child job; does nothing unless this job is running and not yet cancelled.
    • run

      void run()
      Executes this job in the current thread. This method blocks until the transfer either completes successfully or fails for any reason.
      Specified by:
      run in interface Runnable
    • runAsync

      IJob runAsync()
      Executes this job in a new thread. This method does not block.
    • waitUntilStarted

      IJob waitUntilStarted() throws InterruptedException
      Waits for this job to start.
      Returns:
      Throws:
      InterruptedException
    • waitUntilStarted

      IJob waitUntilStarted(long timeout) throws InterruptedException
      Waits up to timeout milliseconds for this job to start or throws InterruptedException.
      Returns:
      Throws:
      InterruptedException
    • waitUntilFinished

      IJob waitUntilFinished() throws InterruptedException
      Waits for this job to complete.
      Returns:
      Throws:
      InterruptedException
    • waitUntilFinished

      IJob waitUntilFinished(long timeout) throws InterruptedException
      Waits up to timeout milliseconds for this job to complete or throws InterruptedException.
      Returns:
      Throws:
      InterruptedException