Simple CIAO tutorial
Note:
- CoSMIC tools are not used in this tutorial.
- This is only a GENERAL 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.
- To download the code of this example please refer to the SVN repository at
$CIAO_ROOT/examples/Hello
.
Example Description
This Hello example is contructed in the following ways:
- 1. There are 2 components in the system: Sender and Receiver
- 2. The Sender will send out the timeout event to the Receiver.
- 3. Upon receiving the timeout event, the Receiver will go and fetch data from the Sender.
- 4. The user could deploy multiple instances of the Receiver without changing any C++/idl source code.
Step-By-Step
Hello_Base
- Write an IDL file (
Hello_Base.idl
) 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 timeout
and an
interface ReadMessage
, which are used by both the
Sender and the Receiver, so we put both of them in Hello_Base.idl.
- Look at the
Hello_Base.mpc
file to get an idea how the Hello_Base_stub
and Hello_Base_svnt projects are organized.
MPC is a utility we used to generate makefiles or VC
project/solution files for all ACE,
TAO and CIAO
libraries.
For Every Components
- Execute :
$CIAO_ROOT/bin/generate_component_mpc.pl -p Hello_Base Sender
in Sender directory
$CIAO_ROOT/bin/generate_component_mpc.pl -p Hello_Base Receiver
in Receiver directory
Note:
- I have different directories for
"Hello_Base", "Sender", "Receiver"
respectively.
- For every
_stub
project, add:
"libs += Hello_Base_DnC_stub"
The output of this scripts includes an MPC file and 3 export header files
(..._svnt_export.h, ..._exec_export.h and ..._stub_export.h).
- Write an idl file for every component (
Sender.idl
and
Receiver.idl
).
Here you can put the
component specific IDL definitions in this file. In this example we have a interface trigger
specific to the Sender. Please note that the Sender component
"supports"
(IDL keyword) this interface.
- Write the CIDL file for every component (
Sender.cidl
and
Receiver.cidl
).
- Compile these cidl files, using
$CIAO_ROOT/bin/cidlc.exe Receiver.cidl --gen-exec-impl -I$CIAO_ROOT/ccm -I$CIAO_ROOT -I$TAO_ROOT
.
This'll result in ..._exec.cpp/..._exec.h and ..._svnt.cpp/..._svnt.h files.
- Write
_exec.h
and _exec.cpp
files which actually implement the component.
Writing all those files could be troublesome to a new CCM user. The
best way of learning this is 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.
The Entry Point
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 starter
. The
starter
will make a invocation on a supported interface
called trigger
on the Sender component to get the whole
distributed application started. The starter
will first
obtain the Sender component object reference through the ior string
supplied as a command argument. Please see the the last part of
Hello/Sender/Sender.mpc
file for details.
Make
- Go to the directory
$CIAO_ROOT/DAnCE
and do:
$ACE_ROOT/bin/mwc.pl
For example, using $ACE_ROOT/bin/mwc.pl -type vc71
if you are using Visual C++ 7.1 IDE
or $ACE_ROOT/bin/mwc.pl -type gnuace
on Linux platforms.
- Look at the generated Makefile(*unx) or Solution/workspace files(Windows) and you got it.
After building DAnCE, a solution or makefile should be generated for this CIAO example.
Navigate to $CIAO_ROOT/examples/Hello
and execute $ACE_ROOT/bin/mwc.pl -type vc71
for
Visual C++ 7.1 or $ACE_ROOT/bin/mwc.pl -type gnuace
on Linux platforms.
Build this example using Visual Studio or make.
Assemble
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
publishes timeout event instead of emits event.
Note: Creating the deployment plan descriptor is a tedious and
error-prone job, you can download CoSMIC to assist
you in this step.
Deploy with DAnCE
Finally you are ready to deploy the component-based application you have developed.
- If you wish to register one or more of your component
instances with CORBA naming service, then please start your naming service
first with multicast mode first ("-m 1" option). Use
-o
to define where
the output ior should be saved.
- Go into the descriptors directory Start NodeManagers
(NodeDameon) by running
run_NodeDaemons.pl
- There are two ways to start the execution manager :
- Using the naming service to locate the node deamons
Navigate to $CIAO_ROOT/examples/Hello/descriptor and execute
$DANCE_ROOT/bin/dance_execution_manager -eEM.ior --domain-nc file://ns.ior
--domain-nc should point to the ior file of the naming service.
- Without using the naming service.
Navigate to $CIAO_ROOT/examples/Hello/descriptor and execute:
$DANCE_ROOT/bin/dance_execution_manager -eEM.ior --node-map NodeManagerMap.dat
NOTE: As one can see, we use the "NodeManagerMap.dat" 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.
Start the plan launcher, with or without using the Naming Service:
- Using the naming service
Navigate to $CIAO_ROOT/examples/Hello/descriptors_naming and execute:
$DANCE_ROOT/bin/dance_plan_launcher -d deploymentplan_naming.cdp -k file://../descriptors/EM.ior
- Without using the naming service
Navigate to $CIAO_ROOT/examples/Hello/descriptors and execute:
$DANCE_ROOT/bin/dance_plan_launcher -x deploymentplan.cdp -k file://EM.ior
After this, components should be deployed successfully.
You can go into the $CIAO_ROOT/examples/Hello/descriptor directory and
run execute $CIAO_ROOT/examples/Hello/Sender/starter -k file://Sender.ior
to start the application. Please make sure that the component IOR
file for the Sender component (Sender.ior
) is present when you run this client.
To stop deployment just run $DANCE_ROOT/bin/dance_plan_launcher -x DeploymentPlan.cdp -k file://EM.ior -q
In addition, have a look at run_test.pl
and see how this can be established.
More Features
Recently DAnCE is enabled with a feature called Redeployment and Reconfiguration (ReDaC). For more information
about how to use this feature, please refer to the ReDaC-Usage-Example.html under $CIAO_ROOT/examples/Hello/.
Email: ciao-users@cse.wustl.edu