Bug 47799 - Domain does not work in Membership and DomainFilterInterceptor.
Domain does not work in Membership and DomainFilterInterceptor.
Status: RESOLVED FIXED
Product: Tomcat 6
Classification: Unclassified
Component: Cluster
6.0.20
All All
: P2 normal (vote)
: default
Assigned To: Tomcat Developers Mailing List
:
Depends on:
Blocks:
  Show dependency tree
 
Reported: 2009-09-08 02:39 UTC by Keiichi Fujino
Modified: 2009-12-21 08:26 UTC (History)
0 users



Attachments
McastService's patch (977 bytes, application/octet-stream)
2009-09-08 02:52 UTC, Keiichi Fujino
Details
DomainFilterInterceptor's patch (769 bytes, application/octet-stream)
2009-09-08 02:54 UTC, Keiichi Fujino
Details

Note You need to log in before you can comment on or make changes to this bug.
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"
    channelSendOptions="6">
...
<Membership className="org.apache.catalina.tribes.membership.McastService"
    address="228.0.0.4" port="45564" frequency="500" dropTime="3000"
    domain="{1,2,3,4}"/>
...
<Interceptor className="org.apache.catalina.tribes.group.interceptors.DomainFilterInterceptor" 
    domain="{1,2,3,4}"/>
...
</Cluster>

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. 
However, 

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.
[start.]
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

[end.]

DomainFilterInterceptor's patch against tomcat_trunk.
[start.]
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));
+    }
+
 }

[end.]


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

sorry.
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

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

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.