× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Chuck,

This is for the utility that runs with AJS on our R&D LPAR when we wish to DLTLIB of all the libraries for an application.
If someone forgets to signoff if some other job is running, the DLTLIB fails.
I've created a WRKWCH against DLTLIB for CPF2113 and CPF3202.
Has been working fine except for the JVM jobs that take long to end.
Between lines 143 and 154 I'm going to add a loop with TAATOOLS/RTVJOBSTS, checking the status of the job that I just ended.

0001.00 /* ********************************************************************** */
0002.00 /* XFER - CL PROGRAM START JW DETERMINE LIB LOCKS, END JOBS, RETRY DLT */
0003.00 /* CPF2113 - CANNOT ALLOCATE LIBRARY */
0004.00 /* CPF3202 - FILE XXXXXXX IN LIBRARY YYYYYY IN USE. */
0005.00 /* BRM SLICE DELETES */
0006.00 /* WRITTEN BY: PAUL STEINMETZ */
0007.00 /* ********************************************************************** */
0008.00 PGM PARM(&WCHOPTSET &SESSIONID &ERRDETECT +
0009.00 &EVENTDATA)
0010.00
0011.00 /* PARAMETERS PASSED TO WATCH EXIT PROGRAM */
0012.00
0013.00 DCL VAR(&WCHOPTSET) TYPE(*CHAR) LEN(10)
0014.00 DCL VAR(&SESSIONID) TYPE(*CHAR) LEN(10)
0015.00 DCL VAR(&ERRDETECT) TYPE(*CHAR) LEN(10)
0016.00 DCL VAR(&EVENTDATA) TYPE(*CHAR) LEN(1024)
0017.00
0018.00 /* LIST JOB LOG MESSAGES (QMHLJOBL) API */
0019.00
0020.00 DCL VAR(&RCVINF) TYPE(*CHAR) LEN(1300)
0021.00 DCL VAR(&RCVLEN) TYPE(*CHAR) LEN(4)
0022.00 DCL VAR(&FORMAT) TYPE(*CHAR) LEN(8) +
0023.00 VALUE('LJOB0100')
0024.00 DCL VAR(&APIERR) TYPE(*CHAR) LEN(16)
0025.00
0026.00 /* LOCAL VARIABLES */
0027.00
0028.00 DCL VAR(&JOBNAME) TYPE(*CHAR) LEN(10)
0029.00 DCL VAR(&JOBUSER) TYPE(*CHAR) LEN(10)
0030.00 DCL VAR(&JOBNUM) TYPE(*CHAR) LEN(6)
0031.00 DCL VAR(&PROGRAM) TYPE(*CHAR) LEN(7)
0032.00 DCL VAR(&CPFMSG) TYPE(*CHAR) LEN(7)
0033.00
0034.00 DCL VAR(&MSGLIB) TYPE(*CHAR) LEN(10)
0035.00 DCL VAR(&OBJLIB) TYPE(*CHAR) LEN(10)
0036.00 DCL VAR(&JOBTYP) TYPE(*CHAR) LEN(1)
0037.00 DCL VAR(&DATTIM) TYPE(*CHAR) LEN(10)
0038.00 DCL VAR(&DATTIMW) TYPE(*CHAR) LEN(20)
0039.00 DCL VAR(&TIMEW) TYPE(*CHAR) LEN(9)
0040.00 DCL VAR(&R) TYPE(*CHAR) LEN(1) VALUE('R')
0041.00
0042.00 DCL VAR(&SUB) TYPE(*CHAR) LEN(1024)
0043.00 DCL VAR(&MSG) TYPE(*CHAR) LEN(4096)
0044.00
0045.00 DCLF FILE(TAAOBJDP) /* CVTOBJLCK MODEL FILE */
0046.00
0047.00 CHGJOB LOG(4 00 *SECLVL) LOGCLPGM(*YES)
0048.00
0049.00 CHGVAR VAR(%BIN(&RCVLEN)) VALUE(1300)
0050.00
0051.00 CHGVAR VAR(&ERRDETECT) VALUE(' ')
0052.00
0053.00 /* OBTAIN JOB/PGM INFORMATION */
0054.00
0055.00 CHGVAR VAR(&CPFMSG) VALUE(%SST(&EVENTDATA 5 7))
0056.00 CHGVAR VAR(&PROGRAM) VALUE(%SST(&EVENTDATA 63 7))
0057.00 CHGVAR VAR(&JOBNAME) VALUE(%SST(&EVENTDATA 33 10))
0058.00 CHGVAR VAR(&JOBUSER) VALUE(%SST(&EVENTDATA 43 10))
0059.00 CHGVAR VAR(&JOBNUM) VALUE(%SST(&EVENTDATA 53 6))
0060.00
0061.00 /* LIBRARY IS IN OFFSET 493 OF &EVENTDATA */
0062.00
0063.00 CHGVAR VAR(&MSGLIB) VALUE(%SST(&EVENTDATA 493 10))
0064.00 CHGVAR VAR(&OBJLIB) VALUE(%SST(&EVENTDATA 503 10))
0065.00 CHGVAR VAR(&JOBTYP) VALUE(%SST(&JOBNAME 9 1))
0066.00
0067.00 RTVJOBA DATETIME(&DATTIMW)
0068.00 CHGVAR VAR(&TIMEW) VALUE(%SST(&DATTIMW 9 9))
0069.00 CHGVAR &DATTIM (&R *CAT &TIMEW)
0070.00
0071.00 DMPCLPGM /* test only */
0072.00
0073.00 /* CALL PGM(QMHLJOBL) PARM(&RCVINF &RCVLEN &FORMAT +
0074.00 &OBJLIB &APIERR) /* List Job Log Messages +
0075.00 (QMHLJOBL) API */
0076.00
0077.00 RTVJOBCMD JOB(&JOBNUM/&JOBUSER/&JOBNAME) /* Find cmds +
0078.00 from job that triggered wrkwch */
0079.00
0080.00 /* SAVE LIST OF OBJECT LOCKS FOR TROUBLESHOOTING */
0081.00 IF COND(&CPFMSG *EQ 'CPF2113') THEN(DO)
0082.00 WRKOBJLCK OBJ(&MSGLIB) OBJTYPE(*LIB) OUTPUT(*PRINT)
0083.00 ENDDO
0084.00 ELSE CMD(DO)
0085.00 WRKOBJLCK OBJ(&OBJLIB/&MSGLIB) OBJTYPE(*FILE) +
0086.00 OUTPUT(*PRINT) /* For CPF3202 */
0087.00 ENDDO
0088.00
0089.00 /* EMAIL OR SNDMSG THAT WRKWCH IS ENGAGED AND ENDING JOBS */
0090.00
0091.00 IF COND(&JOBTYP *EQ 'D') THEN(DO)
0092.00
0093.00 CHGVAR VAR(&SUB) VALUE('Pencor06 WRKWCH for +
0094.00 DLTRNMLIB ' *cat &MSGLIB *cat ' engaged')
0095.00
0096.00 CHGVAR VAR(&MSG) VALUE('Pencor06 WRKWCH for DLTLIB +
0097.00 ' *CAT &MSGLIB *CAT ' engaged; check your +
0098.00 DLTRNMLIB job; library had locks, confirm +
0099.00 that jobs were ended, locks gone, library +
0100.00 deleted')
0101.00 ENDDO
0102.00 ELSE CMD(DO)
0103.00
0104.00 CHGVAR VAR(&SUB) VALUE('Pencor06 WRKWCH for +
0105.00 DLTRNMLIB ' *cat &MSGLIB *cat ' engaged')
0106.00
0107.00 CHGVAR VAR(&MSG) VALUE('Pencor06 WRKWCH for DLTLIB +
0108.00 ' *CAT &MSGLIB *CAT ' engaged; check your +
0109.00 DLTRNMLIB job; library had locks, confirm +
0110.00 that jobs were ended, locks gone, library +
0111.00 was renamed to R current date time')
0112.00
0113.00 ENDDO
0114.00
0115.00 MAILTOOL TOADDR(psteinmetz@xxxxxxxxxx +
0116.00 gdepue@xxxxxxxxxx) +
0117.00 FROMADDR(PENCOR06@xxxxxxxxxx) +
0118.00 SUBJECT(&MSG) MESSAGE(&MSG)
0119.00
0120.00 /* CVTLIBLCK2 - USE TAATOOL CONVERT LIBRARY LOCKS 2 */
0121.00
0122.00 OVRDBF FILE(TAAOBJDP) TOFILE(QTEMP/OBJLCKP) +
0123.00 SECURE(*YES)
0124.00
0125.00 IF COND(&CPFMSG *EQ 'CPF2113') THEN(DO)
0126.00 CVTLIBLCK2 LIB(&MSGLIB) OUTLIB(QTEMP) /* t */
0127.00 MONMSG MSGID(TAA9892) /* LOCKS EXIST */
0128.00 ENDDO
0129.00
0130.00 ELSE CMD(DO)
0131.00 CVTOBJLCK OBJ(&OBJLIB/&MSGLIB) OBJTYPE(*FILE) +
0132.00 OUTLIB(QTEMP) /* t */
0133.00 MONMSG MSGID(CPF9898) /* NO LOCK EXIST */
0134.00 ENDDO
0135.00
0136.00 READ: RCVF
0137.00 MONMSG MSGID(CPF0864) EXEC(GOTO CMDLBL(EOF))
0138.00 /* */
0139.00 /* YOUR HANDLING OF LOCKS */
0140.00 /* */
0141.00
0142.00
0143.00 ENDJOB JOB(&OLJNBR/&OLUSER/&OLJNAM) OPTION(*IMMED) +
0144.00 /* end job with locks */
0145.00 MONMSG MSGID(CPF0000)
0146.00
0147.00 GOTO CMDLBL(READ)
0148.00 EOF: /* ALL LOCKS HAVE BEEN PROCESSED */
0149.00 /* LOCKS EXIST */
0150.00
0151.00 /* RETRY DLTLIB THAT WAS ORIGINALLY LOCKED */
0152.00 /* DELYAY SO ALL JOBS ARE ENDED */
0153.00
0154.00 DLYJOB DLY(5) /* If JVM job, 5 seconds is not long +
0155.00 enough */
0156.00
0157.00 IF COND(&CPFMSG *EQ 'CPF2113') THEN(DO)
0158.00 IF COND(&JOBTYP *EQ 'D') THEN(DO)
0159.00 DLTLIB LIB(&MSGLIB)
0160.00 MONMSG MSGID(CPF0000)
0161.00 ENDDO
0162.00 ELSE CMD(DO)
0163.00 RNMOBJ OBJ(&MSGLIB) OBJTYPE(*LIB) NEWOBJ(&DATTIM)
0164.00 MONMSG MSGID(CPF0000)
0165.00 ENDDO
0166.00 ENDDO
0167.00
0168.00 ELSE CMD(DO)
0169.00 DLTLIB LIB(&OBJLIB)
0170.00 MONMSG MSGID(CPF0000)
0171.00 ENDDO
0172.00
0173.00 ENDPGM
****************** End of data ****************************************

Paul
-----Original Message-----
From: MIDRANGE-L [mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of CRPence
Sent: Tuesday, May 24, 2016 4:11 PM
To: midrange-l@xxxxxxxxxxxx
Subject: Re: ENDJOB JOB(&OLJNBR/&OLUSER/&OLJNAM) OPTION(*IMMED) taking excessively long for JVM jobs.

On 24-May-2016 13:59 -0500, Steinmetz, Paul wrote:
I have a utility that finds locks and then ends those jobs. 99% of the
jobs end LT 5 seconds.
If the job is a JVM job, I've seen it take 2 to 3 minutes to end.

Be thankful not to have hit a job, yet, that is running commitment control with sufficient pending resources\work such that the wait could being perhaps some hours.

Note: only by rare exception should a job be ended *IMMED, and instead, should be ended first with *CTRLD even with a somewhat short wait. A snippet of the help text for the How To End (OPTION) parameter of the End Job (ENDJOB) command: "Note: The *IMMED value might cause undesirable results if data has been partially updated. This value should be used only after a controlled end has been attempted unsuccessfully."

Note: If the jobs that hold the locks are running a specific application, then the application might best enable an End Application Jobs (ENDAPPJOBS) feature that can be invoked, instead of the more indiscriminate ending of jobs; by a design, that can ensure proper cleanup and even allow for special-case\exception scenarios.


Is there a way to tell if the job requested to end immed has ended?

The Retrieve Job Information (QUSRJOBI) or a similar Work Management API [http://www.ibm.com/support/knowledgecenter/ssw_ibm_i_71/apis/qusrjobi.htm].
Less desirable might be a review of the history log; await the /job ended/ completion.


I'd like to add loop to this process and DLYJOB until the jobs have
ended.

Why not just loop instead, on a request allocate exclusively the same object used to decide which jobs to end? There is a Wait Time (WAIT) parameter on the Allocate Object (ALCOBJ) command to effect a timeout and continue. The use of a simple delay with Delay Job (DLYJOB) allows other jobs to obtain a new lock while sleeping, thus more jobs to end [or the code does not account for that effect, and the next step fails because there are once again conflicting jobs]; the DLYJOB with a constant Job Delay Time (DLY) also may allow useless waiting, whereby waiting continues despite all jobs\locks are gone, meaning the job in-wait could have moved on to doing something useful.

--
Regards, Chuck

--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list To post a message email: MIDRANGE-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx Before posting, please take a moment to review the archives at http://archive.midrange.com/midrange-l.

Please contact support@xxxxxxxxxxxx for any subscription related questions.

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.