<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Great Tasting Java &#187; Servlets</title>
	<atom:link href="http://www.greattastingjava.com/wordpress/index.php/category/servlets/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.greattastingjava.com/wordpress</link>
	<description>Headley Williamson's Java code, answers, tutorials, and courses</description>
	<lastBuildDate>Wed, 21 Jul 2010 17:15:39 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>ATG Dynamo DRP Hung threads solution</title>
		<link>http://www.greattastingjava.com/wordpress/index.php/2007/06/19/atg-dynamo-drp-hung-threads-solution/</link>
		<comments>http://www.greattastingjava.com/wordpress/index.php/2007/06/19/atg-dynamo-drp-hung-threads-solution/#comments</comments>
		<pubDate>Tue, 19 Jun 2007 14:44:17 +0000</pubDate>
		<dc:creator>hwilliamson</dc:creator>
				<category><![CDATA[Code Examples]]></category>
		<category><![CDATA[J2EE]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Servlets]]></category>

		<guid isPermaLink="false">http://www.greattastingjava.com/wordpress/2007/06/19/atg-dynamo-drp-hung-threads-solution/</guid>
		<description><![CDATA[What is a DRP Thread?
DRP stands for Distribution and Replication Protocol.  It is the protocol for communication between an HTTP server (Web server) and an application Server (ATG). When a user clicks on a link or summits a form in his/her web browser, that information or the “request” is sent to a webserver. The [...]]]></description>
			<content:encoded><![CDATA[<p>What is a DRP Thread?<br />
DRP stands for Distribution and Replication Protocol.  It is the protocol for communication between an HTTP server (Web server) and an application Server (ATG). When a user clicks on a link or summits a form in his/her web browser, that information or the “request” is sent to a webserver. The webserver examines the request and determines if it needs to pass on the request to the application server. If it does need to pass the request, it uses the DRP protocol to send the message. Inside the application server when it receives a request, it starts a DRP thread to handle the request. That thread performs the necessary actions, and returns the response to the webserver, which then returns the response to the user’s browser.</p>
<p>Why do they get Hung?<br />
The main reason the threads hang is because it can not finish the request in a timely manner. If your data needs continuously updating, some of queries loose efficiency because their execution paths over time need to be re-analyzed. Over the last couple years we have seen this in several of our queries. </p>
<p>Since we have a set number of available DRP threads (40 in our case), when they are all hanging, the application server is no longer able to serve requests. </p>
<p>This problem is an Enterprise problem. This means all ATG applications run into this problem, if the queries don’t return.</p>
<p>The solution to the problem.</p>
<p>Overview<br />
The solution is to first monitor and identify DRP hung threads, send email regarding their hung status, and then kill them before they can do damage. This solution requires a monitor running inside the application server that will periodically take an inventory of the running DRP threads. When a thread age reaches a predetermined threshold, it will be terminated, and information about the terminated thread will be sent to a predetermined email for evaluation.</p>
<p>The following are the control inputs for the DRPThread Monitor stored in a property file. The property file is loaded upon startup.</p>
<p>This tells the monitor to auto-start.<br />
threadMonitorAutoStart = true</p>
<p>This is how often it checks the DRP threads<br />
threadMonitorWaitInterval = 5000</p>
<p>This is percent of DRP threads in use before checking threshold<br />
threadMonitorThreshold= 80</p>
<p>This is the Age limit of threads. When the age limit is surpassed<br />
thresholdAgeLimit = 300000</p>
<p>This is the max age of any thread. A thread over this age is killed<br />
maxThreadAge= 1800000</p>
<p>List of email address sent notifications when a DRP thread is killed<br />
emailNotificationList = hwilliamson@greattastingjava.com</p>
<p>Pseudo Code </p>
<p>1.	Application server starts up<br />
2.	Starts DRP Monitor</p>
<p>a.	If threadMonitorAutoStart = true, then monitor continues to start up, else it stops.<br />
b.	Loop until forced stop</p>
<ul>
i.	Check DRP server<br />
1.	percent active thread > threadMonitorThreshold &#038;&#038; age of thread > thresholdAgeLimit) || age of thread > maxThreadAge  then<br />
a.	Email info about hung thread<br />
b.	Kill thread<br />
ii.	Sleep threadMonitorWaitInterval
</ul>
<p>Code Sample</p>
<p>		while (!forcedStop) {</p>
<p>			try {</p>
<p>				RequestServerHandler handlers[] = drpServer.getRequestHandlers();</p>
<p>				int activeCount = drpServer.getActiveHandlerCount();</p>
<p>				double percentActive = (activeCount/handlers.length) *100.0;</p>
<p>				for (int i = 0; i < handlers.length; i++) {</p>
<p>					if (handlers[i] instanceof DrpServerConnection) {</p>
<p>						DrpServerConnection connection = (DrpServerConnection) handlers[i];<br />
						if (connection.getHandlingRequest()) {</p>
<p>							if ((percentActive> threadMonitorThreshold &#038;&#038; connection.getCurrentRequestTime() > thresholdAgeLimit) ||connection.getCurrentRequestTime() > maxThreadAge)<br />
							{<br />
								logger.debug(&#8221;killing:&#8221; + connection);</p>
<p>								String path = connection.getCurrentRequestPathInfo();<br />
								long time = connection.getCurrentRequestTime();</p>
<p>								connection.killHandler();</p>
<p>								Mail mail = new Mail();<br />
								mail.postMail(emailNotificationList,&#8221;DRP Thread Killed&#8221;, &#8220;Path:&#8221; +path +&#8221;\n&#8221;<br />
																							+&#8221;Time:&#8221; +time+&#8221;\n&#8221;,&#8221;hwilliamson@greattastingjava.com&#8221;);<br />
								logger.debug(&#8221;emailing:&#8221; + emailNotificationList);</p>
<p>							}<br />
						}<br />
					}<br />
				}<br />
				sleepDRPThreadMonitor();<br />
			} catch (Exception ex)<br />
			{<br />
				ex.printStackTrace();<br />
			}<br />
		}</p>
]]></content:encoded>
			<wfw:commentRss>http://www.greattastingjava.com/wordpress/index.php/2007/06/19/atg-dynamo-drp-hung-threads-solution/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to integrate Tomcat and Sokkit</title>
		<link>http://www.greattastingjava.com/wordpress/index.php/2006/01/03/how-to-integrate-tomcat-and-sokkit/</link>
		<comments>http://www.greattastingjava.com/wordpress/index.php/2006/01/03/how-to-integrate-tomcat-and-sokkit/#comments</comments>
		<pubDate>Wed, 04 Jan 2006 04:20:21 +0000</pubDate>
		<dc:creator>hwilliamson</dc:creator>
				<category><![CDATA[Servlets]]></category>

		<guid isPermaLink="false">http://www.greattastingjava.com/wordpress/2006/01/03/how-to-integrate-tomcat-and-sokkit/</guid>
		<description><![CDATA[Example I got working:
Sokkit: 4.0
JDK: 1.5.0_05
Tomcat: 5.0.28

Download and unzip the sokkit_tomcat kit 

Shutdown apache
Download and unzip tomcat.
http://archive.apache.org/dist/jakarta/tomcat-5/v5.0.28/bin/
Download and install JDK 1.5.
http://java.sun.com
Copy &#8220;jakarta-tomcat-5.0.28&#8243; to sokkit folder
Added




set JAVA_HOME=C:\\Program Files\\Java\\jdk1.5.0_05




(Where ever you have your JDK installed)
to top of bin\catalina.bat (after comments) 
Copy tomcat.conf to C:\sokkit\apache2\conf\addonconf
Copy mod_jk.so in C:\sokkit\apache2\modules folder
Start tomcat




	a. cd C:\\sokkit\\jakarta-tomcat-5.0.28\\bin
	b. startup




Start apache
Test page http://localhost/servlets-examples/

]]></description>
			<content:encoded><![CDATA[<p>Example I got working:</p>
<p>Sokkit: 4.0<br />
JDK: 1.5.0_05<br />
Tomcat: 5.0.28</p>
<ol>
<li>Download and unzip the <a href="http://www.greattastingjava.com/downloads/sokkit_tomcat.zip">sokkit_tomcat</a> kit </li>
<p><span id="more-10"></span></p>
<li>Shutdown apache</li>
<li>Download and unzip tomcat.</li>
<p>http://archive.apache.org/dist/jakarta/tomcat-5/v5.0.28/bin/</p>
<li>Download and install JDK 1.5.</li>
<p>http://java.sun.com</p>
<li>Copy &#8220;jakarta-tomcat-5.0.28&#8243; to sokkit folder</li>
<li>Added<br />
<table width="100" border="1" class="ex" cellspacing="0">
<tr>
<td>
<pre>
set JAVA_HOME=C:\\Program Files\\Java\\jdk1.5.0_05
</pre>
</td>
</tr>
</table>
<p>(Where ever you have your JDK installed)<br />
to top of bin\catalina.bat (after comments) </li>
<li>Copy tomcat.conf to C:\sokkit\apache2\conf\addonconf</li>
<li>Copy mod_jk.so in C:\sokkit\apache2\modules folder</li>
<li>Start tomcat</li>
<table width="100" border="1" class="ex" cellspacing="0">
<tr>
<td>
<pre>
	a. cd C:\\sokkit\\jakarta-tomcat-5.0.28\\bin
	b. startup
</pre>
</td>
</tr>
</table>
<li>Start apache</li>
<li>Test page http://localhost/servlets-examples/</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.greattastingjava.com/wordpress/index.php/2006/01/03/how-to-integrate-tomcat-and-sokkit/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
