Hi, I’m working on a project that is currently using SimpleFramework java
web server. I suspect we are running out of worker threads but
unfortunately the api does not give me a mechanism to get a hold of the
thread executors.
With this in mind I am looking at using Grizzly as an alternative, since on
the face on it I should be able to get this information.
I’m creating the server as follows:
private HttpServer server;
private NetworkListener listener;
public static final String localhost = "localhost";
public void runServer(int port) throws IOException
{
logger.info("starting grizzly framework server on port {}", port);
server = new HttpServer();
listener = new NetworkListener("grizzly", localhost, port);
listener.setSecure(false);
listener.getTransport().setIOStrategy(WorkerThreadIOStrategy.getInstance());
server.addListener(listener);
final ServerConfiguration serverConfiguration =
server.getServerConfiguration();
serverConfiguration.addHttpHandler(new HttpHandler()
{
public void service(Request
request, Response response) throws Exception
{
final SimpleDateFormat
format = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.UK);
final String date =
format.format(new Date(System.currentTimeMillis()));
response.setContentType("text/plain");
response.setContentLength(date.length());
response.getWriter().write(date);
}
}
);
server.start();
logger.info("bootstrap of grizzly framework server complete,
running on http://{}:{}", localhost, port);
}
I was trying to print off details of the kernel and thread queue sizes but
the queue object is null:
logger.info("kernel thread pool queue {}",
listener.getTransport().getKernelThreadPoolConfig().getQueue());
logger.info("worker thread pool queue {}",
listener.getTransport().getWorkerThreadPoolConfig().getQueue());
I think the number of pending incoming requests and queued workers should
be the size of each of these Queue objects if they not null?
Note maybe there is a better way of getting this sort of information?
Thanks