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 at the ACE/TAO
41 <a href="https://github.com/DOCGroup/ACE_TAO">github project</a>.
43 The NT Service part of the ImR was developed by Jeff Parsons @<<a
44 href="mailto:parsons@cs.wustl.edu">parsons@cs.wustl.edu</a>@>. He can
45 also be reached via the same channels.
46 It was later extended and enhanced by Justin Michel <michel_j@ociweb.com>
52 @page usersguide Implementation Repository User's Guide
54 In order for a server to make use of the Implementation Repository, it must
55 communicate with the ImR to keep it up to date on such things as the server's
56 running status. These functions now are contained within the POA, so when a
57 Persistent POA is used on a server that has -ORBUseImR specified, it will
58 communicate with an Implementation Repository, if one is available.
60 @subsection description The ImR
62 The ImR is based on the ImR in TAO 1.2.2 with added features to help
63 improve throughput and load balancing. The work to be performed by the
64 Implementation Repository is distributed between two entities (locator
65 and activator) to help achieve the goal of better throughput and load
68 @subsection locator tao_imr_locator
70 The locator acts as the main server which is visible to the
71 application intending to use the ImR. It receives requests sent via
72 tao_imr and distributes the work to the registered activators. It is
73 stateless and does not maintain any information except about the
74 activators that are registered with it. Its job is to act as a
75 mediator between the application and the actual activator that does
76 the real work. As of now, we only support one locator to be running at
77 any time. locator can be reached through the usual methods of
78 -ORBInitRef and -ORBDefaultInitRef and multicast.
80 Commandline Arguments that can be passed to tao_imr_locator
82 -d <level 0..10> locator specific debug level
83 -m support multicast discovery.
84 -l lock the repository, making it read only.
85 -o <filename> write the ior to the file.
86 -t <timeout> specify a startup timeout value (default 60 seconds)
87 -i periodically ping servers to check liveness.
88 -v the minimum successful ping interval. (default 10 seconds)
89 -g the timeout for ping attempts. (default 1 second)
90 -s run as a winNT service
91 -c <command> execute the named service command: install, remove
92 -x <filename> support persistence to the locator. We use XML to support
93 persistence. Names of the activators registered with the locator,
94 their IORs, and the servers registered with each of the activators are
95 saved to the xml file. Use this option to pass the name of the file
96 where the data has to be saved.
97 -p <filename> similar to "-x" but using an ACE_Configuration_Heap file to persist
99 -r similar to "-p" but using an ACE_Configuration_Win32Registry to persist
100 the data. (only available on Win32 platforms)
101 --directory <path> similar to "-x" option, but the repository will be written out
102 to multiple files in the indicated directory: "imr_listings.xml" which
103 indicates all servers and activators in the repository indicating the
104 filename containing that server's or activator's persistence data.
105 This option is used along with the "--primary" or "--backup" option
106 to create a Fault Tolerant locator.
107 --primary pass along with "--directory <dir>" to startup the primary
108 ImR_Locator. See ft_imr_locator subsection.
109 --backup pass along with "--directory <dir>" to startup the backup
110 ImR_Locator. See ft_imr_locator subsection.
111 -UnregisterIfAddressReused Enable the verification that a newly started server is reusing
112 the endpoint address of another server that it is not linked with. If it
113 finds this case, and the existing server is not running, its registration
116 And, of course, the ORB Options.
118 @subsection ft_imr_locator FaultTolerant_ImR_Locator
120 The ImR_Locator implements a fault tolerant service with the following options:
122 The --primary option tells the ImR_Locator that it will startup as the primary
123 in a redundant service pair.
125 The --backup option tells the ImR_Locator that it will startup as the backup
126 in a redundant service pair.
128 The --directory <ft_imr_shared_dir> option tells the ImR_Locator the shared
129 file system directory to use as the backing store for the redundant service
132 The -o <ft_imr_ior_filename> option tells the ImR_Locator to output the
133 redundant service pair ImRService ior file, which it can only do after
134 successfully starting the primary and backup ImRService instances. The ior
135 file contains the combined profiles of the primary and backup ImRLocators. The
136 client must use the ior file to use the fault tolerant locator.
138 The primary and backup ImRLocator instances should have the same ORBEndPoint
139 protocol list so that any client can send a request to either primary or backup
140 regardless of protocol (IIOP,UIOP,etc...).
142 The ImR_Locator primary and backup options cannot be passed on the command
143 line along with -ORBObjRefStyle URL, since that style will cause the backup
144 profile to not be available in the ior.
146 At startup the primary must be started first, then the backup. When
147 a single ImR_Locator goes down, it can be restarted at anytime
148 (using the same ORBEndPoints). If they are both shutdown after a successful
149 startup of the redundant pair, then either the primary or backup can be
150 restarted first. With only a single server running, there is no fault
151 tolerance support, but the original fault tolerant ior which was created
152 by the backup with the -o option can still be used as long as the ORBEndPoint
153 list remains the same for both instances.
155 As long as both the primary and backup ImR_Locators are not shutdown at the
156 same time the Fault Tolerant locator will always be available.
158 @subsection ft_imr_locator_startup FaultTolerant_ImR_Locator Startup
162 <em>Start the primary.</em><br>
163 It will write the replication ior to a file in the shared persistence
168 -ORBEndpoint <primary_hostname:port>
169 --directory <ft_imr_shared_dir>
173 </em>Start the backup.</em><br>
174 Reads the primary replication ior from the shared persistence directory.<br>
175 Writes the multi-profile ior to ft_imr_ior_filename<br>.
179 -ORBEndpoint <backup_hostname:port>
180 --directory <ft_imr_shared_dir>
181 -o <ft_imr_ior_filename>
186 @subsection activator tao_imr_activator
188 Activators, as you might have guessed, do the real work of
189 activating servers or shutting them down and maintaining the information
190 about servers related to them. Only one instance of an activator
191 can be run on one host. The activator is not exposed at all to the
192 application. Only the locator needs to and it is the only one that
193 can contact the activator.
195 An instance of tao_imr_activator first registers itself with the
196 locator so that it can begin to receive requests. When registering
197 with the locator, it passes the hostname where it is being run and
198 its IOR to the locator. And, the locator reaches it using the
201 The Commandline parameters that are valid for tao_imr_activator are
203 -c Run the Service command: install, remove, install_no_imr
204 -d <level 0..5> Debug Information
205 -l Notify the locator of server state changes
206 -o <filename> Write the IOR to a file
207 -s Run as a winNT service.
208 -e <length> Supply an Environment buffer length
209 -m <count> Supply a max number of Environment variables
210 -delay <time> A testing parameter used to impose a delay after the
211 detection of a child process death before notifying the
212 locator of the termination. Should not be used in
213 production environments
214 -detach <1|0> Override the default child-process detachment. By default
215 this value is 0, indicating the child process will terminate.
216 This may also be set or overridden by adding
217 #define IMR_DETACH_CHILD_DEF
218 to your $ACE_ROOT/ace/config.h file to make the default value 1.
221 @subsection work So how does the whole thing work?
223 The first thing to do is to have a locator running. Once the locator
224 is running, we can instantiate one or more activators as needed per
225 the application. As mentioned already, the activators, upon
226 instantiation, register with the locator to be able to receive
229 When a new server has to be added or any change has to the done to an
230 existing server, a request is to be sent to the locator via the
231 tao_imr utility. Startup commands, the working directory, the host
232 where the server should be started up and such other information are
233 passed to the locator via the tao_imr command line arguments.
235 If the host where the server should be started up is passed while
236 adding a new server, the locator chooses the activator that is running
237 on that host to be responsible for the server's activities. Otherwise,
238 an activator is chosen based on the Round robin algorithm. We plan to
239 use better algorithms based on the existing load for the same purpose
240 in future. Whatever way the activator is chosen for a server, once an
241 activator is chosen, that activator remains responsible for the server
242 throughout the server's lifetime.
244 After an activator is chosen, the locator passes the request to the
245 chosen activator. The activator acts on the request and updates its
246 database to reflect the new state of the server.
248 @subsection run How is the ImR run?
251 <li>First run the <b>tao_imr_locator</b>
252 <em>Example:<code> </code> </em><code> tao_imr_locator -o locator.ior<br></code>
253 <li>Run the <b>Activator</b>
254 <em>Example:<code> </code> </em><code> tao_imr_activator -ORBInitRef ImplRepoService=file://locator.ior<br></code>
256 @subsection use How is the ImR used?
258 The main steps for the lifetime of a server that uses the ImR are generally
262 <li>Register name and startup commands with the ImR using <b>tao_imr<br>
263 </b><em>Example:<code> </code> </em><code> tao_imr -ORBInitRef
264 ImplRepoService=file://locator.ior add plane -c "airplane_server -i
265 -ORBInitRef ImplRepoService=file://locator.ior"<br></code>
267 Note that the name used to register the server is the name of the POA
268 which the objects are created in. So in this example, the airplane_server
269 creates a POA called "plane" and activates its servants under
271 <li>Start the server once to generate an ImR-ified IOR<br>
272 <li>Start clients and pass them the above IOR<br>
273 <li>Clients will use the IOR, which will automatically go through the ImR<br>
274 <li>The ImR will start the server if it is not already running<br>
275 <li>At any time when the server is not currently in use by a client, it can be
276 shut down using <strong>tao_imr<br></strong><em>Example:</em><code> tao_imr
277 -ORBInitRef ImplRepoService=file://locator.ior shutdown plane<br>
279 <li>After the server isn't needed anymore, it can be removed from the ImR database
280 using <strong>tao_imr<br></strong><em>Example:<code> </em>tao_imr -ORBInitRef
281 ImplRepoService=file://locator.ior remove plane</code>
284 @subsection serverresponsibilities So what does the server need to do?
286 A server must be run with the argument "-ORBUseImR 1" supplied to
287 ORB_init. Then any object managed by a <strong>persistent</strong> POA will
288 be reachable via the ImR locator. The locator must also be reachable by the
289 server, using -ORBInitRef ImplRepoService=<ior> or similar.
291 @subsection defaultinitref Use of -ORBDefaultInitRef with the ImR
293 As mentioned in the INS documentation (in TAO/docs/INS.html), a base IOR
294 can be passed to the ORB. Then when resolve_initial_reference is called,
295 the ORB can append the service name to the base IOR to form a full IOR.
297 When used with the ImR, this can be a powerful feature. If the ImR's endpoint
298 is used as the base IOR, then the ImR can be used to provide many services via
299 the resolve_initial_reference functionality.
301 For example, let's say the ImR service is running on doriath on port 5555 and
302 the Name Service is already registered with the ImR (in that the ImR knows how
303 to start the Name Service).
305 Now we should be able to run some client that uses the Name Service like this:
307 <code>client -ORBDefaultInitRef corbaloc:iiop:doriath:5555/</code>
309 When the client calls resolve_initial_reference("NameService"), the ORB will
310 resolve that to "corbaloc:iiop:doriath:5555/NameService". The ImR
311 recognizes this IOR as a pointer to the NameService, and will then
312 start it up if necessary. Finally, it will forward the client to the
315 Services used in this way have two requirements:
317 - The server must be registered as the request_initial_reference name. For
318 example, the Name Service is registered as the "NameService", and thus also
319 contains a POA with the name "NameService".
320 - The server must also be able to handle the INS name
321 "corbaloc:iiop:machine:port/poa_name", where the poa_name is the
324 @subsection activationmodes What are activation modes
326 Each server can have one of three different types of activation modes:
329 <li>NORMAL is the default. The server can be started via tao_imr,
330 the command line, and with client requests.
331 <li>MANUAL specifies that the server shouldn't be activated with a
332 client request but can be activated through tao_imr or via the
334 <li>PER_CLIENT specifies that each request to the ImplRepo will
335 result in a new server process started up. Because clients
336 cache the forwarded reference, there is one server per client
337 (more or less). There are some exceptions, such as if the
338 original IOR is used in different threads (each thread would get
339 a different server). <b>Note:</b> The Implementation Repository
340 doesn't store any information about the started servers in this
341 mode, so it cannot be used to shut down the servers. So the
342 servers must have an alternative way of shutting down.
343 <li>AUTO_START specifies that a server should be activated when the
344 Implementation Repository is started. tao_imr also has an
345 autostart command to activate all servers marked AUTO_START.
348 @subsection taoImRior Using the tao_imr ior command
350 First, some background.
352 For the longest time, there was no way with TAO's Implementation
353 Repository to register a server and then start using the client
354 immediately. The server had to be started once just for the purpose
355 of creating an IOR for the client to use. The problem was that it was
356 very difficult to create an IOR without running the server.
358 It would be nice to be able to generate a valid IOR without requiring
359 the program to be run. A valid IOR in this case requires two major
360 things. First it requires the endpoint of the ImR. This is relatively
361 easy to get, since it is encoded in the ImR's IOR. Second it also
362 requires an object key. At the least, this involves both the POA
363 hierarchy and the object name.
365 So if we knew the POA and object names, then we should be able to
366 create an IOR for the server. One possibility would be to have tao_imr
367 ask for both the POA and the object, and then create the POA hierarchy
368 to generate an IOR. Doing the generation is this manner (letting the
369 POA create the reference) shields us from changes in the IOR
370 generation schemes. Since we are using the same code that the server
371 would use, our IORs would be up to date.
373 It ends up there is an easier way to do this. The Interoperable
374 Naming Service is intended to be used in situations where an IOR could
375 be created by hand. Using the same information as above, it is not
376 difficult to take the endpoint information from the ImR and attach the
377 POA name. For example, let's say that we are running the ImR on
378 ringil.ece.uci.edu at port 5000. The endpoint would be
379 "corbaloc:iiop:1.2@ringil.ece.uci.edu:5000". If we are
380 creating an IOR for the nestea server, we'd just need to attach
381 "/nestea_server" to the end of the endpoint. Now we have an
384 So what does this mean for the server?
386 The main issue here is that the server must be changed to support the
387 simplified name. This can be done by using the IORTable like this:
390 CORBA::Object_var table_object =
391 this->orb_->resolve_initial_references ("IORTable";
393 IORTable::Table_var adapter =
394 IORTable::Table::_narrow (table_object.in ());
396 if (CORBA::is_nil (adapter.in ()))
398 ACE_ERROR ((LM_ERROR, "Nil IORTable\n"));
402 adapter->bind (poa_name, server_str.in ());
406 These lines, as taken from the nestea_server example, just uses the same
407 poa_name as registered with the ImR and associates it with the server_obj
408 object in the IOR table. Because the ImR will be able to handle the
409 simplified name (if it uses the POA name scheme) then this IOR will work.
411 Just one more thing, each object that needs an IOR needs to be registered
412 with the IOR table. But this raises the problem of uniqueness; they all
413 can't have the same name. The ImR will actually only look at the name part
414 of the simplified IOR up to the first "/". So both
415 "corbaloc:iiop:1.2@ringil:5000/nestea_server/foo" and
416 "corbaloc:iiop:1.2@ringil:5000/nestea_server/bar" will be treated by
417 the ImR as objects in the "nestea_server" server.
419 @subsection persistence Persistent Implementation Repository
421 TAO's Implementation Repository can be made persistent by doing two things:
425 Always start up the Implementation Repository on the same port. This ensures that
426 the Implementation Repository will not have to re-ImR-ify the IORs of every server
427 registered to it each time it starts up. The way to accomplish this is to add<br>
428 -ORBEndpoint iiop://(hostname):(portnumber)<br>
430 to the activator's startup command line. The host
431 name can be obtained portable in C++ code with the lines<br>
433 ACE_INET_addr ad;<br>
434 char *hostname = ad.get_host_name ();<br>
436 or in a Perl script by adding<br>
438 use Sys::Hostname;<br>
439 $hostname = hostname();<br>
441 There are even specific port numbers, assigned to the OMG by the IANA,
442 which can be used for this purpose. They are 683 (for IIOP) and 684
443 (for IIOP over SSL). For more information about this, see
444 <a href="http://www.iana.org/">http://www.iana.org/</a>
445 and <a href="http://www.isi.edu/in-notes/iana/assignments/port-numbers">
446 http://www.isi.edu/in-notes/iana/assignments/port-numbers</a>.<br><br>
448 Pass the ImR a filename to use for the backing store, specified by the
449 command line option<br>
453 This option must be used the first and every subsequent time the
454 persistent ImR is started up.
460 @page ntservice Running as an NT service
462 The tao_imr_locator.exe can function as a Windows NT Service. The -c
463 option can be used to install and remove the service (this requires
464 Administrator access on the machine).
466 @note When using the locator as a service, it must have all of its
467 required ACE/TAO DLL's in the path or in the same directory. For
468 example, the run_test.pl copies tao_imr_locator.exe to the
469 ACE_wrappers@\bin directory before using "-c install". Alternatively,
470 You can set the usual ACE_ROOT, TAO_ROOT, and PATH environment
471 variables on a system wide basis.
473 The service can be then started either from the Windows NT "Services"
474 Admin Tool or via the "net" program on the command line:
476 <CODE>net start "TAO Implementation Repository Locator"</CODE>
477 <CODE>net start "TAO Implementation Repository Activator"</CODE>
479 The Implementation Repository supports start and stop but not pause.
481 When the Activator is installed using tao_imr_activator -c install, it
482 is added with a dependency on a locator service. If you don't wish to
483 also install the locator on the same machine, then you must use the -c
484 install_no_imr option instead.
486 @subsection serviceopts Service Options
488 Any options that are specified along with -c install, will be saved in
490 HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\TAOIMRActivator\Parameters and
491 HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\TAOIMRLocator\Parameters.
493 tao_imr_activator -c install -d 3 -l -m -o activator.ior -t 30 -orbendpoint iiop://:9988 -orbdebuglevel 1
495 The order of arguments makes no difference, but you must run
496 -c remove and then -c install if you want to change the parameters.
498 You can also manually change these using the typical regedit utility.
503 @page imrandnaming Naming Service
505 @subsection lowdown The Short Answer
507 Register the Naming Service with an Implementation Repository using the
508 POA name "NameService". So for example:
510 <CODE>tao_imr add NameService -c "Naming_Service -ORBUseIMR 1"</CODE>
512 And then an IOR can be created by:
514 <CODE>tao_imr ior NameService</CODE>
516 The above commands depend on multicast (since the commands are shorter and
517 easier put in documents). You might need to add "-ORBInitRef
518 ImplRepoService=..." for a more robust solution.
520 @subsection details Various Details
522 The Naming Service in TAO contains one persistent POA named "NameService".
523 If -ORBUseIMR 1 is passed to it, it will communicate with the ImR as any
524 other persistent POA does. Also, the Naming Service recognizes the INS
525 object key "NameService". This allows you to use the "tao_imr ior"
526 command to create corbaloc IORs.
528 NameService was chosen because resolve_initial_references () uses that
529 name. And that allows us to do interesting things with ORBDefaultInitRef
530 (as shown in the @ref defaultinitref section).