Sun Java System Application Server Enterprise Edition 8.2 High Availability Administration Guide

Chapter 11 RMI-IIOP Load Balancing and Failover

This chapter describes using Sun Java System Application Server’s high-availability features for remote EJB references and JNDI objects over RMI-IIOP.

Overview

With RMI-IIOP load balancing, IIOP client requests are distributed to different server instances or name servers. The goal is to spread the load evenly across the cluster, thus providing scalability. IIOP load balancing combined with EJB clustering and availability also provides EJB failover.

When a client performs a JNDI lookup for an object, the Naming Service creates a InitialContext (IC) object associated with a particular server instance. From then on, all lookup requests made using that IC object are sent to the same server instance. All EJBHome objects looked up with that InitialContext are hosted on the same target server. Any bean references obtained henceforth are also created on the same target host. This effectively provides load balancing, since all clients randomize the list of live target servers when creating InitialContext objects. If the target server instance goes down, the lookup or EJB method invocation will failover to another server instance.

IIOP Load balancing and failover happens transparently. No special steps are needed during application deployment. However, adding or deleting new instances to the cluster will not update an existing client's view of the cluster. To do so, you must manually update the endpoints list on the client.

Requirements

Sun Java System Application Server Enterprise Editionprovides high availability of remote EJB references and NameService objects over RMI-IIOP, provided all the following apply:

Application Server supports load balancing for the following RMI-IIOP clients accessing EJB components deployed on an Application Server.


Note –

Application Server does not support RMI-IIOP load balancing and failover over secure sockets layer (SSL).


Algorithm

Application Server uses a randomization and round-robin algorithm for RMI-IIOP load balancing and failover.

When an RMI-IIOP client first creates a new InitialContext object, the list of available Application Server IIOP endpoints is randomized for that client. For that InitialContext object, the load balancer directs lookup requests and other InitialContext operations to the first endpoint on the randomized list. If the first endpoint is not available then the second endpoint in the list is used, and so on.

Each time the client subsequently creates a new InitialContext object, the endpoint list is rotated so that a different IIOP endpoint is used for InitialContext operations.

When you obtain or create beans from references obtained by an InitialContext object, those beans are created on the Application Server instance serving the IIOP endpoint assigned to the InitialContext object. The references to those beans contain the IIOP endpoint addresses of all Application Server instances in the cluster.

The primary endpoint is the bean endpoint corresponding to the InitialContext endpoint used to look up or create the bean. The other IIOP endpoints in the cluster are designated as alternate endpoints. If the bean's primary endpoint becomes unavailable, further requests on that bean fail over to one of the alternate endpoints.

You can configure RMI-IIOP load balancing and failover to work with applications running in the ACC and with standalone Java clients.

Sample Application

The following directory contains a sample application that demonstrates using RMI-IIOP failover with and without ACC:

install_dir/samples/ee-samples/sfsbfailover

See the index.html file accompanying this sample for instructions on running the application with and without ACC. The ee-samples directory also contains information for setting up your environment to run the samples.

Setting up RMI-IIOP Load Balancing and Failover

You can set up RMI-IIOP load balancing and failover for applications running in the Application Client Container (ACC) and for standalone client applications.

ProcedureTo set up RMI-IIOP load balancing for the Application Client Container

This procedure gives an overview of the steps necessary to use RMI-IIOP load balancing and failover with the application client container (ACC). For additional information on the ACC, see Developing Clients Using the ACC in Sun Java System Application Server Enterprise Edition 8.2 Developer’s Guide.

  1. Go to the install_dir /bin directory.

  2. Run package-appclient.

    This utility produces an appclient.jar file. For more information on package-appclient, see package-appclient( 1M).

  3. Copy the appclient.jar file to the machine where you want your client and extract it.

  4. Edit the asenv.conf or asenv.bat path variables to refer to the correct directory values on that machine.

    The file is at appclient-install-dir /config/.

    For a list of the path variables to update, see package-appclient( 1M).

  5. If required, make the appclient script executable.

    For example, on UNIX use chmod 700.

  6. Find the IIOP listener port numbers for the instances in the cluster.

    Specify the IIOP listeners as endpoints to determine which IIOP listener receives the requests. To display the IIOP listeners in the Admin Console:

    1. In the Admin Console’s tree component, expand the Clusters node.

    2. Expand the cluster.

    3. Select an instance in the cluster.

    4. In the right pane, click the Properties tab.

      Note the IIOP listener port for the specific instance.

    5. Repeat the process for every instance.

  7. Edit sun-acc.xml for the endpoint values.

    Using the IIOP Listeners from the previous step, create endpoint values in the form:

    machine1:instance1–iiop-port, machine2:instance2–iiop-port

    For example:

    <property name="com.sun.appserv.iiop.endpoints" value="host1.sun.com:3335,host2.sun.com:3333,host3.sun.com:3334"\>

  8. Deploy your client application with the --retrieve option to get the client jar file.

    Keep the client jar file on the client machine.

    For example:

    asadmin deploy --user admin --passwordfile pw.txt --retrieve /my_dir myapp

  9. Run the application client as follows:

    appclient -client clientjar -name appname

Next Steps

To test failover, stop one instance in the cluster and see that the application functions normally. You can also have breakpoints (or sleeps) in your client application.

To test load balancing, use multiple clients and see how the load gets distributed among all endpoints.

ProcedureTo set up RMI-IIOP load balancing and failover for Stand-Alone Client

  1. Deploy the application with the --retrieve option to get the client jar file.

    Keep the client jar file on the client machine.

    For example:

    asadmin deploy --user admin --passwordfile pw.txt --retrieve /my_dir myapp

  2. Run the client jar and the required jar files, specifying the endpoints and InitialContext as -D values.

    For example:

    java -Dcom.sun.appserv.iiop.endpoints=
    host1.sun.com:33700,host2.sun.com:33700,host3.sun.com:33700 
    samples.rmiiiopclient.client.Standalone_Client
Next Steps

To test failover, stop one instance in the cluster and confirm that the application functions normally. You can also have breakpoints (or sleeps) in your client application.

To test load balancing, use multiple clients and see how the load gets distributed among all endpoints.