338035 Default acceptors 0.25*CPUs and improved selector/acceptor thread names
git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@2827 7e9141cc-0065-0410-87d8-b60c137991c4
This commit is contained in:
parent
1fd3bc1de2
commit
c952afa8fc
|
@ -17,6 +17,7 @@ jetty-7.3.1-SNAPSHOT
|
|||
+ 337878 Extra tests of security constraints
|
||||
+ 337896 HttpExchange.timeout does not override HttpClient.timeout
|
||||
+ 337898 set client HttpConnection max idle time from exchange timeout
|
||||
+ 338035 Default acceptors 0.25*CPUs and improved selector/acceptor thread names.
|
||||
+ JETTY-1317 More elegent handling of bad URIs in requests
|
||||
+ JETTY-1331 Allow alternate XML configuration processors (eg spring)
|
||||
+ JETTY-1335 HttpClient's SelectConnector clean-up
|
||||
|
|
|
@ -39,7 +39,6 @@ public class LikeJettyXml
|
|||
{
|
||||
public static void main(String[] args) throws Exception
|
||||
{
|
||||
Log.getLog().setDebugEnabled(true);
|
||||
String jetty_home = System.getProperty("jetty.home","../jetty-distribution/target/distribution");
|
||||
System.setProperty("jetty.home",jetty_home);
|
||||
|
||||
|
|
|
@ -793,6 +793,7 @@ public abstract class AbstractConnector extends HttpBuffers implements Connector
|
|||
return name + "@" + (getHost() == null?"0.0.0.0":getHost()) + ":" + (getLocalPort() <= 0?getPort():getLocalPort());
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/* ------------------------------------------------------------ */
|
||||
/* ------------------------------------------------------------ */
|
||||
|
@ -817,7 +818,7 @@ public abstract class AbstractConnector extends HttpBuffers implements Connector
|
|||
|
||||
_acceptorThread[_acceptor] = current;
|
||||
name = _acceptorThread[_acceptor].getName();
|
||||
current.setName(name + " - Acceptor" + _acceptor + " " + AbstractConnector.this);
|
||||
current.setName(name + " Acceptor" + _acceptor + " " + AbstractConnector.this);
|
||||
}
|
||||
int old_priority = current.getPriority();
|
||||
|
||||
|
|
|
@ -77,13 +77,22 @@ public class SelectChannelConnector extends AbstractNIOConnector
|
|||
public SelectChannelConnector()
|
||||
{
|
||||
_manager.setMaxIdleTime(getMaxIdleTime());
|
||||
setAcceptors(Math.max(1,(Runtime.getRuntime().availableProcessors()+3)/4));
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
@Override
|
||||
public void accept(int acceptorID) throws IOException
|
||||
{
|
||||
_manager.doSelect(acceptorID);
|
||||
ServerSocketChannel server = _acceptChannel;
|
||||
if (server!=null && server.isOpen())
|
||||
{
|
||||
SocketChannel channel = _acceptChannel.accept();
|
||||
channel.configureBlocking(false);
|
||||
Socket socket = channel.socket();
|
||||
configure(socket);
|
||||
_manager.register(channel);
|
||||
}
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
@ -238,30 +247,45 @@ public class SelectChannelConnector extends AbstractNIOConnector
|
|||
|
||||
super.doStart();
|
||||
|
||||
// start a thread to accept new connections
|
||||
_manager.dispatch(new Runnable()
|
||||
// start a thread to Select
|
||||
for (int i=0;i<getAcceptors();i++)
|
||||
{
|
||||
public void run()
|
||||
final int id=i;
|
||||
_manager.dispatch(new Runnable()
|
||||
{
|
||||
final ServerSocketChannel server=_acceptChannel;
|
||||
while (isRunning() && _acceptChannel==server && server.isOpen())
|
||||
public void run()
|
||||
{
|
||||
String name=Thread.currentThread().getName();
|
||||
try
|
||||
{
|
||||
SocketChannel channel = server.accept();
|
||||
channel.configureBlocking(false);
|
||||
Socket socket = channel.socket();
|
||||
configure(socket);
|
||||
_manager.register(channel);
|
||||
Thread.currentThread().setName(name+" Selector"+id+" "+SelectChannelConnector.this);
|
||||
while (isRunning())
|
||||
{
|
||||
try
|
||||
{
|
||||
_manager.doSelect(id);
|
||||
}
|
||||
catch(ThreadDeath e)
|
||||
{
|
||||
throw e;
|
||||
}
|
||||
catch(IOException e)
|
||||
{
|
||||
Log.ignore(e);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
Log.warn(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(IOException e)
|
||||
finally
|
||||
{
|
||||
Log.ignore(e);
|
||||
Thread.currentThread().setName(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
|
Loading…
Reference in New Issue