From 67e0b53ca7d3b1c83e0ee0e3b9321bd84137d5c4 Mon Sep 17 00:00:00 2001 From: rfeng Date: Thu, 10 Dec 2009 01:09:59 +0000 Subject: Set the static member port to be the same as the receiver port, see http://www.mail-archive.com/users@tomcat.apache.org/msg24873.html git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@889045 13f79535-47bb-0310-9956-ffa450edef68 --- .../sca/endpoint/tribes/ReplicatedEndpointRegistry.java | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'sca-java-2.x/trunk/modules') diff --git a/sca-java-2.x/trunk/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedEndpointRegistry.java b/sca-java-2.x/trunk/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedEndpointRegistry.java index 848d2e35cb..de01863b6a 100644 --- a/sca-java-2.x/trunk/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedEndpointRegistry.java +++ b/sca-java-2.x/trunk/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedEndpointRegistry.java @@ -78,7 +78,7 @@ public class ReplicatedEndpointRegistry implements EndpointRegistry, LifeCycleLi private String id; private boolean noMultiCast; - private static final Channel createChannel(String address, int port, String bindAddress) { + private static final GroupChannel createChannel(String address, int port, String bindAddress) { //create a channel GroupChannel channel = new GroupChannel(); @@ -95,7 +95,7 @@ public class ReplicatedEndpointRegistry implements EndpointRegistry, LifeCycleLi } else { mcastService.setBind(getBindAddress()); } - + return channel; } @@ -179,26 +179,31 @@ public class ReplicatedEndpointRegistry implements EndpointRegistry, LifeCycleLi if (map != null) { throw new IllegalStateException("The registry has already been started"); } + GroupChannel channel = createChannel(address, port, bind); map = - new ReplicatedMap(null, createChannel(address, port, bind), timeout, this.domainURI, + new ReplicatedMap(null, channel, timeout, this.domainURI, new ClassLoader[] {ReplicatedEndpointRegistry.class.getClassLoader()}); map.addListener(this); if (noMultiCast) { map.getChannel().addInterceptor(new DisableMcastInterceptor()); } - + + // http://www.mail-archive.com/users@tomcat.apache.org/msg24873.html + int port = channel.getChannelReceiver().getPort(); + if (staticRoutes != null) { StaticMembershipInterceptor smi = new StaticMembershipInterceptor(); for (URI staticRoute : staticRoutes) { Member member; try { - member = new StaticMember(staticRoute.getHost(), staticRoute.getPort(), 5000); + // The port has to match the receiver port + member = new StaticMember(staticRoute.getHost(), port, 5000); } catch (IOException e) { throw new RuntimeException(e); } smi.addStaticMember(member); - logger.info("Added static route: " + staticRoute.getHost() + ":" + staticRoute.getPort()); + logger.info("Added static route: " + staticRoute.getHost() + ":" + port); } smi.setLocalMember(map.getChannel().getLocalMember(false)); map.getChannel().addInterceptor(smi); -- cgit v1.2.3