<?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>Kandy Software, Inc. &#187; Featured</title>
	<atom:link href="http://www.kandysoftwareinc.com/tech-articles/category/featured/feed" rel="self" type="application/rss+xml" />
	<link>http://www.kandysoftwareinc.com</link>
	<description></description>
	<lastBuildDate>Wed, 17 Dec 2008 06:47:04 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Longest Increasing Subsequence</title>
		<link>http://www.kandysoftwareinc.com/tech-articles/lis</link>
		<comments>http://www.kandysoftwareinc.com/tech-articles/lis#comments</comments>
		<pubDate>Fri, 15 Feb 2008 00:50:18 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Featured]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[increasing]]></category>
		<category><![CDATA[lis]]></category>
		<category><![CDATA[subsequence]]></category>

		<guid isPermaLink="false">http://www.kandysoftwareinc.com/?p=85</guid>
		<description><![CDATA[A classic computer science problem. The problem is finding the longest increasing subset of numbers within a given set. This article presents a solution in Java. ]]></description>
			<content:encoded><![CDATA[<h3><strong>Introduction</strong></h3>
<p><a href="http://www.kandysoftwareinc.com/wp-content/uploads/2008/11/dna.png"><img src="http://www.kandysoftwareinc.com/wp-content/uploads/2008/11/dna.png" alt="" title="dna" class="alignleft size-medium wp-image-86" /></a>Finding the <a href="http://en.wikipedia.org/wiki/Longest_increasing_subsequence" target="_blank">maximum or longest increasing subsequence</a> (LIS) within a given a set of numbers is a classic Computer Science problem. The algorithm is central to many tools and is used in various disciplines related to mathematics, physics etc. In the field of Bioinformatics, LIS is used to find DNA subsequences matching a certain criteria. By recognizing certain patterns in DNA sequences scientists can determine diseases, genetic disorders etc.</p>
<h3><strong>Problem</strong></h3>
<p>Given a sequence of N integers, find the longest <i>strictly</i> increasing subsequence. For example in the sequence 56, 21, 33, 22, 34, 78, 11, 35, 46, the longest increasing subsequence is 21, 33, 34, 35, 46. In this context we will consider a NXN matrix of integers and find a sequence which is simply a series of adjacent squares. A square may not be used more than once. In the following 10 X 10 grid:</p>
<pre>
  | 0  1  2  3  4  5  6  7  8  9
--+------------------------------
0 | 95 47 30 36 60 31 57 66 12 55
1 | 35 57 41 13 82 80 71 93 31 62
2 | 89 36 98 75 91 24 95 53 37 99
3 | 25 45 26 17 15 84 80 73 96 21
4 | 75 22 43 <font color="red">96</font> 96 36 64 31 45 86
5 | 45 99 <font color="red">68</font> <font color="red">74</font> 54 14 93 17 14 55
6 | 14 42 <font color="red">52</font> 54 34 50 22 84 32 41
7 | 90 <font color="red">44</font> 73 10 71 84 20 12 55 52
8 | 95 <font color="red">33</font> <font color="red">25</font> 31 76 45 44 84 90 52
9 | 94 64 95 <font color="red">24</font> 41 63 87 93 79 12
</pre>
<p>the longest increasing subsequence is of length 8 consisting of entries 24, 25, 33, 44, 52, 68, 74, 96 as highlighted in red.</p>
<h3><strong>Solution</strong></h3>
<p>Each number and its position in the sequence are stored in an array. In the first pass, neighbors for each item in the array are found and are stored along with the item. Items are then sorted by their descending value. In the second and final pass, weights are assigned to the neighbors. The neighbor with the least value is assigned weight 1, the next highest neighbor is assigned 2 and so on. To get the longest increasing subsequence, find the element with the highest weight and print its neighbors in the descending order of weights.</p>
<p>Unzip the attachment and <code>cd</code> into the newly created folder. Compile the classes run as follows:</p>

<div class="wp_syntax"><div class="code"><pre class="dos" style="font-family:monospace;">C:\MaximumIncreasingSubsequence&gt;javac -d bin src\*.java
&nbsp;
C:\MaximumIncreasingSubsequence&gt;java -classpath bin MaximumIncreasingSubsequence small-grid.txt
<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">24</span>, <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span> with value <span style="color: #cc66cc;">129</span> <span style="color: #66cc66;">&#40;</span>weight = <span style="color: #cc66cc;">15</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">24</span>, <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span> with value <span style="color: #cc66cc;">138</span> <span style="color: #66cc66;">&#40;</span>weight = <span style="color: #cc66cc;">14</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">25</span>, <span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span> with value <span style="color: #cc66cc;">167</span> <span style="color: #66cc66;">&#40;</span>weight = <span style="color: #cc66cc;">13</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">25</span>, <span style="color: #cc66cc;">3</span><span style="color: #66cc66;">&#41;</span> with value <span style="color: #cc66cc;">236</span> <span style="color: #66cc66;">&#40;</span>weight = <span style="color: #cc66cc;">12</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">25</span>, <span style="color: #cc66cc;">4</span><span style="color: #66cc66;">&#41;</span> with value <span style="color: #cc66cc;">300</span> <span style="color: #66cc66;">&#40;</span>weight = <span style="color: #cc66cc;">11</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">26</span>, <span style="color: #cc66cc;">4</span><span style="color: #66cc66;">&#41;</span> with value <span style="color: #cc66cc;">338</span> <span style="color: #66cc66;">&#40;</span>weight = <span style="color: #cc66cc;">10</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">27</span>, <span style="color: #cc66cc;">5</span><span style="color: #66cc66;">&#41;</span> with value <span style="color: #cc66cc;">438</span> <span style="color: #66cc66;">&#40;</span>weight = <span style="color: #cc66cc;">9</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">28</span>, <span style="color: #cc66cc;">4</span><span style="color: #66cc66;">&#41;</span> with value <span style="color: #cc66cc;">469</span> <span style="color: #66cc66;">&#40;</span>weight = <span style="color: #cc66cc;">8</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">27</span>, <span style="color: #cc66cc;">4</span><span style="color: #66cc66;">&#41;</span> with value <span style="color: #cc66cc;">596</span> <span style="color: #66cc66;">&#40;</span>weight = <span style="color: #cc66cc;">7</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">27</span>, <span style="color: #cc66cc;">3</span><span style="color: #66cc66;">&#41;</span> with value <span style="color: #cc66cc;">709</span> <span style="color: #66cc66;">&#40;</span>weight = <span style="color: #cc66cc;">6</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">26</span>, <span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span> with value <span style="color: #cc66cc;">723</span> <span style="color: #66cc66;">&#40;</span>weight = <span style="color: #cc66cc;">5</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">27</span>, <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span> with value <span style="color: #cc66cc;">778</span> <span style="color: #66cc66;">&#40;</span>weight = <span style="color: #cc66cc;">4</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">28</span>, <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span> with value <span style="color: #cc66cc;">866</span> <span style="color: #66cc66;">&#40;</span>weight = <span style="color: #cc66cc;">3</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">27</span>, <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span> with value <span style="color: #cc66cc;">939</span> <span style="color: #66cc66;">&#40;</span>weight = <span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">26</span>, <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span> with value <span style="color: #cc66cc;">953</span> <span style="color: #66cc66;">&#40;</span>weight = <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>
Program took: <span style="color: #cc66cc;">380</span> milliseconds</pre></div></div>

<h3><strong>Attachments</strong></h3>
<p><a href='http://www.kandysoftwareinc.com/wp-content/uploads/2008/02/maximumincreasingsubsequence.zip' title='Source code'>Source code</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.kandysoftwareinc.com/tech-articles/lis/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Apache, Tomcat cluster, load balancing using mod_jk</title>
		<link>http://www.kandysoftwareinc.com/tech-articles/apache-tomcat-cluster-load-balancing-using-mod_jk</link>
		<comments>http://www.kandysoftwareinc.com/tech-articles/apache-tomcat-cluster-load-balancing-using-mod_jk#comments</comments>
		<pubDate>Thu, 14 Feb 2008 21:46:28 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[Tomcat]]></category>
		<category><![CDATA[cluster]]></category>
		<category><![CDATA[httpd.conf]]></category>
		<category><![CDATA[load balance]]></category>
		<category><![CDATA[mod_jk]]></category>
		<category><![CDATA[multicast]]></category>
		<category><![CDATA[router]]></category>
		<category><![CDATA[worker]]></category>

		<guid isPermaLink="false">http://www.kandysoftwareinc.com/?p=64</guid>
		<description><![CDATA[This article discusses how to configure multiple Tomcat instances to balance work load using mod_jk Apache connector.]]></description>
			<content:encoded><![CDATA[<p>[print_link]</p>
<h3><strong>Introduction</strong></h3>
<p><a href="http://www.kandysoftwareinc.com/wp-content/uploads/2008/11/tomcat.gif"><img src="http://www.kandysoftwareinc.com/wp-content/uploads/2008/11/tomcat.gif" alt="" title="tomcat" width="130" height="92" class="alignleft size-thumbnail wp-image-68" /></a><a href="http://www.kandysoftwareinc.com/articles/mod_jk.pdf" target="_blank"><img src="http://www.kandysoftwareinc.com/images/PDF_icon.jpg" align="right" height="50" width="50" class="alignleft" border="0"/></a>This article discusses how to install and configure Apache 2.0.x and Tomcat (or JBoss) to communicate with each other via mod_jk. This article also discusses how to setup a Tomcat cluster using mod_jk to balance work load.<br />
<br/></p>
<h3><strong>Install JDK</strong></h3>
<ol>
<li>
Download JDK rpm and launch the executable by running the following commands:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">chmod</span> a+x j2sdk-<span style="color: #000000;">1</span>_4_2_<span style="color: #000000; font-weight: bold;">&lt;</span>version number<span style="color: #000000; font-weight: bold;">&gt;</span>-linux-i586-rpm.bin
.<span style="color: #000000; font-weight: bold;">/</span>j2sdk-<span style="color: #000000;">1</span>_4_2_<span style="color: #000000; font-weight: bold;">&lt;</span>version number<span style="color: #000000; font-weight: bold;">&gt;</span>-linux-i586-rpm.bin</pre></div></div>

</li>
<li>
Type <strong>yes</strong> and agree to the binary license agreement.
</li>
<li>
Become root by running <strong>su</strong> and entering root password
</li>
<li>
Install the rpm. This will install JDK at <code>/usr/java/j2sdk-1.4.2</code>:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">rpm <span style="color: #660033;">-iv</span> jdk-1.4.2_<span style="color: #000000; font-weight: bold;">&lt;</span>version number<span style="color: #000000; font-weight: bold;">&gt;</span>.i386.rpm</pre></div></div>

</li>
<li>
Edit PATH environment variable to include bin directory of JDK by adding the following lines to <code>/etc/profile</code>:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">JAVA_HOME</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>java<span style="color: #000000; font-weight: bold;">/</span>j2sdk-1.4.2_<span style="color: #000000; font-weight: bold;">&lt;</span>version number<span style="color: #000000; font-weight: bold;">&gt;</span>
<span style="color: #7a0874; font-weight: bold;">export</span> JAVA_HOME
<span style="color: #007800;">PATH</span>=<span style="color: #007800;">$JAVA_HOME</span><span style="color: #000000; font-weight: bold;">/</span>bin:<span style="color: #007800;">$PATH</span></pre></div></div>

</li>
</ol>
<h3><strong>Avoid Firewall and Routing issues</strong></h3>
<ol>
<li>
Disable the default firewall (unless you can configure it to allow multicast packets)</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>iptables stop
<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>ip6tables stop</pre></div></div>

</li>
<li>
Add this multicast route:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>route add <span style="color: #660033;">-net</span> 224.0.0.0 netmask 240.0.0.0 dev eth<span style="color: #000000; font-weight: bold;">&lt;</span><span style="color: #c20cb9; font-weight: bold;">id</span><span style="color: #000000; font-weight: bold;">&gt;</span></pre></div></div>

</li>
</ol>
<h3><strong>Install Apache</strong></h3>
<ol>
<li>
Download <code>httpd-2.0.50-i686-pc-linux-gnu.tar.gz</code> into a temporary location and run the following commands to install Apache at <code>/usr/local/share</code>:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">unzip</span> <span style="color: #000000; font-weight: bold;">&lt;</span> httpd-2.0.50-i686-pc-linux-gnu.tar.gz <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">tar</span> xvf -
<span style="color: #7a0874; font-weight: bold;">cd</span> httpd-2.0.50
.<span style="color: #000000; font-weight: bold;">/</span>install-bindist.sh <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span>apache-2.0.50</pre></div></div>

</li>
<li>
Edit PATH environment variable to include bin directory of Apache by adding the following lines to <code>/etc/profile</code>:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">APACHE_HOME</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span>apache-2.0.50
<span style="color: #7a0874; font-weight: bold;">export</span> APACHE_HOME
<span style="color: #007800;">PATH</span>=<span style="color: #007800;">$APACHE_HOME</span><span style="color: #000000; font-weight: bold;">/</span>bin:<span style="color: #007800;">$PATH</span>
<span style="color: #7a0874; font-weight: bold;">export</span> PATH</pre></div></div>

</li>
</ol>
<h3><strong>Install Tomcat</strong></h3>
<ol>
<li>
Move <code>apache-tomcat-x.y.z.zip.zip</code> to <code>/usr/local/share</code> (I will refer to the installation folder by this path) and unzip it:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">unzip</span> apache-tomcat-x.y.z.zip</pre></div></div>

</li>
<li>
Edit PATH environment variable to include bin directory of Apache by adding the following lines to <code>/etc/profile</code>:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">TOMCAT_HOME</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span>apache-tomcat-x.y.z
<span style="color: #7a0874; font-weight: bold;">export</span> TOMCAT_HOME
<span style="color: #007800;">PATH</span>=<span style="color: #007800;">$TOMCAT_HOME</span><span style="color: #000000; font-weight: bold;">/</span>bin:<span style="color: #007800;">$PATH</span>
<span style="color: #7a0874; font-weight: bold;">export</span> PATH</pre></div></div>

</li>
</ol>
<h3><strong>Configure mod_jk</strong></h3>
<ol>
<li>
Copy the mod_jk binary to <code>$APACHE_HOME/modules</code> directory and rename it as <code>mod_jk.so</code>
</li>
<li>
Add the following lines at the very bottom in <code>$APACHE_HOME/conf/httpd.conf</code><br />
<br/></p>

<div class="wp_syntax"><div class="code"><pre class="apache" style="font-family:monospace;"><span style="color: #adadad; font-style: italic;">#Include mod_jk configuration file</span>
<span style="color: #00007f;">Include</span> conf/mod-jk.conf</pre></div></div>

</li>
<li>
Under <code>$APACHE_HOME/conf</code> create <code>mod-jk.conf</code> and write the following lines in it:<br />
<br/></p>

<div class="wp_syntax"><div class="code"><pre class="apache" style="font-family:monospace;"><span style="color: #adadad; font-style: italic;"># Load mod_jk module</span>
<span style="color: #adadad; font-style: italic;"># Specify the filename of the mod_jk lib</span>
<span style="color: #00007f;">LoadModule</span> jk_module modules/mod_jk.so
<span style="color: #adadad; font-style: italic;"># Where to find workers.properties</span>
JkWorkersFile conf/workers.properties
<span style="color: #adadad; font-style: italic;"># Where to put jk logs</span>
JkLogFile logs/mod_jk.log
<span style="color: #adadad; font-style: italic;"># Set the jk log level [debug/error/info]</span>
JkLogLevel info
<span style="color: #adadad; font-style: italic;"># Select the log format</span>
JkLogStampFormat <span style="color: #7f007f;">&quot;[%a %b %d %H:%M:%S %Y]&quot;</span>
<span style="color: #adadad; font-style: italic;"># JkOptions indicates to send SSK KEY SIZE</span>
JkOptions +ForwardKeySize +ForwardURICompat -
ForwardDirectories
<span style="color: #adadad; font-style: italic;"># JkRequestLogFormat</span>
JkRequestLogFormat <span style="color: #7f007f;">&quot;%w %V %T&quot;</span>
JkMount /Context/* loadbalancer</pre></div></div>

<p><br/><br />
Where <font color="#ff0000"><strong>Context</strong></font> is the web-app context name.
</li>
<li>
Under <code>$APACHE_HOME/conf</code> create <code>workers.properties</code> and populate it as follows:<br />
<br/></p>

<div class="wp_syntax"><div class="code"><pre class="apache" style="font-family:monospace;"><span style="color: #adadad; font-style: italic;"># Worker list</span>
worker.list=loadbalancer
<span style="color: #adadad; font-style: italic;"># Define Node1</span>
worker.node1.<span style="color: #00007f;">port</span>=<span style="color: #ff0000;">8009</span>
worker.node1.host=node1.ip.address
worker.node1.type=ajp13
worker.node1.lbfactor=<span style="color: #ff0000;">1</span>
<span style="color: #adadad; font-style: italic;">#worker.node1.local_worker=1 (1)</span>
worker.node1.<span style="color: #00007f;">cachesize</span>=<span style="color: #ff0000;">10</span>
<span style="color: #adadad; font-style: italic;"># Define Node2</span>
worker.node2.<span style="color: #00007f;">port</span>=<span style="color: #ff0000;">8009</span>
worker.node2.host=node2.ip.address
worker.node2.type=ajp13
worker.node2.lbfactor=<span style="color: #ff0000;">1</span>
<span style="color: #adadad; font-style: italic;">#worker.node2.local_worker=1 (1)</span>
worker.node2.<span style="color: #00007f;">cachesize</span>=<span style="color: #ff0000;">10</span>
<span style="color: #adadad; font-style: italic;"># Load-balancer</span>
worker.loadbalancer.type=lb
worker.loadbalancer.balanced_workers=node1, node2
worker.loadbalancer.sticky_session=<span style="color: #ff0000;">1</span>
worker.loadbalancer.local_worker_only=<span style="color: #ff0000;">1</span></pre></div></div>

<p>Add one worker per node and name workers as node1, node2, node3 … nodeN. Don’t forget to define all these as load balancing workers:</p>

<div class="wp_syntax"><div class="code"><pre class="apache" style="font-family:monospace;">worker.loadbalancer.balanced_workers=node1, node2, node3, ... nodeN</pre></div></div>

<p>Replace <code>node1.ip.address</code> with IPAddress of Tomcat(or JBoss) instance1 and so on. The attribute <code>sticky_session=1</code> tells mod_jk that SESSION ID&#8217;s should be routed back to the same Tomcat worker. The <code>lbfactor</code> determines the number of requests a worker receives. The higher the <code>lbfactor</code> the more requests a worker receives.
</li>
<li>
Each node should be named according to the names specified in <code>workers.properties</code>. On each Tomcat instance, edit <code>$TOMCAT_HOME/conf/server.xml</code>. Locate the &lt;Engine&gt; element and add an attribute called jvmRoute:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Engine</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;Catalina&quot;</span> <span style="color: #000066;">defaultHost</span>=<span style="color: #ff0000;">&quot;localhost&quot;</span> <span style="color: #000066;">jvmRoute</span>=<span style="color: #ff0000;">&quot;node1&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
…
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Engine<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

</li>
</ol>
<p><font color="#ff0000"><strong>NOTE: THE jvmRoute ATTRIBUTE MUST MATCH THE NAME SPECIFIED IN workers.properties.</strong></font></p>
<h3><strong>Start Apache and Tomcat</strong></h3>
<ol>
<li>
Start Apache:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">$APACHE_HOME</span><span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>apachectl <span style="color: #660033;">-k</span> start</pre></div></div>

</li>
<li>
To stop use:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">$APACHE_HOME</span><span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>apachectl <span style="color: #660033;">-k</span> stop</pre></div></div>

</li>
<li>
Start Tomcat:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">$TOMCAT_HOME</span><span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>startup.sh</pre></div></div>

</li>
<li>
Stop Tomcat:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">$TOMCAT_HOME</span><span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>shutdown.sh</pre></div></div>

</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.kandysoftwareinc.com/tech-articles/apache-tomcat-cluster-load-balancing-using-mod_jk/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Apache, OpenSSL</title>
		<link>http://www.kandysoftwareinc.com/tech-articles/apache-openssl</link>
		<comments>http://www.kandysoftwareinc.com/tech-articles/apache-openssl#comments</comments>
		<pubDate>Wed, 13 Feb 2008 21:40:04 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[OpenSSL]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[ssl]]></category>

		<guid isPermaLink="false">http://www.kandysoftwareinc.com/?p=62</guid>
		<description><![CDATA[This article discusses how to configure Apache and OpenSSL to serve https content.]]></description>
			<content:encoded><![CDATA[<p>[print_link]</p>
<h3><strong>Introduction</strong></h3>
<p><a href="http://www.kandysoftwareinc.com/wp-content/uploads/2008/11/apache-openssl.png"><img src="http://www.kandysoftwareinc.com/wp-content/uploads/2008/11/apache-openssl.png" alt="" title="apache-openssl" class="alignleft size-medium wp-image-73" /></a>This article discusses how to configure Apache and OpenSSL to serve https content. We assume Apache is installed and OpenSSL commands are available in the PATH environment variable. Otherwise install Apache and OpenSSL using <strong><em>yum</em></strong> or <strong><em>apt</em></strong>.</p>
<h3><strong>Create a working directory</strong></h3>
<p>Let&#8217;s call it sslcert:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">$mkdir</span> sslcert</pre></div></div>

<h3><strong>Create two subdirectories under it</strong></h3>
<p>Create 2 subdirectories under sslcert. Let&#8217;s call them certs and private.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">$cd</span> sslcert
<span style="color: #007800;">$mkdir</span> certs private</pre></div></div>

<h3><strong>Create a database to keep track of each certificate signed</strong></h3>
<p>Run the following commands:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">$echo</span> <span style="color: #ff0000;">'01'</span> <span style="color: #000000; font-weight: bold;">&gt;</span> serial
<span style="color: #007800;">$touch</span> certindex.txt</pre></div></div>

<h3><strong>Make a custom config file for openssl to use</strong></h3>
<p>Copy the config elements into a file called openssl.cnf. (edit as needed):</p>
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td><a href="http://www.kandysoftwareinc.com/wp-content/uploads/2008/01/ssl11.JPG" title="ssl11.JPG"><img src="http://www.kandysoftwareinc.com/wp-content/uploads/2008/01/ssl11.JPG" alt="ssl11.JPG" border="0" /></a></td>
</tr>
<tr>
<td><a href="http://www.kandysoftwareinc.com/wp-content/uploads/2008/01/ssl21.JPG" title="ssl21.JPG"><img src="http://www.kandysoftwareinc.com/wp-content/uploads/2008/01/ssl21.JPG" alt="ssl21.JPG" border="0" /></a></td>
</tr>
</table>
]]></content:encoded>
			<wfw:commentRss>http://www.kandysoftwareinc.com/tech-articles/apache-openssl/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Boggle</title>
		<link>http://www.kandysoftwareinc.com/tech-articles/boggle</link>
		<comments>http://www.kandysoftwareinc.com/tech-articles/boggle#comments</comments>
		<pubDate>Sat, 09 Feb 2008 00:19:29 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Featured]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Boggle]]></category>

		<guid isPermaLink="false">http://www.kandysoftwareinc.com/?p=77</guid>
		<description><![CDATA[A Java implementation of the popular word game.]]></description>
			<content:encoded><![CDATA[<h3><strong>The Game</strong></h3>
<p><a href="http://www.kandysoftwareinc.com/wp-content/uploads/2008/11/boggle.png"><img src="http://www.kandysoftwareinc.com/wp-content/uploads/2008/11/boggle.png" alt="" title="boggle" class="alignleft size-medium wp-image-80" /></a><a href="http://en.wikipedia.org/wiki/Boggle" target="_blank">Boggle</a> is a word game designed by Allan Turoff. The objective of the game is to construct as many different words as you can from a grid of letters. You can use letters (in positions) that are next to each other &#8211; above, below, left, right, diagonal but you can not use the same letter more than once. Each word must be defined in a dictionary. Points are assigned according to the length of the word.</p>
<p>The source code attached here is an implementation of this game in Java. It demonstrates <a href="http://en.wikipedia.org/wiki/Recursion" target="_blank">recursion</a> to solve problems like this game. The program attempts to construct words as defined in <code>dic.txt</code> from <code>puzzle.txt</code>. Points are assigned according to the length of the word.</p>
<h3><strong>Instructions</strong></h3>
<p>To run this program you need JDK 5 or better installed. You can get JDK <a href="http://java.sun.com/javase/downloads/index.jsp" target="_blank">from here</a>.</p>
<ol>
<li>Unzip the file. This creates a folder called <code>Boggle</code></li>
<li>Compile the code: <code>javac src\*.java  -d bin</code></li>
<li>Run the program: <code>java -classpath bin Boggle</code></li>
</ol>

<div class="wp_syntax"><div class="code"><pre class="dos" style="font-family:monospace;">C:\Boggle&gt;javac src\*.java  -d bin
&nbsp;
C:\Boggle&gt;java -classpath bin Boggle
Enter boggle file:
puzzle.txt
Opened puzzle.txt
Enter dictionary name:
dic.txt
Opened dic.txt
Reading files...
Solving...
Word            | Points | Path
----------------+--------+-----------------------
            APR |      <span style="color: #cc66cc;">1</span> | <span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>, <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>, <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span>
      APRTOCFED |     <span style="color: #cc66cc;">15</span> | <span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>, <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>, <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span>, <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span>,<span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span>, <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span>,<span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>, <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span>,<span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>, <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">2</span>,<span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>, <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">2</span>,<span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>, <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">2</span>,<span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span>
            COT |      <span style="color: #cc66cc;">1</span> | <span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span>,<span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>, <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span>,<span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>, <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span>,<span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span>
            FED |      <span style="color: #cc66cc;">1</span> | <span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">2</span>,<span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>, <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">2</span>,<span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>, <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">2</span>,<span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span></pre></div></div>

<h3><strong>Attachments</strong></h3>
<p><a href="http://www.kandysoftwareinc.com/wp-content/uploads/2008/02/boggle.zip">Source code</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.kandysoftwareinc.com/tech-articles/boggle/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
