CORBA makes remote objects easy
Dan Kegel, LULA, 19 Feb 2002
Table of Contents
- CORBA = standard architecture for networked object oriented programming;
includes APIs, protocols, services, and bootstrapping mechanisms.
- Created by OMG (an industry consortium) in 1991; now at version 2.6
- Available from many vendors and as open source
Like SOAP, RMI, DCOM, and RPC:
- CORBA lets you write programs that call functions on different computers
SOAP suffers from growing pains:
- interoperability is a problem
- service discovery standard not finished
- not all languages have good support
CORBA had this kind of problem once too, but not anymore.
Worse, SOAP suffers from problems that probably won't go away:
- Despite its name, SOAP is not particularly object-oriented.
- SOAP's overhead is much higher than that of CORBA.
- SOAP doesn't have any type checking.
RMI is great, but:
- it's not much use with anything but Java
Sun recognized this; Java now lets you use CORBA with RMI.
DCOM works, but:
- it's not much use with anything but Windows
- Microsoft is now discouraging the use of DCOM,
and is pushing people towards SOAP
RPC is the basis of network file systems like
SMB and NFS, and has been in use for over 15 years, but:
- it's not object-oriented
- it's fragmented (Microsoft pushed one flavor, Sun pushed another)
- it's not sexy
CORBA has the following goodies:
- good language support (Java, C++, C, Python, Perl, TCL, LISP, ...)
- good books ("Advanced CORBA Programming with C++")
- free implementations (OmniOrb, TAO, MICO, ORBit)
- good support (mailing lists answer questions quickly)
- commercial implementations (Visibroker, ...)
- embedded system support (CORBAlite; overhead 100-800 KB)
- development tool support (Autoconf)
- debugging tools (Ethereal)
- administrative tools (Naming Service Browsers, Interface Repository Browsers)
- maturity (standard and tools debugged and working well)
To use CORBA:
- Write your object-oriented program as usual
- Get it working all on one computer
- Write a CORBA wrapper for the object you'd like to remote
- Replace references to the local object with references to the remote object
Careful design is neccessary for robustness and good performance, just as
with SOAP, DCOM, or RMI. These tools may make the network invisible,
but just because you can't see it doesn't mean it can't hurt you.
/// Abstract C++ class to access a phone book
class PhoneBook {
public:
/// Look up the phone number for a given name
String lookup(String name) = 0;
};
/// C++ program to use it
main()
{
/// Get access to a concrete subclass of PhoneBook
MySQLPhoneBook book();
String num = book.lookup("Fred Flintstone");
std::cout << "Fred's number is " << num << endl;
}
/// file CorbaPhoneBook.idl: CORBA interface to a phone book
interface CorbaPhoneBook {
/// Look up the phone number for a given name
string lookup(in string name);
}
/// file corbademo.cc: C++ program to use CorbaPhoneBook
#include "CorbaPhoneBook.hh"
main()
{
/// Get a pointer to the naming service
CORBA::ORB_var orb = CORBA::ORB_init(argc, argv, "omniORB3");
CORBA::Object_var nso=orb->resolve_initial_references("NameService");
CosNaming::NamingContext_var nsv = CosNaming::NamingContext::_narrow(nso);
/// Look up the PhoneBook object
CosNaming::Name name;
name.length(1);
name[0].id = "My Phone Book";
CORBA::Object_var pbo = rootContext->resolve(name);
CorbaPhoneBook_var book = CorbaPhoneBook::_narrow(pbo);
/// Look up Fred's number with it
CORBA::String_var num = book->lookup("Fred Flintstone");
std::cout << "Fred's number is " << num << endl;
}
To measure how many clients a FTP server can handle, you need a lot of clients --
more than you can really simulate with a single computer.
dkftpbench is a ftp benchmark that uses a single computer to simulate many users.
It pooped out around five or so thousand ftp clients.
I used CORBA to add distributed load generation to it; it can now test even the
largest FTP server.
Copyright 2002, Dan Kegel
[Return to kegel.com/corba]