source: FOIAVistA/trunk/r/KERNEL-XU-A4A7-USC-XG-XLF-XNOA-XPD-XQ-XVIR-ZI-ZOSF-ZOSV-ZT-ZU-%Z-XIP--XQAB--XUC--XUR--ZIN--ZTED/ZTMS1.m@ 1582

Last change on this file since 1582 was 628, checked in by George Lilly, 15 years ago

initial load of FOIAVistA 6/30/08 version

File size: 5.2 KB
Line 
1%ZTMS1 ;SEA/RDS-TaskMan: Submanager, (Loop & Get Task) ;11/03/2003 13:31
2 ;;8.0;KERNEL;**36,49,104,118,127,136,275**;JUL 10, 1995;
3 ;
4SUBMGR ;START--outer submanager loop
5 D GETTASK G:ZTSK'>0 QUIT^%ZTMS ;task locked
6 I $L($P($G(^%ZTSK(ZTSK,.1)),U,10)) D G SUBMGR
7 . D TSKSTAT("D","Stopped by User") S (ZTSK,ZTQUEUED)=0
8 . Q
9 D PROCESS^%ZTMS2 G:$D(ZTQUIT) QUIT^%ZTMS
10 G SUBMGR
11 ;
12GETTASK ;SUBMGR--retain the partition; check Waiting Lists every 1 seconds
13 D SUB(1) S ZTSK=0
14 ;
15 F ZRT=0:0 D Q:$$EXIT S %=$S($O(^%ZTSCH("JOB",0))>0:1,1:$R(1+$$SUB(0))+1),ZRT=ZRT+% H % ;Space out the SM loop
16 . I $D(^%ZTSCH("WAIT","SUB")) H 5 Q ;Wait
17 . S %ZTIME=$$H3($H),ZTSK=0 I $D(^%ZTSCH("STOP","SUB",ZTPAIR)) Q
18 . D C Q:ZTSK!(ZTYPE="C") ;Do directed work before check for balance
19 . I $$BALANCE S ZRT=ZRT-.4 Q ;Wait for balance, Slow ZRT rise.
20 . D JOB,IOQ:'ZTSK ;Look at last 2 lists
21 . Q
22 Q
23 ;
24EXIT() ;GETTASK--decide whether to exit retention loop
25 I ZTSK,$D(^%ZTSCH("NO-OPTION")),$P(^%ZTSK(ZTSK,0),"^",1,2)="ZTSK^XQ1" D
26 . D SCHTM^%ZTMS2(ZTDTH+60) S ZTSK=0
27 . Q
28 I ZTSK G YES
29 I $D(^%ZTSCH("STOP","SUB",ZTPAIR)) G YES
30 I ZTPFLG("RT")>ZRT G NO ;Retention time check
31 I $$SUB(0)>ZTPFLG("MIN") G YES ;Let extras go
32NO ;EXIT--Don't exit
33 S ^%ZTSCH("SUB",ZTPFLG("HOME"),$J)=$H ;Keep our node current
34 I ZTPFLG("XUSCNT") D SETLOCK^XUSCNT($NA(^%ZTSCH("SUBLK",ZTPFLG("HOME"),$J)))
35 L ^%ZTSCH("SUBLK",ZTPFLG("HOME"),$J) Q 0
36 ;
37YES ;EXIT--adjust counter and set flags
38 D SUB(-1)
39 Q 1
40 ;
41C ;GETTASK--On C type volume sets, get tasks from Cross-Volume Job List
42 I $O(^%ZTSCH("C",ZTPAIR,0))="" Q
43 L +^%ZTSCH("C",ZTPAIR):1 I '$T D:$D(ZTMLOG) LOG^%ZTMS7("No Lock C")
44 S ZTDTH="",^%ZTSCH("C",ZTPAIR)=0
45 F S ZTDTH=$O(^%ZTSCH("C",ZTPAIR,ZTDTH)),ZTSK=0 Q:ZTDTH="" D Q:ZTSK
46 . F S ZTSK=$O(^%ZTSCH("C",ZTPAIR,ZTDTH,ZTSK)),ZX=0 Q:ZTSK="" D Q:ZX
47 .. I $D(^%ZTSK(ZTSK,0))[0!'ZTSK D Q
48 ... I ZTSK'=0,$D(^%ZTSK(ZTSK)) D TSKSTAT("I")
49 ... K ^%ZTSCH("C",ZTPAIR,ZTDTH,ZTSK) S ZTSK=0
50 ... Q
51 .. L +^%ZTSK(ZTSK):0 Q:'$T
52 .. S %ZTIO=^%ZTSCH("C",ZTPAIR,ZTDTH,ZTSK),ZTQUEUED=.5
53 .. I %ZTIO]"" S ZTDEVN=1
54 .. K ^%ZTSCH("C",ZTPAIR,ZTDTH,ZTSK)
55 .. S ZX=1
56 .. Q
57 . Q
58 ;I $D(^%ZTSCH("C",ZTPAIR))=1 K ^%ZTSCH("C",ZTPAIR)
59 L -^%ZTSCH("C",ZTPAIR)
60 Q
61 ;
62BALANCE() ;GETTASK--check load balance, and wait while Manager waits
63 Q:ZTPAIR="" 0
64 I $G(^%ZTSCH("LOADA",ZTPAIR)) Q 1
65 Q 0
66 ;
67JOB ;GETTASK--search Partition Waiting List
68 S ZTSK=0,ZTDTH=0,ZTQUEUED=0
69 L +^%ZTSCH("JOBQ"):1 I '$T D:$D(ZTMLOG) LOG^%ZTMS7("No Lock JOBQ") Q
70J2 S ZTDTH=$O(^%ZTSCH("JOB",ZTDTH)),ZTSK=0 I ZTDTH="" L -^%ZTSCH("JOBQ") Q
71J3 S ZTSK=$O(^%ZTSCH("JOB",ZTDTH,ZTSK)),ZTQUEUED=0 I ZTSK'>0 G J2
72 L +^%ZTSK(ZTSK):0 G J3:'$T
73 I $D(^%ZTSCH("JOB",ZTDTH,ZTSK))[0 L -^%ZTSK(ZTSK) G J3
74 I $D(^%ZTSK(ZTSK,0))[0 D BADTASK L -^%ZTSK(ZTSK) G J3
75 S %ZTIO=^%ZTSCH("JOB",ZTDTH,ZTSK),ZTQUEUED=.5
76 K ^%ZTSCH("JOB",ZTDTH,ZTSK) L -^%ZTSCH("JOBQ") ;Now can release JOBQ
77 ;try and only pick up work for this node.
78 S ZTREC=$G(^%ZTSK(ZTSK,0)),%=$P(ZTREC,U,14) I %[":",%'[ZTNODE D G J3
79 . S ^%ZTSCH("C",%,ZTDTH,ZTSK)=%ZTIO
80 . Q
81 I %ZTIO]"" S ZTDEVN=1
82 Q
83 ;
84BADTASK ;JOB--unschedule tasks with bad numbers or incomplete records
85 S %ZTIO=^%ZTSCH("JOB",ZTDTH,ZTSK) I %ZTIO]"" S ZTDEVN=1
86 I ZTSK'=0,$D(^%ZTSK(ZTSK)) D TSKSTAT("I",3)
87 K ^%ZTSCH("JOB",ZTDTH,ZTSK)
88 S ZTQUEUED=0
89 I %ZTIO]"" D DEVLK(-1,%ZTIO)
90 Q
91 ;
92IOQ ;GETTASK--search Device Waiting List, Lock IO then DEV.
93 S ZTSK=0 I '$D(^%ZTSCH("IO")) Q
94 ;Lock to just to get last scan
95 L +^%ZTSCH("IO"):0 I '$T D:$D(ZTMLOG) LOG^%ZTMS7("No Lock IO")
96 S ZTI=$G(^%ZTSCH("IO")),ZTH=%ZTIME
97 ;Keep 5 sec apart
98 I $TR($$DIFF(%ZTIME,+ZTI,1),"-")'>5 L -^%ZTSCH("IO") D:$D(ZTMLOG) LOG^%ZTMS7("IO TIME") Q
99 S $P(^%ZTSCH("IO"),"^")=%ZTIME,%ZTIO=$P(ZTI,"^",2)
100 L -^%ZTSCH("IO")
101I2 S %ZTIO=$O(^%ZTSCH("IO",%ZTIO)),ZTDTH="" I %ZTIO="" G IOX
102 I $D(^%ZTSCH("IO",%ZTIO))<9 G I2
103 S IOT=^%ZTSCH("IO",%ZTIO)
104 I IOT'["RES" G I2:'$$DEVLK(1,%ZTIO) ;lock device if not RES.
105 I '$D(^%ZTSCH("DEVTRY",%ZTIO)) S ^%ZTSCH("DEVTRY",%ZTIO)=%ZTIME ;Set problem device check
106 S X=%ZTIO,X1=IOT,ZTDEVOK=X D DEVOK^%ZOSV I Y D DEVLK(-1,%ZTIO) G I2
107I3 S ZTDTH=$O(^%ZTSCH("IO",%ZTIO,ZTDTH)),ZTSK=0 I ZTDTH="" D DEVLK(-1,%ZTIO) G I2
108I5 S ZTSK=$O(^%ZTSCH("IO",%ZTIO,ZTDTH,ZTSK)) I ZTSK'>0 G I3
109 L +^%ZTSK(ZTSK):0 G I5:('$T)
110 S ZTQUEUED=.5 D DQ^%ZTM4 I $G(^%ZTSK(ZTSK,0))="" L -^%ZTSK(ZTSK) G I5
111 S ZTH=%ZTIME-20 ;Leave ^%ZTSCH("DEV",io) locked, Released in %ZTMS2
112IOX L +^%ZTSCH("IO"):0 S ^%ZTSCH("IO")=ZTH_"^"_%ZTIO L -^%ZTSCH("IO") ;Update anyway
113 K ZTDEVOK,%ZISCHK
114 Q
115 ;
116DEVLK(X,ZIO,TO) ;1=Lock/-1=unlock the ^%ZTSCH("DEV",ZIO) node.
117 I X<0 L -^%ZTSCH("DEV",ZIO) Q
118 L +^%ZTSCH("DEV",ZIO):(+$G(TO)) I '$T Q 0
119 Q 1
120 ;
121SUB(X) ;Inc/Dec SUB or return SUB count
122 N % L +^%ZTSCH("SUB",ZTPFLG("HOME")):5
123 S %=+$G(^%ZTSCH("SUB",ZTPFLG("HOME"))) S:%<1 %=0
124 I X>0 S ^%ZTSCH("SUB",ZTPFLG("HOME"))=%+1,^%ZTSCH("SUB",ZTPFLG("HOME"),$J)=$H
125 I X<0 S ^%ZTSCH("SUB",ZTPFLG("HOME"))=$S(%>0:%-1,1:0) K ^%ZTSCH("SUB",ZTPFLG("HOME"),$J)
126 L -^%ZTSCH("SUB",ZTPFLG("HOME"))
127 Q:X=0 % Q
128 ;
129DIFF(N,O,T) ;Diff in sec.
130 Q:$G(T) N-O ;For new seconds times
131 Q N-O*86400-$P(O,",",2)+$P(N,",",2)
132 ;
133TSKSTAT(CODE,MSG) ;Update task's status
134 S $P(^%ZTSK(ZTSK,.1),U,1,3)=$G(CODE)_U_$H_U_$G(MSG)
135 Q
136 ;
137H3(%) ;Convert $H to seconds.
138 Q 86400*%+$P(%,",",2)
139H0(%) ;Covert from seconds to $H
140 Q (%\86400)_","_(%#86400)
141 ;
Note: See TracBrowser for help on using the repository browser.