Instrumentation Example


  1. Modifying the Source Code
  2. Compiling the Client and Server
  3. Running the Messenger Example with OVATION

We will illustrate instrumenting applications using the "Messenger" example from the TAO 1.2a Developer's Guide. This example assumes that OVATION is currently configured and running correctly in your environment and that all relevant environment variables (e.g. $ACE_ROOT, $OVATION_ROOT, etc.) are correctly set.

The example consists of a server called MessengerServer that implements a simple Messenger interface, plus a client called MessengerClient that accesses and uses a Messenger CORBA object that the MessengerServer provides. This example code can be found in $OVATION_ROOT/examples/Messenger.

Modifying the Source Code

Messenger Client

In the Messenger example, we want to collect temporal information about the CORBA calls. Since the MessengerServer never exits, we modify the MessengerClient code to flush the data points and write the log file. 

// Send a message the the Messenger object.
CORBA::String_var message = CORBA::string_dup( "Howdy!" );
messenger->send_message( "rick", "Test", message.inout() );

// Print the Messenger's reply.
cout << "Reply: " << message.in() << endl;
OVATION_WRITE_COLLECTOR_LOG("Messenger.log");
OVATION_FLUSH_ALL_DATAPOINT_CACHES();

return 0;

In order to compile the code (such that the servers understands the OVATION macros) the following include needs to be added to MessengerClient.cpp:

#include <probes/Instrumentation.h>

Messenger Server

In addition, we'd like to understand the relationship of a specific milestone (the sending of the message from the server) in relation to the CORBA invocations. We made no modifications to the MessengerServer.cpp file. However to the Messenger_i.cpp, we add the following line:

CORBA::Boolean Messenger_i::send_message (
const char * user_name,
const char * subject,
char *& message
)
throw(CORBA::SystemException)

{
cout << "Message from: " << user_name << endl;
cout << "Subject: " << subject << endl;
cout << "Message: " << message << endl;
CORBA::string_free(message);
message = CORBA::string_dup("Thanks for the message.");
OVATION_MILESTONE_IS_REACHED ("Message is being sent");
return 1;

}

In order to compile the code (such that the client understand the OVATION_MILESTONE_IS_REACHED macro) the following include needs to be added to Messenger_i.cpp:

#include <probes/milestone_probe/Instrumentation.h>

Compiling the Client and Server

Windows

Several modifications need to made to the initial Microsoft Visual C++ project files supplied with the Messenger example in order to compile with OVATION. These changes have already been made to the Project files in the OVATION/examples directory. We review the changes here for informational purposes only. Click on Project and then Settings and make the following changes:

  • Link Tab
    • Category: General
      • Object/library modules:
        • Add ovation.lib to the list
    • Category: Input
      • Additional library path:
        • Add $(OVATION_ROOT)/lib
  • C++ Tab
    • Category: General
      • Preprocessor definitions:
        • Add OVATION_HAS_DLL=1 (for dynamic libraries) or OVATION_HAS_DLL=0 (for static libraries)
    • Category: Preprocessor
      • Additional include directives:
        • Add $(OVATION_ROOT)/src/cplusplus

Linux

Several modifications need to made to the initial Makefiles supplied with the Messenger example in order to compile with OVATION on Linux. These changes have already been made to the Makefile in the $OVATION_ROOT/examples directory. We review the changes here for informational purposes only.  You need to add the following flags as well as add the OVATION and TAO_PortableServer libraries as shown below.

CPPFLAGS += -I$(OVATION_ROOT)/src/cplusplus
LDLIBS += -lOVATION
LDFLAGS += -L$(OVATION_ROOT)/lib

TAO_SRVR_LIBS += -lOVATION
TAO_CLNT_LIBS += -lTAO_PortableServer -lOVATION

Running the Messenger Example with OVATION

Collecting the Data

To start collecting data using OVATION, we create a svc.conf that indicates which directives will by dynamically loaded as the MessengerServer is run. To do this, rename the existing svc_conf file to svc.conf. Before you run the test again, you'll need to start up the OVATION Collector application. On Windows, the command is:

%OVATION_ROOT%\bin\runCollector.bat

On Linux, use the command:

$OVATION_ROOT/bin/runCollector

You should output similar to:

D:\>java -Xms20M -Xmx256M -cp D:\CVS\projects\ova\lib\ovation.jar;D:\CVS\projects\ova\lib\log4j.jar;D:\CVS\projects\ova\
lib\jdom.jar;D:\CVS\projects\ova\lib\jgraph.jar;D:\CVS\projects\ova\lib\xercesImpl.jar;D:\CVS\projects\ova\lib\xmlParser
APIs.jar;D:\CVS\projects\ova\lib\grappa.jar;D:\JacORB_1_4_1\lib\jacorb.jar;D:\CVS\projects\ova\resources com.ociweb.ovat
ion.collector.CollectorMain
Collector IOR is:
corbaloc:iiop:localhost:12169/Ovation_CollectorServer/CollectorPOA/Collector

[ Property "jacorb.hashtable_class" not present. Will use default hashtable implementation ]
Initialized ORB
[ POA RootPOA - ready ]
[ Set BasicListener address string to 132.200.200.149 ]
[ POA CollectorPOA - ready ]
[ POA CollectorPOA - oid: LogController - object is activated ]
[ POA CollectorPOA - oid: Registry - object is activated ]
[ POA CollectorPOA - oid: Collector - object is activated ]
...Ready...
Listening for clients requesting IOR on host 0.0.0.0, port 12168

Now we can rerun the MessengerServer and you should see output similar to:

#511 [DGettingStarted]> MessengerServer.exe
(3428|2548) Here I am in Snooper_Plugin::init!
(3428|2548) Here I am in Ovation::init!
BEGIN pre_init.
END pre_init.
BEGIN post_init.
<orb table empty>
END post_init.
Using HI-res clock
Collector endpoint is "localhost:12169"
(3428|2548) Here I am in Snooper_Probe::init!
BEGIN pre_init.
END pre_init.
BEGIN post_init.
0. "OVATION PROBE ORB" 00C6DC50
END post_init.
D:\CVS\tao\ocitao\ACE_wrappers\TAO\tao\ORB_Table.cpp100orb_id:
IOR written to file Messenger.ior

As well as output from the OVATION Collector that indicates that a connection has been added for the MessengerServer. The next step is to run the MessengerClient.

#524 [GettingStarted]> MessengerClient.exe
(3676|3844) Here I am in Snooper_Plugin::init!
(3676|3844) Here I am in Ovation::init!
BEGIN pre_init.
END pre_init.
BEGIN post_init.
<orb table empty>
END post_init.
Using HI-res clock
Collector endpoint is "localhost:12169"
(3676|3844) Here I am in Snooper_Probe::init!
BEGIN pre_init.
END pre_init.
BEGIN post_init.
0. "OVATION PROBE ORB" 00B1DA40
END post_init.
D:\CVS\tao\ocitao\ACE_wrappers\TAO\tao\ORB_Table.cpp100orb_id:
++++ Gathering data for thread 0x00b26da0
Reply: Thanks for the message.

The program has successfully run and data has been collected by the OVATION Collector and written the data to the file Messenger.log (by default placed in the same directory as where the runCollector script is started).

Visualizing the Data

The sequence diagram below shows the server (in this case "TraceTest(1572)") and the client ("TraceTest(3236)") and the initial send_message() invocation from client (showing a latency of 11 milliseconds). The milestone we inserted into the server code is shown as a light turquoise line and the reply from the server is shown (send_message()) with a latency of 4 milliseconds.

Copyright © 2006 Object Computing, Inc. All rights reserved. | Privacy Policy