Appendix C: Resin and Eclipse


One of the most important aspects of running a Web site that provides information to consumers is reliability. We discussed reliability in Chapter 19 in the form of replicating the servers; in this appendix we discuss another reliability topic: obtaining the status of the Resin server.

Status can be obtained in several ways. An obvious and simple method is to browse various page on the Web site. If the page loads in the browser, then you can be relatively sure the server is operating successfully. If the page doesn't come up, you probably have a bigger problem to handle. A more reliable method for checking your site is Resin's status servlet called ResinStatusServlet.

This servlet isn't available "right out of the box" due to potential security concerns with providing status information. To activate the servlet, the <web-app> configuration information shown in Listing B.1 needs to be added to your resin.conf file.

Listing B.1: Configuration spec for ResinStatusServlet.

start example
 <web-app id='/admin'>   <allow-admin>true</allow-admin>   <servlet-mapping url-pattern='/resin-status'                    servlet-name='com.caucho.servlets.ResinStatusServlet'>     <init-param enable='read'/>   </servlet-mapping>   <!-- only allow the localhost to use the admin -->   <security-constraint>     <ip-constraint>127.0.0.1/32</ip-constraint>     <web-resource-collection>       <url-pattern>/*</url-pattern>     </web-resource-collection>   </security-constraint> </web-app> 
end example

Taking a moment to look at the configuration, we find that the servlet will be located at the URL of /admin/resin-status. When a user browses to any servlet in the /admin directory, this <web-app> element will come into play.

The first element in the <web-app> hierarchy is <allow-admin> which has a value of true. This sub-element is very important because it allows the servlet to be invoked to have access to the class com.caucho.http.admin.Applica-tionAdmin. The ApplicationAdmin class gives the invoked servlet administrative privileges to the executing application. As you can see, this has direct implications for the site's security. A few of the most useful methods available in the ApplicationAdmin class are:

  • void clearCache()— clears the application cache.

  • int getActiveSessionCount()— current # of active sessions.

  • Path getAppDir()— gets the application directory of the current application.

  • ClassLoader getClassLoader()— returns the applications class loader.

  • HostAdmin getHostAdmin()— return a HostAdmin object.

  • ServerAdmin getServerAdmin()— returns a ServerAdmin object.

The last two methods provide even more information about the currently executing application and the server itself. The HostAdmin allows the servlet to obtain information about a virtual host. The second method returns a ServerAdmin object which allows complete administration of the server itself. Methods in this object include:

  • void clearCache()— clears the system cache.

  • void close()— closes the server.

  • void restart()— restarts the server.

There are many additional methods available for obtaining a wide range of statistics about the currently executing server. Looking back at the configuration information from the status servlet, we find that all of the functionality for the ResinStatusServlet can be found in the class com.caucho.servlets. ResinStatusServlet. Because Caucho has made the source code for Resin available, a developer has the option of adding any type of administration control they find necessary for their particular situation.

Due to the security concerns that the administration servlet raises, additional security elements are provided in the <web-app> entry. The <ip-constraint> element is used to limit who can access the servlet. In this case, only browsers that are located on the local machine are able to access the servlet.

Once the configuration file has been updated, use a browser to access the servlet using a URL like:

  • http://localhost:8080/admin/resin-status

The servlet will display a Web page with a variety of information. Figure B.1 shows the first part of the information returned.

click to expand
Figure B.1: First section of information from the ResinStatusServlet.

The first section of information returned from the servlet is data about the server itself, including:

  • Configuration file used for the server.

  • Start time (when the server was executed).

  • Reload time (the time the server last reloaded itself).

  • Total hard drive space.

  • Free hard drive space.

The next section of information details the WEB and srun ports the server is using, as well as information about the threads servicing the ports. For each of the ports, the thread information includes:

  • Active threads (total number of threads current servicing requests).

  • Keep-alive threads (total number of threads in keep-alive state).

  • Configuration values for the threads.

Figure B.2 shows the middle section of information returned by the servlet.

click to expand
Figure B.2: Second section of information from the ResinStatusServlet.

The second section of information begins with the status of the current srun servers. The information provided includes:

  • IP address of all servers.

  • Active thread counts for the servers.

  • Configuration information for the threads.

The srun server information is followed by database statistics. This section is one of the most critical to verifying your site's overall functionality. The database pools section includes:

  • Name of the JNDI resource.

  • URL to the database.

  • Whether the connection is XA based.

  • Active and total connections.

The database stats are important because one of the most resource-intensive activities on your site is database access. These stats will show you which of the JNDI resources are using the most database connections, as well as the most active database host. With this information at hand, you can make the architecture decisions needed to maximize your system's performance.

Finally, Figure B.3 shows the last information returned by the server.

click to expand
Figure B.3: Final section of information from the ResinStatusServlet.

The final section of information returned from the ResinStatusServlet is a list of all applications broken down by host. If you had virtual hosts on the server, all of the applications for those hosts would be listed as well. The information provided shows the total number of sessions currently active for all applications. As you might guess, this number can be used to determine which virtual hosts and specific applications are most active. Again, this information is very useful for scaling and architecture purposes.




Mastering Resin
Mastering Resin
ISBN: 0471431036
EAN: 2147483647
Year: 2002
Pages: 180

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net