summaryrefslogtreecommitdiff
path: root/CIAO/examples/Hello/step-by-step.html
blob: e0211218733d911076dafeac9e4deae5bc880e5f (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
<!--//$Id$  -->
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <title>Step-By-Step of How to build a CIAO application</title>
</head>

<body
 text = "#000000"
 link = "#000fff"
 vLink= "#ff0f0f"
 aLink = "#0000ff"
 bgColor = "#ffffff">

<hr>
<h2>Simple <a href="http://www.dre.vanderbilt.edu/CIAO">CIAO</a> tutorial</h2>
<b>Note:</b>
<ul>
  <li><a href="http://www.dre.vanderbilt.edu/cosmic">CoSMIC</a> tools are not used in this tutorial.</li>
  <li>This is only a <em>GENERAL</em> way of building up a CIAO application and deploying it with DAnCE.
    The user could always change the process in his own way. For example: the IDL file content, the project structure etc.
  </li>
  <li>To download the code of this example please refer to the SVN repository at <code>$CIAO_ROOT/examples/Hello</code>.</li>
</ul>
<hr>

<h2>Example Description</h2>
This Hello example is contructed in the following ways:
<ol>
  <li>There are 2 components in the system: Sender and Receiver</li>
  <li>The Sender will send out the timeout event to the Receiver.</li>
  <li>Upon receiving the timeout event, the Receiver will go and fetch data from the Sender. </li>
  <li>The user could deploy multiple instances of the Receiver without changing any C++/idl source code.</li>
</ol>

<hr>

<h2>Code generation</h2>
Note that an user only need to write the IDL files. All the rest of the files can be generated.
The following code generators are use throughout this example:
<ul>
  <li><code>$CIAO_ROOT/bin/generate_component_mpc.pl</code><br/>
    This perl script is able to generate MPC files out of a single name.
    <a href="http://downloads.ociweb.com/MPC/MakeProjectCreator.pdf">MPC</a> is a utility we use
    to generate makefiles or VC project/solution files for all
    <a href="http://www.cs.wustl.edu/~schmidt/ACE.html">ACE</a>,
    <a href="http://www.cs.wustl.edu/~schmidt/TAO.html">TAO</a> and
    <a href="http://www.cs.wustl.edu/~schmidt/CIAO.html">CIAO</a>
    libraries and executables.<br/>
  </li>
  <li><code>$ACE_ROOT/bin/tao_idl</code>
    Besides all the stub and skeleton code, the TAO IDL compiler is also suitable to generate the
    so called executor files. An executor C++ code file contains the business logic
    the user need to write. Since this should be deployable by the DAnCE framework, there're
    some restriction to this code. The TAO IDL compiler takes care of that.
  </li>
  <li><code>$ACE_ROOT/bin/mwc.pl</code>
    This script will generate VS solutions and/or GNU makefiles out of the generated
    MPC files.
  </li>
</ul>
All these generators will be handled throughout this tutorial.
<hr>

<h2>Step-By-Step</h2>
<h3>Hello_Base</h3>

<ol>
  <li>Write an IDL file (<a href="./Hello_Base/Hello_Base.idl"><code>Hello_Base.idl</code></a>) which contains all
      the interfaces and events common to all the components. The reason
      we do this is because the generated lib of this idl file will be
      linked in by all the components in the system. To reduce the size
      of the component lib we have to include only the necesary part. In
      this example, we have an eventtype <code>timeout</code> and an
      interface <code>ReadMessage</code>, which are used by both the
      Sender and the Receiver, so we put both of them in <a href="Hello_Base/Hello_Base.idl">Hello_Base.idl</a>.
  </li>
  <br/>
  <li>Look at the <a href="Hello_Base/Hello_Base.mpc"><code>Hello_Base.mpc</code></a> file to get an idea how the Hello_Base_stub
      and Hello_Base_svnt projects are organized.<br/>
      There's a utility in $CIAO_ROOT/bin, called generate_component_mpc. This a perl script which is able to generate a complete
      mpc file based on a given name. The commandline used to generate <code>Hello_Base.mpc</code> is:<br/>
      <code>$CIAO_ROOT/bin/generate_component_mpc.pl -e -n -l../lib -o../lib Hello_Base</code><br/>
      Use <code>$CIAO_ROOT/bin/generate_component_mpc.pl --help</code> to get more information about this tool.
      See also the <a href="../../tutorials/Quoter/Simple/01.html">Quoter tutorial</a> for more information.
  </li>
</ol>

<hr>

<h3>For Every Components</h3>

<ol>
  <li>Execute : <br>
  <ul>
    <li><code>$CIAO_ROOT/bin/generate_component_mpc.pl -e -l ../lib -o ../lib -c starter -p Hello_Base Sender</code> in Sender directory.
      The <code>-c</code> option will be handled later on in the step-by-step.
    </li>
    <li><code>$CIAO_ROOT/bin/generate_component_mpc.pl -e -l ../lib -o ../lib -p Hello_Base Receiver</code> in Receiver directory
    </li>
  </ul>
  <b>Note:</b>
  <ul>
    <li>There're different directories for <code>"Hello_Base", "Sender", "Receiver"</code> respectively.
    </li>
    <li>All output DLL's/executable will be stored in a separate directory, called "lib".
    </li>
  </ul>

  <br/>

  <li>Write an IDL file for every component (<a href="Sender/Sender.idl"><code>Sender.idl</code></a> and
      <a href="Receiver/Receiver.idl"><code>Receiver.idl</code></a>). <br> Here you can put the
      component specific IDL definitions in this file. In this example we have a interface <code>trigger</code>
      specific to the Sender. Please note that the Sender component
      <code>"supports"</code> (IDL keyword) this interface. This interface can be used by
      <a href="Sender/starter.cpp"><code>starter</code></a> (an IDL 2 client) to start the application.
  </li>

  <br/>

  <li>There's a possibility that the TAO IDL compiler can generate a 'template' for the executor code.
    Steps to generate executor files:
    <ol>
      <li>Backup the following files to a temporary directory:<br/>
        <ul>
          <li>Sender/Sender_exec.cpp
          </li>
          <li>Sender/Sender_exec.h
          </li>
          <li>Receiver/Receiver_exec.cpp
          </li>
          <li>Receiver/Receiver_exec.h
          </li>
        </ul>
      </li>
      <li>Add -Gex or -Gexr to the <code>idlflags</code> entry in the
        IDL generator projects in the MPC file
      </li>
        <ul>
          <li>Project <code>Hello_Base_Sender_idl_gen</code> in Sender/Sender.mpc
          </li>
          <li>Project <code>Hello_Base_Receiver_idl_gen</code> in Receiver/Receiver.mpc
          </li>
        </ul>
      <li>Generate GNUmakefiles / VS project files and build
      </li>
      <li>Remove -Gex(r) again
      </li>
      <li>Generate GNUmakefiles / VS project files (and build)
      </li>
    </ol>
    <b>Mind the last step! The TAO IDL compiler does not check whether the
      executor file already exists. It will overwrite the existing!</b><br/><br/>
    After step 2 the following files should be overwritten:
    <ul>
      <li>Sender/Sender_exec.cpp
      </li>
      <li>Sender/Sender_exec.h
      </li>
      <li>Receiver/Receiver_exec.cpp
      </li>
      <li>Receiver/Receiver_exec.h
      </li>
    </ul>
  </li>
</ol>

Performing all steps could be troublesome to a new CCM user. The
best way of learning this is to just do more than once. I'll also help to
read the example source code. If you are familliar with CORBA programming,
it should not take too much time before you can declare yourself as a CCM programmer.<br/>

<hr>

<h3>The Entry Point</h3>

After both components are implemented we still need a small program to
initialize the process. In Sender.idl there is a Sender specific
interface with a single method in it created for this purpose. Hence
there is a CORBA client application called <code>starter</code>. The
<code>starter</code> will make a invocation on a supported interface
called <code>trigger</code> on the Sender component to get the whole
distributed application started. The <code>starter</code> will first
obtain the Sender component object reference through the ior string
supplied as a command argument. Please see the the last part of
<code>Sender/Sender.mpc</code> file for details. <br/>

<hr>

<h3>Build</h3>

This example assumes that ACE/TAO/CIAO/DANCE is build. If not, please
follow the instructions to build these frameworks.<br/>
<b>Tip : </b>Experienced users may want to use <code>$CIAO_ROOT/CIAO_TAO_DAnCE.mwc</code>
to generate the needed VC project/solutions of GNU make files.<br/>

Perform the following steps to build this example: <br/>
<ol>
  <li>Navigate to <code>$CIAO_ROOT/examples/Hello</code>
  </li>
  <li>For windows:<br/>
    <ul>
      <li>Visual C++ 2005: execute <code>$ACE_ROOT/bin/mwc.pl -type vc8</code>
      </li>
      <li>Visual C++ 2008: execute <code>$ACE_ROOT/bin/mwc.pl -type vc9</code>
      </li>
      <li>Visual C++ 2010: execute <code>$ACE_ROOT/bin/mwc.pl -type vc10</code>
      </li>
    </ul>
  </li>
  <li>For linux:<br/>
    Execute <code>$ACE_ROOT/bin/mwc.pl -type gnuace</code>.
  </li>
</ol>
Build this example using Visual Studio or make.<br/>

<hr>

<h3>Assemble</h3>

Now we can step forward to build the assembly. Here we are going to
build the simplest case only, which is 1 Receiver and 1 Sender. If you
are interested in CIAO you could try 1 Sender with multiple
Receivers. However, you need to change the Sender.idl to make it
<em>publishes</em> timeout event instead of <em>emits</em> event.<br>
Note: Creating the deployment plan descriptor is a tedious and
    error-prone job, you can download <a
    href="http://www.dre.vanderbilt.edu/cosmic">CoSMIC</a> to assist
    you in this step. <P>

<UL>
<li>You need to create an XML descriptor file to describe your <em>deployment plan</em>, which is
	defined in a <EM>Deployment Plan Descriptor</EM> (.cdp) (see <a href="./descriptors/DeploymentPlan.cdp">Hello deployment plan<a>).
	In this file, you need to declaratively specify how the component assembly is constructed. Specificly, you need to specify
	the component types, component instances, component connections, implementation artifact descriptions, and whether you
  want to register component instances with naming service.<P>

<li> Please make sure that the Modified_Deployment.xsd and XMI.xsd files are in the Hello/descriptors directory.
The former file can be found in $CIAO_ROOT/docs/schema directory. <P>

<li> Create the <em>NodeManagerMap.cdd</em> file containing the CORBALOC IIOP address of each <code>NodeManager</code>
     where it is running. Please refer to the existing <a href="./descriptors/NodeManagerMap.cdd">
     <code>NodeManagerMap.cdd</code></a> for details. Alwyas use for the property name "edu.vanderbilt.dre.DAnCE.StringIOR" and for the
     resourceType "edu.vanderbilt.dre.DAnCE.NodeAddress".
     As you can see, we only specify 2 <code>NodeManagers</code>, which means these two components
     will be installed in the different <code>NodeApplication</code> server. Please refer to the
     <em>flattened_deploymentplan.cdp</em> file to see how a deployer
     could specify the mapping between components and nodes.</li>
</li>
</UL>

<hr>

<h3>Deploy with <A href="../../docs/releasenotes/dance.html">DAnCE</A></h3>
Finally you are ready to deploy the component-based application you have developed.
<br><br>

<UL>
  <LI> If you wish to register one or more of your component
      instances with CORBA <em>naming service</em>, then please start your naming service
      first with multicast mode first ("-m 1" option). Use <code>-o</code> to define where
      the output ior should be saved.<P>

  <LI> Go into the <em> descriptors </em> directory Start NodeManagers
      (NodeDameon) by running <code> run_NodeDaemons.pl </code> <P>

  <LI> There are two ways to start the execution manager :
    <ol>
      <li>Using the naming service to locate the node deamons<br/>
      Navigate to <em>$CIAO_ROOT/examples/Hello/descriptor</em> and execute
      <code>$DANCE_ROOT/bin/dance_execution_manager -eEM.ior --domain-nc file://ns.ior</code><br/>
      --domain-nc should point to the ior file of the naming service.
      </li>

      <li>Without using the naming service.<br/>
      Navigate to <em>$CIAO_ROOT/examples/Hello/descriptor</em> and execute:<br/>
      <code>$DANCE_ROOT/bin/dance_execution_manager -eEM.ior --cdd NodeManagerMap.cdd </code><br/>
      <em>NOTE</em>: As one can see, we use the "NodeManagerMap.cdd" file to instruct the
        Execution_Manager how to find the endpoint of each individual NodeManager (i.e., Node Daemon) where
        component(s) will be deployed. This is non-standard.
      </li>
    </ol>
  </LI>
  </ul><P>

  <LI> Start the plan launcher, with or without using the Naming Service: <br/>
    <ol>
      <li>Using the naming service<br/>
        Navigate to <em>$CIAO_ROOT/examples/Hello/descriptors_naming</em> and execute:<br/>
        <code> $DANCE_ROOT/bin/dance_plan_launcher -d deploymentplan_naming.cdp -k file://../descriptors/EM.ior </code>
      </li>
      <li>Without using the naming service<br/>
        Navigate to <em>$CIAO_ROOT/examples/Hello/descriptors</em> and execute:<br/>
        <code> $DANCE_ROOT/bin/dance_plan_launcher -x deploymentplan.cdp -k file://EM.ior </code><P>
      </li>
    After this, components should be deployed successfully.<P>
    </ol>
</LI>

  <LI> You can go into the <em>$CIAO_ROOT/examples/Hello/descriptor</em> directory and
      run execute <code>$CIAO_ROOT/examples/Hello/Sender/starter -k file://Sender.ior</code> to start the application. Please make sure that the component IOR
      file for the Sender component (<code>Sender.ior</code>) is present when you run this client.<P>
  </LI>
  <LI>To stop deployment just run $DANCE_ROOT/bin/dance_plan_launcher -x DeploymentPlan.cdp -k file://EM.ior -q
  </LI>
</UL>
<br/>
<br/>
In addition, have a look at <a href="./descriptors/run_test.pl"><code>run_test.pl</code></a> and see how this can be established.

<hr>
<h3>More Features</h3>
Recently DAnCE is enabled with a feature called <em>Redeployment and Reconfiguration</em> (ReDaC). For more information
about how to use this feature, please refer to the ReDaC-Usage-Example.html under $CIAO_ROOT/examples/Hello/.
<br><br>

<hr>
<b>Email: </b><a href="mailto:"</a<ADDRESS>ciao-users@list.isis.vanderbilt.edu</ADDRESS>
</body>
</html>