Simple CIAO tutorial

Note:

Example Description

This Hello example is contructed in the following ways:

Step-By-Step

Hello_Base

  1. 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.
  2. 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

  1. Execute :
    Note: The output of this scripts includes an MPC file and 3 export header files (..._svnt_export.h, ..._exec_export.h and ..._stub_export.h).

  2. 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.
  3. Write the CIDL file for every component (Sender.cidl and Receiver.cidl).
  4. 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.
  5. 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

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.

  • Start the plan launcher, with or without using the Naming Service:
    1. 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
    2. 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

    3. 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