Author: fhanik
Date: Wed Apr 26 07:31:25 2006
New Revision: 397203

URL: http://svn.apache.org/viewcvs?rev=397203&view=rev
Log:
Added in support for IPv6

Modified:
    
tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/group/RpcChannel.java
    
tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/membership/MemberImpl.java
    
tomcat/container/tc5.5.x/modules/groupcom/test/org/apache/catalina/tribes/demos/EchoRpcTest.java
    tomcat/container/tc5.5.x/modules/groupcom/to-do.txt

Modified: 
tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/group/RpcChannel.java
URL: 
http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/group/RpcChannel.java?rev=397203&r1=397202&r2=397203&view=diff
==============================================================================
--- 
tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/group/RpcChannel.java
 (original)
+++ 
tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/group/RpcChannel.java
 Wed Apr 26 07:31:25 2006
@@ -15,10 +15,6 @@
  */
 package org.apache.catalina.tribes.group;
 
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
 import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -29,7 +25,6 @@
 import org.apache.catalina.tribes.ChannelListener;
 import org.apache.catalina.tribes.Member;
 import org.apache.catalina.tribes.util.UUIDGenerator;
-import org.apache.catalina.tribes.tipis.*;
 
 /**
  * A channel to handle RPC messaging

Modified: 
tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/membership/MemberImpl.java
URL: 
http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/membership/MemberImpl.java?rev=397203&r1=397202&r2=397203&view=diff
==============================================================================
--- 
tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/membership/MemberImpl.java
 (original)
+++ 
tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/membership/MemberImpl.java
 Wed Apr 26 07:31:25 2006
@@ -173,7 +173,8 @@
         //package looks like
         //alive - 8 bytes
         //port - 4 bytes
-        //host - 4 bytes
+        //host length - 1 byte
+        //host - hl bytes
         //dlen - 4 bytes
         //domain - dlen bytes
         //uniqueId - 16 bytes
@@ -181,20 +182,29 @@
         
         byte[] domaind = this.domain;
         byte[] addr = host;
-        byte[] data = new byte[8+4+addr.length+4+domaind.length+16];
         long alive=System.currentTimeMillis()-getServiceStartTime();
+        byte hl = (byte)addr.length;
+        byte[] data = new byte[8+4+1+addr.length+4+domaind.length+16];
+        int pos = 0;
         //alive data
         XByteBuffer.toBytes((long)alive,data,0);
+        pos += 8;
         //port
-        XByteBuffer.toBytes(port,data,8);
+        XByteBuffer.toBytes(port,data,pos);
+        pos += 4;
+        //host length
+        data[pos++] = hl;
         //host
-        System.arraycopy(addr,0,data,12,addr.length);
+        System.arraycopy(addr,0,data,pos,addr.length);
+        pos+=addr.length;
         //domain length
-        XByteBuffer.toBytes(domaind.length,data,16);
+        XByteBuffer.toBytes(domaind.length,data,pos);
+        pos+=4;
         //domain
-        System.arraycopy(domaind,0,data,20,domaind.length);
+        System.arraycopy(domaind,0,data,pos,domaind.length);
+        pos+=domaind.length;
         //unique Id
-        System.arraycopy(uniqueId,0,data,20+domaind.length,uniqueId.length);
+        System.arraycopy(uniqueId,0,data,pos,uniqueId.length);
         dataPkg = data;
         return data;
     }
@@ -207,30 +217,46 @@
        //package looks like
        //alive - 8 bytes
        //port - 4 bytes
-       //host - 4 bytes
+       //host length - 1 byte
+       //host - hl bytes
        //dlen - 4 bytes
        //domain - dlen bytes
        //uniqueId - 16 bytes
+       int pos = 0;
+
        byte[] alived = new byte[8];
-       System.arraycopy(data, 0, alived, 0, 8);
+       System.arraycopy(data, pos, alived, 0, 8);
+       pos+=8;
        byte[] portd = new byte[4];
-       System.arraycopy(data, 8, portd, 0, 4);
-       byte[] addr = new byte[4];
-       System.arraycopy(data, 12, addr, 0, 4);
-       //FIXME control the nlen
-       //FIXME control the dlen
+       System.arraycopy(data, pos, portd, 0, 4);
+       pos+=4;
+       
+       byte hl = data[pos++];
+       byte[] addr = new byte[hl];
+       System.arraycopy(data, pos, addr, 0, hl);
+       pos+=hl;
+       
        byte[] dlend = new byte[4];
-       System.arraycopy(data, 16, dlend, 0, 4);
+       System.arraycopy(data, pos, dlend, 0, 4);
+       pos+=4;
+       
        int dlen = XByteBuffer.toInt(dlend, 0);
        byte[] domaind = new byte[dlen];
-       System.arraycopy(data, 20, domaind, 0, domaind.length);
+       System.arraycopy(data, pos, domaind, 0, domaind.length);
+       pos+=domaind.length;
+       
        byte[] uniqueId = new byte[16];
-       System.arraycopy(data, 20+domaind.length, uniqueId, 0, 16);
+       System.arraycopy(data, pos, uniqueId, 0, 16);
+       
        member.domain = domaind;
        member.setHost(addr);
        member.setPort(XByteBuffer.toInt(portd, 0));
        member.setMemberAliveTime(XByteBuffer.toLong(alived, 0));
        member.setUniqueId(uniqueId);
+       
+       member.dataPkg = new byte[data.length];
+       System.arraycopy(data,0,member.dataPkg,0,data.length);
+       
        return member;
     }
 
@@ -454,6 +480,22 @@
         byte[] data = this.getData();
         out.writeInt(data.length);
         out.write(data);
+    }
+    
+    public static void main(String[] args) throws Exception {
+        //String host = "127.0.0.1";
+        String host = "1080:0:0:0:8:800:200C:417A";
+        MemberImpl impl = new MemberImpl("domain",host,4444,10000);
+        byte[] data = impl.getData(false);
+        data = impl.getData(false);
+        MemberImpl newimpl = new MemberImpl();
+        MemberImpl.getMember(data,newimpl);
+        byte[] newdata = newimpl.getData(false);
+        System.out.println("Impl:"+impl);
+        System.out.println("NewI:"+newimpl);
+        System.out.println("byte comparison:"+Arrays.equals(data,newdata));
+        System.out.println("byte old:"+Arrays.toString(data));
+        System.out.println("byte new:"+Arrays.toString(newdata));
     }
 
 }

Modified: 
tomcat/container/tc5.5.x/modules/groupcom/test/org/apache/catalina/tribes/demos/EchoRpcTest.java
URL: 
http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/groupcom/test/org/apache/catalina/tribes/demos/EchoRpcTest.java?rev=397203&r1=397202&r2=397203&view=diff
==============================================================================
--- 
tomcat/container/tc5.5.x/modules/groupcom/test/org/apache/catalina/tribes/demos/EchoRpcTest.java
 (original)
+++ 
tomcat/container/tc5.5.x/modules/groupcom/test/org/apache/catalina/tribes/demos/EchoRpcTest.java
 Wed Apr 26 07:31:25 2006
@@ -3,11 +3,11 @@
 import java.io.Serializable;
 
 import org.apache.catalina.tribes.Member;
-import org.apache.catalina.tribes.tipis.RpcCallback;
+import org.apache.catalina.tribes.group.RpcCallback;
 import org.apache.catalina.tribes.Channel;
 import org.apache.catalina.tribes.ManagedChannel;
 import org.apache.catalina.tribes.group.RpcChannel;
-import org.apache.catalina.tribes.tipis.Response;
+import org.apache.catalina.tribes.group.Response;
 
 
 /**

Modified: tomcat/container/tc5.5.x/modules/groupcom/to-do.txt
URL: 
http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/groupcom/to-do.txt?rev=397203&r1=397202&r2=397203&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/groupcom/to-do.txt (original)
+++ tomcat/container/tc5.5.x/modules/groupcom/to-do.txt Wed Apr 26 07:31:25 2006
@@ -33,7 +33,9 @@
  
 Code Tasks:
 ===========================================
-39. Support for IPv6
+41. Build a tipi that is a soft membership
+
+40. channel.stop() - should broadcast a stop message, to avoid timeout
 
 38. Make the AbstractReplicatedMap accept non serializable elements, but just 
don't replicate them
 
@@ -233,4 +235,7 @@
  
  c) RpcChannel - collect "no reply" replies, so that we don't have to time out
 The RpcChannel now works together with the group channel, so that when it 
receives an RPC message
-and no one accepts it, then it can reply immediately. this way the rpc sender 
doesn't have to time out.
\ No newline at end of file
+and no one accepts it, then it can reply immediately. this way the rpc sender 
doesn't have to time out.
+
+39. Support for IPv6
+Notes: Completed. The membership now carries a variable length host address to 
support IPv6
\ No newline at end of file



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to