1 /** -*- HTML-Helper -*-
3 @mainpage Implementation Repository
5 @section intro Introduction
7 The purpose of the Implementation Repository (ImR) in TAO is for the automatic
8 activation of a TAO server when a method is invoked but the server is not
9 running. It does this by working with the server to keep track of when it is
10 activated and stores information on how to reactivate it. Method
11 invocations on the server will actually be sent to the Implementation
12 Repository, which will then be able to start the server process if it is not
13 already running and forward the invocation to the real server.
15 @section resources Resources
17 The ImR in TAO was first based on a paper on the subject by
18 <a href="http://www.triodia.com/staff/michi-henning.html">Michi Henning</a>
19 called <a href="http://www.triodia.com/staff/michi/cacm.pdf">Binding,
20 Migration, and Scalability in CORBA</a>. Mr. Henning later went on to
22 <a href="http://cseng.awl.com/bookdetail.qry?ISBN=0-201-37927-9&ptype=0">
23 Advanced CORBA Programming in C++</a> and included a chapter on the
24 Implementation Repository. The description of the ImR in this chapter is used
25 as the specification for TAO's ImR.
27 @ref usersguide - Overall documentation on how to use the ImR in your programs
29 @ref ntservice - Running the ImR as a NT Service
31 @ref imrandnaming - Using the Naming Service with the Implementation Repository
33 @section authors Authors
35 The guy who first worked on ImR and provided a base for the current
36 ImR is Darrell Brunsch
37 @<<a href="mailto:brunsch@cs.wustl.edu">brunsch@cs.wustl.edu</a>@>.
38 The current version is developed by Phil Mesnier
39 @<<a href="mailto:mesnier_p@ociweb.com">mesnier_p@ociweb.com</a>@>.
40 You can reach us by either email (which is better), or through the
41 <a href="http://www.dre.vanderbilt.edu/~schmidt/ACE-mail.html">ACE mailing list</a>
42 @<<a href="mailto:ace-users@list.isis.vanderbilt.edu">ace-users@list.isis.vanderbilt.edu</a>@>.
43 If you use the mailing list, it is required to join it before sending
44 a question since responses are usually just replied back to the group.
46 The NT Service part of the ImR was developed by Jeff Parsons @<<a
47 href="mailto:parsons@cs.wustl.edu">parsons@cs.wustl.edu</a>@>. He can
48 also be reached via the same channels.
49 It was later extended and enhanced by Justin Michel <michel_j@ociweb.com>
55 @page usersguide Implementation Repository User's Guide
57 In order for a server to make use of the Implementation Repository, it must
58 communicate with the ImR to keep it up to date on such things as the server's
59 running status. These functions now are contained within the POA, so when a
60 Persistent POA is used on a server that has -ORBUseImR specified, it will
61 communicate with an Implementation Repository, if one is available.
63 @subsection description The ImR
65 The ImR is based on the ImR in TAO 1.2.2 with added features to help
66 improve throughput and load balancing. The work to be performed by the
67 Implementation Repository is distributed between two entities (locator
68 and activator) to help achieve the goal of better throughput and load
71 @subsection locator tao_imr_locator
73 The locator acts as the main server which is visible to the
74 application intending to use the ImR. It receives requests sent via
75 tao_imr and distributes the work to the registered activators. It is
76 stateless and does not maintain any information except about the
77 activators that are registered with it. Its job is to act as a
78 mediator between the application and the actual activator that does
79 the real work. As of now, we only support one locator to be running at
80 any time. locator can be reached through the usual methods of
81 -ORBInitRef and -ORBDefaultInitRef and multicast.
83 Commandline Arguments that can be passed to tao_imr_locator
85 -d <level 0..10> locator specific debug level
86 -m support multicast discovery.
87 -l lock the repository, making it read only.
88 -o <filename> write the ior to the file.
89 -t <timeout> specify a startup timeout value (default 60 seconds)
90 -i periodically ping servers to check liveness.
91 -v the minimum successful ping interval. (default 10 seconds)
92 -g the timeout for ping attempts. (default 1 second)
93 -s run as a winNT service
94 -c <command> execute the named service command: install, remove
95 -x <filename> support persistence to the locator. We use XML to support
96 persistence. Names of the activators registered with the locator,
97 their IORs, and the servers registered with each of the activators are
98 saved to the xml file. Use this option to pass the name of the file
99 where the data has to be saved.
100 -p <filename> similar to "-x" but using an ACE_Configuration_Heap file to persist
102 -r similar to "-p" but using an ACE_Configuration_Win32Registry to persist
103 the data. (only available on Win32 platforms)
104 --directory <path> similar to "-x" option, but the repository will be written out
105 to multiple files in the indicated directory: "imr_listings.xml" which
106 indicates all servers and activators in the repository indicating the
107 filename containing that server's or activator's persistence data.
108 This option is used along with the "--primary" or "--backup" option
109 to create a Fault Tolerant locator.
110 --primary pass along with "--directory <dir>" to startup the primary
111 ImR_Locator. See ft_imr_locator subsection.
112 --backup pass along with "--directory <dir>" to startup the backup
113 ImR_Locator. See ft_imr_locator subsection.
114 -UnregisterIfAddressReused Enable the verification that a newly started server is reusing
115 the endpoint address of another server that it is not linked with. If it
116 finds this case, and the existing server is not running, its registration
119 And, of course, the ORB Options.
121 @subsection ft_imr_locator FaultTolerant_ImR_Locator
123 The ImR_Locator implements a fault tolerant service with the following options:
125 The --primary option tells the ImR_Locator that it will startup as the primary
126 in a redundant service pair.
128 The --backup option tells the ImR_Locator that it will startup as the backup
129 in a redundant service pair.
131 The --directory <ft_imr_shared_dir> option tells the ImR_Locator the shared
132 file system directory to use as the backing store for the redundant service
135 The -o <ft_imr_ior_filename> option tells the ImR_Locator to output the
136 redundant service pair ImRService ior file, which it can only do after
137 successfully starting the primary and backup ImRService instances. The ior
138 file contains the combined profiles of the primary and backup ImRLocators. The
139 client must use the ior file to use the fault tolerant locator.
141 The primary and backup ImRLocator instances should have the same ORBEndPoint
142 protocol list so that any client can send a request to either primary or backup
143 regardless of protocol (IIOP,UIOP,etc...).
145 The ImR_Locator primary and backup options cannot be passed on the command
146 line along with -ORBObjRefStyle URL, since that style will cause the backup
147 profile to not be available in the ior.
149 At startup the primary must be started first, then the backup. When
150 a single ImR_Locator goes down, it can be restarted at anytime
151 (using the same ORBEndPoints). If they are both shutdown after a successful
152 startup of the redundant pair, then either the primary or backup can be
153 restarted first. With only a single server running, there is no fault
154 tolerance support, but the original fault tolerant ior which was created
155 by the backup with the -o option can still be used as long as the ORBEndPoint
156 list remains the same for both instances.
158 As long as both the primary and backup ImR_Locators are not shutdown at the
159 same time the Fault Tolerant locator will always be available.
161 @subsection ft_imr_locator_startup FaultTolerant_ImR_Locator Startup
165 <em>Start the primary.</em><br>
166 It will write the replication ior to a file in the shared persistence
171 -ORBEndpoint <primary_hostname:port>
172 --directory <ft_imr_shared_dir>
176 </em>Start the backup.</em><br>
177 Reads the primary replication ior from the shared persistence directory.<br>
178 Writes the multi-profile ior to ft_imr_ior_filename<br>.
182 -ORBEndpoint <backup_hostname:port>
183 --directory <ft_imr_shared_dir>
184 -o <ft_imr_ior_filename>
189 @subsection activator tao_imr_activator
191 Activators, as you might have guessed, do the real work of
192 activating servers or shutting them down and maintaining the information
193 about servers related to them. Only one instance of an activator
194 can be run on one host. The activator is not exposed at all to the
195 application. Only the locator needs to and it is the only one that
196 can contact the activator.
198 An instance of tao_imr_activator first registers itself with the
199 locator so that it can begin to receive requests. When registering
200 with the locator, it passes the hostname where it is being run and
201 its IOR to the locator. And, the locator reaches it using the
204 The Commandline parameters that are valid for tao_imr_activator are
206 -c Run the Service command: install, remove, install_no_imr
207 -d <level 0..5> Debug Information
208 -l Notify the locator of server state changes
209 -o <filename> Write the IOR to a file
210 -s Run as a winNT service.
211 -e <length> Supply an Environment buffer length
212 -m <count> Supply a max number of Environment variables
213 -delay <time> A testing parameter used to impose a delay after the
214 detection of a child process death before notifying the
215 locator of the termination. Should not be used in
216 production environments
217 -detach <1|0> Override the default child-process detachment. By default
218 this value is 0, indicating the child process will terminate.
219 This may also be set or overridden by adding
220 #define IMR_DETACH_CHILD_DEF
221 to your $ACE_ROOT/ace/config.h file to make the default value 1.
224 @subsection work So how does the whole thing work?
226 The first thing to do is to have a locator running. Once the locator
227 is running, we can instantiate one or more activators as needed per
228 the application. As mentioned already, the activators, upon
229 instantiation, register with the locator to be able to receive
232 When a new server has to be added or any change has to the done to an
233 existing server, a request is to be sent to the locator via the
234 tao_imr utility. Startup commands, the working directory, the host
235 where the server should be started up and such other information are
236 passed to the locator via the tao_imr command line arguments.
238 If the host where the server should be started up is passed while
239 adding a new server, the locator chooses the activator that is running
240 on that host to be responsible for the server's activities. Otherwise,
241 an activator is chosen based on the Round robin algorithm. We plan to
242 use better algorithms based on the existing load for the same purpose
243 in future. Whatever way the activator is chosen for a server, once an
244 activator is chosen, that activator remains responsible for the server
245 throughout the server's lifetime.
247 After an activator is chosen, the locator passes the request to the
248 chosen activator. The activator acts on the request and updates its
249 database to reflect the new state of the server.
251 @subsection run How is the ImR run?
254 <li>First run the <b>tao_imr_locator</b>
255 <em>Example:<code> </code> </em><code> tao_imr_locator -o locator.ior<br></code>
256 <li>Run the <b>Activator</b>
257 <em>Example:<code> </code> </em><code> tao_imr_activator -ORBInitRef ImplRepoService=file://locator.ior<br></code>
259 @subsection use How is the ImR used?
261 The main steps for the lifetime of a server that uses the ImR are generally
265 <li>Register name and startup commands with the ImR using <b>tao_imr<br>
266 </b><em>Example:<code> </code> </em><code> tao_imr -ORBInitRef
267 ImplRepoService=file://locator.ior add plane -c "airplane_server -i
268 -ORBInitRef ImplRepoService=file://locator.ior"<br></code>
270 Note that the name used to register the server is the name of the POA
271 which the objects are created in. So in this example, the airplane_server
272 creates a POA called "plane" and activates its servants under
274 <li>Start the server once to generate an ImR-ified IOR<br>
275 <li>Start clients and pass them the above IOR<br>
276 <li>Clients will use the IOR, which will automatically go through the ImR<br>
277 <li>The ImR will start the server if it is not already running<br>
278 <li>At any time when the server is not currently in use by a client, it can be
279 shut down using <strong>tao_imr<br></strong><em>Example:</em><code> tao_imr
280 -ORBInitRef ImplRepoService=file://locator.ior shutdown plane<br>
282 <li>After the server isn't needed anymore, it can be removed from the ImR database
283 using <strong>tao_imr<br></strong><em>Example:<code> </em>tao_imr -ORBInitRef
284 ImplRepoService=file://locator.ior remove plane</code>
287 @subsection serverresponsibilities So what does the server need to do?
289 A server must be run with the argument "-ORBUseImR 1" supplied to
290 ORB_init. Then any object managed by a <strong>persistent</strong> POA will
291 be reachable via the ImR locator. The locator must also be reachable by the
292 server, using -ORBInitRef ImplRepoService=<ior> or similar.
294 @subsection defaultinitref Use of -ORBDefaultInitRef with the ImR
296 As mentioned in the INS documentation (in TAO/docs/INS.html), a base IOR
297 can be passed to the ORB. Then when resolve_initial_reference is called,
298 the ORB can append the service name to the base IOR to form a full IOR.
300 When used with the ImR, this can be a powerful feature. If the ImR's endpoint
301 is used as the base IOR, then the ImR can be used to provide many services via
302 the resolve_initial_reference functionality.
304 For example, let's say the ImR service is running on doriath on port 5555 and
305 the Name Service is already registered with the ImR (in that the ImR knows how
306 to start the Name Service).
308 Now we should be able to run some client that uses the Name Service like this:
310 <code>client -ORBDefaultInitRef corbaloc:iiop:doriath:5555/</code>
312 When the client calls resolve_initial_reference("NameService"), the ORB will
313 resolve that to "corbaloc:iiop:doriath:5555/NameService". The ImR
314 recognizes this IOR as a pointer to the NameService, and will then
315 start it up if necessary. Finally, it will forward the client to the
318 Services used in this way have two requirements:
320 - The server must be registered as the request_initial_reference name. For
321 example, the Name Service is registered as the "NameService", and thus also
322 contains a POA with the name "NameService".
323 - The server must also be able to handle the INS name
324 "corbaloc:iiop:machine:port/poa_name", where the poa_name is the
327 @subsection activationmodes What are activation modes
329 Each server can have one of three different types of activation modes:
332 <li>NORMAL is the default. The server can be started via tao_imr,
333 the command line, and with client requests.
334 <li>MANUAL specifies that the server shouldn't be activated with a
335 client request but can be activated through tao_imr or via the
337 <li>PER_CLIENT specifies that each request to the ImplRepo will
338 result in a new server process started up. Because clients
339 cache the forwarded reference, there is one server per client
340 (more or less). There are some exceptions, such as if the
341 original IOR is used in different threads (each thread would get
342 a different server). <b>Note:</b> The Implementation Repository
343 doesn't store any information about the started servers in this
344 mode, so it cannot be used to shut down the servers. So the
345 servers must have an alternative way of shutting down.
346 <li>AUTO_START specifies that a server should be activated when the
347 Implementation Repository is started. tao_imr also has an
348 autostart command to activate all servers marked AUTO_START.
351 @subsection taoImRior Using the tao_imr ior command
353 First, some background.
355 For the longest time, there was no way with TAO's Implementation
356 Repository to register a server and then start using the client
357 immediately. The server had to be started once just for the purpose
358 of creating an IOR for the client to use. The problem was that it was
359 very difficult to create an IOR without running the server.
361 It would be nice to be able to generate a valid IOR without requiring
362 the program to be run. A valid IOR in this case requires two major
363 things. First it requires the endpoint of the ImR. This is relatively
364 easy to get, since it is encoded in the ImR's IOR. Second it also
365 requires an object key. At the least, this involves both the POA
366 hierarchy and the object name.
368 So if we knew the POA and object names, then we should be able to
369 create an IOR for the server. One possibility would be to have tao_imr
370 ask for both the POA and the object, and then create the POA hierarchy
371 to generate an IOR. Doing the generation is this manner (letting the
372 POA create the reference) shields us from changes in the IOR
373 generation schemes. Since we are using the same code that the server
374 would use, our IORs would be up to date.
376 It ends up there is an easier way to do this. The Interoperable
377 Naming Service is intended to be used in situations where an IOR could
378 be created by hand. Using the same information as above, it is not
379 difficult to take the endpoint information from the ImR and attach the
380 POA name. For example, let's say that we are running the ImR on
381 ringil.ece.uci.edu at port 5000. The endpoint would be
382 "corbaloc:iiop:1.2@ringil.ece.uci.edu:5000". If we are
383 creating an IOR for the nestea server, we'd just need to attach
384 "/nestea_server" to the end of the endpoint. Now we have an
387 So what does this mean for the server?
389 The main issue here is that the server must be changed to support the
390 simplified name. This can be done by using the IORTable like this:
393 CORBA::Object_var table_object =
394 this->orb_->resolve_initial_references ("IORTable";
396 IORTable::Table_var adapter =
397 IORTable::Table::_narrow (table_object.in ());
399 if (CORBA::is_nil (adapter.in ()))
401 ACE_ERROR ((LM_ERROR, "Nil IORTable\n"));
405 adapter->bind (poa_name, server_str.in ());
409 These lines, as taken from the nestea_server example, just uses the same
410 poa_name as registered with the ImR and associates it with the server_obj
411 object in the IOR table. Because the ImR will be able to handle the
412 simplified name (if it uses the POA name scheme) then this IOR will work.
414 Just one more thing, each object that needs an IOR needs to be registered
415 with the IOR table. But this raises the problem of uniqueness; they all
416 can't have the same name. The ImR will actually only look at the name part
417 of the simplified IOR up to the first "/". So both
418 "corbaloc:iiop:1.2@ringil:5000/nestea_server/foo" and
419 "corbaloc:iiop:1.2@ringil:5000/nestea_server/bar" will be treated by
420 the ImR as objects in the "nestea_server" server.
422 @subsection persistence Persistent Implementation Repository
424 TAO's Implementation Repository can be made persistent by doing two things:
428 Always start up the Implementation Repository on the same port. This ensures that
429 the Implementation Repository will not have to re-ImR-ify the IORs of every server
430 registered to it each time it starts up. The way to accomplish this is to add<br>
431 -ORBEndpoint iiop://(hostname):(portnumber)<br>
433 to the activator's startup command line. The host
434 name can be obtained portable in C++ code with the lines<br>
436 ACE_INET_addr ad;<br>
437 char *hostname = ad.get_host_name ();<br>
439 or in a Perl script by adding<br>
441 use Sys::Hostname;<br>
442 $hostname = hostname();<br>
444 There are even specific port numbers, assigned to the OMG by the IANA,
445 which can be used for this purpose. They are 683 (for IIOP) and 684
446 (for IIOP over SSL). For more information about this, see
447 <a href="http://www.iana.org/">http://www.iana.org/</a>
448 and <a href="http://www.isi.edu/in-notes/iana/assignments/port-numbers">
449 http://www.isi.edu/in-notes/iana/assignments/port-numbers</a>.<br><br>
451 Pass the ImR a filename to use for the backing store, specified by the
452 command line option<br>
456 This option must be used the first and every subsequent time the
457 persistent ImR is started up.
463 @page ntservice Running as an NT service
465 The tao_imr_locator.exe can function as a Windows NT Service. The -c
466 option can be used to install and remove the service (this requires
467 Administrator access on the machine).
469 @note When using the locator as a service, it must have all of its
470 required ACE/TAO DLL's in the path or in the same directory. For
471 example, the run_test.pl copies tao_imr_locator.exe to the
472 ACE_wrappers@\bin directory before using "-c install". Alternatively,
473 You can set the usual ACE_ROOT, TAO_ROOT, and PATH environment
474 variables on a system wide basis.
476 The service can be then started either from the Windows NT "Services"
477 Admin Tool or via the "net" program on the command line:
479 <CODE>net start "TAO Implementation Repository Locator"</CODE>
480 <CODE>net start "TAO Implementation Repository Activator"</CODE>
482 The Implementation Repository supports start and stop but not pause.
484 When the Activator is installed using tao_imr_activator -c install, it
485 is added with a dependency on a locator service. If you don't wish to
486 also install the locator on the same machine, then you must use the -c
487 install_no_imr option instead.
489 @subsection serviceopts Service Options
491 Any options that are specified along with -c install, will be saved in
493 HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\TAOIMRActivator\Parameters and
494 HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\TAOIMRLocator\Parameters.
496 tao_imr_activator -c install -d 3 -l -m -o activator.ior -t 30 -orbendpoint iiop://:9988 -orbdebuglevel 1
498 The order of arguments makes no difference, but you must run
499 -c remove and then -c install if you want to change the parameters.
501 You can also manually change these using the typical regedit utility.
506 @page imrandnaming Naming Service
508 @subsection lowdown The Short Answer
510 Register the Naming Service with an Implementation Repository using the
511 POA name "NameService". So for example:
513 <CODE>tao_imr add NameService -c "Naming_Service -ORBUseIMR 1"</CODE>
515 And then an IOR can be created by:
517 <CODE>tao_imr ior NameService</CODE>
519 The above commands depend on multicast (since the commands are shorter and
520 easier put in documents). You might need to add "-ORBInitRef
521 ImplRepoService=..." for a more robust solution.
523 @subsection details Various Details
525 The Naming Service in TAO contains one persistent POA named "NameService".
526 If -ORBUseIMR 1 is passed to it, it will communicate with the ImR as any
527 other persistent POA does. Also, the Naming Service recognizes the INS
528 object key "NameService". This allows you to use the "tao_imr ior"
529 command to create corbaloc IORs.
531 NameService was chosen because resolve_initial_references () uses that
532 name. And that allows us to do interesting things with ORBDefaultInitRef
533 (as shown in the @ref defaultinitref section).