Issue #521 Separate executors for server and connector
HttpChannel uses the server executor LowResourceMonitor checks both server and connector executors.
This commit is contained in:
parent
bf5b6f8939
commit
367a807592
|
@ -22,6 +22,7 @@ import java.io.IOException;
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.Executor;
|
||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
@ -70,6 +71,7 @@ public class HttpChannel implements Runnable, HttpOutput.Interceptor
|
||||||
private final AtomicBoolean _committed = new AtomicBoolean();
|
private final AtomicBoolean _committed = new AtomicBoolean();
|
||||||
private final AtomicInteger _requests = new AtomicInteger();
|
private final AtomicInteger _requests = new AtomicInteger();
|
||||||
private final Connector _connector;
|
private final Connector _connector;
|
||||||
|
private final Executor _executor;
|
||||||
private final HttpConfiguration _configuration;
|
private final HttpConfiguration _configuration;
|
||||||
private final EndPoint _endPoint;
|
private final EndPoint _endPoint;
|
||||||
private final HttpTransport _transport;
|
private final HttpTransport _transport;
|
||||||
|
@ -92,6 +94,20 @@ public class HttpChannel implements Runnable, HttpOutput.Interceptor
|
||||||
_state = new HttpChannelState(this);
|
_state = new HttpChannelState(this);
|
||||||
_request = new Request(this, newHttpInput(_state));
|
_request = new Request(this, newHttpInput(_state));
|
||||||
_response = new Response(this, newHttpOutput());
|
_response = new Response(this, newHttpOutput());
|
||||||
|
|
||||||
|
if (connector==null)
|
||||||
|
{
|
||||||
|
// Testing mode
|
||||||
|
_executor=null;
|
||||||
|
_requestLog=null;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Server server=_connector.getServer();
|
||||||
|
_executor=server.getThreadPool();
|
||||||
|
_requestLog=server.getRequestLog();
|
||||||
|
}
|
||||||
|
|
||||||
_requestLog=_connector==null?null:_connector.getServer().getRequestLog();
|
_requestLog=_connector==null?null:_connector.getServer().getRequestLog();
|
||||||
if (LOG.isDebugEnabled())
|
if (LOG.isDebugEnabled())
|
||||||
LOG.debug("new {} -> {},{},{}",this,_endPoint,_endPoint.getConnection(),_state);
|
LOG.debug("new {} -> {},{},{}",this,_endPoint,_endPoint.getConnection(),_state);
|
||||||
|
@ -735,7 +751,7 @@ public class HttpChannel implements Runnable, HttpOutput.Interceptor
|
||||||
|
|
||||||
protected void execute(Runnable task)
|
protected void execute(Runnable task)
|
||||||
{
|
{
|
||||||
_connector.getExecutor().execute(task);
|
_executor.execute(task);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Scheduler getScheduler()
|
public Scheduler getScheduler()
|
||||||
|
|
|
@ -79,7 +79,6 @@ public class LowResourceMonitor extends AbstractLifeCycle
|
||||||
private String _reasons;
|
private String _reasons;
|
||||||
private long _lowStarted;
|
private long _lowStarted;
|
||||||
|
|
||||||
|
|
||||||
private final Runnable _monitor = new Runnable()
|
private final Runnable _monitor = new Runnable()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
|
@ -255,13 +254,19 @@ public class LowResourceMonitor extends AbstractLifeCycle
|
||||||
String reasons=null;
|
String reasons=null;
|
||||||
String cause="";
|
String cause="";
|
||||||
int connections=0;
|
int connections=0;
|
||||||
|
|
||||||
|
if (_monitorThreads && _server.getThreadPool().isLowOnThreads())
|
||||||
|
{
|
||||||
|
reasons=low(reasons,"Low on threads: "+_server.getThreadPool());
|
||||||
|
cause+="T";
|
||||||
|
}
|
||||||
|
|
||||||
for(Connector connector : getMonitoredOrServerConnectors())
|
for(Connector connector : getMonitoredOrServerConnectors())
|
||||||
{
|
{
|
||||||
connections+=connector.getConnectedEndPoints().size();
|
connections+=connector.getConnectedEndPoints().size();
|
||||||
|
|
||||||
Executor executor = connector.getExecutor();
|
Executor executor = connector.getExecutor();
|
||||||
if (executor instanceof ThreadPool)
|
if (executor instanceof ThreadPool && executor!=_server.getThreadPool())
|
||||||
{
|
{
|
||||||
ThreadPool threadpool=(ThreadPool) executor;
|
ThreadPool threadpool=(ThreadPool) executor;
|
||||||
if (_monitorThreads && threadpool.isLowOnThreads())
|
if (_monitorThreads && threadpool.isLowOnThreads())
|
||||||
|
@ -285,7 +290,6 @@ public class LowResourceMonitor extends AbstractLifeCycle
|
||||||
cause+="M";
|
cause+="M";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (reasons!=null)
|
if (reasons!=null)
|
||||||
{
|
{
|
||||||
// Log the reasons if there is any change in the cause
|
// Log the reasons if there is any change in the cause
|
||||||
|
|
Loading…
Reference in New Issue