com.norconex.jef.progress
Class JobProgress

java.lang.Object
  extended by com.norconex.jef.progress.JobProgress
All Implemented Interfaces:
IJobStatus, ISuiteStopRequestListener, Serializable

public final class JobProgress
extends Object
implements IJobStatus, ISuiteStopRequestListener

Responsible for keeping track reporting job execution progress.

Author:
Pascal Essiembre
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface com.norconex.jef.progress.IJobStatus
IJobStatus.Status
 
Field Summary
static long ACTIVITY_CHECK
          Frequency of activity check.
 
Constructor Summary
JobProgress(String jobId, IJobContext jobContext, IJobStatus jobStatus, JobElapsedTime elapsedTime)
          Creates a job progress initialised with values from a failed job progress we are recovering from.
JobProgress(String jobId, IJobContext jobContext, JobElapsedTime elapsedTime)
          Constructor.
JobProgress(String jobId, IJobContext jobContext, JobElapsedTime elapsedTime, long progress)
          Constructor.
 
Method Summary
 void addJobProgressListener(IJobProgressListener listener)
          Adds a job progress listener.
protected  void fireProgressChanged()
          Notifies all listeners of a change of progress.
 double getCompletionRatio()
          Gets the job completion ration.
 long getElapsedTime()
          Gets how long it took to finish a job, in milliseconds.
 String getElapsedTimeAsString()
          Gets a string representation of how long it tooks to finish a job.
 Date getEndTime()
          Gets the end date of this progress.
 IJobContext getJobContext()
          Gets contextual information about a job.
 String getJobId()
          Gets the associated job unique identifier.
 Date getLastActivity()
          Gets the date on which last activity on the job execution occured.
 IJobStatus getLastFailedJobStatus()
          Gets the last previously failed job progress, if any (assuming we are in recovery).
 String getMetadata()
          Gets meta-data associated with this job progress.
 String getNote()
          Gets the current progress note.
 long getProgress()
          Gets the current progress.
 Date getStartTime()
          Gets the end start of this progress.
 IJobStatus.Status getStatus()
          Gets the job execution status.
 void incrementProgress(long incrementValue)
          Increments the current progress by the given increment value.
 boolean isRecovery()
          Whether this progress is from a recovery attempt from a previously failed job.
 boolean isStatus(IJobStatus.Status... status)
          Checks whether the current progress status matches any of the supplied statuses.
 boolean isStopRequested()
          Whether a request stop this job was received.
 void removeJobProgressListener(IJobProgressListener listener)
          Removes a job progress listener.
 void setMetadata(String metadata)
          Sets meta-data associated with this job progress.
 void setNote(String note)
          Sets teh current progress note.
 void setProgress(long progress)
          Sets the current progress.
 void stopRequestReceived()
          Notifies the job progress that a stop request was received.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ACTIVITY_CHECK

public static final long ACTIVITY_CHECK
Frequency of activity check.

See Also:
Constant Field Values
Constructor Detail

JobProgress

public JobProgress(String jobId,
                   IJobContext jobContext,
                   JobElapsedTime elapsedTime)
Constructor.

Parameters:
jobId - job id
jobContext - job contextual info
elapsedTime - execution elapsed time

JobProgress

public JobProgress(String jobId,
                   IJobContext jobContext,
                   JobElapsedTime elapsedTime,
                   long progress)
Constructor.

Parameters:
jobId - job id
jobContext - job contextual info
elapsedTime - execution elapsed time
progress - current job progress
Since:
1.1

JobProgress

public JobProgress(String jobId,
                   IJobContext jobContext,
                   IJobStatus jobStatus,
                   JobElapsedTime elapsedTime)
Creates a job progress initialised with values from a failed job progress we are recovering from.

Parameters:
jobId - job id
jobContext - job contextual info
jobStatus - job status
elapsedTime - execution elapsed time
Since:
1.1.1
Method Detail

getJobContext

public IJobContext getJobContext()
Gets contextual information about a job.

Specified by:
getJobContext in interface IJobStatus
Returns:
job context
Since:
2.0

getNote

public String getNote()
Gets the current progress note.

Specified by:
getNote in interface IJobStatus
Returns:
Returns the note.

setNote

public void setNote(String note)
Sets teh current progress note.

Parameters:
note - The note to set.

getProgress

public long getProgress()
Gets the current progress.

Specified by:
getProgress in interface IJobStatus
Returns:
Returns the progress.

setProgress

public void setProgress(long progress)
Sets the current progress.

Parameters:
progress - The progress to set.

incrementProgress

public void incrementProgress(long incrementValue)
Increments the current progress by the given increment value.

Parameters:
incrementValue - value by which the progress will be incremented

getJobId

public String getJobId()
Gets the associated job unique identifier.

Specified by:
getJobId in interface IJobStatus
Returns:
the associated job unique identifier

getEndTime

public Date getEndTime()
Gets the end date of this progress. null if the progress never finished.

Specified by:
getEndTime in interface IJobStatus
Returns:
end time

getLastActivity

public Date getLastActivity()
Gets the date on which last activity on the job execution occured.

Specified by:
getLastActivity in interface IJobStatus
Returns:
last activity date

getMetadata

public String getMetadata()
Gets meta-data associated with this job progress.

Specified by:
getMetadata in interface IJobStatus
Returns:
meta-data

setMetadata

public void setMetadata(String metadata)
Sets meta-data associated with this job progress.

Parameters:
metadata - meta-data

getStartTime

public Date getStartTime()
Gets the end start of this progress. null if the progress never started.

Specified by:
getStartTime in interface IJobStatus
Returns:
start time

getElapsedTime

public long getElapsedTime()
Gets how long it took to finish a job, in milliseconds.

Specified by:
getElapsedTime in interface IJobStatus
Returns:
job execution elapsed time

getElapsedTimeAsString

public String getElapsedTimeAsString()
Gets a string representation of how long it tooks to finish a job.

Returns:
job execution elapsed time, as a string

addJobProgressListener

public void addJobProgressListener(IJobProgressListener listener)
Adds a job progress listener.

Parameters:
listener - job progress listener to add

removeJobProgressListener

public void removeJobProgressListener(IJobProgressListener listener)
Removes a job progress listener.

Parameters:
listener - job progress listener to remove

getCompletionRatio

public double getCompletionRatio()
Gets the job completion ration.

Specified by:
getCompletionRatio in interface IJobStatus
Returns:
a double between 0 and 1

getStatus

public IJobStatus.Status getStatus()
Gets the job execution status.

Specified by:
getStatus in interface IJobStatus
Returns:
execution status

isStopRequested

public boolean isStopRequested()
Description copied from interface: IJobStatus
Whether a request stop this job was received.

Specified by:
isStopRequested in interface IJobStatus
Returns:
true if a stop request was received.

isRecovery

public boolean isRecovery()
Whether this progress is from a recovery attempt from a previously failed job.

Specified by:
isRecovery in interface IJobStatus
Returns:
true if the current progress is a recovery
Since:
1.1.1

getLastFailedJobStatus

public IJobStatus getLastFailedJobStatus()
Gets the last previously failed job progress, if any (assuming we are in recovery).

Returns:
last failed job progress
Since:
1.1.1

isStatus

public boolean isStatus(IJobStatus.Status... status)
Checks whether the current progress status matches any of the supplied statuses.

Parameters:
status - one or more statuses to match
Returns:
true if progress status matches supplied statuses
Since:
2.0

fireProgressChanged

protected void fireProgressChanged()
Notifies all listeners of a change of progress.


toString

public String toString()
Overrides:
toString in class Object

stopRequestReceived

public void stopRequestReceived()
Notifies the job progress that a stop request was received.

Specified by:
stopRequestReceived in interface ISuiteStopRequestListener


Copyright © 2007-2013 Norconex Inc.. All Rights Reserved.