This section describes the Smart Agent (osagent), which client programs register with in order to find object implementations. It explains how to configure your own VisiBroker ORB domain, connect Smart Agents on different local networks, and migrate objects from one host to another.
VisiBroker's Smart Agent (osagent) is a dynamic, distributed directory service that provides facilities used by both client programs and object implementations. A Smart Agent must be started on at least one host within your local network. When your client program invokes
bind() on an object, the Smart Agent is automatically consulted. The Smart Agent locates the specified implementation so that a connection can be established between the client and the implementation. The communication with the Smart Agent is completely transparent to the client program.
If the PERSISTENT policy is set on the POA, and
activate_object_with_id is used, the Smart Agent registers the object or implementation so that it can be used by client programs. When an object or implementation is deactivated, the Smart Agent removes it from the list of available objects. Like client programs, the communication with the Smart Agent is completely transparent to the object implementation. For more information about POAs, go to
“Using POAs”.
Due to signal handling changes, bourne and korn shell users need to use the ignoreSignal hup parameter when starting
osagent in order to prevent the hangup (
hup) signal from terminating the process when the user logs out. For example:
nohup $VBROKERDIR/bin/osagent ignoreSignal hup &
The osagent command accepts the following command line arguments:
The following example of the osagent command specifies a particular UDP port:
A Smart Agent sends an “are you alive” message (often called a heartbeat message) to its clients every two minutes to verify the client is still connected. If the client does not respond, the Smart Agent assumes the client has terminated the connection.
To override the default setting, the OSAGENT_PORT variable must be set accordingly before running a Smart Agent, an OAD, object implementations, or client programs assigned to that VisiBroker ORB domain. For example,
To allow the Smart Agent on one network to contact a Smart Agent on another local network, you must make the IP address of the remote Smart Agent available in a file named agentaddr. This is only necessary if the two Smart Agents can not detect each other through the UDP broadcast. The path to this file is specified by the
VBROKER_ADM environment variable that is set for the Smart Agent process. You can override this file name by setting the
OSAGENT_ADDR_FILE environment variable.
The following example shows what the agentaddr file would contain to allow a Smart Agent on Local Network #1 to connect to a Smart Agent on another local network.
With the appropriate agentaddr file, a client program on Network #1 locates and uses object implementations on Network #2. For more information on environment variables, see the VisiBroker
Installation Guide.
When you start the Smart Agent with the -v (verbose) option, each interface that the Smart Agent uses will be listed at the beginning of the messages produced. The example below shows the sample output from a Smart Agent started with the verbose option on a multihomed host.
You can specify interface information for each interface you wish the Smart Agent to use on your multihomed host in the localaddr file. The
localaddr file should have a separate line for each interface that contains the host's IP address, subnet mask, and broadcast address. By default, VisiBroker searches for the
localaddr file in the
VBROKER_ADM directory. You can override this location by setting the
OSAGENT_LOCAL_FILE environment variable to point to this file. Lines in this file that begin with a “
#” character, and are treated as comments and ignored. The code sample below shows the contents of the
localaddr file for the multihomed host listed above:
Though the Smart Agent can automatically configure itself on a multihomed host on UNIX, you can use the localaddr file to explicitly specify the interfaces that your host contains. You can display all available interface values for the UNIX host by using the following command:
The use of the localaddr file with multihomed hosts is required for hosts running Windows because the Smart Agent is not able to automatically configure itself. You can obtain the appropriate values for this file by accessing the TCP/IP protocol properties from the Network Control Panel. If your host is running Windows, the
ipconfig command will provide the needed values. This command is as follows:
By default, vbroker.agent.addr in the properties file is set to
NULL.
You can specify the IP address of a Smart Agent by setting the OSAGENT_ADDR environment variable prior to starting your client program or object implementation. This environment variable takes precedence if a host is not specified as a runtime parameter.
To set the OSAGENT_ADDR environment variable on a Windows system, you can use the System control panel and edit the environment variables:
Your client program or object implementation can use the agentaddr file to circumvent the use of a UDP broadcast message to locate a Smart Agent. Simply create a file containing the IP addresses or fully qualified hostnames of each host where a Smart Agent is running and then set the
OSAGENT_ADDR_FILE environment variable to point to the path of the file. When a client program or object implementation has this environment variable set, VisiBroker will try each address in the file until a Smart Agent is located. This mechanism has the lowest precedence of all the mechanisms for specifying a host. If this file is not specified, the
VBROKER_ADM/agentaddr file is used.
When the connection to an object implementation fails and VisiBroker reconnects the client to a replica object implementation, the bind method of the bind interceptor will be invoked by VisiBroker. The client must provide an implementation of this bind method to bring the state of the replica up to date. Client interceptors are described in
, “Using VisiBroker Interceptors.”.
When the connection to the original object is lost and VisiBroker reconnects the client to the object, the interceptor's rebind_succeeded() method will be invoked by VisiBroker. The client can implement this method to bring the state of the object up to date.
Refer to “Using Portable Interceptors” for more information about how to use the interceptors.
See “Using the Object Activation Daemon (OAD)” for detailed information on registering and unregistering object implementations.
The Smart Finder (osfind) command reports on all VisiBroker related objects and services which are currently available on a given network.
You can use osfind to determine the number of Smart Agent processes running on the network and the exact host on which they are executing. The
osfind command also reports on all VisiBroker objects that are active on the network if these objects are registered with the Smart Agent. You can use
osfind to monitor the status of the network and locate stray objects during the debugging phase.
The osfind command has the following syntax:
The following options are valid with osfind. If no options are specified,
osfind lists all of the agents, OAD's, and implementations in your domain.
osfind is a console application. If you start
osfind from the Start menu, it runs until completion and exits before you can view the results.
When your client application invokes the bind() method, VisiBroker performs several functions on behalf of your application. These are shown below.