Class JobMonitor
- java.lang.Object
-
- zowe.client.sdk.zosjobs.methods.JobMonitor
-
public class JobMonitor extends Object
APIs for monitoring the status of a job. Use these APIs to wait for a job to enter the specified status. All APIs in MonitorJobs invoke z/OSMF jobs REST endpoints to obtain job status information.- Version:
- 2.0
- Author:
- Frank Giordano
-
-
Field Summary
Fields Modifier and Type Field Description static intDEFAULT_ATTEMPTSDefault number of poll attempts to check for the specified job status.static intDEFAULT_LINE_LIMITThe default amount of lines to check from job output.static JobStatus.TypeDEFAULT_STATUSDefault expected job status ("OUTPUT")static intDEFAULT_WATCH_DELAYThe default amount of time (in 3000 milliseconds is 3 seconds) to wait until the next job status poll.
-
Constructor Summary
Constructors Constructor Description JobMonitor(ZosConnection connection)MonitorJobs constructor.JobMonitor(ZosConnection connection, int attempts)MonitorJobs constructor.JobMonitor(ZosConnection connection, int attempts, int watchDelay)MonitorJobs constructor.JobMonitor(ZosConnection connection, int attempts, int watchDelay, int lineLimit)MonitorJobs constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanisRunning(MonitorJobWaitForParams params)Determines if a given job is in a running state or not.booleanwaitByMessage(String jobName, String jobId, String message)Given the jobname/jobid, wait for the given message from the job.booleanwaitByMessage(Job job, String message)Given a Job document (has jobname/jobid), wait for the given message from the job.JobwaitByOutputStatus(String jobName, String jobId)Given the jobname/jobid, wait for the status of the job to be "OUTPUT".JobwaitByOutputStatus(Job job)Given a Job document (has jobname/jobid), wait for the status of the job to be "OUTPUT".JobwaitByStatus(String jobName, String jobId, JobStatus.Type statusType)Given the jobname/jobid, wait for the given status of the job.JobwaitByStatus(Job job, JobStatus.Type statusType)Given a Job document (has jobname/jobid), wait for the given status of the job.booleanwaitMessageCommon(MonitorJobWaitForParams params, String message)Given jobname/jobid, check for the desired message continuously (based on the interval and attempts specified).JobwaitStatusCommon(MonitorJobWaitForParams params)Given jobname/jobid, check for the desired "status" (default is "OUTPUT") continuously (based on the interval and attempts specified).
-
-
-
Field Detail
-
DEFAULT_ATTEMPTS
public static final int DEFAULT_ATTEMPTS
Default number of poll attempts to check for the specified job status.- See Also:
- Constant Field Values
-
DEFAULT_LINE_LIMIT
public static final int DEFAULT_LINE_LIMIT
The default amount of lines to check from job output.- See Also:
- Constant Field Values
-
DEFAULT_STATUS
public static final JobStatus.Type DEFAULT_STATUS
Default expected job status ("OUTPUT")
-
DEFAULT_WATCH_DELAY
public static final int DEFAULT_WATCH_DELAY
The default amount of time (in 3000 milliseconds is 3 seconds) to wait until the next job status poll.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
JobMonitor
public JobMonitor(ZosConnection connection)
MonitorJobs constructor.- Parameters:
connection- connection information, see ZosConnection object
-
JobMonitor
public JobMonitor(ZosConnection connection, int attempts)
MonitorJobs constructor.- Parameters:
connection- connection information, see ZosConnection objectattempts- number of attempts to get status
-
JobMonitor
public JobMonitor(ZosConnection connection, int attempts, int watchDelay)
MonitorJobs constructor.- Parameters:
connection- connection information, see ZosConnection objectattempts- number of attempts to get statuswatchDelay- delay time in milliseconds to wait each time requesting status
-
JobMonitor
public JobMonitor(ZosConnection connection, int attempts, int watchDelay, int lineLimit)
MonitorJobs constructor.- Parameters:
connection- connection information, see ZosConnection objectattempts- number of attempts to get statuswatchDelay- delay time in milliseconds to wait each time requesting statuslineLimit- number of line to inspect job output
-
-
Method Detail
-
isRunning
public boolean isRunning(MonitorJobWaitForParams params) throws ZosmfRequestException
Determines if a given job is in a running state or not.- Parameters:
params- monitor jobs params, see MonitorJobWaitForParams- Returns:
- true if in running state
- Throws:
ZosmfRequestException- request error state
-
waitByMessage
public boolean waitByMessage(Job job, String message) throws ZosmfRequestException
Given a Job document (has jobname/jobid), wait for the given message from the job. This API will poll for the given message once every 3 seconds for at least 1000 times. If the polling interval/duration is NOT sufficient, use "waitForMessageCommon" method to adjust.See JavaDoc for "waitForMessageCommon" for full details on polling and other logic.
- Parameters:
job- document of the z/OS job to wait for (see z/OSMF Jobs APIs for details)message- message string- Returns:
- job document
- Throws:
ZosmfRequestException- request error state
-
waitByMessage
public boolean waitByMessage(String jobName, String jobId, String message) throws ZosmfRequestException
Given the jobname/jobid, wait for the given message from the job. This API will poll for the given message once every 3 seconds for at least 1000 times. If the polling interval/duration is NOT sufficient, use "waitForMessageCommon" method to adjust.See JavaDoc for "waitForMessageCommon" for full details on polling and other logic.
- Parameters:
jobName- the z/OS jobname of the job to wait for output status (see z/OSMF Jobs APIs for details)jobId- the z/OS jobid of the job to wait for output status (see z/OSMF Jobs APIS for details)message- message string- Returns:
- job document
- Throws:
ZosmfRequestException- request error state
-
waitByOutputStatus
public Job waitByOutputStatus(Job job) throws ZosmfRequestException
Given a Job document (has jobname/jobid), wait for the status of the job to be "OUTPUT". This API will poll for the OUTPUT status once every 3 seconds indefinitely. If the polling interval/duration is NOT sufficient, use "waitForStatusCommon" to adjust.See JSDoc for "waitForStatusCommon" for full details on polling and other logic.
- Parameters:
job- document of the z/OS job to wait for (see z/OSMF Jobs APIs for details)- Returns:
- job document
- Throws:
ZosmfRequestException- request error state
-
waitByOutputStatus
public Job waitByOutputStatus(String jobName, String jobId) throws ZosmfRequestException
Given the jobname/jobid, wait for the status of the job to be "OUTPUT". This API will poll for the OUTPUT status once every 3 seconds indefinitely. If the polling interval/duration is NOT sufficient, use "waitForStatusCommon" to adjust.See JavaDoc for "waitForStatusCommon" for full details on polling and other logic.
- Parameters:
jobName- the z/OS jobname of the job to wait for output status (see z/OSMF Jobs APIs for details)jobId- the z/OS jobid of the job to wait for output status (see z/OSMF Jobs APIS for details)- Returns:
- job document
- Throws:
ZosmfRequestException- request error state
-
waitByStatus
public Job waitByStatus(Job job, JobStatus.Type statusType) throws ZosmfRequestException
Given a Job document (has jobname/jobid), wait for the given status of the job. This API will poll for the given status once every 3 seconds for at least 1000 times. If the polling interval/duration is NOT sufficient, use "waitForStatusCommon" method to adjust.See JavaDoc for "waitForStatusCommon" for full details on polling and other logic.
- Parameters:
job- document of the z/OS job to wait for (see z/OSMF Jobs APIs for details)statusType- status type, see JobStatus.Type object- Returns:
- job document
- Throws:
ZosmfRequestException- request error state
-
waitByStatus
public Job waitByStatus(String jobName, String jobId, JobStatus.Type statusType) throws ZosmfRequestException
Given the jobname/jobid, wait for the given status of the job. This API will poll for the given status once every 3 seconds for at least 1000 times. If the polling interval/duration is NOT sufficient, use "waitForStatusCommon" method to adjust.See JavaDoc for "waitForStatusCommon" for full details on polling and other logic.
- Parameters:
jobName- the z/OS jobname of the job to wait for output status (see z/OSMF Jobs APIs for details)jobId- the z/OS jobid of the job to wait for output status (see z/OSMF Jobs APIS for details)statusType- status type, see JobStatus.Type object- Returns:
- job document
- Throws:
ZosmfRequestException- request error state
-
waitMessageCommon
public boolean waitMessageCommon(MonitorJobWaitForParams params, String message) throws ZosmfRequestException
Given jobname/jobid, check for the desired message continuously (based on the interval and attempts specified).- Parameters:
params- monitor jobs parameters, see MonitorJobWaitForParams objectmessage- message string- Returns:
- job document
- Throws:
ZosmfRequestException- request error state
-
waitStatusCommon
public Job waitStatusCommon(MonitorJobWaitForParams params) throws ZosmfRequestException
Given jobname/jobid, check for the desired "status" (default is "OUTPUT") continuously (based on the interval and attempts specified).The "order" of natural job status is: INPUT ACTIVE OUTPUT. If the requested status is earlier in the sequence than the current status of the job, then the method returns immediately (since the job will never enter the requested status) with the current status of the job.
- Parameters:
params- monitor jobs parameters, see MonitorJobWaitForParams object- Returns:
- job document
- Throws:
ZosmfRequestException- request error state
-
-