Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Advanced CORBA Programming wit C++ - M. Henning, S. Vinoski.pdf
Скачиваний:
63
Добавлен:
24.05.2014
Размер:
5 Mб
Скачать

IT-SC book: Advanced CORBA® Programming with C++

A structure of type ProfileBody_1_1 applies only to IIOP and encodes how a client can locate the target object of a request. If a server uses IIOP as its transport, object references created by that server contain an IIOP profile body. To establish a connection, the client side decodes that profile body and uses the host and port number to establish a connection to the server. Having established a connection, the client sends the object key with every request. In other words, the host and port identify the target server, and the object key is decoded by the server to determine which specific object should receive the request.

13.8 Structure of an IOR

CORBA uses interoperable object references as the universal means of identifying an object. As mentioned in Section 2.5.1, object references are opaque to the client-side application code and completely encapsulate everything that is necessary to send requests, including the transport and protocol to be used.

IIOP is the main interoperable protocol used by CORBA, and every ORB claiming interoperability must support IIOP. CORBA also specifies another protocol, known as the DCE Common Inter-ORB Protocol (DCE-CIOP). This protocol is optional (interoperable ORBs need not support it) and uses DCE-RPC as its underlying transport.

DCE-CIOP is an example of what is known as an environment-specific inter-ORB protocol (ESIOP). Environment-specific protocols permit use of CORBA over transports and protocols other than TCP/IP and permit vendors to support proprietary protocols that are optimized for particular environments. As CORBA evolves, we will see support for other transports and protocols. For example, it is likely that a future version will support connection-oriented GIOP over ATM networks and also allow use of connectionless transports such as UDP.

This means that object references must be extensible so that future protocols can be added without breaking existing clients and servers. CORBA specifies an encoding for IORs that meets this requirement. Not only can IORs be extended to carry protocol information for future protocols, but also it is possible for vendors to add their own proprietary protocols. In addition, a single IOR can contain information for multiple protocols. For example, an IOR can contain both IIOP and DCE-CIOP information simultaneously. In that way, clients that are limited to DCE-CIOP can use the same IOR to communicate with an object that clients that are limited to IIOP can use. If a client has access to both transports simultaneously, the ORB run time dynamically chooses which transport to use for a request.

An IOR can also contain multiple profile bodies for the same protocol. For example, an IOR could contain three IIOP profiles, each indicating a different host and port number. When a client invokes a request via the IOR, the ORB run time dynamically chooses one of the three server endpoints indicated in the IOR. This provides a hook for load balancing as well as fault-tolerant ORBs that replicate the same single CORBA object in multiple server processes.[8]

545

IT-SC book: Advanced CORBA® Programming with C++

[8] The OMG has taken the first steps to standardize fault tolerance (see [22]).

The CORBA specification uses pseudo-IDL to define how an IOR encodes the information required to send a request to the correct target object:

module IOP {

// PIDL

typedef unsigned long ProfileId;

const ProfileId

TAG_INTERNET_IOP = 0;

const ProfileId

TAG_MULTIPLE_COMPONENTS = 1;

struct TaggedProfile {

ProfileId

tag;

sequence<octet> profile_data;

};

 

struct IOR {

type_id;

string

sequence<TaggedProfile> profiles;

};

 

typedef unsigned long ComponentId; struct TaggedComponent {

ComponentId tag; sequence<octet> component_data;

};

typedef sequence<TaggedComponent> MultipleComponentProfile;

};

At first glance, this is intimidating, but things are not quite as bad as they look. The main data type in this IDL is struct IOR, which defines the basic encoding of an IOR as a string followed by a sequence of profiles. The type_id string provides the interface type of the IOR in the repository ID format we discuss in Section 4.19. The profiles field is a sequence of protocol-specific profiles, usually one for each protocol supported by the target object. For example, an IOR for an object that can be reached either via IIOP or via DCE-CIOP has two elements in the profiles sequence. Figure 13.7 shows the main structure of an IOR.

Figure 13.7 Main structure of an IOR.

To illustrate, an IOR for the controller in our climate control system contains a repository ID with value IDL:CCS/Controller:1.0. Assuming that the ORB used to implement the controller object supports only IIOP, the repository ID is followed by a single profile containing a structure of type TaggedProfile. A tagged profile contains a tag field and an octet sequence that contains the profile body identified by the tag. In the case of IIOP 1.1, the tag is TAG_INTERNET_IOP (zero), and the profile_data

member encodes a structure of type IIOP::ProfileBody as shown in Section 13.7.

546

IT-SC book: Advanced CORBA® Programming with C++

The OMG administers the namespace for tag values. To support a proprietary protocol, a vendor can request assignment of one or more tag values for its exclusive use. The tag value determines the format of the profile data, so vendors can use an exclusive tag to indicate a vendor-specific profile that encodes the addressing information for a proprietary protocol. Clients attempt to decode the profile information only for those tags they know about and ignore all other profiles. In that way, proprietary protocol information inside an IOR does not compromise interoperability. As long as the IOR contains at least one IIOP profile, any interoperable ORB can use the IOR.

If an IOR profile has the tag TAG_MULTIPLE_COMPONENTS, the profile_data field contains a sequence of type MultipleComponentProfile. Multiple component profiles themselves have internal structure, which is encoded as a sequence of structures of type TaggedComponent. As for profile tags, the OMG also administers the namespace for component tags, so vendors can encode proprietary information in an IOR without compromising interoperability.

Multicomponent profiles are used for service-specific information. For example, ORBs that support the OMG Security Service add a component to every IOR that describes which security mechanism is to be used to secure a request. Another component is used to describe which codeset is to be used for requests containing wide characters.

One of the components specified by CORBA encodes the ORB type. The ORB type describes the specific ORB vendor and ORB version that was used to create the IOR (not all ORBs use this component). The ORB type component enables a number of optimizations. Specifically, if an IOR contains the ORB type, a client can determine whether the IOR was created by the same ORB as the one used by the client. If it was, the client knows how to decode the proprietary parts of the IOR because the IOR was created by the same ORB. The proprietary part of the IOR in turn can contain information to optimize communication between client and server (we show some of these optimizations in Section 14.4.6).

13.9 Bidirectional IIOP

As mentioned in Section 13.4, CORBA 2.3 added GIOP 1.2 and IIOP 1.2 to enable bidirectional communication. This allows client and server to reverse roles without the need to open a separate connection that may be blocked by a firewall. At the time of writing, the specification is undergoing changes, and implementations are unlikely to appear before mid-1999, so we do not cover version 1.2 in detail in this chapter. Here is a summary of the major changes.

GIOP 1.2 does not add new message types but adds extensions to most of the message headers and bodies. These extensions support the additional information that must be exchanged for bidirectional communication.

GIOP 1.2 adds a LOCATE_FORWARD_PERM reply status, which is intended to ease object migration (see Section 14.5).

547

IT-SC book: Advanced CORBA® Programming with C++

GIOP 1.2 tightens the alignment restrictions for a request body to make remarshaling after a LOCATE_FORWARD reply more efficient.

IIOP 1.2 adds additional information to the service context to support bidirectional communication. It also defines a policy that enables bidirectional communication only if both client and server agree to use it. This policy allows administrators to disable bidirectional communication over insecure links and thereby prevent clients from masquerading as someone else's call-back object. If bidirectional communication is disabled, GIOP 1.2 uses a separate connection for callbacks.

13.10 Summary

GIOP specifies the on-the-wire representation of data and the messages that are exchanged between clients and servers. IIOP adds the specific information required for ORBs to interoperate via TCP/IP. All interoperable ORBs support IIOP. In addition, ORBs may support DCE-CIOP or proprietary protocols.

IORs contain the interface type of an object and one or more protocol profiles. Each profile contains the information required by a client to send a request using a specific protocol. A single IOR can contain addressing information for several protocols simultaneously. This arrangement allows a single CORBA object to be reached via different transports and also provides a basic protocol hook for fault-tolerant ORBs.

An IIOP 1.1 profile can contain a number of tagged components. Components encode additional information; for example, they can identify the codeset or security mechanism to be used for a request. Vendors can add proprietary components to IORs to support value-added features or optimizations.

CORBA defines a particular component that identifies the ORB vendor and ORB version. If this component is present in an IOR, clients can detect whether both client and server use the same ORB. If they do, clients can take advantage of this knowledge to optimize communication with the server.

GIOP 1.2 and IIOP 1.2 permit clients and servers to communicate across firewalls over a single connection.

548