Chapter 10: HTTP Connectors Comet Asynchronous IO Support

Chapter 10: HTTP Connectors Comet Asynchronous IO Support If Servlets need to take advantage of the non-blocking IO capabilities, the NIO connector must be explicitly coded for asynchronous IO. This asynchronous IO support is called Comet. Using Comet, a Servlet can respond to incoming events from a client instead of blocking in a read; it can also write responses asynchronously. Comet Servlets implement the org.apache.catalina.CometProcessorinterface, instead of the usual Servlet interface. Through this interface, the Servlet can receive a sequence of events. The following describes some of the events that a Comet Servlet can receive: . BEGIN: The Servlet responds to this event by performing any initialization; this signifies the beginning of the request/response lifecycle; the response object will be available for writing back to the client, but access must be synchronized if multiple threads are involved in this stage. . READ: An event that signifies to the Servlet that one read may be performed on the request stream without blocking; the Servlet must perform this read. Multiple READ events will be fired as request data becomes available. . END: The Servlet is notified that the request processing should now end; the Servlet should complete the writing of the response and reset any initialized fields on the request or response objects. . ERROR: This event from Tomcat 6 notifies the Servlet that an IO Exception or other fatal error has occurred during processing. While servicing any of the preceding events, the Servlet can decide to end processing by calling the close()method on the event. Because the benefit of asynchronous IO can be enjoyed only by Servlets that are explicitly coded to the preceding event-driven model, there is very little reason to configure the NIO Connector for Web applications consisting exclusively of regular servlets that do not support Comet. The Native APR Connector APR is the Apache Portable Runtime, which is a native code library that enables C/C++ software to be written in a platform-independent fashion. APR works well across Windows, Linux, and *nix systems. The Native APR Connector is written using APR, and compiled to native code for optimized platform- specific performance. The Native APR Connector is not a complete Connector in the strictest sense. It actually makes use of the standard Java-based connector for most of its operations. However, when the native code APR connector is enabled, the Java code will switch to native implementation for several performance- and scalability-sensitive operations. The APR Connector optimizes performance and enhances scalability via three main mechanisms: . Use of a sendfile() kernel mode call to send large static files directly from the buffer cache . Use of a single native code keep alive poller to implement connection keep alive for a large number of connections . Use of the OpenSSL native code, which has the potential to accelerate SSL implementation for SSL handling (via hardware)

For high quality java hosting services please check java web hosting website.

Comments are closed.