5 Replies Latest reply on Sep 25, 2009 10:10 AM by brian.stansberry

    Compatibility with JGroups 2.8

    brian.stansberry

      Hi,

      One of the things I'd like to do for the upcoming AS 5.2 is move to JGroups 2.8. The big impediment to that has been that a number of projects (AS, JBC, JBM) have some code that casts JGroups Address objects from the Address interface used in the API to the IpAddress concrete class that JGroups has historically used. A big change in 2.8 is the Address type is no longer IpAddress.

      The use of IpAddress in JBM 1.4.x is in the PostOfficeAddressInfo class, where the cast is done to allow serialization via the JGroups Streamable interface. There's a pretty easy fix for that though, as JGroups exposes a utility method that does what JBM currently does without requiring JBM to cast:

      Index: src/main/org/jboss/messaging/core/impl/postoffice/PostOfficeAddressInfo.java
      ===================================================================
      --- src/main/org/jboss/messaging/core/impl/postoffice/PostOfficeAddressInfo.java (revision 7825)
      +++ src/main/org/jboss/messaging/core/impl/postoffice/PostOfficeAddressInfo.java (working copy)
      @@ -27,7 +27,7 @@
      
      
       import org.jboss.messaging.util.Streamable;
      
       import org.jgroups.Address;
      
      -import org.jgroups.stack.IpAddress;
      
      +import org.jgroups.util.Util;
      
      
      
       /**
      
       *
      
      @@ -70,30 +70,16 @@
      
      
       public void read(DataInputStream in) throws Exception
      
       {
      
      - controlChannelAddress = new IpAddress();
      
      -
      
      - controlChannelAddress.readFrom(in);
      
      -
      
      - dataChannelAddress = new IpAddress();
      
      + controlChannelAddress = Util.readAddress(in);
      
      
      
      - dataChannelAddress.readFrom(in);
      
      + dataChannelAddress = Util.readAddress(in);
      
       }
      
      
      
       public void write(DataOutputStream out) throws Exception
      
       {
      
      - if (!(controlChannelAddress instanceof IpAddress))
      
      - {
      
      - throw new IllegalStateException("Address must be IpAddress");
      
      - }
      
      -
      
      - if (!(dataChannelAddress instanceof IpAddress))
      
      - {
      
      - throw new IllegalStateException("Address must be IpAddress");
      
      - }
      
      + Util.writeAddress(controlChannelAddress, out);
      
      
      
      - controlChannelAddress.writeTo(out);
      
      -
      
      - dataChannelAddress.writeTo(out);
      
      + Util.writeAddress(dataChannelAddress, out);
      
       }
      
      
      
       // Public --------------------------------------------------------
      


      So, looking for input from the JBM team as to

      a) use of JGroups 2.8 in AS 5.2 in general, i.e. compatibility with JBM
      b) possibility of getting the above in a JBM 1.x release for inclusion in AS 5.2.