Back to Naming Service Examples Page Back

Naming Service Example: Load Balancing

Description

The LoadBalancing example shows how to use OpenFusion's LoadBalancer in CosNaming. The example shows how to create multiple CORBA Objects and bind them to the Naming Service with a specific, predefined OpenFusion LoadBalancing policy. The Object bound into the Naming Service in this example is called "Server".

A Client is then able to resolve a Server by resolving it from the Naming Service. Which object is returned depends on the Load Balancing policy that was set when the "Server" Objects were bound to the Naming Service.

The example assigns a unique name to each of the "Server" objects so that the user is able to see clearly which "Server" object is returned by the Naming Service, and hence see what effect the LoadBalancing policies have.

The example consists of a Server object which is bound into the Naming Service, an LBServer object, and an LBClient object. The LBServer is used to place the Server objects into the Naming Service and then waits so that the LBClients are able to resolve a reference to the Server objects. The example consists of three objects: ServerImpl, LBServer, and LBClient.

ServerImpl.java is the CORBA Object that gets bound into the Naming Service. When instantiated it assigns a unique name to itself and provides a method so that other objects can retrieve its unique name. The first Server object to be instantiated has the name "Server 0". The second has the name "Server 1", and so on.

LBServer.java creates three Server objects (see above), and binds them to the Naming Service with a "RoundRobin" LoadBalancing policy.

The LBServer will perform the following tasks:

LBClient.java will resolve the Server Object from the Naming Service, and invoke a method on it to retrieve the Server's name.

The LBClient will perform the following tasks:

Setting up the Naming Service to use the LoadBalancingFactory

  1. Start the Administration Manager and expand the NameService node to show its child nodes.
  2. Select the child node that is called NameSingleton.
  3. In the right-hand pane, select the General tab.
  4. In the table of properties, ensure that the check box for the Enable Load Balancing property is checked.
  5. Right-click on the Naming Service node and from the pop-up menu save the configuration data.
  6. Right-click on the Naming Service node and from the pop-up menu start the Service.

How To Run This Example

First make sure the OpenFusion Naming Service is running on your network with the LoadBalancing option enabled (see above).

If using an ORB which requires persistent POAs to be registered before they can be activated, ensure that the OpenFusion.NamingLBServer POA is registered.

  1. Run the LBServer:
    run -x com.prismt.cos.CosNaming.examples.LoadBalance.LBServer

    This will start the server which has bound a number of objects under the same name in the Naming Service. This should output "Entering Server Loop..." upon successful execution.

  2. Start the LBCLient in a new window:
    run -x com.prismt.cos.CosNaming.examples.LoadBalance.LBClient

    This will resolve a number of Server objects and display their unique ID to the screen, in the order they were resolved under the RoundRobin LoadBalancing policy.


PrismTech TOP
Top