在这里,我试图在到达servlet之前拒绝jetty服务器级别的请求。 由于按照以下配置,线程池有6个最小和10个最大并行执行线程,10个请求可以在线程池中排队,其中55个请求可以在连接器级别排队。 总数为85表示如果一次发送200个请求,则应拒绝115个请求。 但即使我用jmeter一次发送1000个请求。 Jetty服务器满足所有请求。 下面是一段代码。
Server server = new Server();
QueuedThreadPool threadPool = new QueuedThreadPool();
LinkedBlockingQueue<Runnable> queue = new LinkedBlockingQueue<Runnable>(15);
ExecutorThreadPool pool = new ExecutorThreadPool(6, 10, 30000, TimeUnit.MILLISECONDS, queue);
server.setThreadPool(pool);
threadPool.setMaxThreads(AssuranceConfiguration.annetAssurancesrvConsumerThread);
server.setThreadPool(threadPool);
if (AssuranceConfiguration.annetAssurancesrvSslRequired)
{
if (logger.isInfoEnabled())
{
logger.info("Going to use HTTPS, Initialising SSL context....");
}
SslContextFactory sslContextFactory = new SslContextFactory();
sslContextFactory.setKeyStore(JettyServer.class.getResource(KEYSTOREFILE).getFile());
sslContextFactory.setKeyStorePassword(AssuranceConfiguration.annetAssurancesrvKeystoreidentifier);
sslContextFactory.setKeyManagerPassword(AssuranceConfiguration.annetAssurancesrvKeystoremanagerPassword);
SslSelectChannelConnector sslConnector = new SslSelectChannelConnector(sslContextFactory);
sslConnector.setPort(AssuranceConfiguration.annetAssurancesrvPort);
server.setConnectors(new Connector[] { sslConnector });
}
else
{
if (logger.isInfoEnabled())
{
logger.info("Going to use HTTP, Initialising simple context....");
}
SelectChannelConnector simpleConnector = new SelectChannelConnector();
simpleConnector.setPort(AssuranceConfiguration.annetAssurancesrvPort);
simpleConnector.setMaxIdleTime(30000);
simpleConnector.setRequestHeaderSize(8192);
server.setConnectors(new Connector[] { simpleConnector });
simpleConnector.setAcceptQueueSize(55);
}