Application Context state replication

This article describes what Application context state replication is and how to set it up



1 Introduction

2 RMI-cluster enabling a Server

    Go through the following steps to RMI-cluster enable a Server:



    2.1 Step 1: Configure a RMI-cluster service

      Follow this guide to configure the RMI-cluster service

    2.2 Step 2: Verify cluster configuration

      Verify the RMI-cluster configuration by starting up the Servers in cluster-debug mode as described here and then access a Application context state altering resource of one of the clustered Servers. Console output on the Servers of the cluster should show that state is being replicated.

      If no easily usable state altering resource exists on the Servers, a simle JSP page like the one in listing 1 below can be added to one of the Web-modules on the Servers.


      <%@ page import="javax.naming.InitialContext,
      java.io.IOException,
      javax.naming.NamingException,
      javax.naming.NameAlreadyBoundException,
      java.util.HashMap"%>
      <%
      InitialContext context=new InitialContext();
      HashMap map=new HashMap();
      map.put("a","server a");
      map.put("b","server a");
      map.put("c","server a");
      out.write("Current values: ");
      try
      {
      out.write(context.lookup("jnditest")+ "<br>");
      }
      catch (IOException e)
      {
      out.write(e.getMessage()+"<br>");
      }
      catch (NamingException e)
      {
      out.write(e.getMessage()+"<br>");
      }

      try
      {
      context.bind("jnditest",map);
      } catch(NameAlreadyBoundException nabe)
      {
      context.rebind("jnditest",map);
      }

      map.put("d","server a"); //not rebound so not replicated
      try
      {
      out.write("After: "+context.lookup("jnditest")+ "<br>");
      } catch (IOException e)
      {
      out.write(e.getMessage()+"<br>");
      } catch (NamingException e)
      {
      out.write(e.getMessage()+"<br>");
      }
      out.write("<hr>");
      %>
      Listing 1: A sample Application context state altering JSP page

    If the above steps has been completed successfully the Servers should now be able to share their Application contextstate within the cluster.

3 Debugging

    This section describes common techniques that can be used to debug RMI-clustering.



    3.1 Tracing

      In order to get trace information from the cluster services, start the Orion Server with the cluster.debug and rmi.debug system properties set to true, as exemplified in listing 4 below.


      java -Drmi.debug=true -Dcluster.debug=true -jar orion.jar -console
      Listing 4: Starting a Orion server with cluster debug system properties turned on

      The cluster.debug property will list common debug information to the cosole.

      The rmi.debug property will list RMI debug information to the console.

    3.2 Application logs

      Issues the RMI-clustering service has with either sending or receiving state can be found in the Applications application.log file per default.

4 Troubleshooting

    This section describes common problems and possible solutions.



    4.1 Firewall issues

      Make sure that any firewalls allows for the Servers to communicate on the configured multicast address in both directions, both sending and receiving information.

      Using a simple multicast sender/receiver test application allows for testing the configured multicast address and make sure that packets can be both sent and received.

    4.2 Proxies/Gateways issues

      As multicast packets are known to hog down networks if allowed to roam free, most proxies and gateways won't let multicast packets pass. Make sure that the multicast packets can reach all nodes in the cluster and configure any proxies/gateways accordingly.

    4.3 Non distributable state

      If certain objects are not replicated within the cluster, make sure that these values are either Serializable or remote RMI-objects (this also goes for any objects this object is using/referring to).

    4.4 Manipulating bound values

      Serializable objects must be rebound after manipulation in order for the change in state to get replicated.

Copyright 2003 IronFlare AB