Friday, November 30, 2012

Application Module Pool Statistics


It is crtitical to analyze the Application Module pool statistics
for designing better application.

To display statistics related to Application Module pools , call dumpPoolStatistics()
on oracle.jbo.common.ampool.ApplicationPool object.

Create a servlet with the below code and configure the same to web.xml
This servlet will be used to print the AM pool statistics.

a)Create a servlet.
package com.sai.servlet;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.Enumeration;
import oracle.jbo.common.ampool.ApplicationPool;
import oracle.jbo.common.ampool.PoolMgr;
public class AMPoolStatisticsServlet extends HttpServlet {
private static final String CONTENT_TYPE =
"text/html; charset=windows-1252";
public void init(ServletConfig config) throws ServletException {
super.init(config);
}
public void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException,
IOException {
response.setContentType(CONTENT_TYPE);
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<head><title>AM Pool Statistics</title></head>");
out.println("<body>");
PoolMgr poolMgr = PoolMgr.getInstance();
String poolname = request.getParameter("poolname");
if (poolname == null || poolname.equals("")) {
Enumeration keys = poolMgr.getResourcePoolKeys();
if (keys != null) {
out.println("<h3>List of Active Application Module Pools</h3>");
out.println("<ul>");
while (keys.hasMoreElements()) {
String s = (String)keys.nextElement();
out.println("<li><code><a href='AMPoolInfo?poolname=" +
s + "'>" + s + "</a></code></li>");
}
out.println("</ul>");
} else {
out.println("No pools.");
}
} else {
out.println("<h3>Pool Statistics for Pool '" + poolname +
"'</h3>");
out.println("<a href='AMPoolInfo'>Back to Pool List</a>");
out.println("<hr><blockquote><pre>");
ApplicationPool pool =
(ApplicationPool)poolMgr.getResourcePool(poolname);
pool.dumpPoolStatistics(new PrintWriter(out));
out.println("</pre></blockquote>");
}
out.println("</body></html>");
out.close();
}
}


b)Add it to web.xml



c)Run the page .

Url to call the servlet would be in below format.
http://127.0.0.1:7101/AMStatistics-ViewController-context-root/faces/AMPoolInfo

Below is the screen shot of the sample output 

Click on the AM url to display the statistics.



Follow this url for optimizing application pool :)




No comments:

Post a Comment