Bug 47799

Summary: Domain does not work in Membership and DomainFilterInterceptor.
Product: Tomcat 6 Reporter: Keiichi Fujino <fujino.keiichi>
Component: ClusterAssignee: Tomcat Developers Mailing List <dev>
Severity: normal    
Priority: P2    
Version: 6.0.20   
Target Milestone: default   
Hardware: All   
OS: All   
Attachments: McastService's patch
DomainFilterInterceptor's patch

Description Keiichi Fujino 2009-09-08 02:39:42 UTC
I used domain ="{1,2,3,4}" as follows by the Cluster configuration. 
<Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"
<Membership className="org.apache.catalina.tribes.membership.McastService"
    address="" port="45564" frequency="500" dropTime="3000"
<Interceptor className="org.apache.catalina.tribes.group.interceptors.DomainFilterInterceptor" 

However, domain does not work in Membership and DomainFilterInterceptor.

The type of instance variable domain of org.apache.catalina.tribes.membership.McastService
and org.apache.catalina.tribes.group.interceptors.DomainFilterInterceptor is byte array.

org.apache.tomcat.util.IntrospectionUtils#setProperty is invoked 
in org.apache.tomcat.util.digester.SetPropertyRule#begin. 

Because byte array property is not supported in org.apache.tomcat.util.IntrospectionUtils#setProperty, 
McastService#setDomain(byte array) and DomainFilterInterceptor#setDomain(byte array) is never invoked. 

As a result, domain can not set, and domain is always null.

There are two workarounds as follows.
1:org.apache.tomcat.util.IntrospectionUtils#setProperty supports byte array property.

2:Prepares setDomain(String) method for McastService and DomainFilterInterceptor.
  Invoke setDomain(byte array) from setDomain(String).
  This is the same way as org.apache.catalina.tribes.membership.StaticMember. 

I think that it is easy to prepare setDomain(String) method.
I made the patch. 

McastService's patch against tomcat_trunk.
Index: java/org/apache/catalina/tribes/membership/McastService.java
--- java/org/apache/catalina/tribes/membership/McastService.java	(revision 787304)
+++ java/org/apache/catalina/tribes/membership/McastService.java	(working copy)
@@ -30,6 +30,7 @@
 import org.apache.catalina.tribes.MessageListener;
 import org.apache.catalina.tribes.io.ChannelData;
 import org.apache.catalina.tribes.io.XByteBuffer;
+import org.apache.catalina.tribes.util.Arrays;
 import org.apache.catalina.tribes.util.StringManager;
 import org.apache.catalina.tribes.util.UUIDGenerator;
@@ -607,6 +608,12 @@
+    public void setDomain(String domain) {
+        if ( domain == null ) return;
+        if ( domain.startsWith("{") ) setDomain(Arrays.fromString(domain));
+        else setDomain(Arrays.convert(domain));
+    }
      * Simple test program
      * @param args Command-line arguments


DomainFilterInterceptor's patch against tomcat_trunk.
Index: java/org/apache/catalina/tribes/group/interceptors/DomainFilterInterceptor.java
--- java/org/apache/catalina/tribes/group/interceptors/DomainFilterInterceptor.java	(revision 763870)
+++ java/org/apache/catalina/tribes/group/interceptors/DomainFilterInterceptor.java	(working copy)
@@ -97,4 +97,13 @@
     public void setDomain(byte[] domain) {
         this.domain = domain;
+    public void setDomain(String domain) {
+        if ( domain == null ) return;
+        if (domain.startsWith("{"))
+            setDomain(org.apache.catalina.tribes.util.Arrays.fromString(domain));
+	    else
+            setDomain(org.apache.catalina.tribes.util.Arrays.convert(domain));
+    }


Best regards.
Comment 1 Keiichi Fujino 2009-09-08 02:52:50 UTC
Created attachment 24224 [details]
McastService's patch

The previous patch is broken. 
This is correct patch.
Comment 2 Keiichi Fujino 2009-09-08 02:54:08 UTC
Created attachment 24225 [details]
DomainFilterInterceptor's patch

The previous DomainFilterInterceptor's patch is broken. 
This is correct patch.
Comment 3 Keiichi Fujino 2009-09-15 02:11:41 UTC

Please do not ignore this bug report and patch. 
This problem is important.

If we can not specify domain in Membership and DomainFilterInterceptor, 
we can not divide the cluster into a smaller group by the domain.

After all, DomainFilterInterceptor can not be used.
Comment 4 Mark Thomas 2009-11-22 14:39:00 UTC
Thanks for the patch. It has been applied to trunk and proposed for 6.0.x
Comment 5 Mark Thomas 2009-12-21 08:26:33 UTC
This has been fixed in 6.0.x and will be included in 6.0.21 onwards. Thanks again for the patch.