summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/ImplRepo_Service/README
blob: fb14aa12a3310b8bbda7551106aaa03eaf10d3b3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
/** -*- HTML-Helper -*-

@mainpage Implementation Repository

@section intro Introduction

The purpose of the Implementation Repository (ImR) in TAO is for the automatic
activation of a TAO server when a method is invoked but the server is not
running. It does this by working with the server to keep track of when it is
activated and stores information on how to reactivate it. Method
invocations on the server will actually be sent to the Implementation
Repository, which will then be able to start the server process if it is not
already running and forward the invocation to the real server.

@section resources Resources

The ImR in TAO was first based on a paper on the subject by
<a href="http://www.triodia.com/staff/michi-henning.html">Michi Henning</a>
called <a href="http://www.triodia.com/staff/michi/cacm.pdf">Binding,
Migration, and Scalability in CORBA</a>. Mr. Henning later went on to
coauthor the book
<a href="http://cseng.awl.com/bookdetail.qry?ISBN=0-201-37927-9&amp;ptype=0">
Advanced CORBA Programming in C++</a> and included a chapter on the
Implementation Repository. The description of the ImR in this chapter is used
as the specification for TAO's ImR.

@ref usersguide - Overall documentation on how to use the ImR in your programs

@ref ntservice - Running the ImR as a NT Service

@ref imrandnaming - Using the Naming Service with the Implementation Repository

@section authors Authors

The guy who first worked on ImR and provided a base for the current
ImR is Darrell Brunsch
@<<a href="mailto:brunsch@cs.wustl.edu">brunsch@cs.wustl.edu</a>@>.
The current version is developed by Phil Mesnier
@<<a href="mailto:mesnier_p@ociweb.com">mesnier_p@ociweb.com</a>@>.
You can reach us by either email (which is better), or through the
<a href="http://www.dre.vanderbilt.edu/~schmidt/ACE-mail.html">ACE mailing list</a>
@<<a href="mailto:ace-users@list.isis.vanderbilt.edu">ace-users@list.isis.vanderbilt.edu</a>@>,
or through the <a href="news:comp.soft-sys.ace">comp.soft-sys.ace</a>
newsgroup. The newsgroup mirrors the mailing list, but not the other way.
Also, if you use the mailing list, it is best if you join it before sending
a question since responses are usually just replied back to the group.

The NT Service part of the ImR was developed by Jeff Parsons @<<a
href="mailto:parsons@cs.wustl.edu">parsons@cs.wustl.edu</a>@>.  He can
also be reached via the same channels.
It was later extended and enhanced by Justin Michel <michel_j@ociweb.com>

*/


/**
@page usersguide Implementation Repository User's Guide

In order for a server to make use of the Implementation Repository, it must
communicate with the ImR to keep it up to date on such things as the server's
running status. These functions now are contained within the POA, so when a
Persistent POA is used on a server that has -ORBUseImR specified, it will
communicate with an Implementation Repository, if one is available.

@subsection description The ImR

The ImR is based on the ImR in TAO 1.2.2 with added features to help
improve throughput and load balancing. The work to be performed by the
Implementation Repository is distributed between two entities (locator
and activator) to help achieve the goal of better throughput and load
balance.

@subsection locator tao_imr_locator

The locator acts as the main server which is visible to the
application intending to use the ImR. It receives requests sent via
tao_imr and distributes the work to the registered activators.  It is
stateless and does not maintain any information except about the
activators that are registered with it. Its job is to act as a
mediator between the application and the actual activator that does
the real work. As of now, we only support one locator to be running at
any time. locator can be reached through the usual methods of
-ORBInitRef and -ORBDefaultInitRef and multicast.

Commandline Arguments that can be passed to tao_imr_locator

-d <level 0..10>   locator specific debug level
-m                 support multicast discovery.
-l                 lock the repository, making it read only.
-o <filename>      write the ior to the file.
-t <timeout>       specify a startup timeout value (default 60 seconds)
-i                 periodically ping servers to check liveness.
-v                 the minimum successful ping interval. (default 10 seconds)
-g                 the timeout for ping attempts. (default 1 second)
-s                 run as a winNT service
-c <command>       execute the named service command: install, remove
-x <filename>      support persistence to the locator. We use XML to support
                   persistence. Names of the activators registered with the locator,
                   their IORs, and the servers registered with each of the activators are
                   saved to the xml file. Use this option to pass the name of the file
                   where the data has to be saved.
-p <filename>      similar to "-x" but using an ACE_Configuration_Heap file to persist
                   the data.
-r                 similar to "-p" but using an ACE_Configuration_Win32Registry to persist
                   the data. (only available on Win32 platforms)
--directory <path> similar to "-x" option, but the repository will be written out
                   to multiple files in the indicated directory: "imr_listings.xml" which
                   indicates all servers and activators in the repository indicating the
                   filename containing that server's or activator's persistence data.
                   This option is used along with the "--primary" or "--backup" option
                   to create a Fault Tolerant locator.
--primary          pass along with "--directory <dir>" to startup the primary
                   ImR_Locator. See ft_imr_locator subsection.
--backup           pass along with "--directory <dir>" to startup the backup
                   ImR_Locator. See ft_imr_locator subsection.
-UnregisterIfAddressReused Enable the verification that a newly started server is reusing
                   the endpoint address of another server that it is not linked with. If it
                   finds this case, and the existing server is not running, its registration
                   is removed.

  And, of course, the ORB Options.

@subsection ft_imr_locator FaultTolerant_ImR_Locator

The ImR_Locator implements a fault tolerant service with the following options:

  The --primary option tells the ImR_Locator that it will startup as the primary
  in a redundant service pair.

  The --backup option tells the ImR_Locator that it will startup as the backup
  in a redundant service pair.

  The --directory <ft_imr_shared_dir> option tells the ImR_Locator the shared
  file system directory to use as the backing store for the redundant service
  pair.

  The -o <ft_imr_ior_filename> option tells the ImR_Locator to output the
  redundant service pair ImRService ior file, which it can only do after
  successfully starting the primary and backup ImRService instances. The ior
  file contains the combined profiles of the primary and backup ImRLocators. The
  client must use the ior file to use the fault tolerant locator.

The primary and backup ImRLocator instances should have the same ORBEndPoint
protocol list so that any client can send a request to either primary or backup
regardless of protocol (IIOP,UIOP,etc...).

The ImR_Locator primary and backup options cannot be passed on the command
line along with -ORBObjRefStyle URL, since that style will cause the backup
profile to not be available in the ior.

At startup the primary must be started first, then the backup. When
a single ImR_Locator goes down, it can be restarted at anytime
(using the same ORBEndPoints). If they are both shutdown after a successful
startup of the redundant pair, then either the primary or backup can be
restarted first. With only a single server running, there is no fault
tolerance support, but the original fault tolerant ior which was created
by the backup with the -o option can still be used as long as the ORBEndPoint
list remains the same for both instances.

As long as both the primary and backup ImR_Locators are not shutdown at the
same time the Fault Tolerant locator will always be available.

@subsection ft_imr_locator_startup FaultTolerant_ImR_Locator Startup

<ol>
  <li>
    <em>Start the primary.</em><br>
    It will write the replication ior to a file in the shared persistence
    directory.<br>
    <code>
      tao_imr_locator
        --primary
        -ORBEndpoint <primary_hostname:port>
        --directory <ft_imr_shared_dir>
    </code>
  </li>
  <li>
    </em>Start the backup.</em><br>
    Reads the primary replication ior from the shared persistence directory.<br>
    Writes the multi-profile ior to ft_imr_ior_filename<br>.
    <code>
      tao_imr_locator
        --backup
        -ORBEndpoint <backup_hostname:port>
        --directory <ft_imr_shared_dir>
        -o <ft_imr_ior_filename>
    </code>
  </li>
</ol>

@subsection activator tao_imr_activator

Activators, as you might have guessed, do the real work of
activating servers or shutting them down and maintaining the information
about servers related to them. Only one instance of an activator
can be run on one host. The activator is not exposed at all to the
application. Only the locator needs to and it is the only one that
can contact the activator.

An instance of tao_imr_activator first registers itself with the
locator so that it can begin to receive requests. When registering
with the locator, it passes the hostname where it is being run and
its IOR to the locator. And, the locator reaches it using the
same information.

The Commandline parameters that are valid for tao_imr_activator are

-c              Run the Service command: install, remove, install_no_imr
-d <level 0..5> Debug Information
-l              Notify the locator of server state changes
-o <filename>   Write the IOR to a file
-s              Run as a winNT service.
-e <length>     Supply an Environment buffer length
-m <count>      Supply a max number of Environment variables
-delay <time>   A testing parameter used to impose a delay after the
                detection of a child process death before notifying the
                locator of the termination. Should not be used in
                production environments
-detach <1|0>   Override the default child-process detachment. By default
                this value is 0, indicating the child process will terminate.
                This may also be set or overridden by adding
                #define IMR_DETACH_CHILD_DEF
                to your $ACE_ROOT/ace/config.h file to make the default value 1.
-h              Prints the help.

@subsection work So how does the whole thing work?

The first thing to do is to have a locator running. Once the locator
is running, we can instantiate one or more activators as needed per
the application. As mentioned already, the activators, upon
instantiation, register with the locator to be able to receive
requests.

When a new server has to be added or any change has to the done to an
existing server, a request is to be sent to the locator via the
tao_imr utility. Startup commands, the working directory, the host
where the server should be started up and such other information are
passed to the locator via the tao_imr command line arguments.

If the host where the server should be started up is passed while
adding a new server, the locator chooses the activator that is running
on that host to be responsible for the server's activities. Otherwise,
an activator is chosen based on the Round robin algorithm. We plan to
use better algorithms based on the existing load for the same purpose
in future. Whatever way the activator is chosen for a server, once an
activator is chosen, that activator remains responsible for the server
throughout the server's lifetime.

After an activator is chosen, the locator passes the request to the
chosen activator. The activator acts on the request and updates its
database to reflect the new state of the server.

@subsection run How is the ImR run?

<ol>
  <li>First run the <b>tao_imr_locator</b>
    <em>Example:<code> </code> </em><code> tao_imr_locator -o locator.ior<br></code>
  <li>Run the <b>Activator</b>
    <em>Example:<code> </code> </em><code> tao_imr_activator -ORBInitRef ImplRepoService=file://locator.ior<br></code>

@subsection use How is the ImR used?

The main steps for the lifetime of a server that uses the ImR are generally
the following:

<ol>
  <li>Register name and startup commands with the ImR using <b>tao_imr<br>
    </b><em>Example:<code>  </code> </em><code> tao_imr -ORBInitRef
    ImplRepoService=file://locator.ior add plane -c &quot;airplane_server -i
    -ORBInitRef ImplRepoService=file://locator.ior&quot;<br></code>
    <br>
    Note that the name used to register the server is the name of the POA
    which the objects are created in. So in this example, the airplane_server
    creates a POA called &quot;plane&quot; and activates its servants under
    it.<br>
  <li>Start the server once to generate an ImR-ified IOR<br>
  <li>Start clients and pass them the above IOR<br>
  <li>Clients will use the IOR, which will automatically go through the ImR<br>
  <li>The ImR will start the server if it is not already running<br>
  <li>At any time when the server is not currently in use by a client, it can be
      shut down using <strong>tao_imr<br></strong><em>Example:</em><code> tao_imr
      -ORBInitRef ImplRepoService=file://locator.ior shutdown plane<br>
    </code>
  <li>After the server isn't needed anymore, it can be removed from the ImR database
      using <strong>tao_imr<br></strong><em>Example:<code> </em>tao_imr -ORBInitRef
      ImplRepoService=file://locator.ior remove plane</code>
</ol>

@subsection serverresponsibilities So what does the server need to do?

A server must be run with the argument &quot;-ORBUseImR 1&quot; supplied to
ORB_init. Then any object managed by a <strong>persistent</strong> POA will
be reachable via the ImR locator. The locator must also be reachable by the
server, using -ORBInitRef ImplRepoService=<ior> or similar.

@subsection defaultinitref Use of -ORBDefaultInitRef with the ImR

As mentioned in the INS documentation (in TAO/docs/INS.html), a base IOR
can be passed to the ORB.  Then when resolve_initial_reference is called,
the ORB can append the service name to the base IOR to form a full IOR.

When used with the ImR, this can be a powerful feature.  If the ImR's endpoint
is used as the base IOR, then the ImR can be used to provide many services via
the resolve_initial_reference functionality.

For example, let's say the ImR service is running on doriath on port 5555 and
the Name Service is already registered with the ImR (in that the ImR knows how
to start the Name Service).

Now we should be able to run some client that uses the Name Service like this:

<code>client -ORBDefaultInitRef corbaloc:iiop:doriath:5555/</code>

When the client calls resolve_initial_reference("NameService"), the ORB will
resolve that to "corbaloc:iiop:doriath:5555/NameService".  The ImR
recognizes this IOR as a pointer to the NameService, and will then
start it up if necessary.  Finally, it will forward the client to the
Name Service.

Services used in this way have two requirements:

- The server must be registered as the request_initial_reference name.  For
  example, the Name Service is registered as the "NameService", and thus also
  contains a POA with the name "NameService".
- The server must also be able to handle the INS name
  "corbaloc:iiop:machine:port/poa_name", where the poa_name is the
  same name as above.

@subsection activationmodes What are activation modes

Each server can have one of three different types of activation modes:

<ul>
  <li>NORMAL is the default.  The server can be started via tao_imr,
      the command line, and with client requests.
  <li>MANUAL specifies that the server shouldn't be activated with a
      client request but can be activated through tao_imr or via the
      command line.
  <li>PER_CLIENT specifies that each request to the ImplRepo will
      result in a new server process started up.  Because clients
      cache the forwarded reference, there is one server per client
      (more or less).  There are some exceptions, such as if the
      original IOR is used in different threads (each thread would get
      a different server).  <b>Note:</b> The Implementation Repository
      doesn't store any information about the started servers in this
      mode, so it cannot be used to shut down the servers.  So the
      servers must have an alternative way of shutting down.
  <li>AUTO_START specifies that a server should be activated when the
      Implementation Repository is started.  tao_imr also has an
      autostart command to activate all servers marked AUTO_START.
</ul>

@subsection taoImRior Using the tao_imr ior command

First, some background.

For the longest time, there was no way with TAO's Implementation
Repository to register a server and then start using the client
immediately.  The server had to be started once just for the purpose
of creating an IOR for the client to use.  The problem was that it was
very difficult to create an IOR without running the server.

It would be nice to be able to generate a valid IOR without requiring
the program to be run. A valid IOR in this case requires two major
things.  First it requires the endpoint of the ImR. This is relatively
easy to get, since it is encoded in the ImR's IOR.  Second it also
requires an object key.  At the least, this involves both the POA
hierarchy and the object name.

So if we knew the POA and object names, then we should be able to
create an IOR for the server. One possibility would be to have tao_imr
ask for both the POA and the object, and then create the POA hierarchy
to generate an IOR.  Doing the generation is this manner (letting the
POA create the reference) shields us from changes in the IOR
generation schemes.  Since we are using the same code that the server
would use, our IORs would be up to date.

It ends up there is an easier way to do this.  The Interoperable
Naming Service is intended to be used in situations where an IOR could
be created by hand.  Using the same information as above, it is not
difficult to take the endpoint information from the ImR and attach the
POA name.  For example, let's say that we are running the ImR on
ringil.ece.uci.edu at port 5000.  The endpoint would be
&quot;corbaloc:iiop:1.2@ringil.ece.uci.edu:5000&quot;.  If we are
creating an IOR for the nestea server, we'd just need to attach
&quot;/nestea_server&quot; to the end of the endpoint.  Now we have an
IOR.

So what does this mean for the server?

The main issue here is that the server must be changed to support the
simplified name. This can be done by using the IORTable like this:

<CODE>
      CORBA::Object_var table_object =
        this->orb_->resolve_initial_references ("IORTable";

      IORTable::Table_var adapter =
        IORTable::Table::_narrow (table_object.in ());

      if (CORBA::is_nil (adapter.in ()))
        {
          ACE_ERROR ((LM_ERROR, "Nil IORTable\n"));
        }
      else
        {
          adapter->bind (poa_name, server_str.in ());
        }
</CODE>

These lines, as taken from the nestea_server example, just uses the same
poa_name as registered with the ImR and associates it with the server_obj
object in the IOR table.  Because the ImR will be able to handle the
simplified name (if it uses the POA name scheme) then this IOR will work.

Just one more thing, each object that needs an IOR needs to be registered
with the IOR table.  But this raises the problem of uniqueness; they all
can't have the same name.  The ImR will actually only look at the name part
of the simplified IOR up to the first &quot;/&quot;.  So both
&quot;corbaloc:iiop:1.2@ringil:5000/nestea_server/foo&quot; and
&quot;corbaloc:iiop:1.2@ringil:5000/nestea_server/bar&quot; will be treated by
the ImR as objects in the &quot;nestea_server&quot; server.

@subsection persistence Persistent Implementation Repository

TAO's Implementation Repository can be made persistent by doing two things:

<ul>
<li>
Always start up the Implementation Repository on the same port. This ensures that
the Implementation Repository will not have to re-ImR-ify the IORs of every server
registered to it each time it starts up. The way to accomplish this is to add<br>
-ORBEndpoint iiop://(hostname):(portnumber)<br>

to the activator's startup command line. The host
name can be obtained portable in C++ code with the lines<br>

  ACE_INET_addr ad;<br>
  char *hostname = ad.get_host_name ();<br>

or in a Perl script by adding<br>

  use Sys::Hostname;<br>
  $hostname = hostname();<br>

There are even specific port numbers, assigned to the OMG by the IANA,
which can be used for this purpose. They are 683 (for IIOP) and 684
(for IIOP over SSL).  For more information about this, see
<a href="http://www.iana.org/">http://www.iana.org/</a>
and <a href="http://www.isi.edu/in-notes/iana/assignments/port-numbers">
http://www.isi.edu/in-notes/iana/assignments/port-numbers</a>.<br><br>
<li>
Pass the ImR a filename to use for the backing store, specified by the
command line option<br>

-p (filename)<br>

This option must be used the first and every subsequent time the
persistent ImR is started up.

</ul>
*/

/**
@page ntservice Running as an NT service

The tao_imr_locator.exe can function as a Windows NT Service.  The -c
option can be used to install and remove the service (this requires
Administrator access on the machine).

@note When using the locator as a service, it must have all of its
required ACE/TAO DLL's in the path or in the same directory.  For
example, the run_test.pl copies tao_imr_locator.exe to the
ACE_wrappers@\bin directory before using "-c install".  Alternatively,
You can set the usual ACE_ROOT, TAO_ROOT, and PATH environment
variables on a system wide basis.

The service can be then started either from the Windows NT "Services"
Admin Tool or via the "net" program on the command line:

<CODE>net start "TAO Implementation Repository Locator"</CODE>
<CODE>net start "TAO Implementation Repository Activator"</CODE>

The Implementation Repository supports start and stop but not pause.

When the Activator is installed using tao_imr_activator -c install, it
is added with a dependency on a locator service. If you don't wish to
also install the locator on the same machine, then you must use the -c
install_no_imr option instead.

@subsection serviceopts Service Options

Any options that are specified along with -c install, will be saved in
the registry under
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\TAOIMRActivator\Parameters and
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\TAOIMRLocator\Parameters.
For example:
tao_imr_activator -c install -d 3 -l -m -o activator.ior -t 30 -orbendpoint iiop://:9988 -orbdebuglevel 1

The order of arguments makes no difference, but you must run
-c remove and then -c install if you want to change the parameters.

You can also manually change these using the typical regedit utility.

*/

/**
@page imrandnaming Naming Service

@subsection lowdown The Short Answer

Register the Naming Service with an Implementation Repository using the
POA name "NameService".  So for example:

<CODE>tao_imr add NameService -c "Naming_Service -ORBUseIMR 1"</CODE>

And then an IOR can be created by:

<CODE>tao_imr ior NameService</CODE>

The above commands depend on multicast (since the commands are shorter and
easier put in documents).  You might need to add "-ORBInitRef
ImplRepoService=..." for a more robust solution.

@subsection details Various Details

The Naming Service in TAO contains one persistent POA named "NameService".
If -ORBUseIMR 1 is passed to it, it will communicate with the ImR as any
other persistent POA does.  Also, the Naming Service recognizes the INS
object key "NameService".  This allows you to use the "tao_imr ior"
command to create corbaloc IORs.

NameService was chosen because resolve_initial_references () uses that
name.  And that allows us to do interesting things with ORBDefaultInitRef
(as shown in the @ref defaultinitref section).

*/