5 Replies Latest reply on Mar 2, 2004 6:58 AM by Stefano Fornari

    JBoss -> jgroups problem

    Stefano Fornari Newbie

      Hi All,
      I really hope somebody can give me an hint on this matter, because it is driving me crazy :-(

      I have to implement a simple distributed cache between multiple JBoss istances not necessarily clustered.
      I though to use JGroups 2.2, which I understand JBoss uses already for clustering. Therefore, I created a DistributedHashtable in the init() of my servlet as follows:

      JChannel c = new JChannel(config.getInitParameter(PARAM_CHANNEL_PROPERTIES));

      c.connect("thegroup");
      cache = new DistributedHashtable(c, DEFAULT_TIMEOUT);

      The channel is configured in this way:
      "UDP(mcast_addr=228.1.2.3;mcast_port=45566;;ip_ttl=64;bind_addr=127.0.0.1;" +
      "ip_mcast=true;mcast_send_buf_size=150000;mcast_recv_buf_size=80000):" +
      "PING(timeout=2000;num_initial_members=3):" +
      "MERGE2(min_interval=5000;max_interval=10000):" +
      "FD_SOCK:" +
      "VERIFY_SUSPECT(timeout=1500):" +
      "pbcast.NAKACK(gc_lag=50;retransmit_timeout=300,600,1200,2400,4800):" +
      "UNICAST(timeout=5000):" +
      "pbcast.STABLE(desired_avg_gossip=20000):" +
      "FRAG(frag_size=4096;down_thread=false;up_thread=false):" +
      "pbcast.GMS(join_timeout=5000;join_retry_timeout=2000;" +
      "shun=false;print_local_addr=true):" +
      "pbcast.STATE_TRANSFER";

      Then when I run the servlet I put something in the hashtable. It alone works well.

      Then I would like to test it with aother VM. I developed a simple program that creates its own DistributedHastable on a chennel connected to the same group as the other one (see the code at the bottom).

      In short, I have the following strange situation:

      1) both JVMs see each other (I display the channel views)
      2) changes made with the second JVMs are propagated to the JBoss DistributedHahtable
      3) changes made in the JBoss VM are NOT propagated to the second VM!!!!

      I can't really understand why, as I though multicast communications have no a specific direction....

      Any help is very appreciated.

      Stefano
      -------------------------------------------------------------

      2nd VM code:
      =========

      String props="UDP(mcast_addr=228.1.2.3;mcast_port=45566;;ip_ttl=64;bind_addr=127.0.0.1;" +
      "ip_mcast=true;mcast_send_buf_size=150000;mcast_recv_buf_size=80000):" +
      "PING(timeout=2000;num_initial_members=3):" +
      "MERGE2(min_interval=5000;max_interval=10000):" +
      "FD_SOCK:" +
      "VERIFY_SUSPECT(timeout=1500):" +
      "pbcast.NAKACK(gc_lag=50;retransmit_timeout=300,600,1200,2400,4800):" +
      "UNICAST(timeout=5000):" +
      "pbcast.STABLE(desired_avg_gossip=20000):" +
      "FRAG(frag_size=4096;down_thread=false;up_thread=false):" +
      "pbcast.GMS(join_timeout=5000;join_retry_timeout=2000;" +
      "shun=false;print_local_addr=true):" +
      "pbcast.STATE_TRANSFER";
      JChannel c = new JChannel(props);

      c.connect("thegroup");
      DistributedHashtable h = new DistributedHashtable(c, -1);

        • 1. Re: JBoss -> jgroups problem
          Bela Ban Master

          Lose the bind_addr=127.0.0.1.

          I have some code that shows how to access the TreeCache MBean from servlets, I will post a document soon.

          Bela

          • 2. Re: JBoss -> jgroups problem
            Stefano Fornari Newbie

            HI Bela,
            I removed bind_addr=127.0.0.1, but still the same behavior. Can I try anything else?

            Stefano

            • 3. Re: JBoss -> jgroups problem
              Bela Ban Master

              Are you multihomed ? Then you need to set the bind_addr to a *valid* NIC. Note that on Solaris 8 for example, binding to 127.0.0.1 for multicast doesn't work (this was fixed on Solaris 9).

              1. Check what address is printed for each member.
              2. Verify that that name resolves to the same IP address (check /etc/hosts).

              Bela

              • 4. Re: JBoss -> jgroups problem
                Stefano Fornari Newbie

                I have eventually solved the problem.
                It was related to class loading and object serialization. What happened is that when at the end I managed to make the two JBoss instances speak each other, objects put in the table were propagated, but JGroups was not able to deserialize the instances because jgroups-all.jar was in the server//lib directory instead of being deployed within the war file.

                I discovered the problem enabling tracing with Trace.init().

                So, from a beginner to beginners: if you have troubles, first of all enable tracing, it will show you what happens behind the scene.

                Stefano

                • 5. Re: JBoss -> jgroups problem
                  Stefano Fornari Newbie

                  I have eventually solved the problem.
                  It was related to class loading and object serialization. What happened is that when at the end I managed to make the two JBoss instances speak each other, objects put in the table were propagated, but JGroups was not able to deserialize the instances because jgroups-all.jar was in the server/{server}/lib directory instead of being deployed within the war file.

                  I discovered the problem enabling tracing with Trace.init().

                  So, from a beginner to beginners: if you have troubles, first of all enable tracing, it will show you what happens behind the scene.