[Home] [Help]
PACKAGE BODY: APPS.FND_DIAG_CM
Source
1 package body fnd_diag_cm as
2 /* $Header: AFCPDCMB.pls 120.3 2006/02/15 02:12:37 pbasha noship $ */
3
4 --
5 -- Procedure
6 -- DIAG_SQL_PROG
7 --
8 -- Purpose
9 -- Simple PL/SQL stored procedure concurrent program. Will sleep and exit.
10 --
11 -- Arguments:
12 -- IN:
13 -- SLEEPT - number of seconds to sleep (default is 20)
14 -- PROGNM - name of this program, written to logfile for tagging
15 -- OUT:
16 -- ERRBUF - standard CP output
17 -- RETCODE - 0 if successful
18 --
19 procedure diag_sql_prog(ERRBUF OUT NOCOPY VARCHAR2,
20 RETCODE OUT NOCOPY NUMBER,
21 SLEEPT IN NUMBER DEFAULT 20,
22 PROGNM IN VARCHAR2 DEFAULT null)
23 is
24 begin
25 fnd_file.put_line(fnd_file.log, PROGNM || ' test program:');
26 fnd_file.put_line(fnd_file.log, 'Sleep for ' || SLEEPT || ' seconds.');
27 DBMS_LOCK.SLEEP(SLEEPT);
28 fnd_file.put_line(fnd_file.log, 'Awake and exiting.');
29 retcode := 0;
30 exception
31 when others then
32 retcode := 2;
33 end diag_sql_prog;
34
35 --
36 -- Procedure
37 -- DIAG_CRM
38 --
39 -- Purpose
40 -- Test Conflict Resolution Manager. Will submit multiple incompatible
41 -- requests for various conflict domains to determine if any incompatible
42 -- programs are being incorrectly released to run.
43 --
44 -- Arguments:
45 -- IN:
46 -- VOLREQ - number of requests to submit (default is 100)
47 -- NUMDOM - number of different domains to use (default is 10)
48 -- OUT:
49 -- ERRBUF - standard CP output
50 -- RETCODE - 0 if successful, 1 if CRM has been found to have error
51 --
52 procedure diag_crm(ERRBUF OUT NOCOPY VARCHAR2,
53 RETCODE OUT NOCOPY NUMBER,
54 VOLREQ IN NUMBER DEFAULT 100,
55 NUMDOM IN NUMBER DEFAULT 10)
56 is
57 CURSOR con_cursor(parrqid NUMBER, apid NUMBER, bpid NUMBER, cpid NUMBER) IS
58 select a.request_id rqa, b.request_id rqb
59 from fnd_concurrent_requests a, fnd_concurrent_requests b
60 where a.PARENT_REQUEST_ID = parrqid
61 and b.PARENT_REQUEST_ID = parrqid
62 and (a.CRM_RELEASE_DATE < b.actual_COMPLETION_DATE and
63 a.actual_completion_date > b.actual_start_date)
64 and ((a.concurrent_PROGRAM_ID = apid
65 and b.concurrent_PROGRAM_ID = cpid)
66 or
67 (b.concurrent_PROGRAM_ID = apid
68 and a.concurrent_PROGRAM_ID = cpid)
69 or
70 (a.cd_id = b.cd_id
71 and ((a.concurrent_PROGRAM_ID = apid
72 and b.concurrent_PROGRAM_ID = bpid)
73 or
74 (a.concurrent_PROGRAM_ID = bpid
75 and b.concurrent_PROGRAM_ID = apid))));
76
77 rdata varchar2(10);
78 rand number;
79 tdom number;
80 rqid number;
81 spid number;
82 apid number;
83 bpid number;
84 cpid number;
85 base number := 50;
86 i number := 1;
87 tot number := 0;
88 begin
89
90 rqid := FND_GLOBAL.CONC_REQUEST_ID;
91 rdata := fnd_conc_global.request_data;
92
93 if(rdata is null) then
94 rdata := 'YOHO';
95
96 /* Submit Random requests */
97 fnd_file.put_line(fnd_file.log, VOLREQ || ' requests.');
98 fnd_file.put_line(fnd_file.log, NUMDOM || ' domains.');
99
100 DBMS_RANDOM.INITIALIZE(rqid);
101
102 base := base - (NUMDOM / 2);
103
104
105 FOR i IN 1..VOLREQ
106 LOOP
107 rand := DBMS_RANDOM.VALUE(1,4);
108 rand := TRUNC(rand);
109 tdom := DBMS_RANDOM.VALUE(1,NUMDOM);
110 tdom := ROUND(tdom);
111 tdom := tdom + TRUNC(base);
112 if (i < 4) then rand := i;
113 end if;
114 if (rand = 1) then
115 spid := fnd_request.submit_request(application => 'FND',
116 program => 'FNDCRMTA',
117 sub_request => true,
118 argument1 => to_char(tdom),
119 argument2 => 'A');
120 elsif (rand = 2) then
121 spid := fnd_request.submit_request(application => 'FND',
122 program => 'FNDCRMTB',
123 sub_request => true,
124 argument1 => to_char(tdom),
125 argument2 => 'B');
126 else
127 spid := fnd_request.submit_request(application => 'FND',
128 program => 'FNDCRMTC',
129 sub_request => true,
130 argument1 => to_char(tdom),
131 argument2 => 'C');
132 end if;
133 if (spid = 0) then
134 fnd_file.put_line(fnd_file.log, 'Error in request submission');
135 end if;
136 END LOOP;
137
138 /* Wait for them to complete */
139
140 fnd_conc_global.set_req_globals(conc_status => 'PAUSED',
141 request_data => rdata);
142 errbuf := 'Sub Requests Submitted.';
143 retcode := 0;
144
145 else
146
147 /* Check for Conflicts */
148
149 select concurrent_program_id
150 into apid
151 from fnd_concurrent_programs p,fnd_application a
152 where a.application_id = p.application_id and p.concurrent_program_name = 'FNDCRMTA' and a.application_short_name='FND';
153
154 select concurrent_program_id
155 into bpid
156 from fnd_concurrent_programs p,fnd_application a
157 where a.application_id=p.application_id and p.concurrent_program_name = 'FNDCRMTB' and a.application_short_name='FND';
158
159 select concurrent_program_id
160 into cpid
161 from fnd_concurrent_programs p,fnd_application a
162 where a.application_id = p.application_id and p.concurrent_program_name = 'FNDCRMTC' and a.application_short_name='FND';
163
164 FOR con_rec in con_cursor(rqid, apid, bpid, cpid) LOOP
165 fnd_file.put_line(fnd_file.output,
166 'Collision between ' || con_rec.rqa || ' and ' || con_rec.rqb);
167 tot := tot+1;
168 END LOOP;
169
170 errbuf := tot || ' collisions detected.';
171 if (tot = 0) then
172 retcode := 0;
173 else
174 retcode := 1;
175 end if;
176
177 fnd_file.put_line(fnd_file.output, errbuf);
178 end if;
179 end diag_crm;
180
181 end fnd_diag_cm;