Class MonitorJobs
- java.lang.Object
-
- zowe.client.sdk.zosjobs.MonitorJobs
-
public class MonitorJobs 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:
- 1.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 MonitorJobs(ZOSConnection connection)MonitorJobs constructor.MonitorJobs(ZOSConnection connection, int attempts)MonitorJobs constructor.MonitorJobs(ZOSConnection connection, int attempts, int watchDelay)MonitorJobs constructor.MonitorJobs(ZOSConnection connection, int attempts, int watchDelay, int lineLimit)MonitorJobs constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanisJobRunning(MonitorJobWaitForParams params)Determines if a given job is in a running state or not.booleanwaitForJobMessage(String jobName, String jobId, String message)Given the jobname/jobid, waits for the given message from the job.booleanwaitForJobMessage(Job job, String message)Given a Job document (has jobname/jobid), waits for the given message from the job.JobwaitForJobOutputStatus(String jobName, String jobId)Given the jobname/jobid, waits for the status of the job to be "OUTPUT".JobwaitForJobOutputStatus(Job job)Given a Job document (has jobname/jobid), waits for the status of the job to be "OUTPUT".JobwaitForJobStatus(String jobName, String jobId, JobStatus.Type statusType)Given the jobname/jobid, waits for the given status of the job.JobwaitForJobStatus(Job job, JobStatus.Type statusType)Given a Job document (has jobname/jobid), waits for the given status of the job.booleanwaitForMessageCommon(MonitorJobWaitForParams params, String message)Given jobname/jobid, checks for the desired message continuously (based on the interval and attempts specified).JobwaitForStatusCommon(MonitorJobWaitForParams params)Given jobname/jobid, checks for the desired "status" (default is "OUTPUT") continuously (based on the interval and attempts specified).
-
-
-
Field Detail
-
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_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
-
DEFAULT_STATUS
public static final JobStatus.Type DEFAULT_STATUS
Default expected job status ("OUTPUT")
-
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
-
-
Constructor Detail
-
MonitorJobs
public MonitorJobs(ZOSConnection connection)
MonitorJobs constructor.- Parameters:
connection- connection information, see ZOSConnection object
-
MonitorJobs
public MonitorJobs(ZOSConnection connection, int attempts)
MonitorJobs constructor.- Parameters:
connection- connection information, see ZOSConnection objectattempts- number of attempts to get status
-
MonitorJobs
public MonitorJobs(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
-
MonitorJobs
public MonitorJobs(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
-
waitForJobMessage
public boolean waitForJobMessage(Job job, String message) throws Exception
Given a Job document (has jobname/jobid), waits 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:
Exception- error processing wait check request
-
waitForJobMessage
public boolean waitForJobMessage(String jobName, String jobId, String message) throws Exception
Given the jobname/jobid, waits 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:
Exception- error processing wait check request
-
waitForMessageCommon
public boolean waitForMessageCommon(MonitorJobWaitForParams params, String message) throws Exception
Given jobname/jobid, checks 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:
Exception- error processing wait check request
-
waitForJobStatus
public Job waitForJobStatus(Job job, JobStatus.Type statusType) throws Exception
Given a Job document (has jobname/jobid), waits 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:
Exception- error processing wait check request
-
waitForJobStatus
public Job waitForJobStatus(String jobName, String jobId, JobStatus.Type statusType) throws Exception
Given the jobname/jobid, waits 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:
Exception- error processing wait check request
-
waitForJobOutputStatus
public Job waitForJobOutputStatus(Job job) throws Exception
Given a Job document (has jobname/jobid), waits 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:
Exception- error processing wait check request
-
waitForJobOutputStatus
public Job waitForJobOutputStatus(String jobName, String jobId) throws Exception
Given the jobname/jobid, waits 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:
Exception- error processing wait check request
-
waitForStatusCommon
public Job waitForStatusCommon(MonitorJobWaitForParams params) throws Exception
Given jobname/jobid, checks 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:
Exception- error processing wait check request
-
isJobRunning
public boolean isJobRunning(MonitorJobWaitForParams params) throws Exception
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:
Exception- error processing running status check
-
-