2 Replies Latest reply on Aug 31, 2005 4:28 PM by jason1

    Clustered servers on same machine not load-balancing

      In several places on the Forum and Wiki (ex: http://www.jboss.com/index.html?module=bb&op=viewtopic&t=52323)
      I see that I can run a cluster on the same machine (same NIC too). I've set it up using the binding service and it works great UNTIL testing load-balancing of requests across a clustered SLSB. They simply go to the same EJB each time. Any ideas?

      Here is some JGroups logging which tells me they see each other:
      -------------------------------------------------------
      GMS: address is tocarbong1:2535
      -------------------------------------------------------
      12:57:48,612 INFO [TreeCache] viewAccepted(): new members: [tocarbong1:1108, tocarbong1:2535]

      -------------------------------------------------------
      GMS: address is tocarbong1:1108
      -------------------------------------------------------
      12:57:48,628 INFO [TreeCache] viewAccepted(): new members: [tocarbong1:1108, tocarbong1:2535]

      My JUnit looks like this:

      /**
       * Calls ping on the same referenced Delegate SLSB
       * Tests RoundRobin load-balancing policy
       *
       * @throws Exception
       */
      public void testPingClusteredSameEJB() throws Exception {
       String curr;
       String prev = "!!!!!";
      
       // Uses direct EJB lookup rather than ServiceLocator
       InitialContext ic = new InitialContext();
       Object object = ic.lookup(DelegateSLSBeanRemoteHome.JNDI_NAME);
       DelegateSLSBeanRemoteHome home = (DelegateSLSBeanRemoteHome)PortableRemoteObject.narrow(object, DelegateSLSBeanRemoteHome.class);
      DelegateSLSBeanRemote delegateSLSB = home.create();
      
       for (int i=1;i<=10;i++){
       // returns unique name of each JBoss server
       Object pingReturn = delegateSLSB.ping();
      
       curr = pingReturn.toString();
       if (i>1 && curr.equals(prev)) {
       fail("RoundRobin failed. Ping to the same EJB references contacted the same servers in the cluster");
       }
      
       prev = curr;
       }
      }


        • 1. Re: Clustered servers on same machine not load-balancing

          It looks like you're using the non-clustered naming context to lookup your EJB. Try this:

          ...
          Properties props = new Properties();
          props.setProperty(javax.naming.Context.PROVIDER_URL, "jnp://localhost:1100");
          InitialContext ic = new InitialContext(props);
          ...
          



          • 2. Re: Clustered servers on same machine not load-balancing

            Here is my jndi.properties on the client-side. Should auto-discover the servers... Am I missing something in these settings?

            java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
            java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
            jnp.discoveryGroup=230.0.0.4
            jnp.discoveryPort=1102