Merge lp:~jeff-apple/openvista-gtm-integration/bug321745 into lp:openvista-gtm-integration

Proposed by jeff.apple
Status: Merged
Merged at revision: not available
Proposed branch: lp:~jeff-apple/openvista-gtm-integration/bug321745
Merge into: lp:openvista-gtm-integration
Diff against target: None lines
To merge this branch: bzr merge lp:~jeff-apple/openvista-gtm-integration/bug321745
Reviewer Review Type Date Requested Status
Jon Tai Approve
Review via email: mp+5448@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Jon Tai (jontai) wrote :

Looks straightforward. Does decreasing the poll interval impact CIS' performance at all? If not, I'd say go ahead and merge.

review: Approve
4. By jeff.apple

Unmodified

5. By jeff.apple

Reduce polling on reads

6. By jeff.apple

This is the old broker, which we won;t try to support now

Revision history for this message
jeff.apple (jeff-apple) wrote :

> Looks straightforward. Does decreasing the poll interval impact CIS'
> performance at all? If not, I'd say go ahead and merge.

I got the wrong routine. That should have been XWBTCPM, the new style RPC Broker. That is checked into the branch now, even the the diff for the merge proposal does not show it. Look at diff between revs 4 and 5.

I tested performance with and without the patch using OVID to send 10000 RPC broker requests. There was no performance impact. Idle CPU usage did drop, however.

I tried this out, using both the old xinetd method to start and the new menu-driven approach. Both behaved similarly.

So, please re-review.

Revision history for this message
Jon Tai (jontai) wrote :

Still looks good. Thanks for doing the additional testing.

7. By jeff.apple

Comments

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'mumps/XWBTCPL.m'
2--- mumps/XWBTCPL.m 1970-01-01 00:00:00 +0000
3+++ mumps/XWBTCPL.m 2009-04-10 21:22:54 +0000
4@@ -0,0 +1,205 @@
5+XWBTCPL ;SLC/KCM - Listener for TCP connects ;12/09/2004 07:33
6+ ;;1.1;RPC BROKER;**1,7,9,15,16,35**;Mar 28, 1997
7+ ;ISC-SF/EG - DHCP Broker
8+ ;
9+ ; This routine is the background process that listens for client
10+ ; requests to connect to M. When a request is received, This
11+ ; procedure will job a routine to handle the requests of the client.
12+ ;
13+ ; This job may be started in the background with: D STRT^XWBTCP(PORT)
14+ ;
15+ ; When running, this job may be stopped with: D STOP^XWBTCP(PORT)
16+ ;
17+ ; Where port is the known service port to listen for connections
18+ ; p*35 Moved reads and writes to XWBRW
19+ ;
20+EN(XWBTSKT) ; -- accept clients and start the individual message handler
21+ N $ETRAP,$ESTACK S $ETRAP="D ^%ZTER J EN^XWBTCPL($G(XWBTSKT)) HALT"
22+ N RETRY,X,XWBVER,XWBVOL,LEN,MSG,XWBOS,DONE,DSMTCP,NATIP,XWBRBUF
23+ N XWBTIME
24+ S U="^",RETRY="START"
25+ X ^%ZOSF("UCI") S XWBVOL=$P(Y,",",2) ;(*p7,p9*)
26+ IF $G(XWBTSKT)="" S XWBTSKT=9000 ; default service port
27+ S XWBTDEV=XWBTSKT
28+ ;
29+ Q:'$$SEMAPHOR(XWBTSKT,"LOCK") ; -- quit if job is already running
30+ ;
31+ S XWBDEBUG=$$GET^XPAR("SYS","XWBDEBUG") ;(*p35)
32+ I XWBDEBUG D LOGSTART^XWBDLOG("XWBTCPL") ;(*p35)
33+ D UPDTREC(XWBTSKT,3) ;updt RPC BROKER SITE PARAMETER record as RUNNING
34+ D MARKER^XWBTCP(XWBTSKT,-1) ;Clear marker
35+ ;
36+ D SETNM^%ZOSV($E("RPCB_Port:"_XWBTSKT,1,15)) ;change process name
37+ ;
38+RESTART ;
39+ H 5 ;Hibernate so caller can clear (*p16,*p35)
40+ N $ESTACK S $ETRAP="D ETRAP^XWBTCPL"
41+ S DONE=0,X=0,XWBTIME=5,XWBTIME(1)=5
42+ S XWBOS=$S(^%ZOSF("OS")["DSM":"DSM",^("OS")["OpenM":"OpenM",^("OS")["GT.M":"GTM",^("OS")["MSM":"MSM",1:"")
43+ S XWBT("BF")=$S(XWBOS="GT.M":"#",1:"!") ;(*p35)
44+ ;
45+ S %T=0 ;Check for Open success (*p35)
46+ ;DSM
47+ I XWBOS="DSM" O XWBTSKT:TCPCHAN:5 S %T=$T ;Open listener
48+ ;Cache, Terminator = $C(4)512 buffers, queue = 10
49+ I XWBOS="OpenM" S XWBTDEV="|TCP|"_XWBTSKT O XWBTDEV:(:XWBTSKT:"A":$C(4):512:512:10):5 S %T=$T ;(*p35)
50+ ;GT.M (*p35)
51+ I XWBOS="GTM" D
52+ . S @("$ZINTERRUPT=""I $$JOBEXAM^ZU($ZPOSITION)""")
53+ . S XWBTDEV="SKD$"_$J,XWBTSKT=XWBTSKT
54+ . O XWBTDEV:(ZLISTEN=XWBTSKT_":TCP":NODELIMITER:ATTACH="listener":MOREREADTIME=999):5:"SOCKET" S %T=$T Q:'%T
55+ . U XWBTDEV S XWBTDEV("LISTENER")=$KEY
56+ . W /LISTEN(1)
57+ . U XWBTDEV S XWBTDEV("STATUS")=$KEY
58+ . Q
59+ ;Check if got device Open
60+ I '%T D LOG^XWBDLOG("Open "_XWBTSKT_" Fail") Q ;(*p35)
61+ ;
62+ I XWBDEBUG D LOG^XWBDLOG("Port Open: "_XWBTSKT)
63+ F D Q:DONE
64+ . S DONE=0
65+ . ; -- listen for connect & get the initial message from the client
66+ . I XWBOS="DSM" U XWBTSKT S XWBTIME=60 ;Will wait at read
67+ . I XWBOS="MSM" S XWBTDEV=56 O 56 U 56::"TCP" W /SOCKET("",XWBTSKT)
68+ . I XWBOS="OpenM" U XWBTDEV R *X ;Cache will wait here for connection
69+ . I XWBOS="GTM" D
70+ . . K XWBTDEV("SOCKET")
71+ . . F D Q:$D(XWBTDEV("SOCKET"))
72+ . . . ;Wait for connection, $KEY will be "CONNECT|socket_handle|remote_ipaddress"
73+ . . . U XWBTDEV W /WAIT(10) S XWBTDEV("KEY")=$KEY
74+ . . . I XWBTDEV("KEY")="" Q
75+ . . . S XWBTDEV("SOCKET")=$P(XWBTDEV("KEY"),"|",2)
76+ . . . S (XWBTDEV("IP"),IO("GTM-IP"))=$P(XWBTDEV("KEY"),"|",3)
77+ . . . U XWBTDEV:(SOCKET=XWBTDEV("SOCKET"):WIDTH=512:NOWRAP:EXCEPTION="GOTO ETRAP")
78+ . . . Q
79+ . . Q
80+ . ;========================MAIN LOOP=======================
81+ . ;(*p35) change to use MSG, MSG1 and MSG2
82+ . S (MSG,MSG1,MSG2,XWBRBUF)=""
83+ . ;F XCNT=0:0 R MSG1#1:XWBTIME Q:$T I '$T S XCNT=XCNT+1 Q:XCNT>5
84+ . F XCNT=0:0 S MSG1=$$BREAD^XWBRW(1,XWBTIME,1) Q:$L(MSG1) S XCNT=XCNT+1 Q:XCNT>5
85+ . Q:XCNT>5
86+ . I MSG1'="{" D RELEASE(0) Q ;Not the right start so Close.
87+ . S MSG1=MSG1_$$BREAD^XWBRW(4,,1) IF (MSG1'="{XWB}") D RELEASE(0) Q
88+ . S MSG1=MSG1_$$BREAD^XWBRW(6)
89+ . I $E(MSG1,11)="|" D
90+ . . S VL=$$BREAD^XWBRW(1),VL=$A(VL)
91+ . . S XWBVER=$$BREAD^XWBRW(VL)
92+ . . S LEN=$$BREAD^XWBRW(5)
93+ . . S MSG=$$BREAD^XWBRW(+LEN)
94+ . E S X=$E(MSG1,11),LEN=$E(MSG1,6,10)-1,MSG2=$$BREAD^XWBRW(LEN),MSG=X_MSG2,XWBVER=0
95+ . ; -- msg should be: action^client IP^client port^token
96+ . I XWBDEBUG D LOG^XWBDLOG("Hdr:"_MSG1_" Msg:"_MSG) ;(*p35)
97+ . ;
98+ . ; -- if the action is TCPconnect (usual case)
99+ . I $P(MSG,"^")="TCPconnect" D
100+ . . N DZ,%T S DZ="",%T=0,RETRY=$S($G(RETRY)>1:RETRY-1,1:0) ;(*p7*)
101+ . . ;Get the peer and use that IP, Allow use thru a NAT box.
102+ . . S NATIP=$$GETPEER^%ZOSV I $L(NATIP) S $P(MSG,"^",2)=NATIP ;(*p35)
103+ . . I '$$NEWJOB D QSND("reject") Q ;(*p7,*p35)
104+ . . I XWBDEBUG>1 D LOG^XWBDLOG("JOB: "_MSG)
105+ . . ;Job a Server, X should be null
106+ . . J EN^XWBTCPC($P(MSG,"^",2),$P(MSG,"^",3),$P(DZ,"^"),XWBVER,$P(MSG,"^",4))::5 S %T=$T
107+ . . I %T D QSND("accept") ;(*p35)
108+ . . I '%T D QSND("reject") ;(*p35)
109+ . ;
110+ . ; -- if the action is TCPdebug (when msg handler run interactively)
111+ . I $P(MSG,"^")="TCPdebug" D QSND("accept") ;(*p35)
112+ . ;
113+ . ; -- if the action is TCPshutdown, this listener will quit if the
114+ . ; stop flag has been set. This request comes from an M process.
115+ . I $P(MSG,"^")="TCPshutdown" S DONE=1 D QSND^XWBRW("ack")
116+ . D RELEASE(0) ;Now release the connection. (*p7*)
117+ . Q
118+ ; -- loop end
119+ ;
120+ S %=$$SEMAPHOR(XWBTSKT,"UNLOCK") ; destroy 'running flag'
121+ D LOG^XWBDLOG("Exit")
122+ D UPDTREC(XWBTSKT,6) ;updt RPC BROKER SITE PARAMETER record as STOPPED
123+ S $ETRAP="" ;(*p35) Turn off error trap
124+ IF XWBOS="DSM" C XWBTSKT ;Do Close last in case it gets an error
125+ Q
126+ ;
127+QSND(STR) ;Write output (*p35)
128+ D QSND^XWBRW(STR),LOG^XWBDLOG(STR)
129+ Q
130+ ;
131+ETRAP ; -- on trapped error, send error info to client
132+ N XWBERC,XWBERR S $ETRAP="D ^%ZTER J EN^XWBTCPL($G(XWBTSKT)) HALT"
133+ S XWBERC=$$EC^%ZOSV,XWBERR=$C(24)_"M ERROR="_XWBERC_$C(13,10)_"LAST REF="_$$LGR^%ZOSV
134+ D ^%ZTER ;Record error and clear $ECODE
135+ D LOG^XWBDLOG("Error: "_$E(XWBERC,1,200))
136+ S RETRY=$G(RETRY)+1 H 3+(RETRY\5) ;(*p7*) Slow down but never stop
137+ ;Halt if DSM DUPNAME
138+ I XWBERC["F-DUPLNAM" D HALT
139+ . S %=$$SEMAPHOR(XWBTSKT,"UNLOCK") ; destroy 'running flag'
140+ . D UPDTREC(XWBTSKT,6) ;updt RPC BROKER SITE PARAMETER record as STOPPED
141+ . Q
142+ S XWBDEBUG=$G(XWBDEBUG)
143+ ;Set new trap
144+ S $ETRAP="Q:($ESTACK&'$QUIT) Q:$ESTACK -9 S $ECODE="""" G RESTART^XWBTCPL"
145+ ;
146+ I (XWBERC["READ")!(XWBERC["WRITE")!(XWBERC["SYSTEM-F") G ETRAPX
147+ IF XWBOS="DSM" D
148+ . I $D(XWBTLEN),XWBTLEN,XWBERC'["SYSTEM-F" D QSND(XWBERR) ;(p35)
149+ IF XWBOS="OpenM",XWBERC'["<WRITE>" D QSND(XWBERR) ;(*p7,35*)
150+ IF XWBOS="MSM" D QSND(XWBERR) ;(*p7,35*)
151+ETRAPX D RELEASE(1) ;Now close the connection. (*p7*)
152+ I XWBOS="DSM" H 15 ;Wait for device to close
153+ S $ECODE=",U1," Q ;Pass error up to pop stack.
154+ ;
155+FLUSH ;Flush the input buffer
156+ F R X:0 Q:'$T
157+ Q
158+ ;
159+RELEASE(%) ;Now release the connection. (*p7*)
160+ ;Parameter is zero to Release, one to Close
161+ I XWBOS="DSM" D Q ;(*p35)
162+ . I $G(%) C XWBTSKT Q
163+ . U XWBTSKT:DISCONNECT ; release this socket
164+ I XWBOS="OpenM" D Q ;(*p35)
165+ . I $G(%) C XWBTDEV Q
166+ . W *-2 ;Release the socket
167+ I XWBOS="GTM" D Q ;(*p35)
168+ . I $G(%) C XWBTDEV Q
169+ . C XWBTDEV:(SOCKET=XWBTDEV("SOCKET")) ;release the socket
170+ I XWBOS="MSM" C 56
171+ Q
172+ ;
173+UPDTREC(XWBTSKT,STATE,XWBENV) ; -- update STATUS field and ^%ZIS X-ref of the
174+ ;RPC BROKER SITE PARAMETER file
175+ ;XWBTSKT: listener port
176+ N C,XWBOXIEN,XWBPOIEN,XWBFDA
177+ S C=",",U="^"
178+ I $G(XWBENV)'="" S Y=XWBENV
179+ E D GETENV^%ZOSV ;get Y=UCI^VOL^NODE^BOXLOOKUP of current system
180+ ;I STATE=3 S ^%ZIS(8994.171,"RPCB Listener",$P(Y,U,2),$P(Y,U),$P(Y,U,4),XWBTSKT)=$J
181+ ;I STATE=6 K ^%ZIS(8994.171,"RPCB Listener",$P(Y,U,2),$P(Y,U),$P(Y,U,4),XWBTSKT)
182+ ;
183+ S XWBOXIEN=$$FIND1^DIC(8994.17,",1,","",$P(Y,U,4)) ;find rec for box
184+ S XWBPOIEN=$$FIND1^DIC(8994.171,C_XWBOXIEN_",1,","",XWBTSKT)
185+ D:XWBPOIEN>0 ;update STATUS field if entry was found
186+ . D FDA^DILF(8994.171,XWBPOIEN_C_XWBOXIEN_C_1_C,1,"R",STATE,"XWBFDA")
187+ . D FILE^DIE("","XWBFDA")
188+ Q
189+ ;
190+ ;
191+SEMAPHOR(XWBTSKT,XWBACT) ;Lock/Unlock listener semaphore
192+ ;XWBTSKT: listener port, XWBACT: "LOCK" | "UNLOCK" action to perform
193+ ;if LOCK is requested, it will be attempted with 1 sec timeout and if
194+ ;lock was obtained RESULT will be 1, otherwise it will be 0. For
195+ ;unlock RESULT will always be 1.
196+ N RESULT
197+ S U="^",RESULT=1
198+ D GETENV^%ZOSV ;get Y=UCI^VOL^NODE^BOXLOOKUP of current system
199+ I XWBACT="LOCK" D
200+ . L +^%ZIS(8994.171,"RPCB Listener",$P(Y,U,2),$P(Y,U),$P(Y,U,4),XWBTSKT):1
201+ . S RESULT=$T
202+ E L -^%ZIS(8994.171,"RPCB Listener",$P(Y,U,2),$P(Y,U),$P(Y,U,4),XWBTSKT)
203+ Q RESULT
204+ ;
205+NEWJOB() ;Check if OK to start a new job, Return 1 if OK, 0 if not OK.
206+ N X,Y,XQVOL,XUVOL
207+ S X=$O(^XTV(8989.3,1,4,"B",XWBVOL,0)),XUVOL=$S(X>0:^XTV(8989.3,1,4,X,0),1:"ROU^y^1"),XQVOL=XWBVOL
208+ S X=$$INHIBIT^XUSRB ;Returns 1 if new logons are inhibited.
209+ Q 'X

Subscribers

People subscribed via source and target branches