fhanik 2004/01/08 18:50:54
Modified: modules/cluster/src/share/org/apache/catalina/cluster/mcast
McastService.java
modules/cluster/src/share/org/apache/catalina/cluster/tcp
ReplicationListener.java SimpleTcpCluster.java
TcpReplicationThread.java
Log:
fixed 100% cpu bug with the replication listener. We don't want to listen to
OP_WRITE events at all. Added a bind address to the broadcast address
Revision Changes Path
1.5 +9 -5
jakarta-tomcat-catalina/modules/cluster/src/share/org/apache/catalina/cluster/mcast/McastService.java
Index: McastService.java
===================================================================
RCS file:
/home/cvs/jakarta-tomcat-catalina/modules/cluster/src/share/org/apache/catalina/cluster/mcast/McastService.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- McastService.java 18 Dec 2003 04:20:14 -0000 1.4
+++ McastService.java 9 Jan 2004 02:50:54 -0000 1.5
@@ -166,10 +166,14 @@
int port = Integer.parseInt(getProperties().getProperty("tcpListenPort"));
String name = "tcp://"+host+":"+port;
localMember = new McastMember(name,host,port,100);
+ java.net.InetAddress bind = null;
+ if ( properties.getProperty("mcastBindAddress")!= null ) {
+ bind =
java.net.InetAddress.getByName(properties.getProperty("mcastBindAddress"));
+ }
impl = new
McastServiceImpl((McastMember)localMember,Long.parseLong(properties.getProperty("msgFrequency")),
Long.parseLong(properties.getProperty("memberDropTime")),
Integer.parseInt(properties.getProperty("mcastPort")),
- null,
+ bind,
java.net.InetAddress.getByName(properties.getProperty("mcastAddress")),
this);
1.8 +12 -5
jakarta-tomcat-catalina/modules/cluster/src/share/org/apache/catalina/cluster/tcp/ReplicationListener.java
Index: ReplicationListener.java
===================================================================
RCS file:
/home/cvs/jakarta-tomcat-catalina/modules/cluster/src/share/org/apache/catalina/cluster/tcp/ReplicationListener.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- ReplicationListener.java 20 Dec 2003 00:48:52 -0000 1.7
+++ ReplicationListener.java 9 Jan 2004 02:50:54 -0000 1.8
@@ -144,7 +144,9 @@
// selected set contains keys of the ready channels
try {
+ //System.out.println("Selecting with timeout="+timeout);
int n = selector.select(timeout);
+ //System.out.println("select returned="+n);
if (n == 0) {
continue; // nothing to do
}
@@ -160,18 +162,23 @@
SocketChannel channel = server.accept();
registerChannel(selector,
channel,
- SelectionKey.OP_READ |
- SelectionKey.OP_WRITE,
+ SelectionKey.OP_READ,
new ObjectReader(channel, selector,
callback));
}
// is there data to read on this channel?
+ //System.out.println("key readable="+key.isReadable());
if (key.isReadable()) {
readDataFromSocket(key);
+ } else {
+ //System.out.println("This shouldn't get called");
+ key.interestOps(key.interestOps() & (~key.OP_WRITE));
}
+
// remove key from selected set, it's been handled
it.remove();
}
+ System.out.println("Done with loop");
}
catch (java.nio.channels.CancelledKeyException nx) {
log.warn(
1.22 +9 -4
jakarta-tomcat-catalina/modules/cluster/src/share/org/apache/catalina/cluster/tcp/SimpleTcpCluster.java
Index: SimpleTcpCluster.java
===================================================================
RCS file:
/home/cvs/jakarta-tomcat-catalina/modules/cluster/src/share/org/apache/catalina/cluster/tcp/SimpleTcpCluster.java,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- SimpleTcpCluster.java 18 Dec 2003 04:20:15 -0000 1.21
+++ SimpleTcpCluster.java 9 Jan 2004 02:50:54 -0000 1.22
@@ -611,6 +611,11 @@
svcproperties.setProperty("mcastAddress",addr);
}
+
+ public void setMcastBindAddress(String bindaddr) {
+ svcproperties.setProperty("mcastBindAddress",bindaddr);
+ }
+
public void setMcastPort(int port) {
svcproperties.setProperty("mcastPort",String.valueOf(port));
}
1.6 +5 -4
jakarta-tomcat-catalina/modules/cluster/src/share/org/apache/catalina/cluster/tcp/TcpReplicationThread.java
Index: TcpReplicationThread.java
===================================================================
RCS file:
/home/cvs/jakarta-tomcat-catalina/modules/cluster/src/share/org/apache/catalina/cluster/tcp/TcpReplicationThread.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- TcpReplicationThread.java 20 Dec 2003 00:48:52 -0000 1.5
+++ TcpReplicationThread.java 9 Jan 2004 02:50:54 -0000 1.6
@@ -145,6 +145,7 @@
this.key = key;
this.synchronous=synchronous;
key.interestOps (key.interestOps() & (~SelectionKey.OP_READ));
+ key.interestOps (key.interestOps() & (~SelectionKey.OP_WRITE));
this.notify(); // awaken the thread
}
@@ -190,7 +191,7 @@
return;
}
// resume interest in OP_READ, OP_WRITE
- key.interestOps (key.interestOps() | SelectionKey.OP_READ |
SelectionKey.OP_WRITE);
+ key.interestOps (key.interestOps() | SelectionKey.OP_READ);
// cycle the selector so this key is active again
key.selector().wakeup();
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]