You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by co...@apache.org on 2006/07/10 20:42:41 UTC
svn commit: r420610 [3/3] - in /tomcat/sandbox: ./ bin/
java/org/apache/commons/logging/ java/org/apache/coyote/servlet/
java/org/apache/coyote/servlet/servlets/
java/org/apache/coyote/servlet/util/ java/org/apache/tomcat/servlets/file/
java/org/apache...
Modified: tomcat/sandbox/java/org/apache/tomcat/util/net/nio/NioEndpoint.java
URL: http://svn.apache.org/viewvc/tomcat/sandbox/java/org/apache/tomcat/util/net/nio/NioEndpoint.java?rev=420610&r1=420609&r2=420610&view=diff
==============================================================================
--- tomcat/sandbox/java/org/apache/tomcat/util/net/nio/NioEndpoint.java (original)
+++ tomcat/sandbox/java/org/apache/tomcat/util/net/nio/NioEndpoint.java Mon Jul 10 11:42:39 2006
@@ -31,11 +31,10 @@
import java.nio.channels.spi.SelectorProvider;
import java.util.Iterator;
import java.util.Set;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ThreadPoolExecutor;
-import org.apache.tomcat.util.net.TcpConnection;
import org.apache.tomcat.util.net.simple.SimpleEndpoint;
-import org.apache.tomcat.util.threads.ThreadPool;
-import org.apache.tomcat.util.threads.ThreadPoolRunnable;
/** All threads blocked in accept(). New thread created on demand.
@@ -44,77 +43,20 @@
*
*/
public class NioEndpoint extends SimpleEndpoint {
- private ThreadPool tp;
+ private ThreadPoolExecutor tp;
public NioEndpoint() {
- tp=new ThreadPool();
- tp.setMinSpareThreads(2);
- tp.setMaxSpareThreads(8);
+ tp=(ThreadPoolExecutor) Executors.newCachedThreadPool();;
type = "nio";
}
// -------------------- Configuration --------------------
// -------------------- Thread pool --------------------
- public ThreadPool getThreadPool() {
+ public ThreadPoolExecutor getThreadPool() {
return tp;
}
- // wrappers to make JMX happier .
- // TODO: jmx wrapper should be smarter, support delegates.
-
- public void setMaxThreads(int maxThreads) {
- if( maxThreads > 0)
- tp.setMaxThreads(maxThreads);
- }
-
- public int getMaxThreads() {
- return tp.getMaxThreads();
- }
-
- public void setMaxSpareThreads(int maxThreads) {
- if(maxThreads > 0)
- tp.setMaxSpareThreads(maxThreads);
- }
-
- public int getMaxSpareThreads() {
- return tp.getMaxSpareThreads();
- }
-
- public void setMinSpareThreads(int minThreads) {
- if(minThreads > 0)
- tp.setMinSpareThreads(minThreads);
- }
-
- public int getMinSpareThreads() {
- return tp.getMinSpareThreads();
- }
-
- public void setThreadPriority(int threadPriority) {
- tp.setThreadPriority(threadPriority);
- }
-
- public int getThreadPriority() {
- return tp.getThreadPriority();
- }
-
- public void setDaemon(boolean b) {
- daemon=b;
- tp.setDaemon( b );
- }
-
- public boolean getDaemon() {
- return tp.getDaemon();
- }
-
- public String getName() {
- return tp.getName();
- }
-
- public void setName(String name) {
- tp.setName(name);
- }
-
// -------------------- Public methods --------------------
public void initEndpoint() throws IOException, InstantiationException {
@@ -153,7 +95,7 @@
running = true;
paused = false;
- tp.start();
+ //tp.start();
try {
selector = Selector.open();
} catch (IOException e) {
@@ -164,7 +106,7 @@
addSocketAccept( serverSocket, acceptTask);
- tp.runIt(acceptTask);
+ tp.execute(acceptTask);
}
@@ -220,24 +162,18 @@
*
* @author Costin Manolache
*/
- class PollerThread implements ThreadPoolRunnable {
+ class PollerThread implements Runnable {
- public Object[] getInitData() {
- // no synchronization overhead, but 2 array access
- Object obj[]=new Object[2];
- obj[1]= null;//getConnectionHandler().init();
- obj[0]= null; // new TcpConnection();
- return obj;
- }
-
- public void runIt(Object perThrData[]) {
+ public void run() {
try {
int selRes = selector.select();
if( selRes == 0 ) {
System.err.println("Select with 0 keys " +
selector.keys().size() );
- for( SelectionKey k : selector.keys() ) {
+ Iterator sI = selector.keys().iterator();
+ while (sI.hasNext()) {
+ SelectionKey k = (SelectionKey) sI.next();
System.err.println("K " + k.interestOps() +
" " + k.readyOps() + " " + k.toString() + " "
+ k.isValid() );
@@ -265,10 +201,9 @@
// Side effect: if pool is full, accept will happen
// a bit later.
// TODO: customize this if needed
- tp.runIt( this );
+ tp.execute( this );
// now process the socket.
- processSocket(sockC.socket(),
- (Object[]) perThrData[1]);
+ processSocket(sockC.socket());
continue;
}
@@ -290,5 +225,4 @@
}
}
-
}
Modified: tomcat/sandbox/java/org/apache/tomcat/util/net/simple/SimpleEndpoint.java
URL: http://svn.apache.org/viewvc/tomcat/sandbox/java/org/apache/tomcat/util/net/simple/SimpleEndpoint.java?rev=420610&r1=420609&r2=420610&view=diff
==============================================================================
--- tomcat/sandbox/java/org/apache/tomcat/util/net/simple/SimpleEndpoint.java (original)
+++ tomcat/sandbox/java/org/apache/tomcat/util/net/simple/SimpleEndpoint.java Mon Jul 10 11:42:39 2006
@@ -28,9 +28,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.tomcat.util.net.TcpConnectionHandler;
-import org.apache.tomcat.util.res.StringManager;
-import org.apache.tomcat.util.threads.ThreadWithAttributes;
/**
@@ -115,7 +112,6 @@
public void threadStart(SimpleEndpoint ep, Thread t);
public void threadEnd( SimpleEndpoint ep, Thread t);
-
}
@@ -409,7 +405,7 @@
void newAcceptor() {
acceptors++;
- Thread t=new ThreadWithAttributes( this, new AcceptorRunnable());
+ Thread t=new Thread( new AcceptorRunnable());
t.setName("Tomcat-" + threadId++);
if( threadPriority > 0 ) {
t.setPriority(threadPriority);
@@ -487,8 +483,6 @@
}
catch (IOException e) {
- String msg = null;
-
if (running) {
log.error("IOException", e);
}
@@ -539,7 +533,7 @@
return accepted;
}
- public void processSocket(Socket s, Object[] threadData) {
+ public void processSocket(Socket s) {
// Process the connection
int step = 1;
try {
@@ -618,7 +612,7 @@
curThreads++;
// Process the request from this socket
- processSocket(socket, threadData);
+ processSocket(socket);
// Finish up this request
curThreads--;
@@ -635,7 +629,6 @@
synchronized (threadSync) {
threadSync.notifyAll();
}
-
}
}
}
Modified: tomcat/sandbox/resources/coyote-servlet.MF
URL: http://svn.apache.org/viewvc/tomcat/sandbox/resources/coyote-servlet.MF?rev=420610&r1=420609&r2=420610&view=diff
==============================================================================
--- tomcat/sandbox/resources/coyote-servlet.MF (original)
+++ tomcat/sandbox/resources/coyote-servlet.MF Mon Jul 10 11:42:39 2006
@@ -1,2 +1,2 @@
Manifest-version: 1.0
-Main-Class: org.apache.coyote.servlet.Main
+Main-Class: org.apache.coyote.servlet.CoyoteMain
Modified: tomcat/sandbox/resources/runtime.MF
URL: http://svn.apache.org/viewvc/tomcat/sandbox/resources/runtime.MF?rev=420610&r1=420609&r2=420610&view=diff
==============================================================================
--- tomcat/sandbox/resources/runtime.MF (original)
+++ tomcat/sandbox/resources/runtime.MF Mon Jul 10 11:42:39 2006
@@ -1,3 +1,3 @@
Manifest-Version: 1.0
-Main-Class: org.apache.tomcat.standalone.Main
+Main-Class: org.apache.tomcat.standalone.ETomcat
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org