<?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>Praveen&#039;s blog &#187; Computers</title>
	<atom:link href="http://praveen.kumar.in/category/computers/feed/" rel="self" type="application/rss+xml" />
	<link>http://praveen.kumar.in</link>
	<description></description>
	<lastBuildDate>Wed, 22 Jun 2011 01:50:43 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.4</generator>
		<item>
		<title>Building Hadoop and HBase for HBase Maven application development</title>
		<link>http://praveen.kumar.in/2011/06/20/building-hadoop-and-hbase-for-hbase-maven-application-development/</link>
		<comments>http://praveen.kumar.in/2011/06/20/building-hadoop-and-hbase-for-hbase-maven-application-development/#comments</comments>
		<pubDate>Tue, 21 Jun 2011 06:02:40 +0000</pubDate>
		<dc:creator>Praveen Kumar</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[hadoop]]></category>
		<category><![CDATA[hbase]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://praveen.kumar.in/?p=733</guid>
		<description><![CDATA[<a href="http://praveen.kumar.in/2011/06/20/building-hadoop-and-hbase-for-hbase-maven-application-development/" title="Building Hadoop and HBase for HBase Maven application development"></a>]]></description>
			<content:encoded><![CDATA[<a href="http://praveen.kumar.in/2011/06/20/building-hadoop-and-hbase-for-hbase-maven-application-development/" title="Building Hadoop and HBase for HBase Maven application development"></a><p>
<div id="table-of-contents">
<h2>Table of Contents</h2>
<div id="text-table-of-contents">
<ul>
<li><a href="#sec-1">1 Introduction </a></li>
<li><a href="#sec-2">2 Interpreting Maven terminology </a>
<ul>
<li><a href="#sec-2_1">2.1 Maven repository vs repository manager </a></li>
<li><a href="#sec-2_2">2.2 Installing vs deploying artifacts </a></li>
<li><a href="#sec-2_3">2.3 Installing artifacts vs binaries </a></li>
</ul>
</li>
<li><a href="#sec-3">3 Prerequisites </a></li>
<li><a href="#sec-4">4 Building Hadoop common </a>
<ul>
<li><a href="#sec-4_1">4.1 Checkout Hadoop common </a></li>
<li><a href="#sec-4_2">4.2 Create build.properties </a></li>
<li><a href="#sec-4_3">4.3 OPTIONAL: Configure your repository manager </a></li>
<li><a href="#sec-4_4">4.4 Build and install/deploy Hadoop common artifacts </a>
<ul>
<li><a href="#sec-4_4_1">4.4.1 Install artifacts </a></li>
<li><a href="#sec-4_4_2">4.4.2 Deploy artifacts </a></li>
</ul>
</li>
<li><a href="#sec-4_5">4.5 Generate the binary tarball to install on the cluster </a></li>
<li><a href="#sec-4_6">4.6 Install Hadoop binaries on the cluster </a></li>
</ul>
</li>
<li><a href="#sec-5">5 Building HBase </a>
<ul>
<li><a href="#sec-5_1">5.1 Checkout HBase </a></li>
<li><a href="#sec-5_2">5.2 Modify HBase and Hadoop versions </a></li>
<li><a href="#sec-5_3">5.3 OPTIONAL: Specify the URL of your repository manager </a></li>
<li><a href="#sec-5_4">5.4 Build and install/deploy HBase artifacts </a>
<ul>
<li><a href="#sec-5_4_1">5.4.1 Install artifacts </a></li>
<li><a href="#sec-5_4_2">5.4.2 Deploy artifacts </a></li>
</ul>
</li>
<li><a href="#sec-5_5">5.5 Generate the binary tarball to install on the cluster </a></li>
<li><a href="#sec-5_6">5.6 Install HBase binaries on the cluster </a></li>
</ul>
</li>
<li><a href="#sec-6">6 OPTIONAL: Using the HBase artifact in your HBase application </a></li>
<li><a href="#sec-7">7 Feedback </a></li>
<li><a href="#sec-8">8 Credits </a></li>
<li><a href="#sec-9">9 Disclaimer </a></li>
</ul>
</div>
</div>

<div id="outline-container-1" class="outline-2">
<h2 id="sec-1"><span class="section-number-2">1</span> Introduction </h2>
<div class="outline-text-2" id="text-1">


<p>
<a href="http://hbase.apache.org/">HBase</a> 0.90.3 needs <a href="http://hadoop.apache.org/">Hadoop</a> common 0.20-append branch in order to not
lose data. More information about this can be found <a href="http://hbase.apache.org/book/notsoquick.html#hadoop">"Getting Started"</a>
section of HBase guide. However, there is no official release of
Hadoop common 0.20-append binary. In order to have consistent and
right bits on your cluster and your development platform, you need to
compile your own binary version of Hadoop common from the 0.20-append
branch source and your own version of HBase 0.90.3 using that Hadoop
common binary.
</p>
<p>
This article provides an overview of building Hadoop and
HBase for developing HBase applications that are managed using <a href="http://maven.apache.org/">Maven</a>.
</p>
</div>

</div>

<div id="outline-container-2" class="outline-2">
<h2 id="sec-2"><span class="section-number-2">2</span> Interpreting Maven terminology </h2>
<div class="outline-text-2" id="text-2">


<p>
A brief description about a few ambiguous terms is provided in this
section to avoid potential confusion.
</p>

</div>

<div id="outline-container-2_1" class="outline-3">
<h3 id="sec-2_1"><span class="section-number-3">2.1</span> Maven repository vs repository manager </h3>
<div class="outline-text-3" id="text-2_1">

<p>Maven repository refers to <code>~/.m2/repository</code>, whereas Maven
repository manager refers to an artifact repository manager like
<a href="http://archiva.apache.org/">Apache Archiva</a> or <a href="http://www.jfrog.com/products.php">Artifactory</a>.
</p>
</div>

</div>

<div id="outline-container-2_2" class="outline-3">
<h3 id="sec-2_2"><span class="section-number-3">2.2</span> Installing vs deploying artifacts </h3>
<div class="outline-text-3" id="text-2_2">

<p>Installing an artifact is installing it in the Maven repository,
whereas deploying an artifact means publishing the artifact in a Maven
repository manager. For more information, please refer to <a href="http://www.sonatype.com/books/mvnref-book/reference/lifecycle-sect-common-goals.html#lifecycle-sect-install-phase">Maven reference</a>.
</p>
</div>

</div>

<div id="outline-container-2_3" class="outline-3">
<h3 id="sec-2_3"><span class="section-number-3">2.3</span> Installing artifacts vs binaries </h3>
<div class="outline-text-3" id="text-2_3">

<p>Installing artifacts refers to installing them in Maven repository,
whereas installing binaries refers to installing the entire binary
distribution on the cluster.
</p>
</div>
</div>

</div>

<div id="outline-container-3" class="outline-2">
<h2 id="sec-3"><span class="section-number-2">3</span> Prerequisites </h2>
<div class="outline-text-2" id="text-3">


<p>
You need the following components for this process.
</p>
<ul>
<li><a href="http://www.oracle.com/technetwork/java/javase/overview/index-jsp-136246.html">Oracle Java SE 6</a>
</li>
<li><a href="http://www.oracle.com/technetwork/java/javase/downloads/index-jdk5-jsp-142662.html">Oracle Java SE 5</a>
</li>
<li><a href="http://subversion.apache.org/">Apache Subversion</a>
</li>
<li><a href="http://ant.apache.org/">Apache Ant</a>
</li>
<li><a href="http://forrest.apache.org/">Apache Forrest 0.8</a>
</li>
<li><a href="http://maven.apache.org/">Apache Maven</a>
</li>
<li>A Maven repository manager (Optional)
</li>
</ul>

<p>
If you are using a Maven repository manager, then make sure that you
configure the authentication settings for the repository manager in
<code>~/.m2/settings</code> file.
</p>



<pre class="src src-xml">&lt;<span style="color: #0000ff;">settings</span>&gt;
  ...
  &lt;<span style="color: #0000ff;">servers</span>&gt;
    &lt;<span style="color: #0000ff;">server</span>&gt;
      &lt;<span style="color: #0000ff;">id</span>&gt;yourrepo.internal&lt;/<span style="color: #0000ff;">id</span>&gt;
      &lt;<span style="color: #0000ff;">username</span>&gt;USER&lt;/<span style="color: #0000ff;">username</span>&gt;
      &lt;<span style="color: #0000ff;">password</span>&gt;PASSWORD&lt;/<span style="color: #0000ff;">password</span>&gt;
    &lt;/<span style="color: #0000ff;">server</span>&gt;
  &lt;/<span style="color: #0000ff;">servers</span>&gt;
  ...
&lt;/<span style="color: #0000ff;">settings</span>&gt;
</pre>



<p>
<code>yourrepo.internal</code> is the ID that you will be referring to later from
Ant and Maven build configurations.
</p>
<p>
<code>USER</code> and <code>PASSWORD</code> are the username and password of an account with
deployment role in your Maven repository manager.
</p>
</div>

</div>

<div id="outline-container-4" class="outline-2">
<h2 id="sec-4"><span class="section-number-2">4</span> Building Hadoop common </h2>
<div class="outline-text-2" id="text-4">



</div>

<div id="outline-container-4_1" class="outline-3">
<h3 id="sec-4_1"><span class="section-number-3">4.1</span> Checkout Hadoop common </h3>
<div class="outline-text-3" id="text-4_1">


<p>
Checkout Hadoop common from 0.20-append branch.
</p>



<pre class="example">$ svn co http://svn.apache.org/repos/asf/hadoop/common/branches/branch-0.20-append/ hadoop-common-0.20-append
</pre>



</div>

</div>

<div id="outline-container-4_2" class="outline-3">
<h3 id="sec-4_2"><span class="section-number-3">4.2</span> Create build.properties </h3>
<div class="outline-text-3" id="text-4_2">


<p>
Hadoop uses Apache Ant as a build tool. In order to build
<code>hadoop-common</code>, you need to create a
<code>hadoop-common-0.20-append/build.properties</code> file that looks something
like this.
</p>



<pre class="src src-conf-javaprop"><span style="color: #a0522d;">resolvers</span>=internal
<span style="color: #a0522d;">version</span>=0.20-append-r1057313-yourversion
<span style="color: #a0522d;">project.version</span>=${version}
<span style="color: #a0522d;">hadoop.version</span>=${version}
<span style="color: #a0522d;">hadoop-core.version</span>=${version}
<span style="color: #a0522d;">hadoop-hdfs.version</span>=${version}
<span style="color: #a0522d;">hadoop-mapred.version</span>=${version}
</pre>



<p>
Note that at the time of creation of this article, the latest revision
that was available in 0.20-append branch was r1057313.
</p>
<p>
Also, try to assign a meaningful suffix in place of <code>yourversion</code> so
that you can distinguish between the official artifacts and the
artifacts that are deployed by you.
</p>
</div>

</div>

<div id="outline-container-4_3" class="outline-3">
<h3 id="sec-4_3"><span class="section-number-3">4.3</span> OPTIONAL: Configure your repository manager </h3>
<div class="outline-text-3" id="text-4_3">


<p>
Please follow this step only if you are running a Maven repository
manager for team collaboration and you want to deploy the Hadoop
common artifacts to that repository manager.
</p>
<p>
Edit <code>hadoop-common-0.20.append/build.xml</code> and add two new targets.
</p>



<pre class="src src-xml">&lt;<span style="color: #0000ff;">target</span> <span style="color: #a0522d;">name</span>=<span style="color: #8b2252;">"</span><span style="color: #8b2252;">mvn-deploy-internal</span><span style="color: #8b2252;">"</span> <span style="color: #a0522d;">depends</span>=<span style="color: #8b2252;">"</span><span style="color: #8b2252;">mvn-taskdef, bin-package, set-version, simpledeploy-internal</span><span style="color: #8b2252;">"</span>
   <span style="color: #a0522d;">description</span>=<span style="color: #8b2252;">"</span><span style="color: #8b2252;">To deploy hadoop core and test jar's to apache maven repository</span><span style="color: #8b2252;">"</span>/&gt;

&lt;<span style="color: #0000ff;">target</span> <span style="color: #a0522d;">name</span>=<span style="color: #8b2252;">"</span><span style="color: #8b2252;">simpledeploy-internal</span><span style="color: #8b2252;">"</span> <span style="color: #a0522d;">unless</span>=<span style="color: #8b2252;">"</span><span style="color: #8b2252;">staging</span><span style="color: #8b2252;">"</span>&gt;
   &lt;<span style="color: #7a378b;">artifact</span>:<span style="color: #0000ff;">pom</span> <span style="color: #a0522d;">file</span>=<span style="color: #8b2252;">"</span><span style="color: #8b2252;">${hadoop-core.pom}</span><span style="color: #8b2252;">"</span> <span style="color: #a0522d;">id</span>=<span style="color: #8b2252;">"</span><span style="color: #8b2252;">hadoop.core</span><span style="color: #8b2252;">"</span>/&gt;
   &lt;<span style="color: #7a378b;">artifact</span>:<span style="color: #0000ff;">pom</span> <span style="color: #a0522d;">file</span>=<span style="color: #8b2252;">"</span><span style="color: #8b2252;">${hadoop-test.pom}</span><span style="color: #8b2252;">"</span> <span style="color: #a0522d;">id</span>=<span style="color: #8b2252;">"</span><span style="color: #8b2252;">hadoop.test</span><span style="color: #8b2252;">"</span>/&gt;
   &lt;<span style="color: #7a378b;">artifact</span>:<span style="color: #0000ff;">pom</span> <span style="color: #a0522d;">file</span>=<span style="color: #8b2252;">"</span><span style="color: #8b2252;">${hadoop-examples.pom}</span><span style="color: #8b2252;">"</span> <span style="color: #a0522d;">id</span>=<span style="color: #8b2252;">"</span><span style="color: #8b2252;">hadoop.examples</span><span style="color: #8b2252;">"</span>/&gt;
   &lt;<span style="color: #7a378b;">artifact</span>:<span style="color: #0000ff;">pom</span> <span style="color: #a0522d;">file</span>=<span style="color: #8b2252;">"</span><span style="color: #8b2252;">${hadoop-tools.pom}</span><span style="color: #8b2252;">"</span> <span style="color: #a0522d;">id</span>=<span style="color: #8b2252;">"</span><span style="color: #8b2252;">hadoop.tools</span><span style="color: #8b2252;">"</span>/&gt;
   &lt;<span style="color: #7a378b;">artifact</span>:<span style="color: #0000ff;">pom</span> <span style="color: #a0522d;">file</span>=<span style="color: #8b2252;">"</span><span style="color: #8b2252;">${hadoop-streaming.pom}</span><span style="color: #8b2252;">"</span> <span style="color: #a0522d;">id</span>=<span style="color: #8b2252;">"</span><span style="color: #8b2252;">hadoop.streaming</span><span style="color: #8b2252;">"</span>/&gt;

   &lt;<span style="color: #7a378b;">artifact</span>:<span style="color: #0000ff;">install-provider</span> <span style="color: #a0522d;">artifactId</span>=<span style="color: #8b2252;">"</span><span style="color: #8b2252;">wagon-http</span><span style="color: #8b2252;">"</span> <span style="color: #a0522d;">version</span>=<span style="color: #8b2252;">"</span><span style="color: #8b2252;">${wagon-http.version}</span><span style="color: #8b2252;">"</span>/&gt;
   &lt;<span style="color: #7a378b;">artifact</span>:<span style="color: #0000ff;">deploy</span> <span style="color: #a0522d;">file</span>=<span style="color: #8b2252;">"</span><span style="color: #8b2252;">${hadoop-core.jar}</span><span style="color: #8b2252;">"</span>&gt;
       &lt;<span style="color: #0000ff;">remoteRepository</span> <span style="color: #a0522d;">id</span>=<span style="color: #8b2252;">"</span><span style="color: #8b2252;">yourrepo.internal</span><span style="color: #8b2252;">"</span> <span style="color: #a0522d;">url</span>=<span style="color: #8b2252;">"</span><span style="color: #8b2252;">http://yourreposerver.com:port/path</span><span style="color: #8b2252;">"</span>/&gt;
       &lt;<span style="color: #0000ff;">pom</span> <span style="color: #a0522d;">refid</span>=<span style="color: #8b2252;">"</span><span style="color: #8b2252;">hadoop.core</span><span style="color: #8b2252;">"</span>/&gt;
   &lt;/<span style="color: #7a378b;">artifact</span>:<span style="color: #0000ff;">deploy</span>&gt;
   &lt;<span style="color: #7a378b;">artifact</span>:<span style="color: #0000ff;">deploy</span> <span style="color: #a0522d;">file</span>=<span style="color: #8b2252;">"</span><span style="color: #8b2252;">${hadoop-test.jar}</span><span style="color: #8b2252;">"</span>&gt;
       &lt;<span style="color: #0000ff;">remoteRepository</span> <span style="color: #a0522d;">id</span>=<span style="color: #8b2252;">"</span><span style="color: #8b2252;">yourrepo.internal</span><span style="color: #8b2252;">"</span> <span style="color: #a0522d;">url</span>=<span style="color: #8b2252;">"</span><span style="color: #8b2252;">http://yourreposerver.com:port/path</span><span style="color: #8b2252;">"</span>/&gt;
       &lt;<span style="color: #0000ff;">pom</span> <span style="color: #a0522d;">refid</span>=<span style="color: #8b2252;">"</span><span style="color: #8b2252;">hadoop.test</span><span style="color: #8b2252;">"</span>/&gt;
   &lt;/<span style="color: #7a378b;">artifact</span>:<span style="color: #0000ff;">deploy</span>&gt; 
   &lt;<span style="color: #7a378b;">artifact</span>:<span style="color: #0000ff;">deploy</span> <span style="color: #a0522d;">file</span>=<span style="color: #8b2252;">"</span><span style="color: #8b2252;">${hadoop-examples.jar}</span><span style="color: #8b2252;">"</span>&gt;
       &lt;<span style="color: #0000ff;">remoteRepository</span> <span style="color: #a0522d;">id</span>=<span style="color: #8b2252;">"</span><span style="color: #8b2252;">yourrepo.internal</span><span style="color: #8b2252;">"</span> <span style="color: #a0522d;">url</span>=<span style="color: #8b2252;">"</span><span style="color: #8b2252;">http://yourreposerver.com:port/path</span><span style="color: #8b2252;">"</span>/&gt;
       &lt;<span style="color: #0000ff;">pom</span> <span style="color: #a0522d;">refid</span>=<span style="color: #8b2252;">"</span><span style="color: #8b2252;">hadoop.examples</span><span style="color: #8b2252;">"</span>/&gt;
   &lt;/<span style="color: #7a378b;">artifact</span>:<span style="color: #0000ff;">deploy</span>&gt;
   &lt;<span style="color: #7a378b;">artifact</span>:<span style="color: #0000ff;">deploy</span> <span style="color: #a0522d;">file</span>=<span style="color: #8b2252;">"</span><span style="color: #8b2252;">${hadoop-tools.jar}</span><span style="color: #8b2252;">"</span>&gt;
       &lt;<span style="color: #0000ff;">remoteRepository</span> <span style="color: #a0522d;">id</span>=<span style="color: #8b2252;">"</span><span style="color: #8b2252;">yourrepo.internal</span><span style="color: #8b2252;">"</span> <span style="color: #a0522d;">url</span>=<span style="color: #8b2252;">"</span><span style="color: #8b2252;">http://yourreposerver.com:port/path</span><span style="color: #8b2252;">"</span>/&gt;
       &lt;<span style="color: #0000ff;">pom</span> <span style="color: #a0522d;">refid</span>=<span style="color: #8b2252;">"</span><span style="color: #8b2252;">hadoop.tools</span><span style="color: #8b2252;">"</span>/&gt;
   &lt;/<span style="color: #7a378b;">artifact</span>:<span style="color: #0000ff;">deploy</span>&gt;
   &lt;<span style="color: #7a378b;">artifact</span>:<span style="color: #0000ff;">deploy</span> <span style="color: #a0522d;">file</span>=<span style="color: #8b2252;">"</span><span style="color: #8b2252;">${hadoop-streaming.jar}</span><span style="color: #8b2252;">"</span>&gt;
       &lt;<span style="color: #0000ff;">remoteRepository</span> <span style="color: #a0522d;">id</span>=<span style="color: #8b2252;">"</span><span style="color: #8b2252;">yourrepo.internal</span><span style="color: #8b2252;">"</span> <span style="color: #a0522d;">url</span>=<span style="color: #8b2252;">"</span><span style="color: #8b2252;">http://yourreposerver.com:port/path</span><span style="color: #8b2252;">"</span>/&gt;
       &lt;<span style="color: #0000ff;">pom</span> <span style="color: #a0522d;">refid</span>=<span style="color: #8b2252;">"</span><span style="color: #8b2252;">hadoop.streaming</span><span style="color: #8b2252;">"</span>/&gt;
   &lt;/<span style="color: #7a378b;">artifact</span>:<span style="color: #0000ff;">deploy</span>&gt;
&lt;/<span style="color: #0000ff;">target</span>&gt;
</pre>



<p>
Note that <code>yourrepo.internal</code> is the same ID that you have configured
authentication for in the <code>~m2/settings.xml</code> file earlier.
</p>
</div>

</div>

<div id="outline-container-4_4" class="outline-3">
<h3 id="sec-4_4"><span class="section-number-3">4.4</span> Build and install/deploy Hadoop common artifacts </h3>
<div class="outline-text-3" id="text-4_4">


<p>
Now, build and install/deploy Hadoop common artifacts using the Maven ant tasks.
</p>

</div>

<div id="outline-container-4_4_1" class="outline-4">
<h4 id="sec-4_4_1"><span class="section-number-4">4.4.1</span> Install artifacts </h4>
<div class="outline-text-4" id="text-4_4_1">


<p>
If you <b>do not</b> have a repository manager, and <b>skipped the previous step</b>, then use the <code>mvn-install</code> target and <b>skip</b> the "Deploy
artifacts" section. Otherwise, jump directly to "Deploy artifacts"
section.
</p>



<pre class="example">$ ant mvn-install
</pre>



<p>
This target will generate Hadoop common artifacts and Maven POM files,
and install them in your local Maven repository
(<code>~/.m2/repository</code>). 
</p>
</div>

</div>

<div id="outline-container-4_4_2" class="outline-4">
<h4 id="sec-4_4_2"><span class="section-number-4">4.4.2</span> Deploy artifacts </h4>
<div class="outline-text-4" id="text-4_4_2">


<p>
If you have an internal repository manager, you should deploy the
artifacts on it that you have specified in <code>build.xml</code> of the previous
step. To achieve this, run <code>mvn-deploy-internal</code> task.
</p>



<pre class="example">$ ant mvn-deploy-internal
</pre>



<p>
This target will generate the artifacts and Maven POM files, and
publish them to your repository manager that you have specified in
<code>build.xml</code>.
</p>
</div>
</div>

</div>

<div id="outline-container-4_5" class="outline-3">
<h3 id="sec-4_5"><span class="section-number-3">4.5</span> Generate the binary tarball to install on the cluster </h3>
<div class="outline-text-3" id="text-4_5">


<p>
You need to generate a binary tarball to install on the cluster. This
is achieved by running <code>tar</code> target.
</p>



<pre class="example">$ ant tar -Djava5.home=&lt;Java 5 SE Home&gt; -Dforrest.home=&lt;Forrest 0.8 Home&gt;
</pre>



<p>
Please note that you need Java SE/EE 5 and Apache Forrest 0.8 for this
step. Substituting Java SE/EE 5 or Apache Forrest 0.9 will result in a
build failure.
</p>
<p>
This will generate the
<code>hadoop-common-0.20-append/build/hadoop-common-0.20-append-r1057313-yourversion.tar.gz</code>
tarball.
</p>
</div>

</div>

<div id="outline-container-4_6" class="outline-3">
<h3 id="sec-4_6"><span class="section-number-3">4.6</span> Install Hadoop binaries on the cluster </h3>
<div class="outline-text-3" id="text-4_6">


<p>
Copy the tarball that was generated in the previous step to your
cluster, and unpack them in desired location.
</p>
<p>
This ensures that you have a consistent Hadoop installation because
you are not mixing and matching artifacts from a Hadoop common
official release and artifacts that you built.
</p>
</div>
</div>

</div>

<div id="outline-container-5" class="outline-2">
<h2 id="sec-5"><span class="section-number-2">5</span> Building HBase </h2>
<div class="outline-text-2" id="text-5">



</div>

<div id="outline-container-5_1" class="outline-3">
<h3 id="sec-5_1"><span class="section-number-3">5.1</span> Checkout HBase </h3>
<div class="outline-text-3" id="text-5_1">


<p>
Checkout HBase from 0.90.3 tag.
</p>



<pre class="example">$ svn co http://svn.apache.org/repos/asf/hbase/tags/0.90.3 hbase-0.90.3
</pre>



</div>

</div>

<div id="outline-container-5_2" class="outline-3">
<h3 id="sec-5_2"><span class="section-number-3">5.2</span> Modify HBase and Hadoop versions </h3>
<div class="outline-text-3" id="text-5_2">


<p>
Now, edit <code>hbase-0.90.3/pom.xml</code> and modify HBase and Hadoop versions.
</p>



<pre class="src src-xml">...
&lt;<span style="color: #0000ff;">groupId</span>&gt;org.apache.hbase&lt;/<span style="color: #0000ff;">groupId</span>&gt;
&lt;<span style="color: #0000ff;">artifactId</span>&gt;hbase&lt;/<span style="color: #0000ff;">artifactId</span>&gt;
&lt;<span style="color: #0000ff;">packaging</span>&gt;jar&lt;/<span style="color: #0000ff;">packaging</span>&gt;
&lt;<span style="color: #0000ff;">version</span>&gt;0.90.3-yourversion&lt;/<span style="color: #0000ff;">version</span>&gt;
...
 &lt;<span style="color: #0000ff;">hadoop.version</span>&gt;0.20-append-r1057313-yourversion&lt;/<span style="color: #0000ff;">hadoop.version</span>&gt;
...
</pre>



<p>
Note that you should be using the same revision number for Hadoop that
you have assigned while building Hadoop.
</p>
<p>
Also, try to assign a meaningful suffix in place of <code>yourversion</code> so
that you can distinguish between the official artifacts and the
artifacts that are deployed by you.
</p>
</div>

</div>

<div id="outline-container-5_3" class="outline-3">
<h3 id="sec-5_3"><span class="section-number-3">5.3</span> OPTIONAL: Specify the URL of your repository manager </h3>
<div class="outline-text-3" id="text-5_3">


<p>
If you are running an internal repository manager for team
collaboration, it is the time to specify in the
<code>hbase-0.90.3/pom.xml</code>. Add the following section to it.
</p>



<pre class="src src-xml">&lt;<span style="color: #0000ff;">project</span>&gt;
  ...
  &lt;<span style="color: #0000ff;">distributionManagement</span>&gt;
    &lt;<span style="color: #0000ff;">repository</span>&gt;
      &lt;<span style="color: #0000ff;">id</span>&gt;yourrepo.internal&lt;/<span style="color: #0000ff;">id</span>&gt;
      &lt;<span style="color: #0000ff;">name</span>&gt;Your internal repository&lt;/<span style="color: #0000ff;">name</span>&gt;
      &lt;<span style="color: #0000ff;">url</span>&gt;http://yourreposerver.com:port/path&lt;/<span style="color: #0000ff;">url</span>&gt;
    &lt;/<span style="color: #0000ff;">repository</span>&gt;
  &lt;/<span style="color: #0000ff;">distributionManagement</span>&gt;
  ...
&lt;/<span style="color: #0000ff;">project</span>&gt;
</pre>



<p>
Note that <code>yourrepo.internal</code> is the same ID that you have configured
authentication for in the <code>~m2/settings.xml</code> file earlier.
</p>
</div>

</div>

<div id="outline-container-5_4" class="outline-3">
<h3 id="sec-5_4"><span class="section-number-3">5.4</span> Build and install/deploy HBase artifacts </h3>
<div class="outline-text-3" id="text-5_4">


<p>
Now, build and install/deploy HBase artifacts using the Maven goals.
</p>

</div>

<div id="outline-container-5_4_1" class="outline-4">
<h4 id="sec-5_4_1"><span class="section-number-4">5.4.1</span> Install artifacts </h4>
<div class="outline-text-4" id="text-5_4_1">


<p>
If you <b>do not</b> have a repository manager, and <b>skipped the previous step</b>, then use the <code>install</code> goal and <b>skip</b> the "Deploy artifacts"
section. Otherwise, jump directly to "Deploy artifacts" section.
</p>



<pre class="example">$ mvn install
</pre>



<p>
This goal will generate HBase artifacts and Maven POM files, and
install them in your local Maven repository
(<code>~/.m2/repository</code>). <b>Ignore the rest of this section.</b>
</p>
</div>

</div>

<div id="outline-container-5_4_2" class="outline-4">
<h4 id="sec-5_4_2"><span class="section-number-4">5.4.2</span> Deploy artifacts </h4>
<div class="outline-text-4" id="text-5_4_2">


<p>
If you have a repository manager, you should deploy the artifacts on
your internal server that you have specified in <code>pom.xml</code> of the
previous step. To achieve this, invoke <code>deploy</code> goal.
</p>



<pre class="example">$ mvn deploy
</pre>



<p>
This goal will generate the artifacts and Maven POM files, and publish
them to your internal repository manager that you have specified in <code>pom.xml</code>.
</p>
</div>
</div>

</div>

<div id="outline-container-5_5" class="outline-3">
<h3 id="sec-5_5"><span class="section-number-3">5.5</span> Generate the binary tarball to install on the cluster </h3>
<div class="outline-text-3" id="text-5_5">


<p>
You need to generate a binary tarball to install on the cluster. This
is achieved by invoking <code>assembly:single</code> goal.
</p>



<pre class="example">$ mvn assembly:single
</pre>



<p>
This will generate the
<code>hbase-0.90.3/target/hbase-0.90.3-yourversion.tar.gz</code> tarball.
</p>
</div>

</div>

<div id="outline-container-5_6" class="outline-3">
<h3 id="sec-5_6"><span class="section-number-3">5.6</span> Install HBase binaries on the cluster </h3>
<div class="outline-text-3" id="text-5_6">


<p>
Copy the tarball that was generated in the last step to your cluster
and unpack them in the desired location.
</p>
<p>
This ensures that you have a consistent HBase installation with the
right version of Hadoop artifacts that you have built. There is no
need of replacing any artifact by hand because, Maven automatically
pulled the right version of the artifact that you have built.
</p>
</div>
</div>

</div>

<div id="outline-container-6" class="outline-2">
<h2 id="sec-6"><span class="section-number-2">6</span> OPTIONAL: Using the HBase artifact in your HBase application </h2>
<div class="outline-text-2" id="text-6">


<p>
Now you can edit the <code>pom.xml</code> of your HBase application to use the
version of HBase that you have built (0.90.3-yourversion)
</p>
</div>

</div>

<div id="outline-container-7" class="outline-2">
<h2 id="sec-7"><span class="section-number-2">7</span> Feedback </h2>
<div class="outline-text-2" id="text-7">


<p>
I tried to provide only as much information in the article as possible
without overloading the scope of it. I have also taken basic care to
ensure that the above mentioned commands are accurate. However, there
might be some typos or copy paste errors. If you find something that
doesn't work for you please let me know and I'll fix them.
</p>
</div>

</div>

<div id="outline-container-8" class="outline-2">
<h2 id="sec-8"><span class="section-number-2">8</span> Credits </h2>
<div class="outline-text-2" id="text-8">


<ul>
<li>Thanks to <a href="http://www.michael-noll.com/">Michael G. Noll</a> for his <a href="http://www.michael-noll.com/blog/2011/04/14/building-an-hadoop-0-20-x-version-for-hbase-0-90-2/">blog post</a> on building Hadoop.
</li>
<li>Thanks to <a href="https://twitter.com/#!/jpallas">Joe Pallas</a> for his suggestions on this process and review
  of this article.
</li>
</ul>

</div>

</div>

<div id="outline-container-9" class="outline-2">
<h2 id="sec-9"><span class="section-number-2">9</span> Disclaimer </h2>
<div class="outline-text-2" id="text-9">

<p>This article is provided for informational purpose only and I will not
be liable for any errors, omissions, or delays in this information or
any losses, injuries, or damages arising from its use.
</p>

</div>
</div>
</p>
]]></content:encoded>
			<wfw:commentRss>http://praveen.kumar.in/2011/06/20/building-hadoop-and-hbase-for-hbase-maven-application-development/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Making Mac applications to make use of memories larger than 4 GB</title>
		<link>http://praveen.kumar.in/2011/06/19/making-mac-applications-to-make-use-of-memories-larger-than-4-gb/</link>
		<comments>http://praveen.kumar.in/2011/06/19/making-mac-applications-to-make-use-of-memories-larger-than-4-gb/#comments</comments>
		<pubDate>Mon, 20 Jun 2011 02:10:42 +0000</pubDate>
		<dc:creator>Praveen Kumar</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[virtualization]]></category>

		<guid isPermaLink="false">http://praveen.kumar.in/?p=729</guid>
		<description><![CDATA[<a href="http://praveen.kumar.in/2011/06/19/making-mac-applications-to-make-use-of-memories-larger-than-4-gb/" title="Making Mac applications to make use of memories larger than 4 GB"></a>Today, I upgraded the memory on my Macbook Pro (2010) from 4 GB to 8 GB. One of the main reasons for the memory upgrade was to be able to run Mircosoft Windows 7 virtual machine using Oracle VirtualBox. However, &#8230;<p class="read-more"><a href="http://praveen.kumar.in/2011/06/19/making-mac-applications-to-make-use-of-memories-larger-than-4-gb/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://praveen.kumar.in/2011/06/19/making-mac-applications-to-make-use-of-memories-larger-than-4-gb/" title="Making Mac applications to make use of memories larger than 4 GB"></a><p>Today, I upgraded the memory on my Macbook Pro (2010) from 4 GB to 8 GB. One of the main reasons for the memory upgrade was to be able to run <a href="http://windows.microsoft.com/en-US/windows7/products/home">Mircosoft Windows 7</a> virtual machine using <a href="http://www.virtualbox.org/">Oracle VirtualBox</a>. However, I noticed that VirtualBox was not able to see more than 4 GB of memory even after the upgrade while the system reported that there was 8 GB of installed memory. </p>
<p> A quick research showed that Mac OS X 10.6 (Snow Leopard) uses 32-bit kernel by default. This limits the applications to use only 4 GB of memory. In order for the applications to use larger memories, one need to use the 64-bit kernel (provided that you are on a 64-bit platform). There is an <a href="http://support.apple.com/kb/HT3773">Apple support page</a> that describes how to select the desired kernel. </p>
<p> I changed the defaults to use 64-bit kernel. </p>
<pre class="example">$ sudo systemsetup -setkernelbootarchitecture x86_64
</pre>
<p> This configuration is stored in the file <code>/Library/Preferences/SystemConfiguration/com.apple.Boot.plist</code> </p>
<pre class="src src-xml">&lt;?<span style="color: #7f007f;">xml</span> <span style="color: #a0522d;">version</span>=<span style="color: #8b2252;">"</span><span style="color: #8b2252;">1.0</span><span style="color: #8b2252;">"</span> <span style="color: #a0522d;">encoding</span>=<span style="color: #8b2252;">"</span><span style="color: #8b2252;">UTF-8</span><span style="color: #8b2252;">"</span>?&gt;
&lt;!<span style="color: #7f007f;">DOCTYPE</span> plist <span style="color: #7f007f;">PUBLIC</span> <span style="color: #8b2252;">"</span><span style="color: #8b2252;">-//Apple//DTD PLIST 1.0//EN</span><span style="color: #8b2252;">"</span> <span style="color: #8b2252;">"</span><span style="color: #8b2252;">http://www.apple.com/DTDs/PropertyList-1.0.dtd</span><span style="color: #8b2252;">"</span>&gt;
&lt;<span style="color: #0000ff;">plist</span> <span style="color: #a0522d;">version</span>=<span style="color: #8b2252;">"</span><span style="color: #8b2252;">1.0</span><span style="color: #8b2252;">"</span>&gt;
&lt;<span style="color: #0000ff;">dict</span>&gt;
        &lt;<span style="color: #0000ff;">key</span>&gt;Kernel Architecture&lt;/<span style="color: #0000ff;">key</span>&gt;
        &lt;<span style="color: #0000ff;">string</span>&gt;x86_64&lt;/<span style="color: #0000ff;">string</span>&gt;
        &lt;<span style="color: #0000ff;">key</span>&gt;Kernel Flags&lt;/<span style="color: #0000ff;">key</span>&gt;
        &lt;<span style="color: #0000ff;">string</span>&gt;&lt;/<span style="color: #0000ff;">string</span>&gt;
&lt;/<span style="color: #0000ff;">dict</span>&gt;
&lt;/<span style="color: #0000ff;">plist</span>&gt;
</pre>
<p> After making this change and rebooting, VirtualBox was able to see the whole memory. </p>
]]></content:encoded>
			<wfw:commentRss>http://praveen.kumar.in/2011/06/19/making-mac-applications-to-make-use-of-memories-larger-than-4-gb/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Plotting a weight chart using Emacs Org-Mode and Gnuplot</title>
		<link>http://praveen.kumar.in/2011/06/19/plotting-a-weight-chart-using-emacs-org-mode-and-gnuplot-2/</link>
		<comments>http://praveen.kumar.in/2011/06/19/plotting-a-weight-chart-using-emacs-org-mode-and-gnuplot-2/#comments</comments>
		<pubDate>Sun, 19 Jun 2011 15:07:54 +0000</pubDate>
		<dc:creator>Praveen Kumar</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[Health & Fitness]]></category>
		<category><![CDATA[emacs]]></category>
		<category><![CDATA[org-mode]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://praveen.kumar.in/?p=697</guid>
		<description><![CDATA[<a href="http://praveen.kumar.in/2011/06/19/plotting-a-weight-chart-using-emacs-org-mode-and-gnuplot-2/" title="Plotting a weight chart using Emacs Org-Mode and Gnuplot"></a>I discovered about Org-Mode a couple of years ago. Since then, I have started using it for various tasks. One of the recent usage is to track my daily weight. This article describes how to use Org-Mode and Gnuplot to &#8230;<p class="read-more"><a href="http://praveen.kumar.in/2011/06/19/plotting-a-weight-chart-using-emacs-org-mode-and-gnuplot-2/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://praveen.kumar.in/2011/06/19/plotting-a-weight-chart-using-emacs-org-mode-and-gnuplot-2/" title="Plotting a weight chart using Emacs Org-Mode and Gnuplot"></a><div>
<p>I discovered about <a href="http://orgmode.org">Org-Mode</a> a couple of years ago. Since then, I have started using it for various tasks. One of the recent usage is to track my daily weight. This article describes how to use Org-Mode and Gnuplot to plot your weight measurements. </p>
<p> Here is the list of software that I use in my setup. </p>
<ul>
<li><a href="http://www.apple.com/macosx/">Mac OS X 10.6</a> </li>
<li><a href="http://www.gnu.org/software/emacs">GNU Emacs 23.3.1</a> </li>
<li><a href="http://orgmode.org">Org-Mode 7.5</a> </li>
<li><a href="http://gnuplot.info">Gnuplot 4.4</a> </li>
<li><a href="http://xafs.org/BruceRavel/GnuplotMode">Gnuplot mode 0.6.0</a> </li>
</ul>
<p> For the purpose of this article, it is assumed that you have a similar setup that works for you. </p>
<p> As part of my daily measurement, I track three measurements namely, weight, body fat percentage and body water percentage. This data can be represented in an Org table that has four columns as follows. Please note that the data provided below is hypothetical. </p>
<pre class="example">#+PLOT: script:"Weight.plt"
| Date       | Weight |  BF% |  BW% |
|------------+--------+------+------|
| 05/01/2011 |  145.2 | 30.3 | 50.3 |
| 05/02/2011 |  145.1 | 29.4 | 50.7 |
| 05/03/2011 |  144.2 | 30.1 | 50.4 |
| 05/04/2011 |  144.0 | 29.0 | 50.8 |
| 05/05/2011 |  144.1 | 28.7 | 51.0 |
| 05/06/2011 |  144.2 | 29.2 | 50.7 |
| 05/07/2011 |  144.4 | 27.8 | 51.4 |
| 05/08/2011 |  143.7 | 27.6 | 51.5 |
| 05/09/2011 |  143.2 | 28.5 | 51.0 |
| 05/10/2011 |  142.8 | 30.1 | 50.4 |
| 05/11/2011 |  142.2 | 30.1 | 50.4 |
| 05/12/2011 |  142.4 | 29.8 | 50.5 |
| 05/13/2011 |  142.2 | 29.9 | 50.5 |
| 05/14/2011 |  141.2 | 27.4 | 51.6 |
| 05/15/2011 |  141.5 | 27.2 | 51.7 |
|------------+--------+------+------|
| 05/16/2011 |  141.2 | 28.8 | 51.0 |
| 05/17/2011 |  140.8 | 28.9 | 50.9 |
| 05/18/2011 |  140.2 | 29.5 | 50.7 |
| 05/19/2011 |  140.5 | 26.8 | 51.9 |
| 05/20/2011 |  140.4 | 28.1 | 51.3 |
| 05/21/2011 |  139.2 | 26.7 | 51.9 |
| 05/22/2011 |  137.1 | 27.0 | 51.7 |
| 05/23/2011 |  137.5 | 27.0 | 51.7 |
| 05/24/2011 |  137.4 | 28.5 | 51.1 |
| 05/25/2011 |  136.8 | 29.6 | 50.6 |
| 05/26/2011 |  136.3 | 28.8 | 51.0 |
| 05/27/2011 |  136.3 | 28.2 | 51.2 |
| 05/28/2011 |  136.3 | 28.9 | 50.9 |
| 05/29/2011 |  136.2 | 28.0 | 51.3 |
| 05/30/2011 |  135.9 | 28.8 | 50.9 |
| 05/31/2011 |  135.5 | 28.2 | 51.2 |
|------------+--------+------+------|
| 06/01/2011 |  135.1 | 28.2 | 51.2 |
| 06/02/2011 |  135.5 | 28.2 | 51.2 |
| 06/03/2011 |  134.8 | 28.9 | 50.9 |
| 06/04/2011 |  134.4 | 29.6 | 50.6 |
| 06/05/2011 |  134.2 | 27.9 | 51.3 |
| 06/06/2011 |  134.4 | 28.1 | 51.3 |
| 06/07/2011 |  133.2 | 29.2 | 50.8 |
| 06/08/2011 |  133.1 | 28.8 | 51.0 |
| 06/09/2011 |  133.0 | 28.6 | 51.0 |
| 06/10/2011 |  133.2 | 27.8 | 51.4 |
| 06/11/2011 |  132.2 | 27.9 | 51.4 |
| 06/12/2011 |  132.0 | 27.9 | 51.4 |
| 06/13/2011 |  132.1 | 28.9 | 51.0 |
| 06/14/2011 |  131.0 | 29.0 | 50.9 |
| 06/15/2011 |  130.2 | 27.6 | 51.5 |
|------------+--------+------+------|
</pre>
<p> I use the following Gnuplot script, <code>Weight.plt</code> that plots the weight, body fat percentage, absolute body fat, body water percentage and absolute body water. </p>
<pre class="src src-gnuplot"><span style="color: #b22222;"># Weight plotter.</span>

<span style="color: #008b8b;">set</span> terminal aqua <span style="color: #228b22;">title</span> "Weight <span style="color: #7f007f;">plot</span>"
<span style="color: #008b8b;">set</span> xdata time
<span style="color: #008b8b;">set</span> timefmt <span style="color: #8b2252;">'"%m/%d/%Y"'</span>
<span style="color: #008b8b;">set</span> xlabel <span style="color: #8b2252;">'Date'</span>

<span style="color: #008b8b;">set</span> multiplot

<span style="color: #008b8b;">set</span> size 1, 0.33

<span style="color: #b22222;"># Weight.</span>
<span style="color: #008b8b;">set</span> origin 0, 0.66
<span style="color: #008b8b;">set</span> ylabel <span style="color: #8b2252;">'Weight in lb'</span>
<span style="color: #7f007f;">plot</span> <span style="color: #8b2252;">'$datafile'</span> <span style="color: #228b22;">using</span> 1:2 <span style="color: #228b22;">title</span> <span style="color: #8b2252;">'Weight'</span> <span style="color: #228b22;">with</span> <span style="color: #0000ff;">lines</span> linecolor 2

<span style="color: #008b8b;">set</span> size 0.5, 0.33

<span style="color: #b22222;"># Body fat.</span>
<span style="color: #b22222;"># Percentage.</span>
<span style="color: #008b8b;">set</span> origin 0, 0.33
<span style="color: #008b8b;">set</span> ylabel <span style="color: #8b2252;">'Body fat %'</span>
<span style="color: #7f007f;">plot</span> <span style="color: #8b2252;">'$datafile'</span> <span style="color: #228b22;">using</span> 1:3 <span style="color: #228b22;">title</span> <span style="color: #8b2252;">'Body fat %'</span> <span style="color: #228b22;">with</span> <span style="color: #0000ff;">lines</span> linecolor 1
<span style="color: #b22222;"># Absolute.</span>
<span style="color: #008b8b;">set</span> origin 0.5, 0.33
<span style="color: #008b8b;">set</span> ylabel <span style="color: #8b2252;">'Body fat in lb'</span>
<span style="color: #7f007f;">plot</span> <span style="color: #8b2252;">'$datafile'</span> <span style="color: #228b22;">using</span> 1:($3 * $2 / 100) <span style="color: #228b22;">title</span> <span style="color: #8b2252;">'Body fat'</span> <span style="color: #228b22;">with</span> <span style="color: #0000ff;">lines</span> linecolor 1

<span style="color: #b22222;"># Body water.</span>
<span style="color: #b22222;"># Percentage.</span>
<span style="color: #008b8b;">set</span> origin 0, 0
<span style="color: #008b8b;">set</span> ylabel <span style="color: #8b2252;">'Body water %'</span>
<span style="color: #7f007f;">plot</span> <span style="color: #8b2252;">'$datafile'</span> <span style="color: #228b22;">using</span> 1:4 <span style="color: #228b22;">title</span> <span style="color: #8b2252;">'Body water %'</span> <span style="color: #228b22;">with</span> <span style="color: #0000ff;">lines</span> linecolor 3
<span style="color: #b22222;"># Absolute.</span>
<span style="color: #008b8b;">set</span> origin 0.5, 0
<span style="color: #008b8b;">set</span> ylabel <span style="color: #8b2252;">'Body water in lb'</span>
<span style="color: #7f007f;">plot</span> <span style="color: #8b2252;">'$datafile'</span> <span style="color: #228b22;">using</span> 1:($4 * $2 / 100) <span style="color: #228b22;">title</span> <span style="color: #8b2252;">'Body water'</span> <span style="color: #228b22;">with</span> <span style="color: #0000ff;">lines</span> linecolor 3

<span style="color: #008b8b;">unset</span> multiplot
</pre>
<p> Here is the screenshot of the generated plot. Click the thumbnail to get the actual size. </p>
<div align="center">
<p> <a href="http://praveen.kumar.in/wp-content/uploads/2011/06/wpid-OrgModeWeightChart.png" alt="Weight chart" align="center"><img src="http://praveen.kumar.in/wp-content/uploads/2011/06/wpid-OrgModeWeightChartThumb1.png"/></a> </div>
</p></div>
]]></content:encoded>
			<wfw:commentRss>http://praveen.kumar.in/2011/06/19/plotting-a-weight-chart-using-emacs-org-mode-and-gnuplot-2/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Making GNU Emacs detect custom error messages &#8211; A Maven Example</title>
		<link>http://praveen.kumar.in/2011/03/09/making-gnu-emacs-detect-custom-error-messages-a-maven-example/</link>
		<comments>http://praveen.kumar.in/2011/03/09/making-gnu-emacs-detect-custom-error-messages-a-maven-example/#comments</comments>
		<pubDate>Wed, 09 Mar 2011 08:04:07 +0000</pubDate>
		<dc:creator>Praveen Kumar</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[emacs]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://praveen.kumar.in/?p=648</guid>
		<description><![CDATA[<a href="http://praveen.kumar.in/2011/03/09/making-gnu-emacs-detect-custom-error-messages-a-maven-example/" title="Making GNU Emacs detect custom error messages - A Maven Example"></a>GNU Emacs&#8216;s compilation mode is capable of detecting error messages from various standard compilers and build tools. However, it is fairy common for one to run into a format of error message that Emacs can&#8217;t handle by default. As you &#8230;<p class="read-more"><a href="http://praveen.kumar.in/2011/03/09/making-gnu-emacs-detect-custom-error-messages-a-maven-example/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://praveen.kumar.in/2011/03/09/making-gnu-emacs-detect-custom-error-messages-a-maven-example/" title="Making GNU Emacs detect custom error messages - A Maven Example"></a><p>GNU <a href="http://www.gnu.org/software/emacs">Emacs</a>&#8216;s compilation mode is capable of detecting error messages from various standard compilers and build tools. However, it is fairy common for one to run into a format of error message that Emacs can&#8217;t handle by default.</p>
<p>As you know, Emacs is highly extensible and it provides <a href="http://www.gnu.org/software/emacs/manual/html_node/emacs/Compilation-Mode.html">compilation-error-regexp-alist</a> for accomplishing this. I have done this a couple of times earlier and I had to do it one more time lately for adding regular expression for <a href="http://maven.apache.org/">Maven</a> error messages. Construction of these regular expressions is not fun for everyone. However, regexp-builder makes it easier to construct the regular expression interactively. </p>
<p>Because the <a href="http://www.gnu.org/software/emacs/manual/html_node/emacs/Compilation-Mode.html">documentation</a> around <code>compilation-error-regexp-alist</code> isn&#8217;t very intuitive for most, I have decided to make this screencast that describes how to approach this from scratch. Sorry about the typos! For best quality, watch it in HD.</p>
<div align="center">
<iframe title="YouTube video player" width="480" height="293" src="http://www.youtube.com/embed/U_t5vLr_jVc?hd=1" frameborder="0" allowfullscreen></iframe>
</div>
<p><span id="more-648"></span><br />
In summary, here is the customization that has to be added to <code>.emacs</code>.</p>

<div class="wp_syntax"><div class="code"><pre class="lisp"><span style="color: #66cc66;">&#40;</span>add-to-<span style="color: #b1b100;">list</span> 'compilation-error-regexp-alist 'maven<span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#40;</span>add-to-<span style="color: #b1b100;">list</span> 'compilation-error-regexp-alist-alist
	     '<span style="color: #66cc66;">&#40;</span>maven <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\\</span>[ERROR<span style="color: #000099; font-weight: bold;">\\</span>] <span style="color: #000099; font-weight: bold;">\\</span>(.+?<span style="color: #000099; font-weight: bold;">\\</span>):<span style="color: #000099; font-weight: bold;">\\</span>[<span style="color: #000099; font-weight: bold;">\\</span>([0-9]+<span style="color: #000099; font-weight: bold;">\\</span>),<span style="color: #000099; font-weight: bold;">\\</span>([0-9]+<span style="color: #000099; font-weight: bold;">\\</span>)<span style="color: #000099; font-weight: bold;">\\</span>].*&quot;</span>
		     <span style="color: #cc66cc;">1</span> <span style="color: #cc66cc;">2</span> <span style="color: #cc66cc;">3</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>Here is what Emacs&#8217;s inbuilt documentation says about <code>compilation-error-regular-expression-alist</code>:</p>

<div class="wp_syntax"><div class="code"><pre class="txt">compilation-error-regexp-alist is a variable defined in `compile.el'.
Its value is 
(maven absoft ada aix ant bash borland caml comma edg-1 edg-2 epc ftnchek iar ibm irix java jikes-file jikes-line gnu gcc-include lcc makepp mips-1 mips-2 msft omake oracle perl php rxp sparc-pascal-file sparc-pascal-line sparc-pascal-example sun sun-ada watcom 4bsd gcov-file gcov-header gcov-nomark gcov-called-line gcov-never-called perl--Pod::Checker perl--Test perl--Test2 perl--Test::Harness weblint)
&nbsp;
&nbsp;
Documentation:
Alist that specifies how to match errors in compiler output.
On GNU and Unix, any string is a valid filename, so these
matchers must make some common sense assumptions, which catch
normal cases.  A shorter list will be lighter on resource usage.
&nbsp;
Instead of an alist element, you can use a symbol, which is
looked up in `compilation-error-regexp-alist-alist'.  You can see
the predefined symbols and their effects in the file
`etc/compilation.txt' (linked below if you are customizing this).
&nbsp;
Each elt has the form (REGEXP FILE [LINE COLUMN TYPE HYPERLINK
HIGHLIGHT...]).  If REGEXP matches, the FILE'th subexpression
gives the file name, and the LINE'th subexpression gives the line
number.  The COLUMN'th subexpression gives the column number on
that line.
&nbsp;
If FILE, LINE or COLUMN are nil or that index didn't match, that
information is not present on the matched line.  In that case the
file name is assumed to be the same as the previous one in the
buffer, line number defaults to 1 and column defaults to
beginning of line's indentation.
&nbsp;
FILE can also have the form (FILE FORMAT...), where the FORMATs
(e.g. &quot;%s.c&quot;) will be applied in turn to the recognized file
name, until a file of that name is found.  Or FILE can also be a
function that returns (FILENAME) or (RELATIVE-FILENAME . DIRNAME).
In the former case, FILENAME may be relative or absolute.
&nbsp;
LINE can also be of the form (LINE . END-LINE) meaning a range
of lines.  COLUMN can also be of the form (COLUMN . END-COLUMN)
meaning a range of columns starting on LINE and ending on
END-LINE, if that matched.
&nbsp;
TYPE is 2 or nil for a real error or 1 for warning or 0 for info.
TYPE can also be of the form (WARNING . INFO).  In that case this
will be equivalent to 1 if the WARNING'th subexpression matched
or else equivalent to 0 if the INFO'th subexpression matched.
See `compilation-error-face', `compilation-warning-face',
`compilation-info-face' and `compilation-skip-threshold'.
&nbsp;
What matched the HYPERLINK'th subexpression has `mouse-face' and
`compilation-message-face' applied.  If this is nil, the text
matched by the whole REGEXP becomes the hyperlink.
&nbsp;
Additional HIGHLIGHTs as described under `font-lock-keywords' can
be added.
&nbsp;
You can customize this variable.</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://praveen.kumar.in/2011/03/09/making-gnu-emacs-detect-custom-error-messages-a-maven-example/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>GNU Emacs and MIT Scheme on Mac OS X</title>
		<link>http://praveen.kumar.in/2011/03/06/gnu-emacs-and-mit-scheme-on-mac-os-x/</link>
		<comments>http://praveen.kumar.in/2011/03/06/gnu-emacs-and-mit-scheme-on-mac-os-x/#comments</comments>
		<pubDate>Mon, 07 Mar 2011 04:16:13 +0000</pubDate>
		<dc:creator>Praveen Kumar</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[emacs]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://praveen.kumar.in/?p=639</guid>
		<description><![CDATA[<a href="http://praveen.kumar.in/2011/03/06/gnu-emacs-and-mit-scheme-on-mac-os-x/" title="GNU Emacs and MIT Scheme on Mac OS X"></a>Today, I planned to go back to the basics by taking 6.001 Structure and Interpretation of Computer Programs offered by MIT OpenCourseWare. I&#8217;ll save the reason behind it for another post. For running the programs that are used in the &#8230;<p class="read-more"><a href="http://praveen.kumar.in/2011/03/06/gnu-emacs-and-mit-scheme-on-mac-os-x/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://praveen.kumar.in/2011/03/06/gnu-emacs-and-mit-scheme-on-mac-os-x/" title="GNU Emacs and MIT Scheme on Mac OS X"></a><p>Today, I planned to go back to the basics by taking <a href="http://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-001-structure-and-interpretation-of-computer-programs-spring-2005/">6.001 Structure and Interpretation of Computer Programs</a> offered by MIT OpenCourseWare. I&#8217;ll save the reason behind it for another post.</p>
<p>For running the programs that are used in the class, I decided to use <a href="http://www.gnu.org/software/mit-scheme/">MIT/GNU Scheme</a>. I am running <a href="http://www.gnu.org/software/emacs/">GNU Emacs 23</a> on my Mac OS X. After some research, I figured out the best way of doing this is through <a href="http://www.gnu.org/software/mit-scheme/documentation/mit-scheme-user/GNU-Emacs-Interface.html#GNU-Emacs-Interface">xscheme</a>.</p>
<p>First, download the <a href="http://www.gnu.org/software/mit-scheme/">MIT/GNU Scheme binary</a> for Mac OS X and copy it to your Applications directory.  Then configure Emacs to use the downloaded binary by adding the following lines to your <code>.emacs</code>.</p>

<div class="wp_syntax"><div class="code"><pre class="lisp"><span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">setq</span> scheme-program-<span style="color: #b1b100;">name</span>
      <span style="color: #ff0000;">&quot;/Applications/mit-scheme.app/Contents/Resources/mit-scheme&quot;</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#40;</span>require 'xscheme<span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>Now write your Scheme program.</p>

<div class="wp_syntax"><div class="code"><pre class="scheme"><span style="color: #808080; font-style: italic;">; Compute the square root of a given number using successive</span>
<span style="color: #808080; font-style: italic;">; approximation.</span>
&nbsp;
<span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">define</span> <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">sqrt</span> value<span style="color: #66cc66;">&#41;</span>
  <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">define</span> <span style="color: #66cc66;">&#40;</span>is<span style="color: #66cc66;">-</span>good<span style="color: #66cc66;">-</span>enough? guess value<span style="color: #66cc66;">&#41;</span>
    <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&lt;</span> <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">abs</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">-</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">*</span> guess guess<span style="color: #66cc66;">&#41;</span> value<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #cc66cc;">0.0000001</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
  <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">define</span> <span style="color: #66cc66;">&#40;</span>try guess value<span style="color: #66cc66;">&#41;</span>
    <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>is<span style="color: #66cc66;">-</span>good<span style="color: #66cc66;">-</span>enough? guess value<span style="color: #66cc66;">&#41;</span>
	guess
	<span style="color: #66cc66;">&#40;</span>try <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">/</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">+</span> guess <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">/</span> value guess<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span> value<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
  <span style="color: #66cc66;">&#40;</span>try <span style="color: #cc66cc;">1</span> value<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
<span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">sqrt</span> <span style="color: #cc66cc;">4.0</span><span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>Invoke the Scheme process by  <code>'M-x run-scheme'</code>. Send the Scheme buffer to the Scheme process by <code>'M-o'</code> and now you are able to run Scheme programs from Emacs.</p>
<p>Below is the screenshot of Scheme running under my Emacs session.<br />
<div id="attachment_641" class="wp-caption alignleft" style="width: 647px"><a href="http://praveen.kumar.in/wp-content/uploads/2011/03/Screen-shot-2011-03-06-at-7.55.10-PM.png"><img src="http://praveen.kumar.in/wp-content/uploads/2011/03/Screen-shot-2011-03-06-at-7.55.10-PM.png" alt="Emacs and Scheme" title="EmacsAndScheme" width="637" height="736" class="size-full wp-image-641" /></a><p class="wp-caption-text">MIT Scheme running under GNU Emacs</p></div></p>
]]></content:encoded>
			<wfw:commentRss>http://praveen.kumar.in/2011/03/06/gnu-emacs-and-mit-scheme-on-mac-os-x/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Apache Software Foundation</title>
		<link>http://praveen.kumar.in/2011/03/05/apache-software-foundation/</link>
		<comments>http://praveen.kumar.in/2011/03/05/apache-software-foundation/#comments</comments>
		<pubDate>Sun, 06 Mar 2011 03:30:00 +0000</pubDate>
		<dc:creator>Praveen Kumar</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://praveen.kumar.in/?p=634</guid>
		<description><![CDATA[<a href="http://praveen.kumar.in/2011/03/05/apache-software-foundation/" title="Apache Software Foundation"></a>Recently, I started playing with a lot of Open Source products from Apache Software Foundation. It all started with Hadoop, HBase and Cassandra. Day after day, I am getting my hands dirty on more Apache Foundation&#8217;s products like Ant, Maven, &#8230;<p class="read-more"><a href="http://praveen.kumar.in/2011/03/05/apache-software-foundation/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://praveen.kumar.in/2011/03/05/apache-software-foundation/" title="Apache Software Foundation"></a><p>Recently, I started playing with a lot of Open Source products from <a href="http://www.apache.org/foundation/how-it-works.html">Apache Software Foundation</a>. It all started with <a href="http://hadoop.apache.org/">Hadoop</a>, <a href="http://hbase.apache.org/">HBase</a> and <a href="http://cassandra.apache.org/">Cassandra</a>. Day after day, I am getting my hands dirty on more Apache Foundation&#8217;s products like <a href="http://ant.apache.org/">Ant</a>, <a href="http://maven.apache.org/">Maven</a>, <a href="http://archiva.apache.org/">Archiva</a> and <a href="http://incubator.apache.org/thrift/">Thrift</a>.</p>
<p>When trying to build HBase from source, I noticed that the project was using <a href="http://subversion.apache.org/">Subversion</a> for version control. I found it quite odd to see a modern project like HBase not using a distributed version control tool like <a href="http://mercurial.selenic.com/">Mercurial</a> or <a href="http://git-scm.com/">Git</a>. Soon, I realized that all Apache projects&#8217; source code were maintained in Subversion. Then, I made a comment to my co-worker that, &#8220;Maybe Apache Foundation took over Subversion too!&#8221;, soon to realize that it was true. We learned that Subversion became an Apache <a href="http://incubator.apache.org/">Incubator</a> project in 2009 and became an Apache top-level project in 2010.</p>
<p>I am really amazed by the number of projects that are now part of the Apache Software Foundation. Go Apache!</p>
]]></content:encoded>
			<wfw:commentRss>http://praveen.kumar.in/2011/03/05/apache-software-foundation/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Introduction to Test-Driven Development in C++ using Boost Test Library</title>
		<link>http://praveen.kumar.in/2010/04/30/introduction-to-test-driven-development-in-c-using-boost-test-library/</link>
		<comments>http://praveen.kumar.in/2010/04/30/introduction-to-test-driven-development-in-c-using-boost-test-library/#comments</comments>
		<pubDate>Sat, 01 May 2010 04:12:40 +0000</pubDate>
		<dc:creator>Praveen Kumar</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[boost]]></category>
		<category><![CDATA[c++]]></category>
		<category><![CDATA[emacs]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[tdd]]></category>

		<guid isPermaLink="false">http://praveen.kumar.in/?p=609</guid>
		<description><![CDATA[<a href="http://praveen.kumar.in/2010/04/30/introduction-to-test-driven-development-in-c-using-boost-test-library/" title="Introduction to Test-Driven Development in C++ using Boost Test Library"></a>I have been following Test-Driven Development for a few years now. Even though TDD is widespread, often I come across a few friends who aren&#8217;t very familiar with TDD approach. It took a while for me to really appreciate TDD &#8230;<p class="read-more"><a href="http://praveen.kumar.in/2010/04/30/introduction-to-test-driven-development-in-c-using-boost-test-library/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://praveen.kumar.in/2010/04/30/introduction-to-test-driven-development-in-c-using-boost-test-library/" title="Introduction to Test-Driven Development in C++ using Boost Test Library"></a><p>I have been following <a href="http://en.wikipedia.org/wiki/Test-driven_development">Test-Driven Development</a> for a few years now. Even though TDD is widespread, often I come across a few friends who aren&#8217;t very familiar with TDD approach. It took a while for me to really appreciate TDD since I was introduced to it. When I demonstrated TDD in action, I got a few of my friends interested.</p>
<p>We have our <a href="http://unittest.red-bean.com/">own test framework</a> that we use in our project which was primarily developed by <a href="http://malvasiabianca.org/">David Carlton</a>. It works very well for our needs. However, for my personal projects, I wanted to try something that is more widely used in the industry. I started using <a href="http://sourceforge.net/apps/mediawiki/cppunit/index.php?title=Main_Page">CppUnit</a> for a while until I found <a href="http://www.boost.org/doc/libs/1_42_0/libs/test/doc/html/index.html">Boost Test Library</a> coming a long way. Now, I use Boost Test Library for all my personal projects. It is very easy to setup tests and I really like it.</p>
<p>I also wanted to write a quick introduction to Boost Test Library. So, I thought that I will put down a screencast that will solve two purposes of demonstrating Boost Test Library and serve as an introduction to TDD. This is not an extensive demo or an introduction. I have chosen a really simple problem that is often asked in preliminary rounds of technical interviews. But, it is a good place to start. I don&#8217;t guarantee that the solution is efficient. But, it is correct to my knowledge. Please feel free to suggest issues or improvements.</p>
<p>Please note that a HD version of this video is available when viewed on <a href="http://www.vimeo.com/">Vimeo&#8217;s site</a>.</p>
<div align="center">
<object width="400" height="300"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=11370903&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=11370903&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="600" height="450"></embed></object>
<p><a href="http://vimeo.com/11370903">Introduction to Test Driven Development in C++ using Boost Test Library</a> from <a href="http://vimeo.com/user3715271">Praveen Kumar</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
</div>
<p><span id="more-609"></span></p>
<p><strong>Problem:</strong><br />
Implement a function &#8216;<code>int atoi(const std::string &#038;val)</code>&#8216; that converts the given string in decimal notation to its integer value. Return 0 if the input is not a valid integer.</p>
<p><strong>Source code:</strong></p>

<div class="wp_syntax"><div class="code"><pre class="cpp"><span style="color: #339900;">#include &lt;string&gt;</span>
&nbsp;
<span style="color: #339900;">#define BOOST_TEST_MODULE atoi</span>
<span style="color: #339900;">#define BOOST_TEST_DYN_LINK</span>
&nbsp;
<span style="color: #339900;">#include &lt;boost/test/unit_test.hpp&gt;</span>
&nbsp;
<span style="color: #0000ff;">namespace</span> impl <span style="color: #008000;">&#123;</span>
&nbsp;
<span style="color: #0000ff;">int</span> <span style="color: #0000dd;">atoi</span><span style="color: #008000;">&#40;</span><span style="color: #0000ff;">const</span> std<span style="color: #008080;">::</span><span style="color: #007788;">string</span> <span style="color: #000040;">&amp;</span>val<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
    <span style="color: #0000ff;">int</span> result <span style="color: #000080;">=</span> <span style="color: #0000dd;">0</span><span style="color: #008080;">;</span>
    <span style="color: #0000ff;">int</span> multiplier <span style="color: #000080;">=</span> <span style="color: #0000dd;">1</span><span style="color: #008080;">;</span>
    <span style="color: #0000ff;">bool</span> negative <span style="color: #000080;">=</span> <span style="color: #0000ff;">false</span><span style="color: #008080;">;</span>
&nbsp;
    <span style="color: #0000ff;">for</span> <span style="color: #008000;">&#40;</span>std<span style="color: #008080;">::</span><span style="color: #007788;">string</span><span style="color: #008080;">::</span><span style="color: #007788;">const_reverse_iterator</span> i <span style="color: #000080;">=</span> val.<span style="color: #007788;">rbegin</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
         i <span style="color: #000080;">&lt;</span> val.<span style="color: #007788;">rend</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>  <span style="color: #000040;">++</span>i<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
        <span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span><span style="color: #000040;">*</span>i <span style="color: #000080;">&lt;=</span> <span style="color: #FF0000;">'9'</span> <span style="color: #000040;">&amp;&amp;</span> <span style="color: #000040;">*</span>i<span style="color: #000080;">&gt;=</span> <span style="color: #FF0000;">'0'</span> <span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
            result <span style="color: #000040;">+</span><span style="color: #000080;">=</span> <span style="color: #008000;">&#40;</span><span style="color: #000040;">*</span>i <span style="color: #000040;">-</span> <span style="color: #FF0000;">'0'</span><span style="color: #008000;">&#41;</span> <span style="color: #000040;">*</span> multiplier<span style="color: #008080;">;</span>
            multiplier <span style="color: #000040;">*</span><span style="color: #000080;">=</span> <span style="color: #0000dd;">10</span><span style="color: #008080;">;</span>
        <span style="color: #008000;">&#125;</span> <span style="color: #0000ff;">else</span> <span style="color: #008000;">&#123;</span>
            <span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span><span style="color: #000040;">*</span>i <span style="color: #000080;">==</span> <span style="color: #FF0000;">'-'</span> <span style="color: #000040;">&amp;&amp;</span> i <span style="color: #000080;">==</span> val.<span style="color: #007788;">rend</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #000040;">-</span> <span style="color: #0000dd;">1</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
                negative <span style="color: #000080;">=</span> <span style="color: #0000ff;">true</span><span style="color: #008080;">;</span>
            <span style="color: #008000;">&#125;</span> <span style="color: #0000ff;">else</span> <span style="color: #008000;">&#123;</span>
                <span style="color: #0000ff;">return</span> <span style="color: #0000dd;">0</span><span style="color: #008080;">;</span>
            <span style="color: #008000;">&#125;</span>
        <span style="color: #008000;">&#125;</span>
    <span style="color: #008000;">&#125;</span>
    <span style="color: #0000ff;">return</span> negative <span style="color: #008080;">?</span> <span style="color: #000040;">-</span>result <span style="color: #008080;">:</span> result<span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #008000;">&#125;</span> <span style="color: #666666;">// namespace impl</span>
&nbsp;
BOOST_AUTO_TEST_CASE<span style="color: #008000;">&#40;</span>unit_position<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
    BOOST_CHECK_EQUAL<span style="color: #008000;">&#40;</span>impl<span style="color: #008080;">::</span><span style="color: #0000dd;">atoi</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">&quot;6&quot;</span><span style="color: #008000;">&#41;</span>, <span style="color: #0000dd;">6</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
BOOST_AUTO_TEST_CASE<span style="color: #008000;">&#40;</span>tenth_position<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
    BOOST_CHECK_EQUAL<span style="color: #008000;">&#40;</span>impl<span style="color: #008080;">::</span><span style="color: #0000dd;">atoi</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">&quot;45&quot;</span><span style="color: #008000;">&#41;</span>, <span style="color: #0000dd;">45</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
BOOST_AUTO_TEST_CASE<span style="color: #008000;">&#40;</span>large_number<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
    BOOST_CHECK_EQUAL<span style="color: #008000;">&#40;</span>impl<span style="color: #008080;">::</span><span style="color: #0000dd;">atoi</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">&quot;123456789&quot;</span><span style="color: #008000;">&#41;</span>, <span style="color: #0000dd;">123456789</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
BOOST_AUTO_TEST_CASE<span style="color: #008000;">&#40;</span>negative_number<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
    BOOST_CHECK_EQUAL<span style="color: #008000;">&#40;</span>impl<span style="color: #008080;">::</span><span style="color: #0000dd;">atoi</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">&quot;-876&quot;</span><span style="color: #008000;">&#41;</span>, <span style="color: #000040;">-</span><span style="color: #0000dd;">876</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
BOOST_AUTO_TEST_CASE<span style="color: #008000;">&#40;</span>sign_in_wrong_position<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
    BOOST_CHECK_EQUAL<span style="color: #008000;">&#40;</span>impl<span style="color: #008080;">::</span><span style="color: #0000dd;">atoi</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">&quot;72-56&quot;</span><span style="color: #008000;">&#41;</span>, <span style="color: #0000dd;">0</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
BOOST_AUTO_TEST_CASE<span style="color: #008000;">&#40;</span>invalid<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
    BOOST_CHECK_EQUAL<span style="color: #008000;">&#40;</span>impl<span style="color: #008080;">::</span><span style="color: #0000dd;">atoi</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">&quot;abcd&quot;</span><span style="color: #008000;">&#41;</span>, <span style="color: #0000dd;">0</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span></pre></div></div>

<p><strong>Compilation and execution:</strong></p>

<div class="wp_syntax"><div class="code"><pre class="txt"># g++ -g -lboost_unit_test_framework -o atoi atoi.cpp &amp;&amp; ./atoi --log_level=test_suite --report_level=short</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://praveen.kumar.in/2010/04/30/introduction-to-test-driven-development-in-c-using-boost-test-library/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Simple GNU Emacs keyboard macro demonstration</title>
		<link>http://praveen.kumar.in/2010/04/03/simple-gnu-emacs-keyboard-macro-demonstration/</link>
		<comments>http://praveen.kumar.in/2010/04/03/simple-gnu-emacs-keyboard-macro-demonstration/#comments</comments>
		<pubDate>Sat, 03 Apr 2010 21:15:36 +0000</pubDate>
		<dc:creator>Praveen Kumar</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[emacs]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://praveen.kumar.in/?p=603</guid>
		<description><![CDATA[<a href="http://praveen.kumar.in/2010/04/03/simple-gnu-emacs-keyboard-macro-demonstration/" title="Simple GNU Emacs keyboard macro demonstration"></a>My obsession for GNU Emacs has grown over years to an extent where I managed to get a significant amount of users to adopt Emacs. In the past 10 years, I have learned a lot of nice tricks that I &#8230;<p class="read-more"><a href="http://praveen.kumar.in/2010/04/03/simple-gnu-emacs-keyboard-macro-demonstration/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://praveen.kumar.in/2010/04/03/simple-gnu-emacs-keyboard-macro-demonstration/" title="Simple GNU Emacs keyboard macro demonstration"></a><p>My obsession for <a href="http://www.gnu.org/software/emacs/">GNU Emacs</a> has grown over years to an extent where I managed to get a significant amount of users to adopt Emacs. In the past 10 years, I have learned a lot of nice tricks that I can do on Emacs to improve my productivity. So, I have decided to create a series of screencasts demonstrating some of those.</p>
<p>I will start with a very simple one, <a href="http://www.gnu.org/software/emacs/manual/html_node/emacs/Keyboard-Macros.html">macros</a>. Quoting from Emacs documentation, &#8220;A keyboard macro is a command defined by an Emacs user to stand for another sequence of keys. For example, if you discover that you are about to type <code>C-n M-d C-d</code> forty times, you can speed your work by defining a keyboard macro to do <code>C-n M-d C-d</code>, and then executing it 39 more times.&#8221;</p>
<p>In this demo, I have taken a real world example where you have to add C++ class member variables and accessors. There are other efficient ways to do such tasks in GNU Emacs. I personally use <a href="http://code.google.com/p/yasnippet/">yasnippets</a> to do these things. However, this approach is shown just to demonstrate keyboard macros. To supplement this video, please take a look at the keyboard macro documentation that is available within Emacs.</p>
<div align="center">
<object width="640" height="505"><param name="movie" value="http://www.youtube.com/v/L6qSWqKz3eQ&#038;hl=en_US&#038;fs=1&#038;hd=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/L6qSWqKz3eQ&#038;hl=en_US&#038;fs=1&#038;hd=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="505"></embed></object>
</div>
]]></content:encoded>
			<wfw:commentRss>http://praveen.kumar.in/2010/04/03/simple-gnu-emacs-keyboard-macro-demonstration/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting untruncated command line options passed to a Solaris process</title>
		<link>http://praveen.kumar.in/2010/02/24/getting-untruncated-command-line-options-passed-to-a-solaris-process/</link>
		<comments>http://praveen.kumar.in/2010/02/24/getting-untruncated-command-line-options-passed-to-a-solaris-process/#comments</comments>
		<pubDate>Thu, 25 Feb 2010 00:41:23 +0000</pubDate>
		<dc:creator>Praveen Kumar</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[opensolaris]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://praveen.kumar.in/?p=591</guid>
		<description><![CDATA[<a href="http://praveen.kumar.in/2010/02/24/getting-untruncated-command-line-options-passed-to-a-solaris-process/" title="Getting untruncated command line options passed to a Solaris process"></a>If you have ever wanted to get the command line options that were passed to a running Solaris process, you might have noticed that the output of command line arguments from ps is truncated to 80 characters. Looking into /usr/include/sys/procfs.h &#8230;<p class="read-more"><a href="http://praveen.kumar.in/2010/02/24/getting-untruncated-command-line-options-passed-to-a-solaris-process/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://praveen.kumar.in/2010/02/24/getting-untruncated-command-line-options-passed-to-a-solaris-process/" title="Getting untruncated command line options passed to a Solaris process"></a><p>If you have ever wanted to get the command line options that were passed to a running Solaris process, you might have noticed that the output of command line arguments from <code>ps</code> is truncated to 80 characters. Looking into <code>/usr/include/sys/procfs.h</code> will reveal the reason why! This is because of the restriction in <code>struct psinfo</code>. Here are the relevant fields from the definition of <code>struct psinfo</code>.</p>

<div class="wp_syntax"><div class="code"><pre class="c"><span style="color: #339933;">#define	PRFNSZ		16	/* Maximum size of execed filename */</span>
<span style="color: #339933;">#define	PRARGSZ		80	/* number of chars of arguments */</span>
&nbsp;
<span style="color: #993333;">typedef</span> <span style="color: #993333;">struct</span> psinfo <span style="color: #009900;">&#123;</span>
         <span style="color: #808080; font-style: italic;">/* Fields omitted */</span>
         <span style="color: #993333;">char</span> pr_fname<span style="color: #009900;">&#91;</span>PRFNSZ<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>    <span style="color: #808080; font-style: italic;">/* name of exec'ed file */</span>
         <span style="color: #993333;">char</span> pr_psargs<span style="color: #009900;">&#91;</span>PRARGSZ<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>  <span style="color: #808080; font-style: italic;">/* initial characters of arg list */</span>
         <span style="color: #808080; font-style: italic;">/* Fields omitted */</span>
<span style="color: #009900;">&#125;</span> psinfo_t<span style="color: #339933;">;</span></pre></div></div>

<p>So, due to the 80 characters restriction in <code>psinfo::pr_psargs</code>, the kernel will not be keeping track of arguments beyond the limit. Now, the only way to get the information is from the process&#8217; memory of <code>argv</code>. In order to do this, you should have access to read the processes&#8217; memory. This is the trick employed by both <code>pargs</code> and BSD version of <code>ps</code> with <code>-ww</code> switch.</p>
<p>To get the full length command line arguments passed to a process, you can do one of the following.</p>

<div class="wp_syntax"><div class="code"><pre class="txt">$ /usr/ucb/ps eww &lt;pid&gt;</pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="txt">$ pargs -l &lt;pid&gt;</pre></div></div>

<p>One catch here is that, if the process has modified the <code>argv</code> since it was started, the output reported by both <code>ps</code> and <code>pargs</code> will show the modified data and not the initial arguments that were passed in. However, modifying <code>argv</code> within a program is not a standard practice and hence the chance of encountering such a scenario is remote.</p>
]]></content:encoded>
			<wfw:commentRss>http://praveen.kumar.in/2010/02/24/getting-untruncated-command-line-options-passed-to-a-solaris-process/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dumping core file from set-UID, set-GID &#8216;ed processes in Solaris</title>
		<link>http://praveen.kumar.in/2010/02/23/dumping-core-file-from-set-uid-set-gid-ed-processes-in-solaris/</link>
		<comments>http://praveen.kumar.in/2010/02/23/dumping-core-file-from-set-uid-set-gid-ed-processes-in-solaris/#comments</comments>
		<pubDate>Tue, 23 Feb 2010 23:52:44 +0000</pubDate>
		<dc:creator>Praveen Kumar</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[opensolaris]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://praveen.kumar.in/?p=586</guid>
		<description><![CDATA[<a href="http://praveen.kumar.in/2010/02/23/dumping-core-file-from-set-uid-set-gid-ed-processes-in-solaris/" title="Dumping core file from set-UID, set-GID &#039;ed processes in Solaris"></a>I had a previous post on how to turn on core files for set-UID, set-GID processes under Linux. Recently we ran into the same problem on Solaris. To turn on core files for set-id processes, use coreadm. $ pfexec coreadm &#8230;<p class="read-more"><a href="http://praveen.kumar.in/2010/02/23/dumping-core-file-from-set-uid-set-gid-ed-processes-in-solaris/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://praveen.kumar.in/2010/02/23/dumping-core-file-from-set-uid-set-gid-ed-processes-in-solaris/" title="Dumping core file from set-UID, set-GID &#039;ed processes in Solaris"></a><p>I had a <a href="http://praveen.kumar.in/2008/06/05/dumping-core-file-from-set-uid-set-gid-ed-processes-in-linux/">previous post</a> on how to turn on core files for set-UID, set-GID processes under Linux. Recently we ran into the same problem on Solaris. To turn on core files for set-id processes, use <code>coreadm</code>.</p>

<div class="wp_syntax"><div class="code"><pre class="txt">$ pfexec coreadm -e global-setid</pre></div></div>

<p>Please keep in mind that these core files can have information that non-privileged user isn&#8217;t supposed to know. Quoting from Solaris man page:</p>

<div class="wp_syntax"><div class="code"><pre class="txt">     A process that is or ever has been setuid  or  setgid  since
     its  last  exec(2)  presents  security issues that relate to
     dumping  core.  Similarly,  a  process  that  initially  had
     superuser  privileges  and  lost  those  privileges  through
     setuid(2) also presents security issues that are related  to
     dumping core. A process of either type can contain sensitive
     information in  its  address  space  to  which  the  current
     nonprivileged  owner  of the process should not have access.
     If setid core files are enabled, they are created  mode  600
     and owned by the superuser.</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://praveen.kumar.in/2010/02/23/dumping-core-file-from-set-uid-set-gid-ed-processes-in-solaris/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

