Author: fhanik
Date: Fri May 5 15:35:57 2006
New Revision: 400197
URL: http://svn.apache.org/viewcvs?rev=400197&view=rev
Log:
Added first test, fixed bug with dual dispatchers being added in the default
stack
Added:
tomcat/container/tc5.5.x/modules/groupcom/test/java/org/apache/catalina/tribes/test/channel/
tomcat/container/tc5.5.x/modules/groupcom/test/java/org/apache/catalina/tribes/test/channel/ChannelStartStop.java
Removed:
tomcat/container/tc5.5.x/modules/groupcom/test/java/org/apache/catalina/tribes/test/AckProtocol.java
tomcat/container/tc5.5.x/modules/groupcom/test/java/org/apache/catalina/tribes/test/Server.java
tomcat/container/tc5.5.x/modules/groupcom/test/java/org/apache/catalina/tribes/test/ServerThread.java
Modified:
tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/group/ChannelCoordinator.java
tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/group/GroupChannel.java
tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/group/interceptors/MessageDispatchInterceptor.java
tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/membership/McastServiceImpl.java
Modified:
tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/group/ChannelCoordinator.java
URL:
http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/group/ChannelCoordinator.java?rev=400197&r1=400196&r2=400197&view=diff
==============================================================================
---
tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/group/ChannelCoordinator.java
(original)
+++
tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/group/ChannelCoordinator.java
Fri May 5 15:35:57 2006
@@ -125,6 +125,8 @@
if (startLevel == Channel.DEFAULT) return; //we have already
started up all components
if (svc == 0 ) return;//nothing to start
+
+ if (svc == (svc & startLevel)) throw new ChannelException("Channel
already started for level:"+svc);
//must start the receiver first so that we can coordinate the port
it
//listens to with the local membership settings
Modified:
tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/group/GroupChannel.java
URL:
http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/group/GroupChannel.java?rev=400197&r1=400196&r2=400197&view=diff
==============================================================================
---
tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/group/GroupChannel.java
(original)
+++
tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/group/GroupChannel.java
Fri May 5 15:35:57 2006
@@ -192,7 +192,7 @@
protected synchronized void setupDefaultStack() throws ChannelException {
if ( getFirstInterceptor() != null &&
- (!(getFirstInterceptor() instanceof ChannelCoordinator))) {
+ ((getFirstInterceptor().getNext() instanceof
ChannelCoordinator))) {
ChannelInterceptor interceptor = null;
Class clazz = null;
try {
Modified:
tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/group/interceptors/MessageDispatchInterceptor.java
URL:
http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/group/interceptors/MessageDispatchInterceptor.java?rev=400197&r1=400196&r2=400197&view=diff
==============================================================================
---
tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/group/interceptors/MessageDispatchInterceptor.java
(original)
+++
tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/group/interceptors/MessageDispatchInterceptor.java
Fri May 5 15:35:57 2006
@@ -125,8 +125,8 @@
synchronized (this) {
if ( run ) {
run = false;
- queue.setEnabled(false);
msgDispatchThread.interrupt();
+ queue.setEnabled(false);
setAndGetCurrentSize(0);
}//end if
}//sync
Modified:
tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/membership/McastServiceImpl.java
URL:
http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/membership/McastServiceImpl.java?rev=400197&r1=400196&r2=400197&view=diff
==============================================================================
---
tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/membership/McastServiceImpl.java
(original)
+++
tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/membership/McastServiceImpl.java
Fri May 5 15:35:57 2006
@@ -27,6 +27,7 @@
import java.net.SocketTimeoutException;
import org.apache.catalina.tribes.Member;
import org.apache.catalina.tribes.Channel;
+import java.net.InetSocketAddress;
/**
* A <b>membership</b> implementation using simple multicast.
@@ -158,13 +159,11 @@
}
protected void setupSocket() throws IOException {
- if (mcastBindAddress != null) socket = new MulticastSocket(new
java.net.
- InetSocketAddress(mcastBindAddress, port));
+ if (mcastBindAddress != null) socket = new MulticastSocket(new
InetSocketAddress(mcastBindAddress, port));
else socket = new MulticastSocket(port);
if (mcastBindAddress != null) {
if(log.isInfoEnabled())
- log.info("Setting multihome multicast interface to:" +
- mcastBindAddress);
+ log.info("Setting multihome multicast interface to:"
+mcastBindAddress);
socket.setInterface(mcastBindAddress);
} //end if
if ( mcastSoTimeout >= 0 ) {
@@ -221,13 +220,13 @@
if ( (level & Channel.MBR_RX_SEQ)==Channel.MBR_RX_SEQ ) {
valid = true;
doRunReceiver = false;
- receiver.interrupt();
+ if ( receiver !=null ) receiver.interrupt();
receiver = null;
}
if ( (level & Channel.MBR_TX_SEQ)==Channel.MBR_TX_SEQ ) {
valid = true;
doRunSender = false;
- sender.interrupt();
+ if ( sender != null )sender.interrupt();
sender = null;
}
@@ -246,7 +245,7 @@
member.setPayload(payload);
member.getData(true, true);
//leave mcast group
- socket.leaveGroup(address);
+ try {socket.leaveGroup(address);}catch ( Exception ignore){}
serviceStartTime = Long.MAX_VALUE;
}
return (startLevel == 0);
Added:
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=400197&view=auto
==============================================================================
---
tomcat/container/tc5.5.x/modules/groupcom/test/java/org/apache/catalina/tribes/test/channel/ChannelStartStop.java
(added)
+++
tomcat/container/tc5.5.x/modules/groupcom/test/java/org/apache/catalina/tribes/test/channel/ChannelStartStop.java
Fri May 5 15:35:57 2006
@@ -0,0 +1,102 @@
+/*
+ * Copyright 1999,2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ */
+package org.apache.catalina.tribes.test.channel;
+
+import org.apache.catalina.tribes.group.GroupChannel;
+import junit.framework.TestCase;
+
+/**
+ * @author Filip Hanik
+ * @version 1.0
+ */
+public class ChannelStartStop extends TestCase {
+ GroupChannel channel = null;
+ protected void setUp() throws Exception {
+ super.setUp();
+ channel = new GroupChannel();
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ public void testDoubleFullStart() throws Exception {
+ int count = 0;
+ try {
+ channel.start(channel.DEFAULT);
+ count++;
+ } catch ( Exception x){x.printStackTrace();}
+ try {
+ channel.start(channel.DEFAULT);
+ count++;
+ } catch ( Exception x){x.printStackTrace();}
+ assertEquals(count,2);
+ channel.stop(channel.DEFAULT);
+ }
+
+ public void testDoublePartialStart() throws Exception {
+ //try to double start the RX
+ int count = 0;
+ try {
+ channel.start(channel.SND_RX_SEQ);
+ channel.start(channel.MBR_RX_SEQ);
+ count++;
+ } catch ( Exception x){x.printStackTrace();}
+ try {
+ channel.start(channel.MBR_RX_SEQ);
+ count++;
+ } catch ( Exception x){/*expected*/}
+ assertEquals(count,1);
+ channel.stop(channel.DEFAULT);
+ //double the membership sender
+ count = 0;
+ try {
+ channel.start(channel.SND_RX_SEQ);
+ channel.start(channel.MBR_TX_SEQ);
+ count++;
+ } catch ( Exception x){x.printStackTrace();}
+ try {
+ channel.start(channel.MBR_TX_SEQ);
+ count++;
+ } catch ( Exception x){/*expected*/}
+ assertEquals(count,1);
+ channel.stop(channel.DEFAULT);
+
+ count = 0;
+ try {
+ channel.start(channel.SND_RX_SEQ);
+ count++;
+ } catch ( Exception x){x.printStackTrace();}
+ try {
+ channel.start(channel.SND_RX_SEQ);
+ count++;
+ } catch ( Exception x){/*expected*/}
+ assertEquals(count,1);
+ channel.stop(channel.DEFAULT);
+
+ count = 0;
+ try {
+ channel.start(channel.SND_TX_SEQ);
+ count++;
+ } catch ( Exception x){x.printStackTrace();}
+ try {
+ channel.start(channel.SND_TX_SEQ);
+ count++;
+ } catch ( Exception x){/*expected*/}
+ assertEquals(count,1);
+ channel.stop(channel.DEFAULT);
+ }
+
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]