Produced by Araxis Merge on 9/25/2018 2:13:01 PM Central Daylight Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.
# | Location | File | Last Modified |
---|---|---|---|
1 | build 3.zip\build 3\MHLTH_YS_137_Source\JavaScript\resources\javaJDF-1.8.0\src\com\sun\corba\se\impl\activation | ServerManagerImpl.java | Mon Jan 22 14:46:38 2018 UTC |
2 | build 3.zip\build 3\MHLTH_YS_137_Source\JavaScript\resources\javaJDF-1.8.0\src\com\sun\corba\se\impl\activation | ServerManagerImpl.java | Wed Sep 12 16:17:47 2018 UTC |
Description | Between Files 1 and 2 |
|
---|---|---|
Text Blocks | Lines | |
Unchanged | 2 | 1288 |
Changed | 1 | 2 |
Inserted | 0 | 0 |
Removed | 0 | 0 |
Whitespace | |
---|---|
Character case | Differences in character case are significant |
Line endings | Differences in line endings (CR and LF characters) are ignored |
CR/LF characters | Not shown in the comparison detail |
No regular expressions were active.
1 | /* | |
2 | * Copyrig ht (c) 199 7, 2013, O racle and/ or its aff iliates. A ll rights reserved. | |
3 | * DO NOT ALTER OR R EMOVE COPY RIGHT NOTI CES OR THI S FILE HEA DER. | |
4 | * | |
5 | * This co de is free software; you can r edistribut e it and/o r modify i t | |
6 | * under t he terms o f the GNU General Pu blic Licen se version 2 only, a s | |
7 | * publish ed by the Free Softw are Founda tion. Ora cle design ates this | |
8 | * particu lar file a s subject to the "Cl asspath" e xception a s provided | |
9 | * by Orac le in the LICENSE fi le that ac companied this code. | |
10 | * | |
11 | * This co de is dist ributed in the hope that it wi ll be usef ul, but WI THOUT | |
12 | * ANY WAR RANTY; wit hout even the implie d warranty of MERCHA NTABILITY or | |
13 | * FITNESS FOR A PAR TICULAR PU RPOSE. Se e the GNU General Pu blic Licen se | |
14 | * version 2 for mor e details (a copy is included in the LIC ENSE file that | |
15 | * accompa nied this code). | |
16 | * | |
17 | * You sho uld have r eceived a copy of th e GNU Gene ral Public License v ersion | |
18 | * 2 along with this work; if not, write to the Fr ee Softwar e Foundati on, | |
19 | * Inc., 5 1 Franklin St, Fifth Floor, Bo ston, MA 0 2110-1301 USA. | |
20 | * | |
21 | * Please contact Or acle, 500 Oracle Par kway, Redw ood Shores , CA 94065 USA | |
22 | * or visi t www.orac le.com if you need a dditional informatio n or have any | |
23 | * questio ns. | |
24 | */ | |
25 | ||
26 | package co m.sun.corb a.se.impl. activation ; | |
27 | ||
28 | /** | |
29 | * | |
30 | * @author Rohi t Garg | |
31 | * @author Ken Cavanaugh | |
32 | * @author Hema nth Puttas wamy | |
33 | * @since JDK1 .2 | |
34 | */ | |
35 | ||
36 | import jav a.lang.ref lect.Const ructor; | |
37 | import jav a.util.Arr ayList; | |
38 | import jav a.util.Has hMap; | |
39 | import jav a.util.Ite rator; | |
40 | import jav a.util.NoS uchElement Exception; | |
41 | ||
42 | import org .omg.CORBA .OBJECT_NO T_EXIST; | |
43 | import org .omg.CORBA .SystemExc eption; | |
44 | ||
45 | import com .sun.corba .se.spi.ac tivation.E ndPointInf o; | |
46 | import com .sun.corba .se.spi.ac tivation.I IOP_CLEAR_ TEXT; | |
47 | import com .sun.corba .se.spi.ac tivation.O RBPortInfo ; | |
48 | import com .sun.corba .se.spi.ac tivation.R epository; | |
49 | import com .sun.corba .se.spi.ac tivation.L ocatorPack age.Server Location; | |
50 | import com .sun.corba .se.spi.ac tivation.L ocatorPack age.Server LocationPe rORB; | |
51 | import com .sun.corba .se.spi.ac tivation.R epositoryP ackage.Ser verDef; | |
52 | import com .sun.corba .se.spi.ac tivation._ ServerMana gerImplBas e; | |
53 | import com .sun.corba .se.spi.ac tivation.S erverAlrea dyActive; | |
54 | import com .sun.corba .se.spi.ac tivation.S erverAlrea dyInstalle d; | |
55 | import com .sun.corba .se.spi.ac tivation.S erverAlrea dyUninstal led; | |
56 | import com .sun.corba .se.spi.ac tivation.S erverNotRe gistered; | |
57 | import com .sun.corba .se.spi.ac tivation.O RBAlreadyR egistered; | |
58 | import com .sun.corba .se.spi.ac tivation.S erverHeldD own; | |
59 | import com .sun.corba .se.spi.ac tivation.S erverNotAc tive; | |
60 | import com .sun.corba .se.spi.ac tivation.N oSuchEndPo int; | |
61 | import com .sun.corba .se.spi.ac tivation.I nvalidORBi d; | |
62 | import com .sun.corba .se.spi.ac tivation.S erver; | |
63 | import com .sun.corba .se.spi.ac tivation.I IOP_CLEAR_ TEXT; | |
64 | import com .sun.corba .se.spi.io r.IORTempl ate ; | |
65 | import com .sun.corba .se.spi.io r.IOR ; | |
66 | import com .sun.corba .se.spi.io r.ObjectKe y ; | |
67 | import com .sun.corba .se.spi.io r.ObjectKe yTemplate ; | |
68 | import com .sun.corba .se.spi.io r.IORFacto ries ; | |
69 | import com .sun.corba .se.spi.io r.iiop.GIO PVersion ; | |
70 | import com .sun.corba .se.spi.io r.iiop.IIO PAddress ; | |
71 | import com .sun.corba .se.spi.io r.iiop.IIO PProfileTe mplate ; | |
72 | import com .sun.corba .se.spi.io r.iiop.IIO PFactories ; | |
73 | import com .sun.corba .se.spi.le gacy.conne ction.Lega cyServerSo cketEndPoi ntInfo; | |
74 | import com .sun.corba .se.spi.tr ansport.So cketOrChan nelAccepto r; | |
75 | import com .sun.corba .se.spi.or b.ORB ; | |
76 | import com .sun.corba .se.spi.pr otocol.For wardExcept ion; | |
77 | import com .sun.corba .se.spi.tr ansport.Co rbaTranspo rtManager; | |
78 | ||
79 | import com .sun.corba .se.spi.lo gging.CORB ALogDomain s ; | |
80 | import com .sun.corba .se.impl.l ogging.Act ivationSys temExcepti on ; | |
81 | ||
82 | import com .sun.corba .se.impl.o a.poa.BadS erverIdHan dler; | |
83 | import com .sun.corba .se.impl.o rbutil.ORB Constants; | |
84 | import com .sun.corba .se.impl.o rbutil.ORB Utility; | |
85 | import com .sun.corba .se.impl.u til.Utilit y; | |
86 | ||
87 | public cla ss ServerM anagerImpl extends _ ServerMana gerImplBas e | |
88 | implem ents BadSe rverIdHand ler | |
89 | { | |
90 | // Usi ng HashMap , since sy nchronizat ion should be done b y the call ing | |
91 | // rou tines | |
92 | HashMa p serverTa ble; | |
93 | Reposi tory repos itory; | |
94 | ||
95 | CorbaT ransportMa nager tran sportManag er; | |
96 | int in itialPort; | |
97 | ORB or b; | |
98 | Activa tionSystem Exception wrapper; | |
99 | String dbDirName ; | |
100 | boolea n debug = false ; | |
101 | ||
102 | privat e int serv erStartupD elay; | |
103 | ||
104 | Server ManagerImp l(ORB orb, CorbaTran sportManag er transpo rtManager, | |
105 | Reposito ry reposit ory, Strin g dbDirNam e, boolean debug) | |
106 | { | |
107 | th is.orb = o rb; | |
108 | wr apper = Ac tivationSy stemExcept ion.get( o rb, CORBAL ogDomains. ORBD_ACTIV ATOR ) ; | |
109 | ||
110 | th is.transpo rtManager = transpor tManager; // REVISIT - NOT USE D. | |
111 | th is.reposit ory = repo sitory; | |
112 | th is.dbDirNa me = dbDir Name; | |
113 | th is.debug = debug ; | |
114 | ||
115 | Le gacyServer SocketEndP ointInfo e ndpoint = | |
116 | orb.getL egacyServe rSocketMan ager() | |
117 | .leg acyGetEndp oint(Legac yServerSoc ketEndPoin tInfo.BOOT _NAMING); | |
118 | ||
119 | in itialPort = ((Socket OrChannelA cceptor)en dpoint) | |
120 | .getServ erSocket() .getLocalP ort(); | |
121 | se rverTable = new Hash Map(256); | |
122 | ||
123 | // The Serve rStartupDe lay is the delay add ed after t he Server registers | |
124 | // end point informati on. This i s to allow the serve r to compl etely | |
125 | // initializ e after OR B is insta ntiated. | |
126 | se rverStartu pDelay = O RBConstant s.DEFAULT_ SERVER_STA RTUP_DELAY ; | |
127 | St ring dela y = System .getProper ty( ORBCon stants.SER VER_STARTU P_DELAY); | |
128 | if ( delay != null ) { | |
129 | try { | |
130 | serv erStartupD elay = Int eger.parse Int( delay ); | |
131 | } catch ( Exceptio n e ) { | |
132 | // J ust use th e default 1000 milli seconds as the defau lt | |
133 | } | |
134 | } | |
135 | ||
136 | Cl ass cls = orb.getORB Data( ).ge tBadServer IdHandler( ); | |
137 | if ( cls == n ull ) { | |
138 | orb.setB adServerId Handler( t his ); | |
139 | } else { | |
140 | orb.init BadServerI dHandler() ; | |
141 | } | |
142 | ||
143 | or b.connect( this); | |
144 | Pr ocessMonit orThread.s tart( serv erTable ); | |
145 | } | |
146 | ||
147 | public void acti vate(int s erverId) | |
148 | th rows Serve rAlreadyAc tive, Serv erNotRegis tered, Ser verHeldDow n | |
149 | { | |
150 | ||
151 | Se rverLocati on locat ion; | |
152 | Se rverTableE ntry entry ; | |
153 | In teger key = new Inte ger(server Id); | |
154 | ||
155 | sy nchronized (serverTab le) { | |
156 | entry = (ServerTab leEntry) s erverTable .get(key); | |
157 | } | |
158 | ||
159 | if (entry != null && e ntry.isAct ive()) { | |
160 | if (debu g) | |
161 | Syst em.out.pri ntln( "Ser verManager Impl: acti vate for s erver Id " + | |
162 | serv erId + " f ailed beca use server is alread y active. " + | |
163 | "ent ry = " + e ntry ) ; | |
164 | ||
165 | throw ne w ServerAl readyActiv e( serverI d ); | |
166 | } | |
167 | ||
168 | // locate th e server | |
169 | tr y { | |
170 | ||
171 | // We ca ll getEntr y here so that state of the en try is | |
172 | // check ed for val idity befo re we actu ally go an d locate a server | |
173 | ||
174 | entry = getEntry(s erverId); | |
175 | ||
176 | if (debu g) | |
177 | Syst em.out.pri ntln( "Ser verManager Impl: loca teServer c alled with " + | |
178 | " server Id=" + ser verId + " endpointTy pe=" | |
179 | + IIOP_C LEAR_TEXT. value + " block=fals e" ) ; | |
180 | ||
181 | location = locateS erver(entr y, IIOP_CL EAR_TEXT.v alue, fals e); | |
182 | ||
183 | if (debu g) | |
184 | Syst em.out.pri ntln( "Ser verManager Impl: acti vate for s erver Id " + | |
185 | serv erId + " f ound locat ion " + | |
186 | loca tion.hostn ame + " an d activate d it" ) ; | |
187 | } catch (NoS uchEndPoin t ex) { | |
188 | if (debu g) | |
189 | Syst em.out.pri ntln( "Ser verManager Impl: acti vate for s erver Id " + | |
190 | " th rew NoSuch Endpoint e xception, which was ignored" ) ; | |
191 | } | |
192 | } | |
193 | ||
194 | public void acti ve(int ser verId, Ser ver server ) throws S erverNotRe gistered | |
195 | { | |
196 | Se rverTableE ntry entry ; | |
197 | In teger key = new Inte ger(server Id); | |
198 | ||
199 | sy nchronized (serverTa ble) { | |
200 | entry = (ServerTab leEntry) s erverTable .get(key); | |
201 | ||
202 | if (entr y == null) { | |
203 | if ( debug) | |
204 | System.out .println( "ServerMan agerImpl: active for server Id " + | |
205 | serverId + " called, but no su ch server is registe red." ) ; | |
206 | ||
207 | thro w wrapper. serverNotE xpectedToR egister() ; | |
208 | } else { | |
209 | if ( debug) | |
210 | System.out .println( "ServerMan agerImpl: active for server Id " + | |
211 | serverId + " called. This ser ver is now active." ) ; | |
212 | ||
213 | entr y.register (server); | |
214 | } | |
215 | } | |
216 | } | |
217 | ||
218 | public void regi sterEndpoi nts( int s erverId, S tring orbI d, | |
219 | En dPointInfo [] endpoi ntList ) t hrows NoSu chEndPoint , ServerNo tRegistere d, | |
220 | OR BAlreadyRe gistered | |
221 | { | |
222 | // orbId is ignored fo r now | |
223 | Se rverTableE ntry entry ; | |
224 | In teger key = new Inte ger(server Id); | |
225 | ||
226 | sy nchronized (serverTa ble) { | |
227 | entry = (ServerTab leEntry) s erverTable .get(key); | |
228 | ||
229 | if (entr y == null) { | |
230 | if ( debug) | |
231 | System.out .println( | |
232 | "Serve rManagerIm pl: regist erEndpoint for serve r Id " + | |
233 | server Id + " cal led, but n o such ser ver is reg istered." ) ; | |
234 | ||
235 | thro w wrapper. serverNotE xpectedToR egister() ; | |
236 | } else { | |
237 | if ( debug) | |
238 | System.out .println( | |
239 | "Serve rManagerIm pl: regist erEndpoint s for serv er Id " + | |
240 | server Id + " cal led. This server is now activ e." ) ; | |
241 | ||
242 | entr y.register Ports( orb Id, endpoi ntList ); | |
243 | ||
244 | } | |
245 | } | |
246 | } | |
247 | ||
248 | public int[] get ActiveServ ers() | |
249 | { | |
250 | Se rverTableE ntry entry ; | |
251 | in t[] list = null; | |
252 | ||
253 | sy nchronized (serverTa ble) { | |
254 | // unlik e vectors, list is n ot synchro nized | |
255 | ||
256 | ArrayLis t servers = new Arra yList(0); | |
257 | ||
258 | Iterator serverLis t = server Table.keyS et().itera tor(); | |
259 | ||
260 | try { | |
261 | whil e (serverL ist.hasNex t()) { | |
262 | Integer ke y = (Integ er) server List.next( ); | |
263 | // get an entry | |
264 | entry = (S erverTable Entry) ser verTable.g et(key); | |
265 | ||
266 | if (entry. isValid() && entry.i sActive()) { | |
267 | server s.add(entr y); | |
268 | } | |
269 | } | |
270 | } catch (NoSuchEle mentExcept ion e) { | |
271 | // a ll done | |
272 | } | |
273 | ||
274 | // colle ct the act ive entrie s | |
275 | list = n ew int[ser vers.size( )]; | |
276 | for (int i = 0; i < servers. size(); i+ +) { | |
277 | entr y = (Serve rTableEntr y) servers .get(i); | |
278 | list [i] = entr y.getServe rId(); | |
279 | } | |
280 | } | |
281 | ||
282 | if (debug) { | |
283 | StringBu ffer sb = new String Buffer() ; | |
284 | for (int ctr=0; ct r<list.len gth; ctr++ ) { | |
285 | sb.a ppend( ' ' ) ; | |
286 | sb.a ppend( lis t[ctr] ) ; | |
287 | } | |
288 | ||
289 | System.o ut.println ( "ServerM anagerImpl : getActiv eServers r eturns" + | |
290 | sb.toStr ing() ) ; | |
291 | } | |
292 | ||
293 | re turn list; | |
294 | } | |
295 | ||
296 | public void shut down(int s erverId) t hrows Serv erNotActiv e | |
297 | { | |
298 | Se rverTableE ntry entry ; | |
299 | In teger key = new Inte ger(server Id); | |
300 | ||
301 | sy nchronized (serverTab le) { | |
302 | entry = (ServerTab leEntry) s erverTable .remove(ke y); | |
303 | ||
304 | if (entr y == null) { | |
305 | if ( debug) | |
306 | System.out .println( "ServerMan agerImpl: shutdown f or server Id " + | |
307 | serv erId + " t hrows Serv erNotActiv e." ) ; | |
308 | ||
309 | thro w new Serv erNotActiv e( serverI d ); | |
310 | } | |
311 | ||
312 | try { | |
313 | entr y.destroy( ); | |
314 | ||
315 | if ( debug) | |
316 | System.out .println( "ServerMan agerImpl: shutdown f or server Id " + | |
317 | serv erId + " c ompleted." ) ; | |
318 | } catch (Exception e) { | |
319 | if ( debug) | |
320 | System.out .println( "ServerMan agerImpl: shutdown f or server Id " + | |
321 | serv erId + " t hrew excep tion " + e ) ; | |
322 | } | |
323 | } | |
324 | } | |
325 | ||
326 | privat e ServerTa bleEntry g etEntry( i nt serverI d ) | |
327 | th rows Serve rNotRegist ered | |
328 | { | |
329 | In teger key = new Inte ger(server Id); | |
330 | Se rverTableE ntry entry = null ; | |
331 | ||
332 | sy nchronized (serverTa ble) { | |
333 | entry = (ServerTab leEntry) s erverTable .get(key); | |
334 | ||
335 | if (debu g) | |
336 | if ( entry == n ull) { | |
337 | System.out .println( "ServerMan agerImpl: getEntry: " + | |
338 | "no active server fo und." ) ; | |
339 | } el se { | |
340 | System.out .println( "ServerMan agerImpl: getEntry: " + | |
341 | " active s erver foun d " + entr y + "." ) ; | |
342 | } | |
343 | ||
344 | if ((ent ry != null ) && (!ent ry.isValid ())) { | |
345 | serv erTable.re move(key); | |
346 | entr y = null; | |
347 | } | |
348 | ||
349 | if (entr y == null) { | |
350 | Serv erDef serv erDef = re pository.g etServer(s erverId); | |
351 | ||
352 | entr y = new Se rverTableE ntry( wrap per, | |
353 | serverId, serverDef, initialPo rt, dbDirN ame, false , debug); | |
354 | serv erTable.pu t(key, ent ry); | |
355 | entr y.activate () ; | |
356 | } | |
357 | } | |
358 | ||
359 | re turn entry ; | |
360 | } | |
361 | ||
362 | privat e ServerLo cation loc ateServer (ServerTab leEntry en try, Strin g endpoint Type, | |
363 | boolean bl ock) | |
364 | th rows NoSuc hEndPoint, ServerNot Registered , ServerHe ldDown | |
365 | { | |
366 | Se rverLocati on locatio n = new Se rverLocati on() ; | |
367 | ||
368 | // if server location is desired , then wai t for the server | |
369 | // to regist er back, t hen return location | |
370 | ||
371 | OR BPortInfo [] serverO RBAndPortL ist; | |
372 | if (block) { | |
373 | try { | |
374 | serverORBA ndPortList = entry.l ookup(endp ointType); | |
375 | } catch (Exception ex) { | |
376 | if ( debug) | |
377 | System.out .println( "ServerMan agerImpl: locateServ er: " + | |
378 | "server he ld down" ) ; | |
379 | ||
380 | thro w new Serv erHeldDown ( entry.ge tServerId( ) ); | |
381 | } | |
382 | ||
383 | String h ost = | |
384 | orb. getLegacyS erverSocke tManager() | |
385 | .legacyGet Endpoint(L egacyServe rSocketEnd PointInfo. DEFAULT_EN DPOINT).ge tHostName( ); | |
386 | location .hostname = host ; | |
387 | int list Length; | |
388 | if (serv erORBAndPo rtList != null) { | |
389 | list Length = s erverORBAn dPortList. length; | |
390 | } else { | |
391 | list Length = 0 ; | |
392 | } | |
393 | location .ports = n ew ORBPort Info[listL ength]; | |
394 | for (int i = 0; i < listLeng th; i++) { | |
395 | loca tion.ports [i] = new ORBPortInf o(serverOR BAndPortLi st[i].orbI d, | |
396 | server ORBAndPort List[i].po rt) ; | |
397 | ||
398 | if ( debug) | |
399 | System.out .println( "ServerMan agerImpl: locateServ er: " + | |
400 | "ser ver locate d at locat ion " + | |
401 | loca tion.hostn ame + " OR Bid " + | |
402 | serv erORBAndPo rtList[i]. orbId + | |
403 | " Po rt " + ser verORBAndP ortList[i] .port) ; | |
404 | } | |
405 | } | |
406 | ||
407 | re turn locat ion; | |
408 | } | |
409 | ||
410 | privat e ServerLo cationPerO RB locateS erverForOR B (ServerT ableEntry entry, Str ing orbId, | |
411 | boolean bl ock) | |
412 | th rows Inval idORBid, S erverNotRe gistered, ServerHeld Down | |
413 | { | |
414 | Se rverLocati onPerORB l ocation = new Server LocationPe rORB() ; | |
415 | ||
416 | // if server location is desired , then wai t for the server | |
417 | // to regist er back, t hen return location | |
418 | ||
419 | En dPointInfo [] endpoi ntInfoList ; | |
420 | if (block) { | |
421 | try { | |
422 | endp ointInfoLi st = entry .lookupFor ORB(orbId) ; | |
423 | } catch (InvalidOR Bid ex) { | |
424 | thro w ex; | |
425 | } catch (Exception ex) { | |
426 | if ( debug) | |
427 | System.out .println( "ServerMan agerImpl: locateServ erForORB: " + | |
428 | "server he ld down" ) ; | |
429 | ||
430 | thro w new Serv erHeldDown ( entry.ge tServerId( ) ); | |
431 | } | |
432 | ||
433 | String h ost = | |
434 | orb. getLegacyS erverSocke tManager() | |
435 | .legacyGet Endpoint(L egacyServe rSocketEnd PointInfo. DEFAULT_EN DPOINT).ge tHostName( ); | |
436 | location .hostname = host ; | |
437 | int list Length; | |
438 | if (endp ointInfoLi st != null ) { | |
439 | list Length = e ndpointInf oList.leng th; | |
440 | } else { | |
441 | list Length = 0 ; | |
442 | } | |
443 | location .ports = n ew EndPoin tInfo[list Length]; | |
444 | for (int i = 0; i < listLeng th; i++) { | |
445 | loca tion.ports [i] = new EndPointIn fo(endpoin tInfoList[ i].endpoin tType, | |
446 | endpoi ntInfoList [i].port) ; | |
447 | ||
448 | if ( debug) | |
449 | System.out .println( "ServerMan agerImpl: locateServ er: " + | |
450 | "ser ver locate d at locat ion " + | |
451 | loca tion.hostn ame + " en dpointType " + | |
452 | endp ointInfoLi st[i].endp ointType + | |
453 | " Po rt " + end pointInfoL ist[i].por t) ; | |
454 | } | |
455 | } | |
456 | ||
457 | re turn locat ion; | |
458 | } | |
459 | ||
460 | public String[] getORBName s(int serv erId) | |
461 | th rows Serve rNotRegist ered | |
462 | { | |
463 | tr y { | |
464 | ServerTa bleEntry e ntry = get Entry( ser verId ) ; | |
465 | return ( entry.getO RBList()); | |
466 | } catch (Exc eption ex) { | |
467 | throw ne w ServerNo tRegistere d(serverId ); | |
468 | } | |
469 | } | |
470 | ||
471 | privat e ServerTa bleEntry g etRunningE ntry( int serverId ) | |
472 | th rows Serve rNotRegist ered | |
473 | { | |
474 | Se rverTableE ntry entry = getEntr y( serverI d ) ; | |
475 | ||
476 | tr y { | |
477 | // this is to see if the ser ver has an y listener s | |
478 | ORBPortI nfo [] ser verORBAndP ortList = entry.look up(IIOP_CL EAR_TEXT.v alue) ; | |
479 | } catch (Exc eption exc ) { | |
480 | return n ull ; | |
481 | } | |
482 | re turn entry ; | |
483 | ||
484 | } | |
485 | ||
486 | public void inst all( int s erverId ) | |
487 | th rows Serve rNotRegist ered, Serv erHeldDown , ServerAl readyInsta lled | |
488 | { | |
489 | Se rverTableE ntry entry = getRunn ingEntry( serverId ) ; | |
490 | if (entry != null) { | |
491 | reposito ry.install ( serverId ) ; | |
492 | entry.in stall() ; | |
493 | } | |
494 | } | |
495 | ||
496 | public void unin stall( int serverId ) | |
497 | th rows Serve rNotRegist ered, Serv erHeldDown , ServerAl readyUnins talled | |
498 | { | |
499 | Se rverTableE ntry entry = | |
500 | (ServerT ableEntry) serverTab le.get( ne w Integer( serverId) ); | |
501 | ||
502 | if (entry != null) { | |
503 | ||
504 | entry = | |
505 | (Ser verTableEn try) serve rTable.rem ove(new In teger(serv erId)); | |
506 | ||
507 | if (entr y == null) { | |
508 | if ( debug) | |
509 | System.out .println( "ServerMan agerImpl: shutdown f or server Id " + | |
510 | serv erId + " t hrows Serv erNotActiv e." ) ; | |
511 | ||
512 | thro w new Serv erHeldDown ( serverId ); | |
513 | } | |
514 | ||
515 | entry.un install(); | |
516 | } | |
517 | } | |
518 | ||
519 | public ServerLoc ation loca teServer ( int server Id, String endpointT ype) | |
520 | th rows NoSuc hEndPoint, ServerNot Registered , ServerHe ldDown | |
521 | { | |
522 | Se rverTableE ntry entry = getEntr y( serverI d ) ; | |
523 | if (debug) | |
524 | System.o ut.println ( "ServerM anagerImpl : locateSe rver calle d with " + | |
525 | " server Id=" + ser verId + " endpointTy pe=" + | |
526 | endpoint Type + " b lock=true" ) ; | |
527 | ||
528 | // passing i n entry to eliminate multiple lookups fo r | |
529 | // the same entry in s ome cases | |
530 | ||
531 | re turn locat eServer(en try, endpo intType, t rue); | |
532 | } | |
533 | ||
534 | /** Th is method is used to obtain th e register ed ports f or an ORB. | |
535 | * This is useful for custo m Bad serv er ID hand lers in OR BD. | |
536 | */ | |
537 | public ServerLoc ationPerOR B locateSe rverForORB (int serv erId, Stri ng orbId) | |
538 | th rows Inval idORBid, S erverNotRe gistered, ServerHeld Down | |
539 | { | |
540 | Se rverTableE ntry entry = getEntr y( serverI d ) ; | |
541 | ||
542 | // passing i n entry to eliminate multiple lookups fo r | |
543 | // the same entry in s ome cases | |
544 | ||
545 | if (debug) | |
546 | System.o ut.println ( "ServerM anagerImpl : locateSe rverForORB called wi th " + | |
547 | " server Id=" + ser verId + " orbId=" + orbId + | |
548 | " block= true" ) ; | |
549 | re turn locat eServerFor ORB(entry, orbId, tr ue); | |
550 | } | |
551 | ||
552 | ||
553 | public void hand le(ObjectK ey okey) | |
554 | { | |
555 | IO R newIOR = null; | |
556 | Se rverLocati onPerORB l ocation; | |
557 | ||
558 | // we need t o get the serverid a nd the orb id from th e object k ey | |
559 | Ob jectKeyTem plate okte mp = okey. getTemplat e(); | |
560 | in t serverId = oktemp. getServerI d() ; | |
561 | St ring orbId = oktemp. getORBId() ; | |
562 | ||
563 | tr y { | |
564 | // get t he ORBName correspon ding to th e orbMapid , that was | |
565 | // first registere d by the s erver | |
566 | ServerTa bleEntry e ntry = get Entry( ser verId ) ; | |
567 | location = locateS erverForOR B(entry, o rbId, true ); | |
568 | ||
569 | if (debu g) | |
570 | Syst em.out.pri ntln( "Ser verManager Impl: hand le called for server id" + | |
571 | server Id + " or bid " + o rbId) ; | |
572 | ||
573 | // we re ceived a l ist of por ts corresp onding to an ORB in a | |
574 | // parti cular serv er, now re trieve the one corre sponding | |
575 | // to II OP_CLEAR_T EXT, and f or other c reated the tagged | |
576 | // compo nents to b e added to the IOR | |
577 | ||
578 | int clearP ORT
|
|
579 | EndPoint Info[] lis tenerPorts = locatio n.ports; | |
580 | for (int i = 0; i < listener Ports.leng th; i++) { | |
581 | if ( (listenerP orts[i].en dpointType ).equals(I IOP_CLEAR_ TEXT.value )) { | |
582 | clearPort = listener Ports[i].p ort; | |
583 | break; | |
584 | } | |
585 | } | |
586 | ||
587 | // creat e a new IO R with the correct p ort and co rrect tagg ed | |
588 | // compo nents | |
589 | IIOPAddr ess addr = IIOPFacto ries.makeI IOPAddress ( orb, | |
590 | loca tion.hostn ame, clear Port ) ; | |
591 | IIOPProf ileTemplat e iptemp = | |
592 | IIOP Factories. makeIIOPPr ofileTempl ate( | |
593 | orb, GIOPV ersion.V1_ 2, addr ) ; | |
594 | if (GIOP Version.V1 _2.support sIORIIOPPr ofileCompo nents()) { | |
595 | ipte mp.add(IIO PFactories .makeCodeS etsCompone nt(orb)); | |
596 | ipte mp.add(IIO PFactories .makeMaxSt reamFormat VersionCom ponent()); | |
597 | } | |
598 | IORTempl ate iortem p = IORFac tories.mak eIORTempla te(oktemp) ; | |
599 | iortemp. add( iptem p ) ; | |
600 | ||
601 | newIOR = iortemp.m akeIOR(orb , "IDL:org /omg/CORBA /Object:1. 0", | |
602 | okey .getId() ) ; | |
603 | } catch (Exc eption e) { | |
604 | throw wr apper.erro rInBadServ erIdHandle r( e ) ; | |
605 | } | |
606 | ||
607 | if (debug) | |
608 | System.o ut.println ( "ServerM anagerImpl : handle " + | |
609 | "throws ForwardExc eption" ) ; | |
610 | ||
611 | ||
612 | tr y { | |
613 | // This delay is r equired in case of S erver is a ctivated o r | |
614 | // re-ac tivated th e first ti me. Server needs som e time bef ore | |
615 | // handl ing all th e requests . | |
616 | // (Talk to Ken to see wheth er there i s a better way of do ing this). | |
617 | Thread.s leep( serv erStartupD elay ); | |
618 | } catch ( Ex ception e ) { | |
619 | System.o ut.println ( "Excepti on = " + e ); | |
620 | e.printS tackTrace( ); | |
621 | } | |
622 | ||
623 | th row new Fo rwardExcep tion(orb, newIOR); | |
624 | } | |
625 | ||
626 | public int getEn dpoint(Str ing endpoi ntType) th rows NoSuc hEndPoint | |
627 | { | |
628 | re turn orb.g etLegacySe rverSocket Manager() | |
629 | .legacyG etTransien tServerPor t(endpoint Type); | |
630 | } | |
631 | ||
632 | public int getSe rverPortFo rType(Serv erLocation PerORB loc ation, | |
633 | Stri ng endPoin tType) | |
634 | th rows NoSuc hEndPoint | |
635 | { | |
636 | En dPointInfo [] listene rPorts = l ocation.po rts; | |
637 | fo r (int i = 0; i < li stenerPort s.length; i++) { | |
638 | if ((lis tenerPorts [i].endpoi ntType).eq uals(endPo intType)) { | |
639 | retu rn listene rPorts[i]. port; | |
640 | } | |
641 | } | |
642 | th row new No SuchEndPoi nt(); | |
643 | } | |
644 | ||
645 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.