NVSSTM ;BJS/DALLAS OIFO START/STOP TASKMAN FOR CACHE v2011 ; 7/23/12 3:18pm
;;2.0;;NVSMENU;;Build 5
;
;
S NVSTMOS=$$OS^%ZOSV
;
I $G(IOF)="" D HOME^%ZIS
S NVSNODE=$P($ZU(110),".")
S NVSVOL=$ZDEFNSP
S NVSCFG=$P($ZU(86),"*",2)
;
F D Q:$D(DIRUT)
.I $G(IOF)'="" W @IOF
.W !!,$$CJ^XLFSTR("START/STOP TASK MANAGER",80)
.W !!,$$CJ^XLFSTR("** NOTE **",80)
.W !,$$CJ^XLFSTR("Task Manager must be started by a call to",80)
.W !,$$CJ^XLFSTR("a "_$G(NVSTMOS)_" file to insure that the process",80)
.W !,$$CJ^XLFSTR("is started with the appropriate privileges.",80)
.W !,$$CJ^XLFSTR("**********",80)
.W !!?3,"Current Node : ",NVSNODE
.W !?3,"Namespace : ",NVSVOL
.W !?3,"Cache Config : ",NVSCFG
.S DIR(0)="NA^1:3"
.S DIR("A",1)=" 1 = Start Task Manager for config "_NVSCFG_" on "_NVSNODE
.S DIR("A",2)=" 2 = Stop Task Manager and Sub-managers for config "_NVSCFG_" on "_NVSNODE
.S DIR("A",3)=" 3 = Exit"
.S DIR("A",4)=" "
.S DIR("A")=" Select OPTION NUMBER (1-3): "
.S DIR("B")=3
.S DIR("?")="or enter ""^"" to exit."
.S DIR("?",1)="?? Please enter an OPTION NUMBER, 1 through 3"
.W ! D ^DIR K DIR
.I Y=3 S DIRUT=1
.I $D(DIRUT) Q
.S NVSANS=Y
.I NVSANS=1 D TM Q
.I NVSANS=2 D STM Q
K DIRUT,DTOUT,NVSANS,NVSCFG,NVSNODE,NVSVOL,NVSTMOS,X,Y
Q
Q
TM S U="^"
S:'$D(DTIME) DTIME=300
CHECK D TMSTAT
I '$G(NVSTMRUN) G NSP ;taskman is not already running
I $G(NVSTMRUN) D
.K NVSTMRUN
.W !!,"It appears Taskman is already running for config ",NVSCFG
.K DIR S DIR(0)="Y",DIR("A")="Are you sure you want to continue?",DIR("B")="NO"
.W ! D ^DIR K DIR
.Q:$D(DIRUT)!(Y'=1)
.I Y=1 G NSP
.;
.Q
;
;
Q
NSP ;
W !!,"What Namespace would you like to start Task Manager in?"
W !,"Namespace: "_$ZDEFNSP R "// ",NVSTMNSP:DTIME
G:$T=0 EXIT
G:NVSTMNSP[U EXIT
I NVSTMNSP="" S NVSTMNSP=$ZDEFNSP G START
I NVSTMNSP["?" D HELPTM G NSP
CHKNSP ;if default NSP wasn't selected, check to make sure namespace entered is valid
;$ZU function to test if namespace exists
;I $ZU(90,10,$G(NVSTMNSP))'=1 W !!,"The namespace "_NVSTMNSP_" does not exist!",!! G NSP
;testing class method
;
I '##Class(%SYS.Namespace).Exists(NVSTMNSP) W !!,"The namespace "_NVSTMNSP_" does not exist!",!! G NSP
;Namespace exists - so drop through to START
;
START ;start Taskman in the identified namespace
S DIR(0)="Y",DIR("A")="Are you ready to start Task Manager in "_NVSTMNSP,DIR("B")="Yes" D ^DIR I Y=1 G START1
Q
START1 ;
D TASKMAN^|"%SYS"|ZSTU(NVSTMNSP)
W !!,"Starting Task Manager in "_NVSTMNSP_".....",!! H 3
D EXIT
Q
EXIT K NVSTMNSP
Q
STM ;stop taskman
; *** under developement ***
N DIR,DIRUT,DTOUT,NVSTMLIS,NVSTMPID,X,Y
D TMSTAT(.NVSTMLIS)
I +$G(NVSTMLIS)=0 D Q
.S DIR(0)="EA"
.S DIR("A")="Press <enter> to return to main menu..."
.W ! D ^DIR K DIR
W !
S NVSTMNOD=""
F S NVSTMNOD=$O(NVSTMLIS(NVSTMNOD)) Q:NVSTMNOD=""!($D(DIRUT)) D
.S DIR(0)="YA"
.S DIR("A")="Stop Task Manager in "_NVSTMNOD_"? "
.S DIR("B")="NO"
.S DIR("?")="Answer YES or NO, or enter ""^"" to abort"
.D ^DIR K DIR
.I $D(DIRUT) Q
.I Y'=1 Q
.W !?2,"stopping the manager..."
.D SMAN^ZTMKU(NVSTMNOD)
.S NVSTMPID=NVSTMLIS(NVSTMNOD)
.F I=1:1:10 Q:'$D(^%ZTSCH("STATUS",NVSTMPID)) W "." H 1
.I $D(^%ZTSCH("STATUS",NVSTMNOD)) W !?2,"ERROR -- Manager job would not stop!" Q
.W "done."
.W !?2,"stopping any idle sub-manager(s)..."
.D SSUB^ZTMKU(NVSTMNOD)
.W "done."
K DIRUT,DTOUT,NVSTMNOD,X,Y
S DIR(0)="EA"
S DIR("A")="Press <enter> to return to the main menu..."
W ! D ^DIR K DIR
Q
TMSTAT(LIST) ; check and list current Task Manager status...
; LIST = an array name passed by reference into which current TM jobs are listed
;returns LIST=number of TM manager jobs in ^%ZTSCH("STATUS")
;LIST(node name)=TM job status line from ^%ZTSCH("STATUS",pid)
N NVSTMDAT,NVSTMPID,NVSTMRUN
S LIST=0
W !!,"Current Task Manager status:"
I '+$O(^%ZTSCH("STATUS",0)) D Q
.W $C(7)
.W !,"**NO TASK MANAGER JOBS FOUND IN ^%ZTSCH(""STATUS"") FOR "_$G(NVSVOL)_"!**"
W !!,"Process ID"
W ?20,"Node"
W ?35,"Status"
S NVSTMPID=0,NVSTMRUN=1
F S NVSTMPID=$O(^%ZTSCH("STATUS",NVSTMPID)) Q:'NVSTMPID D
.S NVSTMDAT=^%ZTSCH("STATUS",NVSTMPID)
.W !,NVSTMPID
.W ?20,$P(NVSTMDAT,"^",3)
.W ?35,$P(NVSTMDAT,"^",2)," ",$P(NVSTMDAT,"^",4)
.S LIST=LIST+1
.S LIST($P(NVSTMDAT,"^",3))=NVSTMPID
.K NVSTMDAT
Q
HELPTM ;
W !!,"Please enter the name of the Namespace which you would"
W !,"like to start Task Manager in.",!
D LIST^%NSP
W !,"The default Namespace for this configuration is ",$ZDEFNSP,!
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HNVSSTM 4644 printed Nov 22, 2024@17:27:44 Page 2
NVSSTM ;BJS/DALLAS OIFO START/STOP TASKMAN FOR CACHE v2011 ; 7/23/12 3:18pm
+1 ;;2.0;;NVSMENU;;Build 5
+2 ;
+3 ;
+4 SET NVSTMOS=$$OS^%ZOSV
+5 ;
+6 IF $GET(IOF)=""
DO HOME^%ZIS
+7 SET NVSNODE=$PIECE($ZU(110),".")
+8 SET NVSVOL=$ZDEFNSP
+9 SET NVSCFG=$PIECE($ZU(86),"*",2)
+10 ;
+11 FOR
Begin DoDot:1
+12 IF $GET(IOF)'=""
WRITE @IOF
+13 WRITE !!,$$CJ^XLFSTR("START/STOP TASK MANAGER",80)
+14 WRITE !!,$$CJ^XLFSTR("** NOTE **",80)
+15 WRITE !,$$CJ^XLFSTR("Task Manager must be started by a call to",80)
+16 WRITE !,$$CJ^XLFSTR("a "_$GET(NVSTMOS)_" file to insure that the process",80)
+17 WRITE !,$$CJ^XLFSTR("is started with the appropriate privileges.",80)
+18 WRITE !,$$CJ^XLFSTR("**********",80)
+19 WRITE !!?3,"Current Node : ",NVSNODE
+20 WRITE !?3,"Namespace : ",NVSVOL
+21 WRITE !?3,"Cache Config : ",NVSCFG
+22 SET DIR(0)="NA^1:3"
+23 SET DIR("A",1)=" 1 = Start Task Manager for config "_NVSCFG_" on "_NVSNODE
+24 SET DIR("A",2)=" 2 = Stop Task Manager and Sub-managers for config "_NVSCFG_" on "_NVSNODE
+25 SET DIR("A",3)=" 3 = Exit"
+26 SET DIR("A",4)=" "
+27 SET DIR("A")=" Select OPTION NUMBER (1-3): "
+28 SET DIR("B")=3
+29 SET DIR("?")="or enter ""^"" to exit."
+30 SET DIR("?",1)="?? Please enter an OPTION NUMBER, 1 through 3"
+31 WRITE !
DO ^DIR
KILL DIR
+32 IF Y=3
SET DIRUT=1
+33 IF $DATA(DIRUT)
QUIT
+34 SET NVSANS=Y
+35 IF NVSANS=1
DO TM
QUIT
+36 IF NVSANS=2
DO STM
QUIT
End DoDot:1
if $DATA(DIRUT)
QUIT
+37 KILL DIRUT,DTOUT,NVSANS,NVSCFG,NVSNODE,NVSVOL,NVSTMOS,X,Y
+38 QUIT
+39 QUIT
TM SET U="^"
+1 if '$DATA(DTIME)
SET DTIME=300
CHECK DO TMSTAT
+1 ;taskman is not already running
IF '$GET(NVSTMRUN)
GOTO NSP
+2 IF $GET(NVSTMRUN)
Begin DoDot:1
+3 KILL NVSTMRUN
+4 WRITE !!,"It appears Taskman is already running for config ",NVSCFG
+5 KILL DIR
SET DIR(0)="Y"
SET DIR("A")="Are you sure you want to continue?"
SET DIR("B")="NO"
+6 WRITE !
DO ^DIR
KILL DIR
+7 if $DATA(DIRUT)!(Y'=1)
QUIT
+8 IF Y=1
GOTO NSP
+9 ;
+10 QUIT
End DoDot:1
+11 ;
+12 ;
+13 QUIT
NSP ;
+1 WRITE !!,"What Namespace would you like to start Task Manager in?"
+2 WRITE !,"Namespace: "_$ZDEFNSP
READ "// ",NVSTMNSP:DTIME
+3 if $TEST=0
GOTO EXIT
+4 if NVSTMNSP[U
GOTO EXIT
+5 IF NVSTMNSP=""
SET NVSTMNSP=$ZDEFNSP
GOTO START
+6 IF NVSTMNSP["?"
DO HELPTM
GOTO NSP
CHKNSP ;if default NSP wasn't selected, check to make sure namespace entered is valid
+1 ;$ZU function to test if namespace exists
+2 ;I $ZU(90,10,$G(NVSTMNSP))'=1 W !!,"The namespace "_NVSTMNSP_" does not exist!",!! G NSP
+3 ;testing class method
+4 ;
+5 IF '##Class(%SYS.Namespace).Exists(NVSTMNSP)
WRITE !!,"The namespace "_NVSTMNSP_" does not exist!",!!
GOTO NSP
+6 ;Namespace exists - so drop through to START
+7 ;
START ;start Taskman in the identified namespace
+1 SET DIR(0)="Y"
SET DIR("A")="Are you ready to start Task Manager in "_NVSTMNSP
SET DIR("B")="Yes"
DO ^DIR
IF Y=1
GOTO START1
+2 QUIT
START1 ;
+1 DO TASKMAN^|"%SYS"|ZSTU(NVSTMNSP)
+2 WRITE !!,"Starting Task Manager in "_NVSTMNSP_".....",!!
HANG 3
+3 DO EXIT
+4 QUIT
EXIT KILL NVSTMNSP
+1 QUIT
STM ;stop taskman
+1 ; *** under developement ***
+2 NEW DIR,DIRUT,DTOUT,NVSTMLIS,NVSTMPID,X,Y
+3 DO TMSTAT(.NVSTMLIS)
+4 IF +$GET(NVSTMLIS)=0
Begin DoDot:1
+5 SET DIR(0)="EA"
+6 SET DIR("A")="Press <enter> to return to main menu..."
+7 WRITE !
DO ^DIR
KILL DIR
End DoDot:1
QUIT
+8 WRITE !
+9 SET NVSTMNOD=""
+10 FOR
SET NVSTMNOD=$ORDER(NVSTMLIS(NVSTMNOD))
if NVSTMNOD=""!($DATA(DIRUT))
QUIT
Begin DoDot:1
+11 SET DIR(0)="YA"
+12 SET DIR("A")="Stop Task Manager in "_NVSTMNOD_"? "
+13 SET DIR("B")="NO"
+14 SET DIR("?")="Answer YES or NO, or enter ""^"" to abort"
+15 DO ^DIR
KILL DIR
+16 IF $DATA(DIRUT)
QUIT
+17 IF Y'=1
QUIT
+18 WRITE !?2,"stopping the manager..."
+19 DO SMAN^ZTMKU(NVSTMNOD)
+20 SET NVSTMPID=NVSTMLIS(NVSTMNOD)
+21 FOR I=1:1:10
if '$DATA(^%ZTSCH("STATUS",NVSTMPID))
QUIT
WRITE "."
HANG 1
+22 IF $DATA(^%ZTSCH("STATUS",NVSTMNOD))
WRITE !?2,"ERROR -- Manager job would not stop!"
QUIT
+23 WRITE "done."
+24 WRITE !?2,"stopping any idle sub-manager(s)..."
+25 DO SSUB^ZTMKU(NVSTMNOD)
+26 WRITE "done."
End DoDot:1
+27 KILL DIRUT,DTOUT,NVSTMNOD,X,Y
+28 SET DIR(0)="EA"
+29 SET DIR("A")="Press <enter> to return to the main menu..."
+30 WRITE !
DO ^DIR
KILL DIR
+31 QUIT
TMSTAT(LIST) ; check and list current Task Manager status...
+1 ; LIST = an array name passed by reference into which current TM jobs are listed
+2 ;returns LIST=number of TM manager jobs in ^%ZTSCH("STATUS")
+3 ;LIST(node name)=TM job status line from ^%ZTSCH("STATUS",pid)
+4 NEW NVSTMDAT,NVSTMPID,NVSTMRUN
+5 SET LIST=0
+6 WRITE !!,"Current Task Manager status:"
+7 IF '+$ORDER(^%ZTSCH("STATUS",0))
Begin DoDot:1
+8 WRITE $CHAR(7)
+9 WRITE !,"**NO TASK MANAGER JOBS FOUND IN ^%ZTSCH(""STATUS"") FOR "_$GET(NVSVOL)_"!**"
End DoDot:1
QUIT
+10 WRITE !!,"Process ID"
+11 WRITE ?20,"Node"
+12 WRITE ?35,"Status"
+13 SET NVSTMPID=0
SET NVSTMRUN=1
+14 FOR
SET NVSTMPID=$ORDER(^%ZTSCH("STATUS",NVSTMPID))
if 'NVSTMPID
QUIT
Begin DoDot:1
+15 SET NVSTMDAT=^%ZTSCH("STATUS",NVSTMPID)
+16 WRITE !,NVSTMPID
+17 WRITE ?20,$PIECE(NVSTMDAT,"^",3)
+18 WRITE ?35,$PIECE(NVSTMDAT,"^",2)," ",$PIECE(NVSTMDAT,"^",4)
+19 SET LIST=LIST+1
+20 SET LIST($PIECE(NVSTMDAT,"^",3))=NVSTMPID
+21 KILL NVSTMDAT
End DoDot:1
+22 QUIT
HELPTM ;
+1 WRITE !!,"Please enter the name of the Namespace which you would"
+2 WRITE !,"like to start Task Manager in.",!
+3 DO LIST^%NSP
+4 WRITE !,"The default Namespace for this configuration is ",$ZDEFNSP,!
+5 QUIT