Issue #1643 Configure selectors for AbstractProxyServlet

This commit is contained in:
Greg Wilkins 2017-06-27 10:36:17 +02:00
parent 0bfc41e068
commit 432b941f32
1 changed files with 9 additions and 2 deletions

View File

@ -44,6 +44,7 @@ import org.eclipse.jetty.client.HttpClient;
import org.eclipse.jetty.client.ProtocolHandlers;
import org.eclipse.jetty.client.api.Request;
import org.eclipse.jetty.client.api.Response;
import org.eclipse.jetty.client.http.HttpClientTransportOverHTTP;
import org.eclipse.jetty.http.HttpField;
import org.eclipse.jetty.http.HttpHeader;
import org.eclipse.jetty.http.HttpHeaderValue;
@ -259,7 +260,7 @@ public abstract class AbstractProxyServlet extends HttpServlet
* </tr>
* </tbody>
* </table>
*
* @see #newHttpClient()
* @return a {@link HttpClient} configured from the {@link #getServletConfig() servlet configuration}
* @throws ServletException if the {@link HttpClient} cannot be created
*/
@ -340,11 +341,17 @@ public abstract class AbstractProxyServlet extends HttpServlet
}
/**
* The servlet init parameter 'selectors' can be set for the number of
* selector threads to be used by the HttpClient.
* @return a new HttpClient instance
*/
protected HttpClient newHttpClient()
{
return new HttpClient();
int selectors = (Runtime.getRuntime().availableProcessors() + 1) / 2;
String value = getServletConfig().getInitParameter("selectors");
if (value != null)
selectors = Integer.parseInt(value);
return new HttpClient(new HttpClientTransportOverHTTP(selectors),null);
}
protected HttpClient getHttpClient()