Class 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:
    3.0
    Author:
    Frank Giordano
    • 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 object
        attempts - number of attempts to get status
      • JobMonitor

        public JobMonitor​(ZosConnection connection,
                          int attempts,
                          int watchDelay)
        MonitorJobs constructor.
        Parameters:
        connection - connection information, see ZosConnection object
        attempts - number of attempts to get status
        watchDelay - 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 object
        attempts - number of attempts to get status
        watchDelay - delay time in milliseconds to wait each time requesting status
        lineLimit - number of line to inspect job output
    • Method Detail

      • 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 object
        message - 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