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
|
<!Doctype HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<title>Implementation Repository</title>
<!-- $Id$ -->
</head>
<body text = "#000000"
link="#000fff"
vlink="#ffofof"
bgcolor="#ffffff">
<h3>Implementation Repository</h3>
<P> In the previous example, the client must contact the server
at least once. If the server has been moved to a different host or
port, or if the server is down, binding between the client and
the server fails. Indirect binding through an external location
broker like the Implementation Repository solves this problem.
</P>
<P>An implementation repository maintains a data structure known
as a server table to keep track of the servers. It maintains a
registry of known servers, records which server is currently
running on which host and at which port number, and starts
servers on demand if they are registered to do so.
</P>
<P> When a server
creates a persistent reference, it sets the address and port
number in the profile body of the IOR to point at the
implementation repository that is responsible for the server.
When a client uses this IOR, it gets connected to the
implementation repository, provided the implementation
repository is not down. The repository decodes this IOR and uses
the POA name from the object key to index into its server
table. The repository replies with the current addressing
information of the actual server. The client now sends the
request to the actual server.
</P>
<P>In this example, let's proceed to modify our previous stock
factory example to support indirect binding through an
implementation repository.
</P>
<P>The only thing we have to do for this is to register our
childPOA with the implementation repository.
</P>
<PRE>
orb->_tao_add_to_IOR_table ("childPOA", stock_factory.in ());
</PRE>
<P> Then, we stringify all the object references as usual and
print them out.
</P>
<PRE>
CORBA::String_var ior = orb->object_to_string (stock_factory.in ());
</PRE>
<H3>Exercise</H3>
Modify the <a href=../Server/server.cpp>server.cpp</a> in the simple
server to create the persistent child POA.
You can use the same
<a href=../Quoter.idl>Quoter.idl</a>
<a href=../Server/Stock_i.h>Stock_i.h</a>
<a href=../Server/Stock_i.cpp>Stock_i.cpp</a>
<a href=../Server/Stock_Factory_i.h>Stock_Factory_i.h</a>
<a href=../Server/Stock_Factory_i.cpp>Stock_Factory_i.cpp</a>
<a href=../Client/client.cpp>Client.cpp</a>
You can use this <a href=Quoter_Simple_Impl_Repo_Server.mpc>MPC file</a>.
<H3>Solution</H3>
Compare your server.cpp with <a href = server.cpp>server.cpp</a> file.
<H3>Testing</H3>
<P>To test your changes, you need to run four programs. The first
step is to start up the Implementation Repository provided
with TAO. The Implementation Repository is split into one locator at least
one activator. The locator provides the interface visible
to the application intending to use the repository (in our case,
the client), while the activators do the real work of activating
and maintaining servers.
</P>
<P>First, we start the locator. We need to dump the IOR of the ImplRepo_Service to a file,
so that both the activator and the client can find the locator.
</P>
<PRE>
$ $TAO_ROOT/orbsvcs/ImplRepo_Service/ImplRepo_Service -o implrepo.ior -d 0 -ORBobjrefstyle URL &
</PRE>
<P>Second, we start the activator, pointing it to the locator's IOR file.
</P>
<PRE>
$ $TAO_ROOT/orbsvcs/ImplRepo_Service/ImR_Activator -ORBInitRef ImplRepoService=file://implrepo.ior
ImR Activator: Starting doc.ece.uci.edu
ImR Activator: Registered with ImR.
</PRE>
<P> Next, we need to register our server with the implementation
repository. We can use the
<CODE>$TAO_ROOT/orbsvcs/ImplRepo_Service/tao_imr</CODE>
application provided with TAO to add our server to the server
database in the implementation repository.
</P>
<PRE>
$ $TAO_ROOT/orbsvcs/ImplRepo_Service/tao_imr -ORBInitRef
ImplRepoService=file://implrepo.ior add childPOA -c
"./server -ORBUseIMR 1 -ORBobjrefstyle URL -ORBInitRef
ImplRepoService=file://implrepo.ior"
Successfully registered server <childPOA>
</PRE>
<p> On Windows platforms, use this command instead to register the server
in the implementation repository
</p>
<PRE>
$ACE_ROOT/bin/tao_imr -ORBInitRef ImplRepoService=file://implrepo.ior
add childPOA -c "./server -ORBUseIMR 1 -ORBobjrefstyle URL
-ORBInitRef ImplRepoService=file://implrepo.ior"
</PRE>
<P> We specify the <CODE>-ORBInitRef</CODE> option to use the IOR in
the <CODE>implrepo.ior</CODE> file and the <CODE>-ORBUseIMR</CODE>
option to tell the server to use the IMR for notification of its
startup and shutdown.
</P>
<P>The next step is to generate a simple IOR for our server
to be used with the IMR, using the
<CODE>ior</CODE> option, and write it to <CODE>stock_factory.ior</CODE>.
</P>
<PRE>
$tao_imr -ORBInitRef ImplRepoService=file://implrepo.ior ior
childPOA -f stock_factory.ior
corbaloc:iiop:1.1@doc.ece.uci.edu:2690/childPOA
</PRE>
<P> From now, the implementation repository is all set to keep
track of our server and do the needful on a method invocation
on our server.
</P>
<P> Now, execute the client as usual.
</P>
<PRE>
./client file://stock_factory.ior MSFT RHAT
The price of a stock in "Microsoft, Inc." is $91
The price of a stock in "RedHat, Inc." is $210
</PRE>
<P> For testing the persistency of the POA, let's shut down the
server and then run the client.
</P>
<PRE>
$tao_imr -ORBInitRef ImplRepoService=file://implrepo.ior
shutdown childPOA
Successfully shutdown server <childPOA>
./client file://stock_factory.ior MSFT RHAT
The price of a stock in "RedHat, Inc." is $210
The price of a stock in "Microsoft, Inc." is $91
</PRE>
<H3>More Reading</H3>
<P>More information on Implementation Repository is
<A HREF="../../../../../docs/implrepo/index.html">here</A>.
</P>
<P>The <A HREF="http://www.triodia.com/staff/michi-henning.html">Henning</A> and <A HREF="http://www.iona.com/hyplan/vinoski/">Vinoski</A>
<A HREF="http://www.iona.com/hyplan/vinoski/#book">CORBA book</A> discusses POA policies in detail. Likewise,
the Schmidt and Vinoski
<A HREF="http://www.cs.wustl.edu/~schmidt/report-doc.html">columns</A> in C++ Report also include several articles about the POA. Finally,
the <A HREF="http://www.cs.wustl.edu/~schmidt/TAO.html">TAO</A>
distribution includes <A HREF="../../../../../examples/POA">examples</A> that illustrate how
to use the POA policies.
</P>
<hr>
<address><a href="mailto:pgontla@ece.uci.edu">Priyanka Gontla</a></address>
<!-- Created: Wed Mar 29 17:35:30 PST 2000 -->
<!-- hhmts start -->
Last modified: Sat May 19 17:19:07 CDT 2001
<!-- hhmts end -->
</body>
</html>
|