You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by fh...@apache.org on 2003/04/03 04:29:38 UTC
cvs commit: jakarta-tomcat-catalina/modules/cluster/src/share/org/apache/catalina/cluster/tcp ReplicationListener.java SimpleTcpCluster.java
fhanik 2003/04/02 18:29:38
Modified: modules/cluster/etc cluster-server.xml
modules/cluster/src/share/org/apache/catalina/cluster/tcp
ReplicationListener.java SimpleTcpCluster.java
Log:
added in the host auto flag, and fixed the select timeout from 4.1.x branch
Revision Changes Path
1.2 +35 -28 jakarta-tomcat-catalina/modules/cluster/etc/cluster-server.xml
Index: cluster-server.xml
===================================================================
RCS file: /home/cvs/jakarta-tomcat-catalina/modules/cluster/etc/cluster-server.xml,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- cluster-server.xml 22 Feb 2003 00:46:22 -0000 1.1
+++ cluster-server.xml 3 Apr 2003 02:29:38 -0000 1.2
@@ -231,23 +231,29 @@
tcpThreadCount = the number of threads to handle incoming replication requests, optimal would be the same amount of threads as nodes
- tcpListenAddress = the listen address (bind address) for TCP cluster request on this host, in case of multiple ethernet cards
+ tcpListenAddress = the listen address (bind address) for TCP cluster request on this host,
+ in case of multiple ethernet cards.
+ auto means that address becomes
+ InetAddress.getLocalHost().getHostAddress()
tcpListenPort = the tcp listen port
+
+ tcpSelectorTimeout = the timeout (ms) for the Selector.select() method in case the OS
+ has a wakup bug in java.nio. Set to 0 for no timeout
printToScreen = true means that managers will also print to std.out
expireSessionsOnShutdown = true means that
useDirtyFlag = true means that we only replicate a session after setAttribute,removeAttribute has been called.
- false means to replicate the session after each request.
- false means that replication would work for the following piece of code:
- <%
- HashMap map = new HashMap();
- session.setAttribute("map",map);
- map.put("key","value");
- %>
- -->
+ false means to replicate the session after each request.
+ false means that replication would work for the following piece of code:
+ <%
+ HashMap map = new HashMap();
+ session.setAttribute("map",map);
+ map.put("key","value");
+ %>
+ -->
<Cluster className="org.apache.catalina.cluster.tcp.SimpleTcpCluster"
@@ -259,33 +265,34 @@
mcastFrequency="500"
mcastDropTime="3000"
tcpThreadCount="2"
- tcpListenAddress="localhost"
+ tcpListenAddress="auto"
tcpListenPort="4001"
+ tcpSelectorTimeout="100"
printToScreen="false"
expireSessionsOnShutdown="false"
useDirtyFlag="true"
/>
<!--
- When configuring for clustering, you also add in a valve to catch all the requests
- coming in, at the end of the request, the session may or may not be replicated.
- A session is replicated if and only if all the conditions are met:
- 1. useDirtyFlag is true or setAttribute or removeAttribute has been called AND
- 2. a session exists (has been created)
- 3. the request is not trapped by the "filter" attribute
-
- The filter attribute is to filter out requests that could not modify the session,
- hence we don't replicate the session after the end of this request.
- The filter is negative, ie, anything you put in the filter, you mean to filter out,
- ie, no replication will be done on requests that match one of the filters.
- The filter attribute is delimited by ;, so you can't escape out ; even if you wanted to.
-
- filter=".*\.gif;.*\.js;" means that we will not replicate the session after requests with the URI
- ending with .gif and .js are intercepted.
- -->
-
+ When configuring for clustering, you also add in a valve to catch all the requests
+ coming in, at the end of the request, the session may or may not be replicated.
+ A session is replicated if and only if all the conditions are met:
+ 1. useDirtyFlag is true or setAttribute or removeAttribute has been called AND
+ 2. a session exists (has been created)
+ 3. the request is not trapped by the "filter" attribute
+
+ The filter attribute is to filter out requests that could not modify the session,
+ hence we don't replicate the session after the end of this request.
+ The filter is negative, ie, anything you put in the filter, you mean to filter out,
+ ie, no replication will be done on requests that match one of the filters.
+ The filter attribute is delimited by ;, so you can't escape out ; even if you wanted to.
+
+ filter=".*\.gif;.*\.js;" means that we will not replicate the session after requests with the URI
+ ending with .gif and .js are intercepted.
+ -->
+
<Valve className="org.apache.catalina.cluster.tcp.ReplicationValve"
- filter=".*\.gif;.*\.js;.*\.jpg;.*\.htm;.*\.html;.*\.txt;"/>
+ filter=".*\.gif;.*\.js;.*\.jpg;.*\.htm;.*\.html;.*\.txt;"/>
<!-- Add the following attributes if you want to turn XML validation
on. Remember to comment the Host element above.
1.3 +8 -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.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ReplicationListener.java 20 Mar 2003 20:46:14 -0000 1.2
+++ ReplicationListener.java 3 Apr 2003 02:29:38 -0000 1.3
@@ -90,15 +90,18 @@
private ListenCallback callback;
private java.net.InetAddress bind;
private int port;
+ private long timeout = 0;
public ReplicationListener(ListenCallback callback,
int poolSize,
java.net.InetAddress bind,
- int port)
+ int port,
+ long timeout)
{
pool = new ThreadPool(poolSize);
this.callback = callback;
this.bind = bind;
this.port = port;
+ this.timeout = timeout;
}
public void run()
@@ -132,7 +135,7 @@
while (doListen) {
// this may block for a long time, upon return the
// selected set contains keys of the ready channels
- int n = selector.select();
+ int n = selector.select(timeout);
if (n == 0) {
continue; // nothing to do
}
1.10 +27 -12 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.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- SimpleTcpCluster.java 26 Mar 2003 17:40:02 -0000 1.9
+++ SimpleTcpCluster.java 3 Apr 2003 02:29:38 -0000 1.10
@@ -262,9 +262,10 @@
*/
protected long msgFrequency = 500;
/**
- * A reference to the membership service.
+ * java.nio.Channels.Selector.select timeout in case the JDK has a
+ * poor nio implementation
*/
-
+ protected long tcpSelectorTimeout = 100;
/**
* The channel configuration.
@@ -471,7 +472,8 @@
new ReplicationListener(this,
this.tcpThreadCount,
this.tcpAddress,
- this.tcpPort);
+ this.tcpPort,
+ this.tcpSelectorTimeout);
mReplicationListener.setDaemon(true);
mReplicationListener.start();
mReplicationTransmitter = new ReplicationTransmitter(new SocketSender[0]);
@@ -602,8 +604,15 @@
public void setTcpListenAddress(String address) {
try {
- tcpAddress = java.net.InetAddress.getByName(address);
- svcproperties.setProperty("tcpListenHost",address);
+ if ("auto".equals(address) )
+ {
+ address = java.net.InetAddress.getLocalHost().getHostAddress();
+ tcpAddress = java.net.InetAddress.getByName(address);
+ }
+ else
+ {
+ tcpAddress = java.net.InetAddress.getByName(address);
+ }//end if
}catch ( Exception x ){
log.error("Unable to set listen address",x);
}
@@ -625,6 +634,12 @@
this.tcpPort = port;
svcproperties.setProperty("tcpListenPort",String.valueOf(port));
}
+
+ public void setTcpSelectorTimeout(long timeout) {
+ this.tcpSelectorTimeout = timeout;
+ }
+
+
public void messageDataReceived(byte[] data) {
try {
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org