Chapter 5: The ORB Smart Agent

This chapter describes the osagent, which provides directory service functions, fault tolerance and object migration facilities. It includes the following major sections:

Smart Agent Features

ORB Domains

Connecting Agents on Different Local Networks

Using Point-to-point Communications

Object Implementation Fault Tolerance

Object Migration

Advanced Networking Options

Smart Agent Features

VisiBroker's osagent is a dynamic, distributed directory service that provides facilities for both client applications and object implementations. When a client application invokes the _bind method on an object, the osagent locates the specified implementation and object so that a connection can be established between the client and the implementation. Object implementations register their objects with the osagent so that client applications can locate and use those objects. When an object or implementation is destroyed, the osagent removes them from its list of available objects.

Agent Communication

An osagent may be started on any host. To locate an osagent, client applications and object implementations send a broadcast message, and the first osagent to respond will be used. Once an osagent has been located, a point-to-point UDP communication is established for registration and look-up requests. The UDP protocol is used because it consumes fewer network resources than a TCP connection. All registration and locate requests are dynamic, so there are no required configuration files or mappings to maintain.

Note: Broadcast messages are usually used only to locate an osagent. All other communication with the osagent makes use of a point-to-point communication. "Using Point-to-point Communications" on page 5-5 describes how to override the use of broadcast messages.

Agent-to-Agent Cooperation

When multiple instances of the osagent are started on different hosts, each osagent will recognize a subset of the objects available and communicate with other osagents to locate objects it cannot find. If one of the osagent processes should terminate unexpectedly, all implementations registered with that agent will be notified and they will automatically re-register with another available osagent.

Cooperation with the OAD

The osagent maintains a list of all persistent object implementations that are registered with the Object Activation Daemon. When the ORB requests the osagent to locate an object that has been registered directly with the osagent, the address of the object is returned. If the requested object is registered with the OAD, the osagent will return the address of the OAD capable of activating the object and the ORB will contact that OAD.

The following figure shows the sequence of locating and activating an object registered with the OAD.

Starting the osagent

At least one instance of the osagent should be running on your local network. The following example shows how to start the osagent. The verbose mode option provides informational and diagnostic messages. Local network refers to the part of the network within which broadcast message can be sent-machines in the same subnet

osagent -v

Agent Fault Tolerance

If you run more than one instance of the osagent on a local network and one of those agents becomes unavailable, all object implementations registered with that agent will be automatically re-registered with another agent. Likewise, client applications using an osagent that becomes unavailable will be automatically switched to another agent by VisiBroker. No special coding techniques are required to take advantage of this osagent fault-tolerance, as long as more than one osagent exists on your local network.

ORB Domains

It is often desirable to have two or more separate ORB domains running at the same time. One domain might consist of the production versions of client applications and object implementations while another domain might be made up of test versions of the same clients and objects that have not yet been released for general use.

The following figure shows separate ORB Domains.

VisiBroker allows you to distinguish between two or more ORB domains on the same network by using a unique UDP port number for the osagents for each domain. The environment variable OSAGENT_PORT must be set on each host running an osagent, an oad, object implementations, or client applications assigned to that ORB domain.

Caution: Check with your system administrator to determine what port numbers are available for your use.

The following example shows the setting of the OSAGENT_PORT environment variable for a UNIX system running csh.

prompt> setenv OSAGENT_PORT 5678
prompt> osagent &
prompt> oad &

Connecting Agents on Different Local Networks

If you start multiple osagents on your local network, they will discover each other by using UDP broadcast messages. Your network administrator configures a local network by specifying the scope of broadcast messages using the IP subnet mask. Figure 5-5 shows two local networks, connected by a network link

The following figure shows two osagent processes and their IP addresses, located on separate, connected local networks.

To allow the osagent on one network to contact an osagent on another local network, you must make the IP address of the remote osagent available in a file named agentaddr. Figure 5-6 shows what this file would contain to allow the osagent on local network #1 to connect to the osagent on the other network. The path to this file is specified by the ORBELINE environment variable that is set for the osagent process.

The following example shows the content of the agentaddr file for the osagent on network #1.

101.10.2.6
With the appropriate agentaddr file, the client application on network #1 could locate and use object implementations on network #2. For more information on environment variables, see the VisiBroker for C++ Reference Guide.

Note: Even if a remote network has multiple osagents running, you need to list all of the osagents for that network in the agentaddr file.

Using Point-to-point Communications

VisiBroker provides you with three different strategies for circumventing the use of UDP broadcast messages for locating osagent processes. When an osagent is located with any of these alternate approaches, that agent will be used for all subsequent interactions. If an osagent cannot be located using any of these alternate approaches, the ORB will revert to using the broadcast message scheme to locate an osagent.

Specifying IP addresses with the agentaddr File

You can use the agentaddr file to circumvent the use of UDP broadcast message to locate an osagent. Simply create an agentaddr file containing the IP addresses of each node where an osagent is running and then set the OSAGENT_ADDR environment variable to point to the location of the agentaddr file. When a client application or object implementation has this environment variable set, the ORB will try each address in the file until an osagent is located.

Specifying IP addresses as Run-time Parameters

The following example shows how you can specify an osagent's IP address as a run-time parameter for your client application or object implementation. You can have a machine with many IP addresses. If you do have many IP addresses on a machine, specify a particular address on the command line for any program using the orb. See "Advanced Networking Options" on page 5-9 for more information on this and other run-time parameters.


prompt> server -ORBagentaddr 101.10.2.6 &

...

or

prompt> client -ORBagentaddr 199.10.9.5

Object Implementation Fault Tolerance

You can provide object implementation fault tolerance for stateless objects by simply starting instances of those objects on multiple hosts. The osagent will detect the loss of the connection between the client application and the object implementation and the ORB will automatically attempt to establish a connection with another instance of the object implementation. The client can continue invoking methods on the object without being concerned that a new instance of the object is being used.

Caution: The rebind option, discussed in "Enabling Re-Binds" on page 3-8, must be enabled if the ORB is to be able re-connect the client with a replica object implementation.

Object Implementations that Maintain State

Fault tolerance can still be achieved with object implementations that maintain state, but it will not be transparent to the client application. In these cases, the client application must register an event handler for the ORB object. When the connection to an object implementation fails and the ORB re-connects the client to a replica object implementation, the event handler's rebind_succeeded method will be invoked by the ORB. The client can implement this method to bring the state of the replica up to date. Event handlers are described in Chapter 7.

Replicating Instantiated Objects

If the ORB objects that you wish to be fault tolerant are created by a server process instantiating the implementation's C++ class, you need only ensure that the server process is started on multiple hosts.

Replicating Objects Registered with the OAD

If the ORB objects that you wish to be fault tolerant are registered with the oad, you must ensure that the oad is started on multiple hosts. Furthermore, you must ensure that the ORB objects are registered with each of the oad processes.

Note: The type of object replication provided by VisiBroker does not provide a multi-cast or mirroring facility. At any given time there is always a one-to-one correspondence between a client application and a particular object implementation.

Object Migration

Object migration is the process of terminating an object implementation on one host and then starting it on another host. Object migration can be used to move objects from overloaded hosts to hosts that have more resources or processing power. Object migration can also be used to keep objects available when a host has to be shutdown for hardware or software maintenance.

Caution: The rebind option, discussed in "Enabling Re-Binds" on page 3-8, must be enabled for the ORB to be able re-connect a client with a object implementation that has migrated to a new host.

The migration of objects that do not maintain state is transparent to the client application. If a client is connected to an object implementation that has migrated, the osagent will detect the loss of the connection and transparently re-connect the client to the new object on the new host.

Migrating Object that Maintain State

The migration of objects that maintain state is also possible, but it will not be transparent to a client application that has connected before the migration process begins. In these cases, the client application must register an event handler for the ORB object. When the connection to the original object is lost and the ORB re-connects the client to the object, the event handler's rebind_succeeded method will be invoked by the ORB. The client can implement this method to bring the state of the object up to date. Event handlers are described in Chapter 7.

Migrating Instantiated Objects

If the ORB objects that you wish to migrate were created by a server process instantiating the implementation's C++ class, you need only terminate the server process and start it on a new host. When the original instance is terminated, it will be un-registered with the osagent. When the new instance is started on the new host, it will register with the osagent. From that point on, client invocations will be routed to the object implementation on the new host.

Migrating Objects Registered with the OAD

If the ORB objects that you wish to migrate are registered with the oad, you will need to ensure they are un-registered with the oad. Furthermore, you must ensure that the ORB objects are then registered with the oad on the new host. Here are the steps:

  1. Un-register the object implementation from the OAD on the old host.
  2. Terminate the object implementation on the old host.
  3. Register the object implementation with the OAD on the new host.
See Chapter 4 for detailed information on registering and unregistering object implementations.

Advanced Networking Options

Although VisiBroker provides reasonable default settings for the network resources it uses, you may fine-tune these setting through parameters passed to the ORB_init method. The object implementation can set similar options through parameters passed to the BOA_init method.

ORB_init Options

Figure 5-8 shows the definition of the ORB_init method and the arguments it accepts. The argc and argv parameters are passed in exactly the same format as arguments passed to your client's main routine. The argc parameter defines the number of arguments and argv is an array of char pointers to those arguments. ORB settings take the form of type-value pairs, enabling them to be distinguished from other arguments passed to your client application. In fact, the ORB_init method will ignore any arguments it does not recognize. The following section summarizes the ORB_init options.

The following example shows the ORB_init method definition.


class CORBA {

...

static ORB_ptr ORB_init(int& argc, char *const *argv,

*orb_id = (char *)NULL);

...

};

In the preceding example, orb_id identifies the type of ORB. Currently "Internet ORB" is the only supported value.

This section lists the ORB_init options. The type/value pair is given and then the purpose.

-ORBagentaddr ip_address

Specifies the IP address of the host running the osagent this client should use. If an osagent is not found at the specified address or if this option is not specified, broadcast messages will be used to locate an osagent. You can have a machine with many IP addresses. If you do have many IP addresses on a machine, specify a particular address on the command line for any program using the orb.

-ORBagentport port_number

Specifies the port number of the osagent. This option can be used if multiple ORB domains are in use, described in "ORB Domains" on page 5-4.

-ORBsendbufsize buffer_size

Specifies the size of the buffer used to send client requests. If not specified, an appropriate buffer size will be used.

-ORBrcvbufsize buffer_size

Specifies the size of the buffer used to receive responses. If not specified, an appropriate buffer size will be used.

-ORBmbufsize buffer_size

Specifies the size of the intermediate buffer used by VisiBroker. An argument will be copied to the intermediate buffer if it is not too big, otherwise VisiBroker will maintain a pointer to the argument instead of copying it. Changing this parameter can seriously affect the performance of your system.

-ORBshmsize size

Specifies the size of the send and receive segments in shared memory. If your client applications and object implementations communicate via shared memory, you may use this option to enhance performance.

BOA_init Options

The following example shows the definition of the BOA_init method and the arguments it accepts. Like the ORB_init method, the argc and argv parameters passed to BOA_init are in exactly the same format as arguments passed to your object implementation's main routine. All but two of the BOA settings take the form of type-value pairs. The BOA_init method will ignore any arguments it does not recognize. The following section summarizes the BOA_init options. boa_identifier identifies the type of object-adaptor to be used.


class CORBA {

...

static BOA_ptr BOA_init(int& argc, char *const *argv,

const char *boa_identifier = "PMC_BOA");

...

};

BOA_init options are listed in the following section. The type/value pair is given first followed by the purpose.

-OAipaddr ip_address

Specifies the IP address to be used for the Object Adaptor. Use this option if your machine has multiple network interfaces and the BOA is associated with just one address. If no option is specified, the host's default address is used.

-OAport port_number

Specifies the port number to be used by this process. If none is specified, an unused port will be selected.

-OAsendbufsize buffer_size

Specifies the size of the buffer used to send messages. If not specified, an appropriate value will be used.

-OArcvbufsize buffer_size

Specifies the size of the buffer used to receive messages. If not specified, an appropriate value will be used.

-OAnoshm

Disables the use of shared memory as a message transport.

-OAshm

Enables the use of shared memory as a message transport. This option is the default.


[Preface] [Chapter 1] [Chapter 2] [Chapter 3] [Chapter 4] [Chapter 5] [Chapter 6]
[Chapter 7] [Chapter 8] [Chapter 9] [Chapter 10] [Chapter 11] [Chapter 12] [Appendix A]