You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by fh...@apache.org on 2006/05/06 00:59:37 UTC

svn commit: r400201 - in /tomcat/container/tc5.5.x/modules: groupcom/build/ groupcom/src/share/org/apache/catalina/tribes/ groupcom/src/share/org/apache/catalina/tribes/membership/ groupcom/test/java/org/apache/catalina/tribes/test/ groupcom/test/java/...

Author: fhanik
Date: Fri May  5 15:59:35 2006
New Revision: 400201

URL: http://svn.apache.org/viewcvs?rev=400201&view=rev
Log:
Removed domains, since we are doing so many changes, there is no reason we can't implement that correctly

Modified:
    tomcat/container/tc5.5.x/modules/groupcom/build/build.xml
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/Member.java
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/membership/McastService.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/java/org/apache/catalina/tribes/test/TestNioSender.java
    tomcat/container/tc5.5.x/modules/groupcom/test/java/org/apache/catalina/tribes/test/channel/ChannelStartStop.java
    tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/ha/session/BackupManager.java
    tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/ha/session/DeltaManager.java

Modified: tomcat/container/tc5.5.x/modules/groupcom/build/build.xml
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/groupcom/build/build.xml?rev=400201&r1=400200&r2=400201&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/groupcom/build/build.xml (original)
+++ tomcat/container/tc5.5.x/modules/groupcom/build/build.xml Fri May  5 15:59:35 2006
@@ -9,7 +9,7 @@
     
   <path id="java.sourcepath">
     <pathelement location="${basedir}/src/share"/>
-    <pathelement location="${basedir}/test"/>
+    <pathelement location="${basedir}/test/java"/>
   </path>
 
   <path id="javadoc.sourcepath">

Modified: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/Member.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/Member.java?rev=400201&r1=400200&r2=400201&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/Member.java (original)
+++ tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/Member.java Fri May  5 15:59:35 2006
@@ -50,14 +50,6 @@
     public String getName();
   
     /**
-     * Returns the name of the cluster domain from this node
-     * @deprecated domains and partitioning will not be handled
-     * by the membership service in the future<br>
-     * To broadcast a domain use the payload feature of the membership service
-     */
-    public String getDomain();
-    
-    /**
      * Returns the listen host for the ChannelReceiver implementation
      * @return IPv4 or IPv6 representation of the host address this member listens to incoming data
      * @see ChannelReceiver

Modified: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/membership/McastService.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/membership/McastService.java?rev=400201&r1=400200&r2=400201&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/membership/McastService.java (original)
+++ tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/membership/McastService.java Fri May  5 15:59:35 2006
@@ -230,7 +230,6 @@
     public void start(int level) throws java.lang.Exception {
         hasProperty(properties,"mcastPort");
         hasProperty(properties,"mcastAddress");
-        hasProperty(properties,"mcastClusterDomain");
         hasProperty(properties,"memberDropTime");
         hasProperty(properties,"mcastFrequency");
         hasProperty(properties,"tcpListenPort");
@@ -245,9 +244,8 @@
         int port = Integer.parseInt(getProperties().getProperty("tcpListenPort"));
         
         if ( localMember == null ) {
-            localMember = new MemberImpl(domain, host, port, 100);
+            localMember = new MemberImpl(host, port, 100);
         } else {
-            localMember.setDomain(domain);
             localMember.setHostname(host);
             localMember.setPort(port);
             localMember.setMemberAliveTime(100);

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=400201&r1=400200&r2=400201&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 Fri May  5 15:59:35 2006
@@ -50,7 +50,6 @@
     public static final transient String TCP_LISTEN_PORT = "tcpListenPort";
     public static final transient String TCP_LISTEN_HOST = "tcpListenHost";
     public static final transient String MEMBER_NAME = "memberName";
-    public static final transient String MEMBER_DOMAIN = "memberDomain";
     
     /**
      * The listen host for this member
@@ -63,16 +62,6 @@
     protected int port;
 
     /**
-     * The name of the cluster domain from this node
-     * @deprecated - will no longer be transported, this can be handled through payloads
-     */
-    protected byte[] domain;
-    /**
-     * @deprecated - will no longer be transported, ths can be handled through payloads
-     */
-    protected transient String domainname;
-    
-    /**
      * Counter for how many messages have been sent from this member
      */
     protected int msgCount = 0;
@@ -118,16 +107,21 @@
      * @param host - the tcp listen host
      * @param port - the tcp listen port
      */
-    public MemberImpl(String domain,
-                       String host,
-                       int port,
-                       long aliveTime) throws IOException {
+    public MemberImpl(String host,
+                      int port,
+                      long aliveTime) throws IOException {
         setHostname(host);
         this.port = port;
-        this.domain = domain.getBytes();
         this.memberAliveTime=aliveTime;
     }
     
+    public MemberImpl(String host,
+                      int port,
+                      long aliveTime,
+                      byte[] payload) throws IOException {
+        this(host,port,aliveTime);
+        setPayload(payload);
+    }
     
     public boolean isReady() {
         return SenderState.getSenderState(this).isReady();
@@ -151,7 +145,6 @@
         map.put(MemberImpl.TCP_LISTEN_HOST,this.host);
         map.put(MemberImpl.TCP_LISTEN_PORT,String.valueOf(this.port));
         map.put(MemberImpl.MEMBER_NAME,getName());
-        map.put(MemberImpl.MEMBER_DOMAIN,domain);
         return map;
     }
 
@@ -205,11 +198,10 @@
         //payload plen bytes
         
         
-        byte[] domaind = this.domain;
         byte[] addr = host;
         long alive=System.currentTimeMillis()-getServiceStartTime();
         byte hl = (byte)addr.length;
-        byte[] data = new byte[8+4+1+addr.length+4+domaind.length+16+4+payload.length];
+        byte[] data = new byte[8+4+1+addr.length+16+4+payload.length];
         int pos = 0;
         //alive data
         XByteBuffer.toBytes((long)alive,data,0);
@@ -222,12 +214,6 @@
         //host
         System.arraycopy(addr,0,data,pos,addr.length);
         pos+=addr.length;
-        //domain length
-        XByteBuffer.toBytes(domaind.length,data,pos);
-        pos+=4;
-        //domain
-        System.arraycopy(domaind,0,data,pos,domaind.length);
-        pos+=domaind.length;
         //unique Id
         System.arraycopy(uniqueId,0,data,pos,uniqueId.length);
         pos+=uniqueId.length;
@@ -252,9 +238,9 @@
        //port - 4 bytes
        //host length - 1 byte
        //host - hl bytes
-       //dlen - 4 bytes
-       //domain - dlen bytes
        //uniqueId - 16 bytes
+       //payload length - 4bytes
+       //payload - pl bytes
        int pos = 0;
 
        byte[] alived = new byte[8];
@@ -289,7 +275,6 @@
        System.arraycopy(data, pos, payload, 0, payload.length);
        pos+=payload.length;
        
-       member.domain = domaind;
        member.setHost(addr);
        member.setPort(XByteBuffer.toInt(portd, 0));
        member.setMemberAliveTime(XByteBuffer.toLong(alived, 0));
@@ -315,15 +300,6 @@
     }
     
     /**
-     * Return the domain of this object
-     * @return a cluster domain to the cluster
-     */
-    public String getDomain() {
-        if ( this.domainname == null ) this.domainname = new String(domain);
-        return this.domainname;
-    }
-    
-    /**
      * Return the listen port of this member
      * @return - tcp listen port
      */
@@ -385,7 +361,6 @@
     public String toString()  {
         StringBuffer buf = new StringBuffer("org.apache.catalina.tribes.membership.MemberImpl[");
         buf.append(getName()).append(",");
-        buf.append(getDomain()).append(",");
         buf.append(getHostname()).append(",");
         buf.append(port).append(", alive=");
         buf.append(memberAliveTime).append(",");
@@ -425,67 +400,6 @@
             return false;
     }
     
-
-    /**
-     * Converts for bytes (ip address) to a string representation of it<BR>
-     * Highly optimized method.
-     * @param address (4 bytes ip address)
-     * @return string representation of that ip address
-     */
-    private static final String addressToString(byte[] address) {
-        int q, r = 0;
-        int charPos = 15;
-        char[] buf = new char[15];
-        char dot = '.';
-
-        int i = address[3] & 0xFF;
-        for (; ; )
-        {
-            q = (i * 52429) >>> (19);
-            r = i - ( (q << 3) + (q << 1));
-            buf[--charPos] = digits[r];
-            i = q;
-            if (i == 0)
-                break;
-        }
-        buf[--charPos] = dot;
-        i = address[2] & 0xFF;
-        for (; ; )
-        {
-            q = (i * 52429) >>> (19);
-            r = i - ( (q << 3) + (q << 1));
-            buf[--charPos] = digits[r];
-            i = q;
-            if (i == 0)
-                break;
-        }
-        buf[--charPos] = dot;
-
-        i = address[1] & 0xFF;
-        for (; ; )
-        {
-            q = (i * 52429) >>> (19);
-            r = i - ( (q << 3) + (q << 1));
-            buf[--charPos] = digits[r];
-            i = q;
-            if (i == 0)
-                break;
-        }
-
-        buf[--charPos] = dot;
-        i = address[0] & 0xFF;
-
-        for (; ; )
-        {
-            q = (i * 52429) >>> (19);
-            r = i - ( (q << 3) + (q << 1));
-            buf[--charPos] = digits[r];
-            i = q;
-            if (i == 0)
-                break;
-        }
-        return new String(buf, charPos, 15 - charPos);
-    }
     public void setHost(byte[] host) {
         this.host = host;
     }
@@ -499,10 +413,6 @@
         this.msgCount = msgCount;
     }
 
-    public void setDomain(String domain) {
-        this.domain = domain.getBytes();
-        this.dataPkg = null;
-    }
     public void setPort(int port) {
         this.port = port;
         this.dataPkg = null;

Modified: tomcat/container/tc5.5.x/modules/groupcom/test/java/org/apache/catalina/tribes/test/TestNioSender.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/groupcom/test/java/org/apache/catalina/tribes/test/TestNioSender.java?rev=400201&r1=400200&r2=400201&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/groupcom/test/java/org/apache/catalina/tribes/test/TestNioSender.java (original)
+++ tomcat/container/tc5.5.x/modules/groupcom/test/java/org/apache/catalina/tribes/test/TestNioSender.java Fri May  5 15:59:35 2006
@@ -47,7 +47,7 @@
 
     public void init() throws Exception {
         selector = Selector.open();
-        mbr = new MemberImpl("","localhost",4444,0);
+        mbr = new MemberImpl("localhost",4444,0);
         NioSender sender = new NioSender();
         sender.setDestination(mbr);
         sender.setDirectBuffer(true);

Modified: tomcat/container/tc5.5.x/modules/groupcom/test/java/org/apache/catalina/tribes/test/channel/ChannelStartStop.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/groupcom/test/java/org/apache/catalina/tribes/test/channel/ChannelStartStop.java?rev=400201&r1=400200&r2=400201&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/groupcom/test/java/org/apache/catalina/tribes/test/channel/ChannelStartStop.java (original)
+++ tomcat/container/tc5.5.x/modules/groupcom/test/java/org/apache/catalina/tribes/test/channel/ChannelStartStop.java Fri May  5 15:59:35 2006
@@ -98,5 +98,20 @@
         assertEquals(count,1);
         channel.stop(channel.DEFAULT);
     }
+    
+    public void testFalseOption() throws Exception {
+        int flag = 0xFFF0;//should get ignored by the underlying components
+        int count = 0;
+        try {
+            channel.start(flag);
+            count++;
+        } catch ( Exception x){x.printStackTrace();}
+        try {
+            channel.start(flag);
+            count++;
+        } catch ( Exception x){/*expected*/}
+        assertEquals(count,2);
+        channel.stop(channel.DEFAULT);
+    }
 
 }

Modified: tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/ha/session/BackupManager.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/ha/session/BackupManager.java?rev=400201&r1=400200&r2=400201&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/ha/session/BackupManager.java (original)
+++ tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/ha/session/BackupManager.java Fri May  5 15:59:35 2006
@@ -208,7 +208,7 @@
     public String getMapName() {
         CatalinaCluster catclust = (CatalinaCluster)cluster;
         Member local = catclust.getLocalMember();
-        return catclust.getManagerName(getName(),this)+"-"+local.getDomain();
+        return catclust.getManagerName(getName(),this)+"-"+"";
     }
 
     /**

Modified: tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/ha/session/DeltaManager.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/ha/session/DeltaManager.java?rev=400201&r1=400200&r2=400201&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/ha/session/DeltaManager.java (original)
+++ tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/ha/session/DeltaManager.java Fri May  5 15:59:35 2006
@@ -931,16 +931,8 @@
     protected Member findSessionMasterMember() {
         Member mbr = null;
         Member mbrs[] = cluster.getMembers();
-        String localMemberDomain = cluster.getLocalMember().getDomain();
-        if(isSendClusterDomainOnly()) {
-            for (int i = 0; mbr == null && i < mbrs.length; i++) {
-                Member member = mbrs[i];
-                if(localMemberDomain.equals(member.getDomain())) mbr = member ;
-            }
-        } else {
-            if(mbrs.length != 0 ) mbr = mbrs[0];
-        }
-        if(mbr == null && log.isWarnEnabled()) log.warn(sm.getString("deltaManager.noMasterMember",getName(), localMemberDomain));
+        if(mbrs.length != 0 ) mbr = mbrs[0];
+        if(mbr == null && log.isWarnEnabled()) log.warn(sm.getString("deltaManager.noMasterMember",getName(), ""));
         if(mbr != null && log.isDebugEnabled()) log.warn(sm.getString("deltaManager.foundMasterMember",getName(), mbr));
         return mbr;
     }
@@ -1263,15 +1255,14 @@
      * Test that sender and local domain is the same
      */
     protected boolean checkSenderDomain(SessionMessage msg,Member sender) {
-        String localMemberDomain = cluster.getLocalMember().getDomain();
-        boolean sameDomain= localMemberDomain.equals(sender.getDomain());
+        boolean sameDomain= true;
         if (!sameDomain && log.isWarnEnabled()) {
                 log.warn(sm.getString("deltaManager.receiveMessage.fromWrongDomain",
                          new Object[] {getName(), 
                          msg.getEventTypeString(), 
                          sender,
-                         sender.getDomain(),
-                         localMemberDomain }));
+                         "",
+                         "" }));
         }
         return sameDomain ;
     }



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Re: svn commit: r400201 - in /tomcat/container/tc5.5.x/modules: groupcom/build/ groupcom/src/share/org/apache/catalina/tribes/ groupcom/src/share/org/apache/catalina/tribes/membership/ groupcom/test/java/org/apache/catalina/tribes/test/ groupcom/test/java/...

Posted by Filip Hanik - Dev Lists <de...@hanik.com>.
sure thing,
The current implementation was:
- add a domain field
- broadcast the domain field
- change replication code to accomodate for the field
- change server.xml to set the domain
- replication only occurs within the domain

The exact same functionality could have been achieved:
- change mcastAddr in server.xml
- replication only occurs within the domain

So as you can see, so much code was written that could have been done
with one tiny configuration change. And, the comm layer had no benefit 
of it either,
so it was an applicatin specific need, and the code trickled down all 
the way to the comm layer,
and that is the problem with the old app. many features needed in the 
app layer, were coded in the comm layer and the other way around.

If the data was only valuable to the application that sits on top, then 
it should be managed by the application on top.
The functionality still exists:
http://people.apache.org/~fhanik/tribes/javadoc/org/apache/catalina/tribes/MembershipService.html#setPayload(byte[])

When a channel is created today, the application can set a custom 
payload (domain,admin JMX port,load averages,anything you can think of)
can be broadcasted. So the feature is still there, its just application 
specific. The comm layer knows nothing about domains.

With the custom payload you have lost 0 features over the old 
implementation, but you have gained a lot more flexibility, as you not 
are limited to just broadcasting a domain, you can broadcast all kinds 
of useful data.

Remember, that you can also build a custom interceptor that modifies 
both membership and message data as it passes through the channel, only 
your imagination becomes the limitation here.

For example, TcpFailureDetector, a simple implementation that overrides 
the multicast membership for failure detection.
http://people.apache.org/~fhanik/tribes/javadoc/org/apache/catalina/tribes/group/interceptors/TcpFailureDetector.html
this interceptor keeps its own membership and if a member times out, it 
will verify the timeout with a connection attempt.

This is just a simple example of how an interceptor can override 
implemented membership logic, you can create an interceptor that 
implements all kinds of logic to manipulate membership.

What we've done with "ha" and "groupcom" modules is to split logic to 
keep it where it belongs.
I have compiled a little introduction to Tribes which gives you a basic 
understanding of the feature set
http://people.apache.org/~fhanik/tribes/docs/introduction.html

As you can see, tribes is extremely customizable, only you imagination 
is the limit.

Filip


Peter Rossbach wrote:
> Can you please explain how domain memberships at future works?
>
> Peter
>
> Am 06.05.2006 um 00:59 schrieb fhanik@apache.org:
>
>> Author: fhanik
>> Date: Fri May  5 15:59:35 2006
>> New Revision: 400201
>>
>> URL: http://svn.apache.org/viewcvs?rev=400201&view=rev
>> Log:
>> Removed domains, since we are doing so many changes, there is no 
>> reason we can't implement that correctly
>>
>> M
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: dev-help@tomcat.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Re: svn commit: r400201 - in /tomcat/container/tc5.5.x/modules: groupcom/build/ groupcom/src/share/org/apache/catalina/tribes/ groupcom/src/share/org/apache/catalina/tribes/membership/ groupcom/test/java/org/apache/catalina/tribes/test/ groupcom/test/java/...

Posted by Peter Rossbach <pr...@objektpark.de>.
Can you please explain how domain memberships at future works?

Peter

Am 06.05.2006 um 00:59 schrieb fhanik@apache.org:

> Author: fhanik
> Date: Fri May  5 15:59:35 2006
> New Revision: 400201
>
> URL: http://svn.apache.org/viewcvs?rev=400201&view=rev
> Log:
> Removed domains, since we are doing so many changes, there is no  
> reason we can't implement that correctly
>
> M

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org