while (_serverSocket != null) {
try {
// Set up HTTP connection
Socket socket = _serverSocket.accept();
final DefaultHttpServerConnection conn = new DefaultHttpServerConnection();
conn.bind(socket, _params);
_executor.execute(new ManagedContextRunnable() {
@Override
protected void runInContext() {
HttpContext context = new BasicHttpContext(null);
try {
while(!Thread.interrupted() && conn.isOpen()) {
if(s_logger.isTraceEnabled())
s_logger.trace("dispatching cluster request from " + conn.getRemoteAddress().toString());
_httpService.handleRequest(conn, context);
if(s_logger.isTraceEnabled())
s_logger.trace("Cluster request from " + conn.getRemoteAddress().toString() + " is processed");
}
} catch (ConnectionClosedException ex) {
// client close and read time out exceptions are expected
// when KEEP-AVLIE is enabled
s_logger.trace("Client closed connection", ex);
} catch (IOException ex) {
s_logger.trace("I/O error", ex);
} catch (HttpException ex) {
s_logger.error("Unrecoverable HTTP protocol violation", ex);
} finally {
try {
conn.shutdown();
} catch (IOException ignore) {
s_logger.error("unexpected exception", ignore);
}
}
}