corba programming using ace/tao ken waller eel 6897 - software development for real time engineering...
TRANSCRIPT
CORBA Programming Using ACE/TAO
Ken WallerEEL 6897 - Software Development for Real Time Engineering Systems
Fall 2007
Agenda What Is CORBA? CORBA Basics
Clients, Servers, and Servants ORBs and POAs IDL and the Role of IDL Compilers IORs Tying it all together
Overview of ACE/TAO Example 1: Simple Client-Server CORBA Services
Naming Service Trading Service Event Service
Example 2: Using the Naming Service Multi-Threaded Issues Using CORBA Example 3: A Multi-Threaded Server
What Is CORBA? Common Object Request Broker
Architecture Common Architecture Object Request Broker – ORB
Specification from the OMG http://www.omg.org/technology/docu
ments/corba_spec_catalog.htm
Must be implemented before usable
What Is CORBA? More specifically:
“(CORBA) is a standard defined by the Object Management Group (OMG) that enables software components written in multiple computer languages and running on multiple computers to work together ” (1)
Allows for Object Interoperability, regardless of: Operating Systems Programming Language Takes care of Marshalling and Unmarshalling of Data
A method to perform Distributed Computing
What Is CORBA?
Program A
• Running on a Windows PC
• Written in Java
Program B
• Running on a Linux Machine
• Written in C++
CORBA
What is CORBA? CORBA is being used in many industries
Defense, Financial, Medical CORBA can be used to:
Harness the power of several machines to solve a problem
Several CPU’s Simulations
Communicate between real Tactical Systems
Perform true component based development
What is CORBA? Conceptually simple:
Simply sending messages and data between objects running on different machines
Not unlike objects communicating “Devil is in the Details” (3)
Many new concepts and terms to learn ORB, POA, IOR, etc. “Alphabet Soup”
True experts are rare and highly sought after Abstraction above Sockets
CORBA Basics: Clients, Servers, and Servants CORBA Clients
An Application (program) Request services from Servant object
Invoke a method call Can exist on a different computer
from Servant Can also exist on same computer, or
even within the same program, as the Servant
Implemented by Software Developer
CORBA Basics: Clients, Servers, and Servants CORBA Servers
An Application (program) Performs setup needed to get Servants
configured properly ORB’s, POA’s
Instantiates and starts Servants object(s) Once configuration done and Servant(s)
running, Clients can begin to send messages
Implemented by Software Developer
CORBA Basics: Clients, Servers, and Servants
Servants Objects Implement interfaces Respond to Client requests Exists within the same program as
the Server that created and started it Implemented by Software Developer
ORB’s and POA’s ORB: Object Request Broker
The “ORB” in “CORBA” At the heart of CORBA
Enables communication Implemented by ORB Vendor
An organization that implements the CORBA Specification (a company, a University, etc.)
Can be viewed as an API/Framework Set of classes and method
Used by Clients and Servers to properly setup communication
Client and Server ORB’s communicate over a network Glue between Client and Server applications
ORB’s and POA’s POA: Portable Object Adapter
A central CORBA goal: Programs using different ORB’s (provided by different ORB Vendors) can still communicate
In the early days of CORBA, this was not possible A clear shortcoming
The POA was adopted as the solution Can be viewed as an API/Framework
Set of classes and method Sits between ORB’s and Servants
Glue between Servants and ORBs Job is to:
Receive messages from ORB’s Activate the appropriate Servant Deliver the message to the Servant
CORBA Basics: IDL IDL: The Interface Definition Language
Keyword: Definition No “executable” code (cannot implement
anything) Very similar to C++ Header Files Language independent from Target Language
Allows Client and Server applications to be written in different (several) languages
A “contract” between Clients and Servers Both MUST have the exact same IDL Specifies messages and data that can be sent by
Clients and received by Servants Written by Software Developer
CORBA Basics: IDL Used to define interfaces (i.e. Servants)
Classes and methods that provide services IDL Provides…
Primitive Data Types (int, float, boolean, char, string)
Ability to compose primitives into more complex data structures
Enumerations, Unions, Arrays, etc. Object-Oriented Inheritance
CORBA Basics: IDL IDL Compilers
Converts IDL files to target language files Done via Language Mappings
Useful to understand your Language Mapping scheme
Target language files contain all the implementation code that facilitates CORBA-based communication
More or less “hides” the details from you Creates client “stubs” and Server “skeletons” Provided by ORB Vendor
CORBA Basics: IDL
IDL FileIDL
Compiler
Client Stub Files Server Skeleton Files
Generates
Generates
Generated Files are in Target Language:
• C++
• Java
• etc.
Generated Files are in Target Language:
• C++
• Java
• etc.
Client Programs used the classes in the Client Stub files to send messages to the Servant objects
Client Program Servant Object
Servant Objects inherit from classes in the Server Skeleton files to receive messages from the Client programs
Association Inheritance
CORBA Basics: IDL Can also generate
empty Servant class files
IDL Compiler converts to C++ (in this case)
CORBA Basics: IOR’s IOR: Interoperable Object Reference
Can be thought of as a “Distributed Pointer” Unique to each Servant Used by ORB’s and POA’s to locate Servants
For Clients, used to find Servants across networks For Servers, used to find proper Servant running within
the application Opaque to Client and Server applications
Only meaningful to ORB’s and POA’s Contains information about IP Address, Port Numbers,
networking protocols used, etc. The difficult part is obtaining them
This is the purpose/reasoning behind developing and using CORBA Services
CORBA Basics: IOR’s Can be viewed in “stringified” format,
but… Still not very meaningful
CORBA Basics: IOR’s
Standardized, to some degree:
… …
Standardized by the OMG:
• Used by Client side ORB’s to locate Server side (destination) ORB’s
• Contains information needed to make physical connection
NOT Standardized by the OMG; proprietary to ORB Vendors
• Used by Server side ORB’s and POA’s to locate destination Servants
CORBA Basics: Tying it All Together In order to use CORBA:
Obtain a CORBA implementation ACE/TAO is used in this presentation (free, open source) ORBIX (commercial) is most widely used (better support) Consider what platforms and languages vendor supports
Learn how to use the CORBA API Can read the specification
Massive Perhaps “too technical”
Recommended: Find a good CORBA book More clear and concise See (3)
Must also rely on documentation from the CORBA implementation provider
The specs standardize lots of things, but not everything Some aspects left to the CORBA implementers
CORBA Basics: Tying it All Together Recommended development
strategy: Develop IDL and system architecture
(i.e. High-Level design) Sequence Diagrams and UML can be
useful during this phase Decide IOR passing strategy (i.e.
CORBA Services) Design and Develop Server and Client
programs
CORBA Basics: Tying it All Together In general, a Server program must take the following steps:
Configure the ORB Configure the POA Create and Configure the Servant object Register the Servant’s IOR with a CORBA Service Start the Servant
In general, a Client program must take the following steps: Configure the ORB (different from Server ORB) Obtain a Servant’s IOR from a CORBA Service Use the IOR to call a method on the Servant object
These directions are oversimplification Must learn how to use the CORBA API properly This is just a High-Level view
In general, the server program must be run before the client program
CORBA Basics: Tying it All Together
Server ORB POA Servant
Configure ORB
Configure POA
Create/Configure Servant Object
Start Servant
CORBA Service
Register Servant IOR Client ORB
Configure ORB
Obtain IOR
IOR
Call Servant Method
Response *optional*
CORBA Basics: Tying it All Together
Client Program
IOR (Servant Ref)
Server Program
ServantMessage(Data)
Logical Flow
Client Program Server Program
Servant
Actual Flow
POA
ORB
IOR (Servant Ref)
ORB
Once ORB’s and POA’s set up and
configured properly, transparency is
possible
• ORB’s communicate over network
• POA’s activate servants and deliver messages
Overview of ACE/TAO ACE: Adaptive Communications
Environment Object-Oriented Framework/API Implements many concurrent
programming design patterns Can be used to build more complex
communications-based packages For example, an ORB
Freely available from (2)
Overview of ACE/TAO TAO: The ACE ORB
Built on top of ACE A CORBA implementation Includes many (if not all) CORBA
features specified by the OMG Not just an ORB Provides POA’s, CORBA Services, etc.
Object-Oriented Framework/API Freely available from (2)
Example 1: Simply Client/Server
CORBA Services Previous example:
Server started the Servant Servant wrote its IOR out to a file in a
stringified format Client obtained IOR by reading the IOR in
from the file This is not true distribution The CORBA Specification includes
extensions to help facilitate obtaining IOR’s in a more distributed fashion
CORBA Services: The Naming Service The CORBA Naming Service is similar to
the White Pages (phone book) Servants place their “names,” along
with their IOR’s, into the Naming Service The Naming Service stores these as pairs
Later, Clients obtain IOR’s from the Naming Service by passing the name of the Servant object to it The Naming Service returns the IOR
Clients may then use to make requests
CORBA Services: The Trading Service The CORBA Naming Service is similar to the
Yellow Pages (phone book) Servants place a description of the services
they can provide (i.e. their “Trades”), along with their IOR’s, into the Trading Services
The Trading Service stores these Clients obtain IOR’s from the Trading Service
by passing the type(s) of Services they require The Trading Service returns an IOR
Clients may then use to make requests
Example 2: Using the Naming Service
Multi-Threaded Issues Using CORBA Server performance can be
improved by using multiple threads GUI Thread Listening Thread Processing Thread
Can also use multiple ORBs and POAs to improve performance Requires a multi-threaded solution
Example 3: A Multi-Threaded Server
Conclusions Advantages:
Object-Oriented distributed communication Easy to define messages and data contents using IDL Once setup/configuration of ORB’s, POA’s, Servants,
IOR’s complete, communication is fairly straightforward Relieves programmers from having to write Socket
software Disadvantages:
Can be difficult to learn Even harder to master
Scalability issues could cause a mind-boggling amount of ORB’s, POA, threads, etc. to be used
Acquiring IOR’s can be difficult
References
(1) http://en.wikipedia.org/wiki/CORBA
(2) http://download.dre.vanderbilt.edu/
(3) “Advanced CORBA Programming with C++” by Henning and Vinoski
Questions?