Issue #1643 Configure selectors for AbstractProxyServlet
This commit is contained in:
parent
c6d45c0af1
commit
27d85cb77e
|
@ -44,6 +44,7 @@ import org.eclipse.jetty.client.HttpClient;
|
||||||
import org.eclipse.jetty.client.ProtocolHandlers;
|
import org.eclipse.jetty.client.ProtocolHandlers;
|
||||||
import org.eclipse.jetty.client.api.Request;
|
import org.eclipse.jetty.client.api.Request;
|
||||||
import org.eclipse.jetty.client.api.Response;
|
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.HttpField;
|
||||||
import org.eclipse.jetty.http.HttpHeader;
|
import org.eclipse.jetty.http.HttpHeader;
|
||||||
import org.eclipse.jetty.http.HttpHeaderValue;
|
import org.eclipse.jetty.http.HttpHeaderValue;
|
||||||
|
@ -259,7 +260,7 @@ public abstract class AbstractProxyServlet extends HttpServlet
|
||||||
* </tr>
|
* </tr>
|
||||||
* </tbody>
|
* </tbody>
|
||||||
* </table>
|
* </table>
|
||||||
*
|
* @see #newHttpClient()
|
||||||
* @return a {@link HttpClient} configured from the {@link #getServletConfig() servlet configuration}
|
* @return a {@link HttpClient} configured from the {@link #getServletConfig() servlet configuration}
|
||||||
* @throws ServletException if the {@link HttpClient} cannot be created
|
* @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
|
* @return a new HttpClient instance
|
||||||
*/
|
*/
|
||||||
protected HttpClient newHttpClient()
|
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()
|
protected HttpClient getHttpClient()
|
||||||
|
|
Loading…
Reference in New Issue