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 CVS repository at
$CIAO_ROOT/DAnCE/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 becuse 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.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
- Use:
$CIAO_ROOT/bin/generate_component_mpc.pl -p Hello_Base Sender
$CIAO_ROOT/bin/generate_component_mpc.pl -p Hello_Base Receiver
Note:
- I have different directories for
"Hello_Base", "Sender", "Receiver"
respectively.
- For every
_stub
project, add:
"libs += Hello_Base_DnC_stub"
- Use the export script to generate the export files. (3 files per
component).
- Write an idl file for every compoent. 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.
- 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
(use -type option if you are using a compiler/IDE other than gnuace -which by default generates GNU makefiles)
For example, using $ACE_ROOT/bin/mwc.pl -type vc71
if you are using Visual C++ 7.1 IDE.
- Look at the generated Makefile(*unx) , Solution/workspace files(Windows) and you got it.
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
Receiver. However, you need to change the Sender.idl to make it
publishes timeout event instead of emits event.
- You need to create an XML descriptor file to describe your
deployment plan, which is defined in a Deployment Plan Descriptor (.cdp).
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.
- Please make sure that the Modified_Deployment.xsd and XMI.xsd files are in the Hello/descriptors directory.
The former file could be found in $CIAO_ROOT/docs/schema directory.
- Create the NodeManagerMap.dat file containing the CORBALOC IIOP address of each
NodeManager (Node_Daemon)
where it is running. Please refer to the existing NodeManagerMap.dat
for details,
as you can see, we only specify 2 NodeManagers
, which means these two components
will be installed in the different NodeApplication
server. Please refer to the
flattened_deploymentplan.cdp file to see how a deployer
could specify the mapping between components and nodes.
Note: Creating the deployment plan descriptor is a tedious and
error-prone job, you can download CoSMIC to assist
you in this step.
Run
Finally you are ready to test the application you have made.
- If you specify that you want to register one or more component
instances with naming service, please start your naming service
first.
- Go into the descriptors directory Start NodeManagers
(NodeDameon) by running
run_NodeDaemons.pl
- Start the execution manager:
$CIAO_ROOT/DAnCE/ExecutionManager/Execution_Manager -o EM.ior -i 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, so this is non-standard. We plan to use Naming Service to do this in the future.
- Start the executor:
$CIAO_ROOT/DAnCE/Plan_Launcher/plan_launcher -p flattened_deploymentplan.cdp -k file://EM.ior
After this, components should be deployed successfully.
- You can go into the
$CIAO_ROOT/DAnCE/examples/Hello/descriptor directory and
run the
$CIAO_ROOT/DAnCE/examples/Hello/Sender/starter
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.
Email: ciao-users@cse.wustl.edu