tag:blogger.com,1999:blog-35866450453035015662024-03-05T23:49:43.419-08:00Developer to DeveloperAnonymoushttp://www.blogger.com/profile/10713264593334966481noreply@blogger.comBlogger24125tag:blogger.com,1999:blog-3586645045303501566.post-79216942780698789372015-08-08T01:03:00.000-07:002015-08-08T01:03:02.905-07:00How to set up Wireless network on Ubuntu 14.04 LTS to Connect it from Android ? <div dir="ltr" style="text-align: left;" trbidi="on">
Hey guys,<br />
<br />
How you doing. Couple of days back I got stucked at some point to connect my android to my laptop in ubuntu.<br />
<br />
The problem was - I used to connect to internet using Wirless USB dongal and I neither have wireless routers nor have have any ethernet connection to try out alternatives like USB tethering etc. I was struggling much to set up wifi hostspot in ubuntu. The wifi hotspot used to activate successfully but never it was detected in my Asus android phone.<br />
<br />
Here is the simplest solution I found out there.<br />
<br />
Install this beautiful software [<b>kde-nm-connection-editor</b>] if you had not installed in your pc. It will make your connection editing task much simpler than any thing else.<br />
<br />
Go to ubuntu software center and search <b>kde-nm-connection-editor </b> install.<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhaDeKWSZAU_W4iFW1Z3_aWcUJ-uN6zVQJVQeSRcstRm3j9vHqPk3sPHRnBkOXQ-x6Hff8YC3vaJAMziJRkNTRXVdGp7kJ-ZDX1VFgKjckwV3IZlgcYmbPML55xcaVa0FuGkHyuhTOX1VQ/s1600/Screenshot+from+2015-08-08+13%253A04%253A08.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="355" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhaDeKWSZAU_W4iFW1Z3_aWcUJ-uN6zVQJVQeSRcstRm3j9vHqPk3sPHRnBkOXQ-x6Hff8YC3vaJAMziJRkNTRXVdGp7kJ-ZDX1VFgKjckwV3IZlgcYmbPML55xcaVa0FuGkHyuhTOX1VQ/s400/Screenshot+from+2015-08-08+13%253A04%253A08.png" width="400" /></a><br />
Next, Open the terminal[<b>ctrl+alt+t</b>] and type <b>kde-nm-connection-editor , </b>the connection editor will pop out :<br />
<br />
<b>On Wireless tab:</b><br />
<b><br /></b>
1. Click on Add <b>>> Wireless shared </b><br />
<b>2. </b>On wireless tab Give any Identification name on SSID.<br />
3. Choose the mode to <b>Access Point </b>and select the wlan0 [your enlisted wifi card]<br />
4. Click on Okey.<br />
<br />
<b>On Wireless Security tab: </b><br />
1. Choose <b>WPA and WPA2 Person </b>in security field.<br />
2. Give the password to the specified field.<br />
<br />
Click on Okey and your are done.<br />
<br />
Now it's your time to connect the Wirless dongal to laptop.<br />
<br />
<b>Now on title bar of your laptop</b><br />
1. Click on the Network Icon<br />
2. Click on Connect to Hidden Wifi Network<br />
3. On Connection tab: select the network you have recently setup in your previous step.<br />
4. Click on Connect<br />
<br />
After successful connection, you can see the your recently set up network in connected state apart from your usb Dongal connection.<br />
<br />
Now on mobile turn on the wifi - You will be able to detect your recently set up network. Connect it using the password you have provided while setting up the connection.<br />
<br />
Enjoy Up..!!<br />
Cheers.. <br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<b><br /></b>
<b><br /></b>
<b><br /></b>
<b><br /></b>
<br />
<b><br /></b>
</div>
Anonymoushttp://www.blogger.com/profile/10713264593334966481noreply@blogger.com0tag:blogger.com,1999:blog-3586645045303501566.post-71005926532853913822015-06-13T06:05:00.001-07:002015-06-13T06:13:31.797-07:00How to Add Java Decompiler Plugin for Eclipse in Linux Environment ? <div dir="ltr" style="text-align: left;" trbidi="on">
<div style="text-align: justify;">
Decompilation is required some times , if you are interested to view internal class details of compiled java <b>.class</b> files. One of the interesting area is, you would like to view internal details of Thread class or any other classes in java. For that, normally what is done is to go at Java reference API site and see all the methods and interfaces. That's awful. Why not directly view all the methods and attributes in Eclipse editor itself. Here is the Way !</div>
<br />
<div style="text-align: justify;">
Required two things : <b>Jad Decompiler </b>and<b> Eclipse Plugin for Jad Decompiler</b></div>
<br />
<div style="text-align: justify;">
<span style="font-weight: bold;"><br /></span></div>
<b>Download and install Jad Decompiler - </b><a href="http://varaneckas.com/jad/jad158e.linux.static.zip" style="background: rgb(255, 255, 255); box-sizing: border-box; color: #428bca; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20px; text-decoration: none;">Jad 1.5.8e for Linux (statically linked)</a><b> </b>from this <a href="http://varaneckas.com/jad/" target="_blank">location</a><br />
<br />
Extract the tar.gz file the file names <b>jad</b> will be there, remember its full path name.<br />
<br />
Now <b>download eclipse jad</b> plugin jar from this <a href="http://jadclipse.sourceforge.net/wiki/index.php/Main_Page#Download" target="_blank">source</a> and copy it to the<b> ./plugins</b> directory of your eclipse.<br />
<br />
Restart the eclipse: Go to <b>Preference >> Java >></b> You will find the plugin with name <b>jadClipse.</b><br />
<br />
Then set the <b>path to decompiler </b>to the path you have extracted the tar.gz file in previous step: as for ex- /your/Dir/<b>jad</b> <br />
<br />
Remember that : jad is the file name, do not forget to include this. You have to give full file name not the directory only. Try to open any .class complied file of java.<br />
<br />
That's it, you are done. Enjoy !!<br />
<br />
<br />
<br />
<b>Problem :</b> Still after setting all the above tasks properly, not able to view the Java class .<br />
There might the problem with eclipse editor in associating Jad Plugin as the default in associated editor section. Follow Below steps in eclipse:<br />
<b>Windows >> Preferences >> General >> Editors >> File Associations </b><br />
<br />
Remove all Associated Editors and then add <b>jadclipse Class File viewer </b>and make it default. <br />
Restart the eclipse and Try again to re- open the file.<br />
<br />
<br />
<b><br /></b>
<br />
<div style="border: 0px; box-sizing: border-box; color: #3f4549; font-family: 'Helvetica Neue', arial, sans-serif; font-size: 15px; line-height: 21px; margin-bottom: 15px; padding: 0px;">
<br /></div>
<br /></div>
Anonymoushttp://www.blogger.com/profile/10713264593334966481noreply@blogger.com0tag:blogger.com,1999:blog-3586645045303501566.post-6310473699577169842014-06-26T06:40:00.000-07:002014-07-10T23:32:42.145-07:00Introduction to Hadoop<div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="margin-bottom: 0pt; margin-top: 0pt;">
<div style="text-align: justify;">
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<a href="https://www.blogger.com/blogger.g?blogID=3586645045303501566" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"></a><a href="https://www.blogger.com/blogger.g?blogID=3586645045303501566" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"></a><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;">In 1990’s around 1400 MB
of data was the maximum and had a transfer speed of 4.4 MB/s, i.e. It
would take around 311 sec or almost 5 minutes to transfer data. 20 years later,
one terabyte drives are the norm, but the transfer speed is around 100 MB/S. Time
required to read the whole disk is (1*1024*1024/(100*60*60)) = 2.9 hours.<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;">The obvious way to
reduce the time is to read from multiple disks at once. Imagine if we had
100 drives, each holding one hundredth of the data. Working in parallel, we
could read the data in under two minutes. ==>2.9*100/60 .The
first problem to solve is hardware failure: as soon as you start using many
pieces of hardware, the chance that one will fail is fairly high. A common way
of avoiding data loss is through replication: redundant copies of the data are
kept by the system so that in the event of failure, there is another copy
available. This is how RAID works, for instance, although Hadoop’s file
system, the Hadoop Distributed File system (HDFS), takes a slightly different
approach.<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;">The second problem is
that most analysis tasks need to be able to combine the data in some way;
data read from one disk may need to be combined with the data from any of
the other 99 disks. Hadoop provides: a reliable shared storage and analysis system.
The storage is provided by HDFS and analysis by Map Reduce.<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;">Seeking: </span></b><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"> is the process of moving the disk’s head
to a particular place on the disk to read or write data. It characterizes the
latency of a disk operation, whereas the transfer rate corresponds to a disk’s
bandwidth.<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;">Map Reduce VS RDBMS:</span></b><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;">Map Reduce is a good fit
for problems that need to analyze the whole data set, in a batch fashion,
particularly for ad hoc analysis. An RDBMS is good for point queries or
updates, where the data set has been indexed to deliver low-latency retrieval
and update times of a relatively small amount of data.<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;">Map Reduce: Suits
applications where the data is written once, and read many times,
relational database is good for data sets that are continually updated. Relational
data is often normalized to retain its integrity and remove
redundancy. Normalization poses problems for Map Reduce. A web server
log is a good example of a set of records that is not normalized.<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;">If you double the size
of the input data, a job will run twice as slow. But if you also double the
size of the cluster, a job will run as fast as the original one. This is not
generally true of SQL queries. Map Reduce tries to collocate the data with
the compute node, so data access is fast since it is local. This feature, known
as data locality, is at the heart of Map Reduce and is the reason for its
good performance.<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;">Map Reduce are limited
to key and value types that are related in specified ways, and mappers and
reducers run with very limited coordination between one another (the
mappers pass keys and values to reducers).<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;">Hadoop introduction:</span></b><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;">Created by Doug
Cutting In 2004, Google published the paper that introduced Map Reduce to
the world.<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;">Nutch developers had a
working Map Reduce implementation in Nutch(Apache) <o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;">Hadoop & Hadoop
Ecosystem:</span></b><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;">Common: A set of
components and interfaces for distributed file systems and general I/O<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;">(Serialization, Java
RPC, persistent data structures).<o:p></o:p></span></div>
<ul type="disc">
<li class="MsoNormal" style="text-align: justify;"><b><span style="font-family: "Times New Roman","serif"; font-size: 13.5pt; mso-fareast-font-family: "Times New Roman";">HDFS</span></b><span style="font-family: "Times New Roman","serif"; font-size: 13.5pt; mso-fareast-font-family: "Times New Roman";">: Distributed file system that runs on large clusters
of commodity machines<o:p></o:p></span></li>
<li class="MsoNormal" style="text-align: justify;"><b><span style="font-family: "Times New Roman","serif"; font-size: 13.5pt; mso-fareast-font-family: "Times New Roman";">Pig</span></b><span style="font-family: "Times New Roman","serif"; font-size: 13.5pt; mso-fareast-font-family: "Times New Roman";">: Data flow language, explores very large
datasets.<o:p></o:p></span></li>
<li class="MsoNormal" style="text-align: justify;"><b><span style="font-family: "Times New Roman","serif"; font-size: 13.5pt; mso-fareast-font-family: "Times New Roman";">Hive</span></b><span style="font-family: "Times New Roman","serif"; font-size: 13.5pt; mso-fareast-font-family: "Times New Roman";">: Distributed data warehouse<o:p></o:p></span></li>
<li class="MsoNormal" style="text-align: justify;"><b><span style="font-family: "Times New Roman","serif"; font-size: 13.5pt; mso-fareast-font-family: "Times New Roman";">HBase</span></b><span style="font-family: "Times New Roman","serif"; font-size: 13.5pt; mso-fareast-font-family: "Times New Roman";">: Column-oriented database<o:p></o:p></span></li>
<li class="MsoNormal" style="text-align: justify;"><b><span style="font-family: "Times New Roman","serif"; font-size: 13.5pt; mso-fareast-font-family: "Times New Roman";">Zookeeper: D</span></b><span style="font-family: "Times New Roman","serif"; font-size: 13.5pt; mso-fareast-font-family: "Times New Roman";">istributed, highly available coordination service.<o:p></o:p></span></li>
<li class="MsoNormal" style="text-align: justify;"><b><span style="font-family: "Times New Roman","serif"; font-size: 13.5pt; mso-fareast-font-family: "Times New Roman";">Sqoop</span></b><span style="font-family: "Times New Roman","serif"; font-size: 13.5pt; mso-fareast-font-family: "Times New Roman";">: Moving data between relational databases and HDFS.<o:p></o:p></span></li>
</ul>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;">Map Reduce:</span></b><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<ul type="disc">
<li class="MsoNormal" style="text-align: justify;"><span style="font-family: "Times New Roman","serif"; font-size: 13.5pt; mso-fareast-font-family: "Times New Roman";">Programming model for data
processing<o:p></o:p></span></li>
<li class="MsoNormal" style="text-align: justify;"><span style="font-family: "Times New Roman","serif"; font-size: 13.5pt; mso-fareast-font-family: "Times New Roman";">Map Reduce programs are
inherently parallel.<o:p></o:p></span></li>
<li class="MsoNormal" style="text-align: justify;"><span style="font-family: "Times New Roman","serif"; font-size: 13.5pt; mso-fareast-font-family: "Times New Roman";">What’s the highest recorded
global temperature for each year in the dataset?<o:p></o:p></span></li>
<li class="MsoNormal" style="text-align: justify;"><span style="font-family: "Times New Roman","serif"; font-size: 13.5pt; mso-fareast-font-family: "Times New Roman";">Performance baseline<o:p></o:p></span></li>
</ul>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;">Map Reduce works by
breaking the processing into two phases: the map phase and the reduce
phase. Each phase has key-value pairs as input and output, the types of
which may be chosen by the programmer. The programmer also specifies two
functions: the map function and the reduce function.<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;">Choose text input format each
line can be a text values, & key be the offset.<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;">Use case find max
temperature</span></b><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;">Sample data:<o:p></o:p></span></div>
<!-- HTML generated using hilite.me --><br />
<div style="background: #ffffff; border-width: .0.01em .0.01em .0.01em .8em; border: solid green; overflow: auto; padding: .2em .6em; width: auto;">
<pre style="line-height: 125%; margin: 0;">0067011990999991950051507004...9999999N9+00001+99999999999...
0043011990999991950051512004...9999999N9+00221+99999999999...
0043011990999991950051518004...9999999N9-00111+99999999999...
0043012650999991949032412004...0500001N9+01111+99999999999...
0043012650999991949032418004...0500001N9+00781+99999999999...
</pre>
</div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;">Data presented to map
function (Key -Value pair)<o:p></o:p></span></div>
<!-- HTML generated using hilite.me --><br />
<div style="background: #ffffff; border-width: .0.01em .0.01em .0.01em .8em; border: solid green; overflow: auto; padding: .2em .6em; width: auto;">
<pre style="line-height: 125%; margin: 0;">(0, 0067011990999991950051507004...9999999N9+00001+99999999999...)
(106, 0043011990999991950051512004...9999999N9+00221+99999999999...)
(212, 0043011990999991950051518004...9999999N9-00111+99999999999...)
(318, 0043012650999991949032412004...0500001N9+01111+99999999999...)
(424, 0043012650999991949032418004...0500001N9+00781+99999999999...)
</pre>
</div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;">Map function output</span></b><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<!-- HTML generated using hilite.me --><br />
<div style="background: #ffffff; border-width: .0.01em .0.01em .0.01em .8em; border: solid green; overflow: auto; padding: .2em .6em; width: auto;">
<pre style="line-height: 125%; margin: 0;"><a href="https://www.blogger.com/blogger.g?blogID=3586645045303501566" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"></a><a href="https://www.blogger.com/blogger.g?blogID=3586645045303501566" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"></a><a href="https://www.blogger.com/blogger.g?blogID=3586645045303501566" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"></a>(1950, 0)
(1950, 22)
(1950, <span style="border: 1px solid #FF0000;">−</span>11)
(1949, 111)
(1949, 78)
</pre>
</div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;">The output from the map
function is processed by the Map Reduce framework before<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;">Being sent to the reduce
function. =>Sorts & Groups [Combiner]<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<!-- HTML generated using hilite.me --><br />
<div style="background: #ffffff; border-width: .0.01em .0.01em .0.01em .8em; border: solid green; overflow: auto; padding: .2em .6em; width: auto;">
<pre style="line-height: 125%; margin: 0;">(1949, [111, 78])
(1950, [0, 22, <span style="border: 1px solid #FF0000;">−</span>11])
</pre>
</div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;">Reducer:</span></b><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;">All the reduce function
has to do now is iterate through the list and pick up the maximum reading:<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
</div>
<!-- HTML generated using hilite.me --><br />
<div style="background: #ffffff; border-width: .0.01em .0.01em .0.01em .8em; border: solid green; overflow: auto; padding: .2em .6em; width: auto;">
<pre style="line-height: 125%; margin: 0;">(1949, 111)
(1950, 22)
</pre>
</div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;">
<!--[if !supportLineBreakNewLine]--><br />
<!--[endif]--><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><!--[if gte vml 1]><v:shapetype
id="_x0000_t75" coordsize="21600,21600" o:spt="75" o:preferrelative="t"
path="m@4@5l@4@11@9@11@9@5xe" filled="f" stroked="f">
<v:stroke joinstyle="miter"/>
<v:formulas>
<v:f eqn="if lineDrawn pixelLineWidth 0"/>
<v:f eqn="sum @0 1 0"/>
<v:f eqn="sum 0 0 @1"/>
<v:f eqn="prod @2 1 2"/>
<v:f eqn="prod @3 21600 pixelWidth"/>
<v:f eqn="prod @3 21600 pixelHeight"/>
<v:f eqn="sum @0 0 1"/>
<v:f eqn="prod @6 1 2"/>
<v:f eqn="prod @7 21600 pixelWidth"/>
<v:f eqn="sum @8 21600 0"/>
<v:f eqn="prod @7 21600 pixelHeight"/>
<v:f eqn="sum @10 21600 0"/>
</v:formulas>
<v:path o:extrusionok="f" gradientshapeok="t" o:connecttype="rect"/>
<o:lock v:ext="edit" aspectratio="t"/>
</v:shapetype><v:shape id="Picture_x0020_2" o:spid="_x0000_i1026" type="#_x0000_t75"
alt="https://lh6.googleusercontent.com/LZypZGvkOGQQuTdxU4mlqizkoXumYtKDg-FONkt6ZioEqBsUfbvzOxn245GSRiul_eSNNhQMDgQbzLwus8hYEeLL8_T6u9dbTj6PJUBlKKIUg-UbRpiT5o5ODLQhag"
style='width:543.75pt;height:105pt;visibility:visible;mso-wrap-style:square'>
<v:imagedata src="file:///C:\Users\PREMS~1.BIS\AppData\Local\Temp\msohtmlclip1\01\clip_image001.png"
o:title="LZypZGvkOGQQuTdxU4mlqizkoXumYtKDg-FONkt6ZioEqBsUfbvzOxn245GSRiul_eSNNhQMDgQbzLwus8hYEeLL8_T6u9dbTj6PJUBlKKIUg-UbRpiT5o5ODLQhag"/>
</v:shape><![endif]--><!--[if !vml]--><!--[endif]--></span><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><u><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">Java
Map Reduce Code:</span></u></b><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><br />
<!--[if !supportLineBreakNewLine]--><br />
<!--[endif]--><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">3 things =>Map
function, Reduce function, some code to run job.</span><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><br />
<!--[if !supportLineBreakNewLine]--><br />
<!--[endif]--><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">Creating project:</span></b><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><br />
<!--[if !supportLineBreakNewLine]--><br />
<!--[endif]--><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">Create a new java
project</span><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">Add jar from: <b>Hadoop
home</b> & <b>Hadoop Home/lib</b></span><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">C:\Hadoop\hadoop-1.1.0-SNAPSHOT</span><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">C:\Hadoop\hadoop-1.1.0-SNAPSHOT\lib</span><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">General procedure:</span></b><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">Set a job </span><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">Assign mapper class</span><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">Assign reducer class</span><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><br />
<!--[if !supportLineBreakNewLine]--><br />
<!--[endif]--><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">CustomMapper class
extends Mapper (input key, input value, outputKey, outputValue)</span><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">Input key -- some key </span><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">Input value --Line </span><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">Output Key -- year</span><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">Output Value --MaxTemp</span><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><br />
<!--[if !supportLineBreakNewLine]--><br />
<!--[endif]--><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<i><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">map function (<b>inputKey</b>,<b>
inputValue</b>)</span></i><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><br />
<!--[if !supportLineBreakNewLine]--><br />
<!--[endif]--><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">Hadoop own data types:</span></b><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><br />
<!--[if !supportLineBreakNewLine]--><br />
<!--[endif]--><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">These are found in the <b>org.apache.hadoop.io
package</b>.</span><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">LongWritable </span></b><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">==>Like Long</span><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">Text </span></b><span style="font-family: Arial, sans-serif; font-size: 11.5pt;"> =>Like String</span><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">IntWritable </span></b><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">==>Like Integer</span><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><u><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">Setting
jar by class:</span></u></b><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">Hadoop will distribute
this file around the cluster, & locate the relevant jar.</span><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">job.</span><span style="color: #9900ff; font-family: "Arial","sans-serif"; font-size: 11.5pt; mso-fareast-font-family: "Times New Roman";">setJarByClass</span><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">(MaxTemperatureDriver.class);</span><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><u><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">Specify
input and output path:</span></u></b><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><br />
<!--[if !supportLineBreakNewLine]--><br />
<!--[endif]--><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">FileInputFormat.</span><span style="color: #9900ff; font-family: "Arial","sans-serif"; font-size: 11.5pt; mso-fareast-font-family: "Times New Roman";">addInputPath</span><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">(job, new Path(args[0]));</span><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">FileOutputFormat.</span><span style="color: #9900ff; font-family: "Arial","sans-serif"; font-size: 11.5pt; mso-fareast-font-family: "Times New Roman";">setOutputPath</span><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">(job,new Path(args[1]));</span><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><br />
<!--[if !supportLineBreakNewLine]--><br />
<!--[endif]--><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><u><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">Setting
mapper and reducers:</span></u></b><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><br />
<!--[if !supportLineBreakNewLine]--><br />
<!--[endif]--><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">Hadoop send individual
jar to each </span><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">job.</span><b><span style="color: #9900ff; font-family: "Arial","sans-serif"; font-size: 11.5pt; mso-fareast-font-family: "Times New Roman";">setMapperClass</span></b><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">(MaxTemperatureMapper.class);</span><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">job.</span><span style="color: #9900ff; font-family: "Arial","sans-serif"; font-size: 11.5pt; mso-fareast-font-family: "Times New Roman";">setReducerClass</span><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">(MaxTemperatureReducer.class);</span><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><br />
<!--[if !supportLineBreakNewLine]--><br />
<!--[endif]--><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><u><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">Waiting
for completion:</span></u></b><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">After setting the job,
hadoop will wait for completion of job. This is done by :</span><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">(job.</span><span style="color: #9900ff; font-family: "Arial","sans-serif"; font-size: 11.5pt; mso-fareast-font-family: "Times New Roman";">waitForCompletion</span><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">(true) ? 0:1)</span><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><u><span style="font-family: Arial, sans-serif; font-size: 12pt;">Data
Flow:</span></u></b><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><br />
<!--[if !supportLineBreakNewLine]--><br />
<!--[endif]--><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, sans-serif; font-size: 12pt;">Hadoop runs the <b>job </b>by
dividing it into tasks: <b>map tasks</b> and <b>reduce tasks</b>.</span><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">Job Execution process is
controlled by 2 types of nodes:</span><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<ul style="margin-top: 0in;" type="disc">
<li class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: justify; vertical-align: baseline;"><span style="font-family: "Arial","sans-serif"; font-size: 11.5pt; mso-fareast-font-family: "Times New Roman";">A
<b>job tracker </b>: coordinates all the jobs run on the system by
scheduling tasks to run on tasktrackers.<o:p></o:p></span></li>
<li class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: justify; vertical-align: baseline;"><b><span style="font-family: "Arial","sans-serif"; font-size: 11.5pt; mso-fareast-font-family: "Times New Roman";">Task
trackers</span></b><span style="font-family: "Arial","sans-serif"; font-size: 11.5pt; mso-fareast-font-family: "Times New Roman";">: run tasks and send progress
reports to the job tracker. Task fails, the job tracker can reschedule it
on a different task tracker.<o:p></o:p></span></li>
</ul>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">Splits: </span></b><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<ul style="margin-top: 0in;" type="disc">
<li class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: justify; vertical-align: baseline;"><span style="font-family: "Arial","sans-serif"; font-size: 11.5pt; mso-fareast-font-family: "Times New Roman";">Input
to Map reduce job are split into fixed pieces by Hadoop.<o:p></o:p></span></li>
<li class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: justify; vertical-align: baseline;"><span style="font-family: "Arial","sans-serif"; font-size: 11.5pt; mso-fareast-font-family: "Times New Roman";">Creates
one map task for each split.<o:p></o:p></span></li>
<li class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: justify; vertical-align: baseline;"><span style="font-family: "Arial","sans-serif"; font-size: 11.5pt; mso-fareast-font-family: "Times New Roman";">Many
splits, less time to process rather than whole input.<o:p></o:p></span></li>
<li class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: justify; vertical-align: baseline;"><span style="font-family: "Arial","sans-serif"; font-size: 11.5pt; mso-fareast-font-family: "Times New Roman";">Processing
splits in parallel will make it better load balanced.<o:p></o:p></span></li>
<li class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: justify; vertical-align: baseline;"><span style="font-family: "Arial","sans-serif"; font-size: 11.5pt; mso-fareast-font-family: "Times New Roman";">Faster
machine will be able to process it more proportionally.<o:p></o:p></span></li>
<li class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: justify; vertical-align: baseline;"><span style="font-family: "Arial","sans-serif"; font-size: 11.5pt; mso-fareast-font-family: "Times New Roman";">Splits
are too small managing the splits and of map task creation begins to
dominate the total job execution time.<o:p></o:p></span></li>
<li class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: justify; vertical-align: baseline;"><span style="font-family: "Arial","sans-serif"; font-size: 11.5pt; mso-fareast-font-family: "Times New Roman";">Good
split size tends to be the size of an HDFS block, 64MB by default.<o:p></o:p></span></li>
</ul>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><br />
<!--[if !supportLineBreakNewLine]--><br />
<!--[endif]--><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">Data locality
optimization:</span></b><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<ul style="margin-top: 0in;" type="disc">
<li class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: justify; vertical-align: baseline;"><span style="font-family: "Arial","sans-serif"; font-size: 11.5pt; mso-fareast-font-family: "Times New Roman";">Run
the map task on a node where the input data resides in HDFS.<o:p></o:p></span></li>
<li class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: justify; vertical-align: baseline;"><span style="font-family: "Arial","sans-serif"; font-size: 11.5pt; mso-fareast-font-family: "Times New Roman";">Helps
reduce cluster b/w<o:p></o:p></span></li>
<li class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: justify; vertical-align: baseline;"><span style="font-family: "Arial","sans-serif"; font-size: 11.5pt; mso-fareast-font-family: "Times New Roman";">Splits
can be spanned over multiple blocks in HDFS.<o:p></o:p></span></li>
</ul>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><br />
<!--[if !supportLineBreakNewLine]--><br />
<!--[endif]--><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">Map tasks & Reduce
task:</span></b><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<ul style="margin-top: 0in;" type="disc">
<li class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: justify; vertical-align: baseline;"><span style="font-family: "Arial","sans-serif"; font-size: 11.5pt; mso-fareast-font-family: "Times New Roman";">As
maps tasks are intermediate steps, those are stored in local disk instead
of HDFS because it is processed by reduced task to produce the final
output.<o:p></o:p></span></li>
<li class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: justify; vertical-align: baseline;"><span style="font-family: "Arial","sans-serif"; font-size: 11.5pt; mso-fareast-font-family: "Times New Roman";">The
input to the single reducer is normally the output from the all the
mappers.<o:p></o:p></span></li>
<li class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: justify; vertical-align: baseline;"><span style="font-family: "Arial","sans-serif"; font-size: 11.5pt; mso-fareast-font-family: "Times New Roman";">The
output of reduce are tasks are stored in HDFS.<o:p></o:p></span></li>
<li class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: justify; vertical-align: baseline;"><span style="font-family: "Arial","sans-serif"; font-size: 11.5pt; mso-fareast-font-family: "Times New Roman";">The
first replica stored at local node & other replicas are stored at off <b>rack
node.</b><o:p></o:p></span></li>
</ul>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><br />
<!--[if !supportLineBreakNewLine]--><br />
<!--[endif]--><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">Combiner: </span></b><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<ul style="margin-top: 0in;" type="disc">
<li class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: justify; vertical-align: baseline;"><span style="font-family: "Arial","sans-serif"; font-size: 11.5pt; mso-fareast-font-family: "Times New Roman";">To
minimize the data transferred between map and reduce tasks, Hadoop uses
combiners after mapper to combine multiple mappers output which is then
send to reducer.<o:p></o:p></span></li>
<li class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: justify; vertical-align: baseline;"><span style="font-family: "Arial","sans-serif"; font-size: 11.5pt; mso-fareast-font-family: "Times New Roman";">After
setting mapper class, set combiner if you need by and defined on Reducer
class :<o:p></o:p></span></li>
</ul>
<div class="MsoNormal" style="margin-bottom: 0.0001pt; text-indent: 0.5in;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">job.</span><span style="color: #9900ff; font-family: "Arial","sans-serif"; font-size: 11.5pt; mso-fareast-font-family: "Times New Roman";">setCombinerClass</span><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">(MaxTemperatureReducer.class);</span><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">Reducer:</span></b><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<ul style="margin-top: 0in;" type="disc">
<li class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: justify; vertical-align: baseline;"><span style="font-family: "Arial","sans-serif"; font-size: 11.5pt; mso-fareast-font-family: "Times New Roman";">Hadoop
Streaming uses UNIX standard streams as the interface between Hadoop and
your program. <o:p></o:p></span></li>
<li class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: justify; vertical-align: baseline;"><span style="font-family: "Arial","sans-serif"; font-size: 11.5pt; mso-fareast-font-family: "Times New Roman";">Streaming
is naturally suited for text processing<o:p></o:p></span></li>
<li class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: justify; vertical-align: baseline;"><span style="font-family: "Arial","sans-serif"; font-size: 11.5pt; mso-fareast-font-family: "Times New Roman";">Hadoop
Pipes: C++ interface to Hadoop Map Reduce<o:p></o:p></span></li>
</ul>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><u><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">Configuration:</span></u></b><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><br />
<!--[if !supportLineBreakNewLine]--><br />
<!--[endif]--><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">C:\hadoop\hadoop-1.1.0-SNAPSHOT\conf</span></b><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><span style="color: #9900ff; font-family: "Arial","sans-serif"; font-size: 11.5pt; mso-fareast-font-family: "Times New Roman";">hdfs-site.xml:</span></b><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><br />
<!--[if !supportLineBreakNewLine]--><br />
<!--[endif]--><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">dfs.replication </span></b><b><span style="font-family: 'Cambria Math', serif; font-size: 11.5pt;">⇒</span></b><b><span style="font-family: Arial, sans-serif; font-size: 11.5pt;"> </span></b><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">This property set the replication factor for data.</span><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">dfs.<b>webhdfs</b>.enabled</span><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">Summary:</span></b><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">Active Hadoop node ||
Passive Hadoop (Secondary name node)</span><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">Name node </span></b><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">server: is a Hadoop name node server that runs</span><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><br />
<!--[if !supportLineBreakNewLine]--><br />
<!--[endif]--><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">20-35 Peta Bytes of data
</span></b><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">large cluster can support.</span><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">Underlying file System
options [HDFS]:</span></b><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><br />
<!--[if !supportLineBreakNewLine]--><br />
<!--[endif]--><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">You do not format the
hard drive with HDFS but use ext3, ext4 or XFS slave hard drive.</span><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">HDFS =>Abstract file
system</span><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">Ext4 recommendations for
hard drive format.</span><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">Commands:</span></b><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><br />
<!--[if !supportLineBreakNewLine]--><br />
<!--[endif]--><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">hadoop fs </span></b><span style="color: #9900ff; font-family: "Arial","sans-serif"; font-size: 11.5pt; mso-fareast-font-family: "Times New Roman";">-help</span><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><br />
<!--[if !supportLineBreakNewLine]--><br />
<!--[endif]--><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">bin</span></b><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">/<b>hadoop</b> fs</span><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt; text-indent: 0.5in;">
<b><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">-ls</span></b><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">-mkdir</span></b><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">-copyFromLocal</span></b><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">-copyToLocal</span></b><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">-moveToLocal</span></b><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">-rm</span></b><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">-tail</span></b><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">-chmod</span></b><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">-setrep -w 4 -R
/dir1/s-dir/ //</span></b><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">Replication factor change to 4 recursively for this subdirectory</span><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><u><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">Yahoo
4500 node clusters:</span></u></b><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><br />
<!--[if !supportLineBreakNewLine]--><br />
<!--[endif]--><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">110 Racks </span><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">Each rack 40 slaves</span><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">At top there is rack
switch for each rack</span><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">8 core switches </span><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">Every slaves machine has
2 Cat five cables going at top of rack switch, that means each to of rack
switch has 40*2 = 80 Ports in each rack.</span><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><br />
<!--[if !supportLineBreakNewLine]--><br />
<!--[endif]--><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">Within rack its’ 1GB
network, However core switch layer is 10GB network, of which 8GB
is dedicated for
HDFS & rest 2GB for Map reduce administration, & user traffic on the
network.</span><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><br />
<!--[if !supportLineBreakNewLine]--><br />
<!--[endif]--><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">Rack awareness:</span></b><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><span style="font-family: Arial, sans-serif; font-size: 11.5pt;"> </span></b><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">Name node is rack aware.</span><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><br />
<!--[if !supportLineBreakNewLine]--><br />
<!--[endif]--><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><u><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">Commands:</span></u></b><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><br />
<!--[if !supportLineBreakNewLine]--><br />
<!--[endif]--><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">Hadoop</span></b><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><span style="font-family: Arial, sans-serif; font-size: 11.5pt;"> FS</span></b><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">What are the files at
root of HDFS?</span><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">haddop fs <b>-ls /</b></span><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><br />
<!--[if !supportLineBreakNewLine]--><br />
<!--[endif]--><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><span style="font-family: Consolas; font-size: 12pt;">dfs -ls</span></b><b><span style="background: white; color: #323232; font-family: Consolas; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"> </span></b><b><span style="font-family: Consolas; font-size: 12pt;">/user/hduser/
==></span></b><span style="font-family: Consolas; font-size: 12pt;">works at both linux
& windows</span><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><br />
<!--[if !supportLineBreakNewLine]--><br />
<!--[endif]--><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><u><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">Make
new dir:</span></u></b><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><br />
<!--[if !supportLineBreakNewLine]--><br />
<!--[endif]--><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">mkdir
/user/clusdra/newDir</span></b><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><br />
<!--[if !supportLineBreakNewLine]--><br />
<!--[endif]--><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">hadoop fs </span></b><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">-ls copyFromLocaal shakesspear.txt
/user/username/newDir</span><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><br />
<!--[if !supportLineBreakNewLine]--><br />
<!--[endif]--><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">Filesystem check
command:</span></b><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><br />
<!--[if !supportLineBreakNewLine]--><br />
<!--[endif]--><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">% <b>hadoop fsck </b>/
-files -blocks</span><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">in windows: <b>hadoop
fsck \ -files -blocks</b></span><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><br />
<!--[if !supportLineBreakNewLine]--><br />
<!--[endif]--><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><u><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">-copyToLocal:
</span></u></b><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<ul style="margin-top: 0in;" type="disc">
<li class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: justify; vertical-align: baseline;"><span style="font-family: "Arial","sans-serif"; font-size: 11.5pt; mso-fareast-font-family: "Times New Roman";">hadoop
fs </span><span style="color: #9900ff; font-family: "Arial","sans-serif"; font-size: 11.5pt; mso-fareast-font-family: "Times New Roman";">-copyToLocal </span><span style="color: blue; font-family: "Arial","sans-serif"; font-size: 11.5pt; mso-fareast-font-family: "Times New Roman";">hdfs://localhost/user/hadoop</span><span style="font-family: "Arial","sans-serif"; font-size: 11.5pt; mso-fareast-font-family: "Times New Roman";">/<b>test1.txt</b> C:\Users\prems.bist\Desktop\test.txt<o:p></o:p></span></li>
</ul>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><br />
<!--[if !supportLineBreakNewLine]--><br />
<!--[endif]--><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><u><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">-copyFromLocal:</span></u></b><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">hadoop fs </span><span style="color: #9900ff; font-family: "Arial","sans-serif"; font-size: 11.5pt; mso-fareast-font-family: "Times New Roman";">-copyFromLocal </span><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">D:\tutorials\test.txt</span><span style="color: blue; font-family: "Arial","sans-serif"; font-size: 11.5pt; mso-fareast-font-family: "Times New Roman";"> hdfs://localhost/user</span><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">/hadoop/test1.txt</span><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><br />
<!--[if !supportLineBreakNewLine]--><br />
<!--[endif]--><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><u><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">Listing
files inside the directory of hdfs:</span></u></b><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><br />
<!--[if !supportLineBreakNewLine]--><br />
<!--[endif]--><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">hadoop fs -ls
hdfs://localhost/user/hadoop/<b>yourFolder => </b>Enlists all the files at
yourFolder dir.</span><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><br />
<!--[if !supportLineBreakNewLine]--><br />
<!--[endif]--><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">can use the relative
path as well as:</span><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">hadoop fs -copyFromLocal
<b>input/docs/quangle.txt /user/tom/quangle.txt</b></span><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><br />
<!--[if !supportLineBreakNewLine]--><br />
<!--[endif]--><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><u><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">command
Examples in windows:</span></u></b><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><br />
<!--[if !supportLineBreakNewLine]--><br />
<!--[endif]--><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">hadoop fs -mkdir books</span></b><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><span style="font-family: Arial, sans-serif; font-size: 11.5pt;"> </span></b><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">//Creates directory book at C:\users\prems.bist <b>but </b>it
will not be seen thorough user
prems.bist</span><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">hadoop fs -ls</span></b><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><u><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">Example
2 -command :</span></u></b><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><br />
<!--[if !supportLineBreakNewLine]--><br />
<!--[endif]--><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">hadoop fs <b>-mkdir </b>input
//makes
directory named input</span><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">hadoop fs -ls input
//It
will so nothing as there is no files</span><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">hadoop fs <b>-put *.xml </b>input
//Puts all the files starting with .xml
in input directory</span><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><br />
<!--[if !supportLineBreakNewLine]--><br />
<!--[endif]--><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><span style="color: #9900ff; font-family: "Arial","sans-serif"; font-size: 11.5pt; mso-fareast-font-family: "Times New Roman";">output:</span></b><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">Found 1 items</span><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">drwxr-xr-x <b> -
</b>prems.bist <b>supergroup </b> 0
2014-03-13 13:09 /user/prems.bist/books</span><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><br />
<!--[if !supportLineBreakNewLine]--><br />
<!--[endif]--><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">Column first</span></b><span style="font-family: Arial, sans-serif; font-size: 11.5pt;"> -->filePermssion</span><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">Second column </span></b><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">=>replication factory which is (-) thats
means not defined yet.</span><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">Third column : </span></b><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">Owner </span><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">Fourth column :</span></b><span style="font-family: Arial, sans-serif; font-size: 11.5pt;"> group</span><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">Fifth column: </span></b><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">size of the file in byte 0 for dierctory</span><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">6th & seventh
column:</span></b><span style="font-family: Arial, sans-serif; font-size: 11.5pt;"> Last modified date
& time</span><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">8th Column: </span></b><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">Absolutely name of file or directory</span><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><u><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">Examples
3 - command Running jar through command line:</span></u></b><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><br />
<!--[if !supportLineBreakNewLine]--><br />
<!--[endif]--><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">Create directory</span></b><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt; text-indent: 0.5in;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">hadoop dfs -mkdir <b>hdfs:/inputFolder</b></span><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">Show directory</span></b><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">hadoop dfs -ls hdfs:/</span><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><br />
<!--[if !supportLineBreakNewLine]--><br />
<!--[endif]--><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">Copy the files from
localSystem</span></b><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">hadoop dfs
-copyFromLocal D:\SampleData\input hdfs:/inputFolder</span><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><br />
<!--[if !supportLineBreakNewLine]--><br />
<!--[endif]--><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">Run the Jar file </span></b><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">hadoop jar jarName
runningClassName inputFileLocation outputFileLocation </span><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">ex- </span><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, sans-serif; font-size: 8.5pt;">hadoop jar
D:\target\MapReduce-1.0-SNAPSHOT.jar com.impetus.hadoop.WordCount
hdfs:/wordCountFolder/sampleData hdfs:/outputFolder</span><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><br />
<!--[if !supportLineBreakNewLine]--><br />
<!--[endif]--><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">Viewing file output:</span></b><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">hadoop dfs -cat
/outputFolder/part-00000</span><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><u><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">List
all the files in root directory of local filesystem ie( </span></u></b><u><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">files of c drive<b>):</b></span></u><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><br />
<!--[if !supportLineBreakNewLine]--><br />
<!--[endif]--><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">hadoop fs -ls</span><b><span style="color: red; font-family: "Arial","sans-serif"; font-size: 11.5pt; mso-fareast-font-family: "Times New Roman";"> file:/// </span></b><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><u><span style="font-family: Arial, sans-serif; font-size: 14.5pt;">HDFS:</span></u></b><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">Distributed filesystems:</span></b><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<ul style="margin-top: 0in;" type="disc">
<li class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: justify; vertical-align: baseline;"><span style="font-family: "Arial","sans-serif"; font-size: 11.5pt; mso-fareast-font-family: "Times New Roman";">Filesystems
that manage the storage across a network of machines.<o:p></o:p></span></li>
</ul>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><br />
<!--[if !supportLineBreakNewLine]--><br />
<!--[endif]--><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">Commodity hardware:</span></b><span style="font-family: Arial, sans-serif; font-size: 11.5pt;"> Normal hardware devices</span><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">Streaming data access</span></b><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">: Time to read all dataset is more important
than reading a first one.</span><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">Low-latency data access:</span></b><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">Lots of small files</span></b><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">: Since the namenode holds filesystem metadata
in memory, the limit to the number of files in a filesystem is governed by the
amount of memory on the namenode.</span><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">Multiple writers,
arbitrary file modifications : </span></b><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">Files in HDFS may be written to by a single writer</span><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><u><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">Block:</span></u></b><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><br />
<!--[if !supportLineBreakNewLine]--><br />
<!--[endif]--><o:p></o:p></span></div>
<ul style="margin-top: 0in;" type="disc">
<li class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: justify; vertical-align: baseline;"><span style="font-family: "Arial","sans-serif"; font-size: 11.5pt; mso-fareast-font-family: "Times New Roman";">Is
the minimum amount of data that it a disk can read or write.<o:p></o:p></span></li>
<li class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: justify; vertical-align: baseline;"><span style="font-family: "Arial","sans-serif"; font-size: 11.5pt; mso-fareast-font-family: "Times New Roman";">File
system blocks are typically a few kilobytes in size, while disk blocks are
normally 512 bytes.<o:p></o:p></span></li>
<li class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: justify; vertical-align: baseline;"><span style="font-family: "Arial","sans-serif"; font-size: 11.5pt; mso-fareast-font-family: "Times New Roman";">HDFS,
too, has the concept of a block, but it is a much larger unit—64 MB. Like
in a file system for a single disk, files in HDFS are broken into
block-sized chunks,<o:p></o:p></span></li>
<li class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: justify; vertical-align: baseline;"><span style="font-family: "Arial","sans-serif"; font-size: 11.5pt; mso-fareast-font-family: "Times New Roman";">Which
are stored as independent units. HDFS blocks are large compared to disk
blocks, and the reason is to minimize the cost of seeks.<o:p></o:p></span></li>
<li class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: justify; vertical-align: baseline;"><span style="font-family: "Arial","sans-serif"; font-size: 11.5pt; mso-fareast-font-family: "Times New Roman";">A
quick calculation shows that if the seek time is around 10 ms, and the
transfer rate is 100 MB/s, then to make the seek time 1% of the transfer
time, we need to make the block size around 100 MB.<o:p></o:p></span></li>
<li class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: justify; vertical-align: baseline;"><span style="font-family: "Arial","sans-serif"; font-size: 11.5pt; mso-fareast-font-family: "Times New Roman";">+<o:p></o:p></span></li>
</ul>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">Fail over and Fencing:</span></b><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">The transition from the
active namenode to the standby is managed by a new entity in</span><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">The system called the<b>
failover controller</b>. The first implementation uses <b>ZooKeeper </b>to
ensure that only one name node is active.<b> Failover </b>may also be initiated
manually by an administrator, in the case of routine maintenance, for example.
This is known as a graceful failover, since the failover controller</span><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">Arranges an orderly
transition for both name nodes to switch roles. <b>STONITH </b>=>Shoot the
other node in the head.</span><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><br />
<!--[if !supportLineBreakNewLine]--><br />
<!--[endif]--><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">Default HDFS port</span></b><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">: 8020</span><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">org.apache.hadoop.fs.FileSystem
</span></b><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">represents a file system
in Hadoop.</span><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><u><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">Accessing
HDFS over Http:</span></u></b><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><br />
<!--[if !supportLineBreakNewLine]--><br />
<!--[endif]--><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">2 ways:</span><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">1) Using HDFS daemons
that server http request to clients</span><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">2) Using distributed
file system API’s (Using proxies)</span><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><br />
<!--[if !supportLineBreakNewLine]--><br />
<!--[endif]--><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">Hadoop file systems: </span></b><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><br />
<!--[if !supportLineBreakNewLine]--><br />
<!--[endif]--><o:p></o:p></span></div>
<table border="0" cellpadding="0" cellspacing="0" class="MsoNormalTable" style="border-collapse: collapse; mso-yfti-tbllook: 1184;">
<tbody>
<tr>
<td style="border: solid black 1.0pt; mso-border-alt: solid black .75pt; padding: 5.25pt 5.25pt 5.25pt 5.25pt;" valign="top"><div class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: justify;">
<b><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">Name</span></b><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
</td>
<td style="border-left: none; border: solid black 1.0pt; mso-border-alt: solid black .75pt; mso-border-left-alt: solid black .75pt; padding: 5.25pt 5.25pt 5.25pt 5.25pt;" valign="top"><div class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: justify;">
<b><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">URI
scheme</span></b><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
</td>
<td style="border-left: none; border: solid black 1.0pt; mso-border-alt: solid black .75pt; mso-border-left-alt: solid black .75pt; padding: 5.25pt 5.25pt 5.25pt 5.25pt;" valign="top"><div class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: justify;">
<b><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">Class</span></b><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
</td>
<td style="border-left: none; border: solid black 1.0pt; mso-border-alt: solid black .75pt; mso-border-left-alt: solid black .75pt; padding: 5.25pt 5.25pt 5.25pt 5.25pt;" valign="top"><div class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: justify;">
<b><span style="font-family: Arial, sans-serif; font-size: 11.5pt;">Description</span></b><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
</td>
</tr>
<tr>
<td style="border-top: none; border: solid black 1.0pt; mso-border-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 5.25pt 5.25pt 5.25pt 5.25pt;" valign="top"><div class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: justify;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">Local</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
</td>
<td style="border-bottom: solid black 1.0pt; border-left: none; border-right: solid black 1.0pt; border-top: none; mso-border-alt: solid black .75pt; mso-border-left-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 5.25pt 5.25pt 5.25pt 5.25pt;" valign="top"><div class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: justify;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">file</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
</td>
<td style="border-bottom: solid black 1.0pt; border-left: none; border-right: solid black 1.0pt; border-top: none; mso-border-alt: solid black .75pt; mso-border-left-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 5.25pt 5.25pt 5.25pt 5.25pt;" valign="top"><div class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: justify;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">fs.LocalFileSystem</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
</td>
<td style="border-bottom: solid black 1.0pt; border-left: none; border-right: solid black 1.0pt; border-top: none; mso-border-alt: solid black .75pt; mso-border-left-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 5.25pt 5.25pt 5.25pt 5.25pt;" valign="top"></td>
</tr>
<tr>
<td style="border-top: none; border: solid black 1.0pt; mso-border-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 5.25pt 5.25pt 5.25pt 5.25pt;" valign="top"><div class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: justify;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">HDFS</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
</td>
<td style="border-bottom: solid black 1.0pt; border-left: none; border-right: solid black 1.0pt; border-top: none; mso-border-alt: solid black .75pt; mso-border-left-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 5.25pt 5.25pt 5.25pt 5.25pt;" valign="top"><div class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: justify;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">hdfs</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
</td>
<td style="border-bottom: solid black 1.0pt; border-left: none; border-right: solid black 1.0pt; border-top: none; mso-border-alt: solid black .75pt; mso-border-left-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 5.25pt 5.25pt 5.25pt 5.25pt;" valign="top"><div class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: justify;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">hdfs.DistributedFileSystem</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
</td>
<td style="border-bottom: solid black 1.0pt; border-left: none; border-right: solid black 1.0pt; border-top: none; mso-border-alt: solid black .75pt; mso-border-left-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 5.25pt 5.25pt 5.25pt 5.25pt;" valign="top"></td>
</tr>
<tr>
<td style="border-top: none; border: solid black 1.0pt; mso-border-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 5.25pt 5.25pt 5.25pt 5.25pt;" valign="top"><div class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: justify;">
<span style="color: blue; font-family: "Arial","sans-serif"; font-size: 11.5pt; mso-fareast-font-family: "Times New Roman";">HFTP</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
</td>
<td style="border-bottom: solid black 1.0pt; border-left: none; border-right: solid black 1.0pt; border-top: none; mso-border-alt: solid black .75pt; mso-border-left-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 5.25pt 5.25pt 5.25pt 5.25pt;" valign="top"><div class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: justify;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">hftp</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
</td>
<td style="border-bottom: solid black 1.0pt; border-left: none; border-right: solid black 1.0pt; border-top: none; mso-border-alt: solid black .75pt; mso-border-left-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 5.25pt 5.25pt 5.25pt 5.25pt;" valign="top"><div class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: justify;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">hdfs.HftpFileSystem</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
</td>
<td style="border-bottom: solid black 1.0pt; border-left: none; border-right: solid black 1.0pt; border-top: none; mso-border-alt: solid black .75pt; mso-border-left-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 5.25pt 5.25pt 5.25pt 5.25pt;" valign="top"><div class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: justify;">
<span style="font-family: Arial, sans-serif; font-size: 9pt;">Provides read only
access to HDFS over http</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
</td>
</tr>
<tr>
<td style="border-top: none; border: solid black 1.0pt; mso-border-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 5.25pt 5.25pt 5.25pt 5.25pt;" valign="top"><div class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: justify;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">HSFTP</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
</td>
<td style="border-bottom: solid black 1.0pt; border-left: none; border-right: solid black 1.0pt; border-top: none; mso-border-alt: solid black .75pt; mso-border-left-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 5.25pt 5.25pt 5.25pt 5.25pt;" valign="top"><div class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: justify;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">hsftp</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
</td>
<td style="border-bottom: solid black 1.0pt; border-left: none; border-right: solid black 1.0pt; border-top: none; mso-border-alt: solid black .75pt; mso-border-left-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 5.25pt 5.25pt 5.25pt 5.25pt;" valign="top"><div class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: justify;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">hdfs.HsftpFileSystem</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
</td>
<td style="border-bottom: solid black 1.0pt; border-left: none; border-right: solid black 1.0pt; border-top: none; mso-border-alt: solid black .75pt; mso-border-left-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 5.25pt 5.25pt 5.25pt 5.25pt;" valign="top"><div class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: justify;">
<span style="font-family: Arial, sans-serif; font-size: 9pt;">Providing read-only
access to HDFS over HTTPS.</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
</td>
</tr>
<tr>
<td style="border-top: none; border: solid black 1.0pt; mso-border-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 5.25pt 5.25pt 5.25pt 5.25pt;" valign="top"><div class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: justify;">
<b><span style="color: #9900ff; font-family: "Arial","sans-serif"; font-size: 11.5pt; mso-fareast-font-family: "Times New Roman";">WebHDFS</span></b><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
</td>
<td style="border-bottom: solid black 1.0pt; border-left: none; border-right: solid black 1.0pt; border-top: none; mso-border-alt: solid black .75pt; mso-border-left-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 5.25pt 5.25pt 5.25pt 5.25pt;" valign="top"><div class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: justify;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">webhdfs</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
</td>
<td style="border-bottom: solid black 1.0pt; border-left: none; border-right: solid black 1.0pt; border-top: none; mso-border-alt: solid black .75pt; mso-border-left-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 5.25pt 5.25pt 5.25pt 5.25pt;" valign="top"><div class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: justify;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">hdfs.web.WebHdfsFile</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: justify;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">System</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
</td>
<td style="border-bottom: solid black 1.0pt; border-left: none; border-right: solid black 1.0pt; border-top: none; mso-border-alt: solid black .75pt; mso-border-left-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 5.25pt 5.25pt 5.25pt 5.25pt;" valign="top"><div class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: justify;">
<span style="font-family: Arial, sans-serif; font-size: 9pt;">Secured read write
access to http.</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
</td>
</tr>
<tr>
<td style="border-top: none; border: solid black 1.0pt; mso-border-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 5.25pt 5.25pt 5.25pt 5.25pt;" valign="top"><div class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: justify;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">HAR</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
</td>
<td style="border-bottom: solid black 1.0pt; border-left: none; border-right: solid black 1.0pt; border-top: none; mso-border-alt: solid black .75pt; mso-border-left-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 5.25pt 5.25pt 5.25pt 5.25pt;" valign="top"><div class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: justify;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">har</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
</td>
<td style="border-bottom: solid black 1.0pt; border-left: none; border-right: solid black 1.0pt; border-top: none; mso-border-alt: solid black .75pt; mso-border-left-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 5.25pt 5.25pt 5.25pt 5.25pt;" valign="top"><div class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: justify;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">fs.HarFileSystem</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
</td>
<td style="border-bottom: solid black 1.0pt; border-left: none; border-right: solid black 1.0pt; border-top: none; mso-border-alt: solid black .75pt; mso-border-left-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 5.25pt 5.25pt 5.25pt 5.25pt;" valign="top"><div class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: justify;">
<span style="font-family: Arial, sans-serif; font-size: 9pt;">Archiving </span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
</td>
</tr>
<tr>
<td style="border-top: none; border: solid black 1.0pt; mso-border-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 5.25pt 5.25pt 5.25pt 5.25pt;" valign="top"><div class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: justify;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">KFS</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
</td>
<td style="border-bottom: solid black 1.0pt; border-left: none; border-right: solid black 1.0pt; border-top: none; mso-border-alt: solid black .75pt; mso-border-left-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 5.25pt 5.25pt 5.25pt 5.25pt;" valign="top"><div class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: justify;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">kfs</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
</td>
<td style="border-bottom: solid black 1.0pt; border-left: none; border-right: solid black 1.0pt; border-top: none; mso-border-alt: solid black .75pt; mso-border-left-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 5.25pt 5.25pt 5.25pt 5.25pt;" valign="top"><div class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: justify;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">fs.kfs.KosmosFileSystem</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
</td>
<td style="border-bottom: solid black 1.0pt; border-left: none; border-right: solid black 1.0pt; border-top: none; mso-border-alt: solid black .75pt; mso-border-left-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 5.25pt 5.25pt 5.25pt 5.25pt;" valign="top"><div class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: justify;">
<span style="font-family: Arial, sans-serif; font-size: 9pt;">CloudStore writtenn in
C++</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
</td>
</tr>
<tr>
<td style="border-top: none; border: solid black 1.0pt; mso-border-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 5.25pt 5.25pt 5.25pt 5.25pt;" valign="top"><div class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: justify;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">FTP</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
</td>
<td style="border-bottom: solid black 1.0pt; border-left: none; border-right: solid black 1.0pt; border-top: none; mso-border-alt: solid black .75pt; mso-border-left-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 5.25pt 5.25pt 5.25pt 5.25pt;" valign="top"><div class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: justify;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">ftp</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
</td>
<td style="border-bottom: solid black 1.0pt; border-left: none; border-right: solid black 1.0pt; border-top: none; mso-border-alt: solid black .75pt; mso-border-left-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 5.25pt 5.25pt 5.25pt 5.25pt;" valign="top"><div class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: justify;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">fs.ftp.FTPFileSystem</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
</td>
<td style="border-bottom: solid black 1.0pt; border-left: none; border-right: solid black 1.0pt; border-top: none; mso-border-alt: solid black .75pt; mso-border-left-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 5.25pt 5.25pt 5.25pt 5.25pt;" valign="top"><div class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: justify;">
<span style="font-family: Arial, sans-serif; font-size: 9pt;">FTP server backed file
system</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
</td>
</tr>
<tr>
<td style="border-top: none; border: solid black 1.0pt; mso-border-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 5.25pt 5.25pt 5.25pt 5.25pt;" valign="top"><div class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: justify;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">S3</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
</td>
<td style="border-bottom: solid black 1.0pt; border-left: none; border-right: solid black 1.0pt; border-top: none; mso-border-alt: solid black .75pt; mso-border-left-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 5.25pt 5.25pt 5.25pt 5.25pt;" valign="top"><div class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: justify;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">s3</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
</td>
<td style="border-bottom: solid black 1.0pt; border-left: none; border-right: solid black 1.0pt; border-top: none; mso-border-alt: solid black .75pt; mso-border-left-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 5.25pt 5.25pt 5.25pt 5.25pt;" valign="top"></td>
<td style="border-bottom: solid black 1.0pt; border-left: none; border-right: solid black 1.0pt; border-top: none; mso-border-alt: solid black .75pt; mso-border-left-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 5.25pt 5.25pt 5.25pt 5.25pt;" valign="top"><div class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: justify;">
<span style="font-family: Arial, sans-serif; font-size: 9pt;">Amazon backed</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
</td>
</tr>
<tr>
<td style="border-top: none; border: solid black 1.0pt; mso-border-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 5.25pt 5.25pt 5.25pt 5.25pt;" valign="top"><div class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: justify;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">Distributed</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: justify;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">RAID</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
</td>
<td style="border-bottom: solid black 1.0pt; border-left: none; border-right: solid black 1.0pt; border-top: none; mso-border-alt: solid black .75pt; mso-border-left-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 5.25pt 5.25pt 5.25pt 5.25pt;" valign="top"><div class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: justify;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">hdfs</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
</td>
<td style="border-bottom: solid black 1.0pt; border-left: none; border-right: solid black 1.0pt; border-top: none; mso-border-alt: solid black .75pt; mso-border-left-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 5.25pt 5.25pt 5.25pt 5.25pt;" valign="top"><div class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: justify;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">hdfs.DistributedRaidFi</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: justify;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">leSystem</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
</td>
<td style="border-bottom: solid black 1.0pt; border-left: none; border-right: solid black 1.0pt; border-top: none; mso-border-alt: solid black .75pt; mso-border-left-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 5.25pt 5.25pt 5.25pt 5.25pt;" valign="top"><div class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: justify;">
<a href="https://www.blogger.com/blogger.g?blogID=3586645045303501566" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"></a><a href="https://www.blogger.com/blogger.g?blogID=3586645045303501566" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"></a><a href="https://www.blogger.com/blogger.g?blogID=3586645045303501566" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"></a><span style="font-family: Arial, sans-serif; font-size: 9pt;">“RAID” version of HDFS</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
</td>
</tr>
<tr>
<td style="border-top: none; border: solid black 1.0pt; mso-border-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 5.25pt 5.25pt 5.25pt 5.25pt;" valign="top"><div class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: justify;">
<b><span style="color: #9900ff; font-family: "Arial","sans-serif"; font-size: 11.5pt; mso-fareast-font-family: "Times New Roman";">View</span></b><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
</td>
<td style="border-bottom: solid black 1.0pt; border-left: none; border-right: solid black 1.0pt; border-top: none; mso-border-alt: solid black .75pt; mso-border-left-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 5.25pt 5.25pt 5.25pt 5.25pt;" valign="top"><div class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: justify;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">viewfs</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
</td>
<td style="border-bottom: solid black 1.0pt; border-left: none; border-right: solid black 1.0pt; border-top: none; mso-border-alt: solid black .75pt; mso-border-left-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 5.25pt 5.25pt 5.25pt 5.25pt;" valign="top"><div class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: justify;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">viewfs.ViewFileSystem</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
</td>
<td style="border-bottom: solid black 1.0pt; border-left: none; border-right: solid black 1.0pt; border-top: none; mso-border-alt: solid black .75pt; mso-border-left-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; padding: 5.25pt 5.25pt 5.25pt 5.25pt;" valign="top"><div class="MsoNormal" style="margin-bottom: 0.0001pt; text-align: justify;">
<span style="font-family: Arial, sans-serif; font-size: 9pt;">client-side mount
table for other Hadoop filesystems</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
</td>
</tr>
</tbody></table>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><br />
<!--[if !supportLineBreakNewLine]--><b>File System functions:</b><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">FilSystem dfs <b>= </b>FileSystem.get(config);</span><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">getWorkingDirectory <b>=></b>
Returns working path</span><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">delete </span><span style="font-family: 'Cambria Math', serif; font-size: 11.5pt;">⇒</span><span style="font-family: Arial, sans-serif; font-size: 11.5pt;"> To delete file.</span><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">createNewFile() </span><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">exists(src)</span><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">getDefaultBlockSize()</span><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">available() //returns
estimated number of byte remaining </span><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">//Create directory</span><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">hadoop dfs -mkdir
hdfs:/inputFolder</span><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">//Show directory</span><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">fs:/ //Copy the files<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">hadoop dfs -ls h<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">d from localSystem<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">mLocal
D:\SampleData\input hdfs:/inputFolder //Run the Jar file<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">hadoop dfs -copyFr<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">o <o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">hadoop jar jarName
runningClassName inputFileLocation outputFileLocation <o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">hdfs:/wordCountFolder/sampleData
hdfs:/outputFolder //output Can be seen as : hadoop dfs -cat
/outputFolder/part-00000<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Arial, sans-serif; font-size: 11.5pt;">hadoop jar
D:\target\MapReduce-1.0-SNAPSHOT.jar com.impetus.hadoop.WordCount<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal">
<b><span style="color: #073763; font-family: "Arial","sans-serif"; font-size: 11.5pt; mso-fareast-font-family: "Times New Roman";">References: Hadoop Defnitive Guide</span></b><b><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></b></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><i><span style="color: #073763; font-family: "Arial","sans-serif"; font-size: 11.5pt; mso-fareast-font-family: "Times New Roman";">Happy Learning
cheers.!!</span></i></b><span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal">
<br /></div>
</div>
</div>
</div>
Anonymoushttp://www.blogger.com/profile/10713264593334966481noreply@blogger.com1tag:blogger.com,1999:blog-3586645045303501566.post-6156664938771789882014-06-26T06:29:00.000-07:002014-06-26T06:29:19.615-07:00Installing Activity Designer Plugin<div dir="ltr" style="text-align: left;" trbidi="on">
Activiti Designer is an open-source workflow engine eclipse plugin used to design business workflow processes.<br />
<br />
<br />
<div style="text-align: justify;">
Follow these steps to install the plugin in eclipse.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
</div>
<ul>
<li><b>Help </b>> Install New Software</li>
<li>Click <b>Add</b></li>
<li>Fill in the name field with <b>Activiti BPMN 2.0 designer</b>, and fill in the location field with <b>http://activiti.org/designer/update/</b></li>
</ul>
<br />
<div style="text-align: justify;">
<br /></div>
<br />
<br />
Cheers !!<br />
Happy Learning<br />
<br /></div>
Anonymoushttp://www.blogger.com/profile/10713264593334966481noreply@blogger.com0tag:blogger.com,1999:blog-3586645045303501566.post-62808130693020548132014-06-12T07:00:00.000-07:002014-06-12T07:02:35.077-07:00Custom input split and custom NLineInputFormat Record in Hadoop<div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="MsoNormal" style="text-align: justify;">
Hadoop by default splits an input data file into 64MB Of
multiple logical partitions. Each of these chunk data files will be passed to
individual mappers, thus providing the data parallelism. If the file size is
less than 64MB then only one mapper will be used for computation. Let’s
consider a scenario where we have a file less than 64MB but the logical computation
within the file is too high. If this is to be handled by a single mapper, it
will take significant time. Let’s say we
have 10 node cluster. Thus we want at least 10 mapper to be run, one on each
node so that the overall computation time could be significantly reduced by 10 times.
Furthermore, it is assumed that network transfer time << total computation
time. <o:p></o:p></div>
<br />
<div class="MsoNormal" style="text-align: justify;">
There are multiple ways to custom split the file in hadoop. You
can set your custom split size through the terminal while running the job,
setting the configuration property at run time or at configuration fie, & overriding
the method at input format class. Let’s look at briefly how you can do it.<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal" style="text-align: justify;">
There are multiple ways to custom split the file in hadoop. You
can set your custom split size through the terminal while running the job,
setting the configuration property at run time or at configuration fie, & overriding
the method at input format class. Let’s look at briefly how you can do it.<o:p></o:p></div>
<div class="MsoNormal" style="text-align: justify;">
<br /></div>
<div class="MsoListParagraph" style="margin-left: .25in; mso-add-space: auto; mso-list: l0 level1 lfo1; text-indent: -.25in;">
<!--[if !supportLists]--><b>1)<span style="font-size: 7pt; font-weight: normal;"> </span></b><!--[endif]--><b>Setting split size using terminal:<o:p></o:p></b></div>
<div class="MsoNormal" style="text-align: justify;">
hadoop jar movie.jar <span style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: Arial, sans-serif; font-size: 10pt; line-height: 107%;">-D</span> mapred.max.split.size<span style="white-space: pre-wrap;">=8388608 </span>inputFile.txt
outputLocation<o:p></o:p></div>
<div class="MsoNormal">
</div>
<div class="MsoNormal" style="text-align: justify;">
As in the above command , the property <b><span style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: Arial, sans-serif; font-size: 10pt; line-height: 107%;">mapred.max.split.size</span><span style="white-space: pre-wrap;"> </span></b><span style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: Arial, sans-serif; font-size: 10pt; line-height: 107%;">is used to specify the particular custom split value
for the particular job. The parameter <b>–D </b>is used set any configuration
properties through the terminal.<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: Arial, sans-serif; font-size: 10pt; line-height: 107%;"><br /></span></div>
<div class="MsoListParagraph" style="margin-left: .25in; mso-add-space: auto; mso-list: l0 level1 lfo1; text-indent: -.25in;">
<b>2)<span style="font-size: 7pt; font-weight: normal;"> </span></b><!--[endif]--><b>Setting split size through Configuration
file:<o:p></o:p></b></div>
<div class="MsoListParagraph" style="margin-left: .25in; mso-add-space: auto; mso-list: l0 level1 lfo1; text-indent: -.25in;">
<b><br /></b></div>
<div class="MsoNormal">
<span style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: Arial, sans-serif; font-size: 10pt; line-height: 107%;">
<!-- HTML generated using hilite.me --></span>
<br />
<div style="background: #ffffff; border-width: .1em .1em .1em .8em; border: solid green; overflow: auto; padding: .2em .6em; width: auto;">
<pre style="line-height: 125%; margin: 0;"><span style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: Arial, sans-serif; font-size: 10pt; line-height: 107%;"> conf.<span style="color: red;">set</span>(<span style="color: blue;">"mapred.max.split.size"</span>, MAX_SPLIT_SIZE);
conf.<span style="color: red;">set</span>(<span style="color: blue;">"mapred.min.split.size"</span>, MIN_SPLIT_SIZE);
JobConf jobConf = <span style="color: navy; font-weight: bold;">new</span> JobConf(conf, MaxTemperatureDriver.<span style="color: red;">class</span>);
Job job = <span style="color: navy; font-weight: bold;">new</span> Job(jobConf);
</span></pre>
</div>
<span style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: Arial, sans-serif; font-size: 10pt; line-height: 107%;">
</span>
<br />
<div>
<br />
<div class="MsoNormal">
<div style="text-align: justify;">
<span style="background: white;">Take an instance of
configuration file and set the property <span style="color: #9900ff;">mapred.max.split.size
</span>to the specified no of bytes. Here MAX_SPLIT_SIZE is any predefined
value in bytes. After setting the
configuration, take an instance of <b>JobConf
</b>which will be used to configure all the properties related to particular
job. Then specify job configuration instance as a parameter to a specified job.<o:p></o:p></span></div>
<div style="text-align: justify;">
<span style="background: white;"><br /></span></div>
<div style="text-align: justify;">
<span style="background: white;"></span></div>
<div class="MsoListParagraph" style="margin-left: .25in; mso-add-space: auto; mso-list: l0 level1 lfo1; text-indent: -.25in;">
<b>3)<span style="font-size: 7pt; font-weight: normal;"> </span></b><!--[endif]--><b>Setting split size through
CustomInputFormat Class:<o:p></o:p></b></div>
<div class="MsoListParagraph" style="margin-left: .25in; mso-add-space: auto; mso-list: l0 level1 lfo1; text-indent: -.25in;">
<b><br /></b></div>
<div class="MsoNormal">
Any class which extends FileInputFormat class can override
computeSplitSize() method . This method has to return a <b>long</b> value which will determine the maximum split size length in
terms of bytes.<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
</div>
</div>
</div>
<!-- HTML generated using hilite.me --><br />
<div style="background: #ffffff; border-width: .1em .1em .1em .8em; border: solid green; overflow: auto; padding: .2em .6em; width: auto;">
<pre style="line-height: 125%; margin: 0;">@Override
<span style="color: navy; font-weight: bold;">protected</span> <span style="color: navy; font-weight: bold;">long</span> computeSplitSize(<span style="color: navy; font-weight: bold;">long</span> blockSize, <span style="color: navy; font-weight: bold;">long</span> minSize, <span style="color: navy; font-weight: bold;">long</span> maxSize) {
<span style="color: navy; font-weight: bold;">return</span> <span style="color: navy; font-weight: bold;">super</span>.<span style="color: red;">computeSplitSize</span>(blockSize, minSize, MAX_SPLIT_SIZE);
}
</pre>
</div>
<div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
Here is a simple maximum temperature file example for custom
split and NLineRecord Reader.<o:p></o:p></div>
<br />
<div class="MsoNormal">
Directory Structure:<o:p></o:p></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgIDI7TVYMFHHHdIliURcIrPVlHZYTNyytsnpKrTQPBsqHE_e02JnHeWCpyIwGyI8AKYf9PKi91lybIcO4caoag45rdsH0YrCKfsnUhbcqqG5OloO0iHh215Vmz31YBSRX2mElBcZiP_LA/s1600/directorySt.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgIDI7TVYMFHHHdIliURcIrPVlHZYTNyytsnpKrTQPBsqHE_e02JnHeWCpyIwGyI8AKYf9PKi91lybIcO4caoag45rdsH0YrCKfsnUhbcqqG5OloO0iHh215Vmz31YBSRX2mElBcZiP_LA/s1600/directorySt.png" /></a></div>
<div class="MsoNormal">
<br /></div>
</div>
<div>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<b>MaxTemperatureDriver.java</b></div>
<!-- HTML generated using hilite.me --><br />
<div style="background: #ffffff; border-width: .0.01em .0.01em .0.01em .8em; border: solid green; overflow: auto; padding: .2em .6em; width: auto;">
<pre style="line-height: 125%; margin: 0;"><span style="color: navy; font-weight: bold;">package</span> com.<span style="color: red;">HdMovie</span>.<span style="color: red;">customFormatter</span>;
<span style="color: navy; font-weight: bold;">import</span> org.apache.hadoop.conf.Configuration;
<span style="color: navy; font-weight: bold;">import</span> org.apache.hadoop.conf.Configured;
<span style="color: navy; font-weight: bold;">import</span> org.apache.hadoop.fs.Path;
<span style="color: navy; font-weight: bold;">import</span> org.apache.hadoop.io.IntWritable;
<span style="color: navy; font-weight: bold;">import</span> org.apache.hadoop.io.Text;
<span style="color: navy; font-weight: bold;">import</span> org.apache.hadoop.mapred.JobConf;
<span style="color: navy; font-weight: bold;">import</span> org.apache.hadoop.mapreduce.Job;
<span style="color: navy; font-weight: bold;">import</span> org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
<span style="color: navy; font-weight: bold;">import</span> org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
<span style="color: navy; font-weight: bold;">import</span> org.apache.hadoop.util.Tool;
<span style="color: navy; font-weight: bold;">import</span> org.apache.hadoop.util.ToolRunner;
<span style="color: #008800; font-style: italic;">/*This class is responsible for running map reduce job*/</span>
<span style="color: navy; font-weight: bold;">public</span> <span style="color: navy; font-weight: bold;">class</span> MaxTemperatureDriver <span style="color: navy; font-weight: bold;">extends</span> Configured <span style="color: navy; font-weight: bold;">implements</span> Tool{
<span style="color: navy; font-weight: bold;">private</span> <span style="color: navy; font-weight: bold;">static</span> <span style="color: navy; font-weight: bold;">final</span> String MAX_SPLIT_SIZE = <span style="color: blue;">"8388608"</span>;
<span style="color: navy; font-weight: bold;">private</span> <span style="color: navy; font-weight: bold;">static</span> <span style="color: navy; font-weight: bold;">final</span> String MIN_SPLIT_SIZE = <span style="color: blue;">"0"</span>;
<span style="color: navy; font-weight: bold;">public</span> <span style="color: navy; font-weight: bold;">int</span> run(String[] args) <span style="color: navy; font-weight: bold;">throws</span> Exception
{
<span style="color: navy; font-weight: bold;">if</span>(args.<span style="color: red;">length</span> !=<span style="color: blue;">2</span>) {
System.<span style="color: red;">err</span>.<span style="color: red;">println</span>(<span style="color: blue;">"Usage: MaxTemperatureDriver <input path> <outputpath>"</span>);
System.<span style="color: red;">exit</span>(-<span style="color: blue;">1</span>);
}
Configuration conf = getConf();
conf.<span style="color: red;">setBoolean</span>(<span style="color: blue;">"mapred.task.profile"</span>, <span style="color: navy; font-weight: bold;">true</span>);
conf.<span style="color: red;">set</span>(<span style="color: blue;">"mapred.task.profile.params"</span>, <span style="color: blue;">"-agentlib:hprof=cpu=samples,"</span> +
<span style="color: blue;">"heap=sites,depth=6,force=n,thread=y,verbose=n,file=%s"</span>);
conf.<span style="color: red;">set</span>(<span style="color: blue;">"mapred.task.profile.maps"</span>, <span style="color: blue;">"0-2"</span>);
conf.<span style="color: red;">set</span>(<span style="color: blue;">"mapred.task.profile.reduces"</span>, <span style="color: blue;">""</span>); <span style="color: #008800; font-style: italic;">// no reduces</span>
<span style="color: #008800; font-style: italic;">//conf.set("mapred.max.split.size", MAX_SPLIT_SIZE);</span>
<span style="color: #008800; font-style: italic;">//conf.set("mapred.min.split.size", MIN_SPLIT_SIZE);</span>
JobConf jobConf = <span style="color: navy; font-weight: bold;">new</span> JobConf(conf, MaxTemperatureDriver.<span style="color: red;">class</span>);
<span style="color: #008800; font-style: italic;">//Setting a job</span>
Job job = <span style="color: navy; font-weight: bold;">new</span> Job(jobConf);
job.<span style="color: red;">setJarByClass</span>(MaxTemperatureDriver.<span style="color: red;">class</span>);
job.<span style="color: red;">setJobName</span>(<span style="color: blue;">"Max Temperature"</span>);
job.<span style="color: red;">getConfiguration</span>();
<span style="color: #008800; font-style: italic;">/**</span>
<span style="color: #008800; font-style: italic;"> * If we want to enable compression of map output</span>
<span style="color: #008800; font-style: italic;"> * We can use the below configuration</span>
<span style="color: #008800; font-style: italic;"> * Libraries can be GzipCodec , LzoCodec,SnappyCodec use following:</span>
<span style="color: #008800; font-style: italic;"> * job.getConfiguration().setBoolean("mapred.compress.map.output", true);</span>
<span style="color: #008800; font-style: italic;"> * job.getConfiguration().setClass("mapred.map.output.compression.codec", GzipCodec.class, CompressionCodec.class);</span>
<span style="color: #008800; font-style: italic;"> */</span>
<span style="color: #008800; font-style: italic;">//Adding input path of the file</span>
FileInputFormat.<span style="color: red;">addInputPath</span>(job, <span style="color: navy; font-weight: bold;">new</span> Path(args[<span style="color: blue;">0</span>]));
job.<span style="color: red;">setInputFormatClass</span>(NLinesInputFormat.<span style="color: red;">class</span>);
<span style="color: #008800; font-style: italic;">//Set output directory </span>
FileOutputFormat.<span style="color: red;">setOutputPath</span>(job,<span style="color: navy; font-weight: bold;">new</span> Path(args[<span style="color: blue;">1</span>]));
job.<span style="color: red;">setMapperClass</span>(MaxTemperatureMapper.<span style="color: red;">class</span>);
job.<span style="color: red;">setReducerClass</span>(MaxTemperatureReducer.<span style="color: red;">class</span>);
job.<span style="color: red;">setOutputKeyClass</span>(Text.<span style="color: red;">class</span>);
job.<span style="color: red;">setOutputValueClass</span>(IntWritable.<span style="color: red;">class</span>);
System.<span style="color: red;">exit</span>(job.<span style="color: red;">waitForCompletion</span>(<span style="color: navy; font-weight: bold;">true</span>) ? <span style="color: blue;">0</span>:<span style="color: blue;">1</span>);
<span style="color: navy; font-weight: bold;">boolean</span> success = job.<span style="color: red;">waitForCompletion</span>(<span style="color: navy; font-weight: bold;">true</span>);
<span style="color: navy; font-weight: bold;">return</span> success ? <span style="color: blue;">0</span> : <span style="color: blue;">1</span>;
}
<span style="color: navy; font-weight: bold;">public</span> <span style="color: navy; font-weight: bold;">static</span> <span style="color: navy; font-weight: bold;">void</span> main(String[] args) <span style="color: navy; font-weight: bold;">throws</span> Exception {
MaxTemperatureDriver driver = <span style="color: navy; font-weight: bold;">new</span> MaxTemperatureDriver();
<span style="color: navy; font-weight: bold;">int</span> exitCode = ToolRunner.<span style="color: red;">run</span>(driver, args);
System.<span style="color: red;">exit</span>(exitCode);
}
}
</pre>
</div>
<div>
<b><br /></b>
<b>MaxTemperatureMapper.java
</b><br />
<b><br /></b></div>
</div>
<div style="background: #ffffff; border-width: .0.01em .0.01em .0.01em .8em; border: solid green; overflow: auto; padding: .2em .6em; width: auto;">
<pre style="line-height: 125%; margin: 0;"><span style="color: navy; font-weight: bold;">package</span> com.<span style="color: red;">HdMovie</span>.<span style="color: red;">customFormatter</span>;
<span style="color: navy; font-weight: bold;">import</span> java.io.IOException;
<span style="color: navy; font-weight: bold;">import</span> org.apache.hadoop.io.IntWritable;
<span style="color: navy; font-weight: bold;">import</span> org.apache.hadoop.io.LongWritable;
<span style="color: navy; font-weight: bold;">import</span> org.apache.hadoop.io.Text;
<span style="color: navy; font-weight: bold;">import</span> org.apache.hadoop.mapreduce.Mapper;
<span style="color: navy; font-weight: bold;">import</span> org.apache.log4j.Level;
<span style="color: navy; font-weight: bold;">import</span> org.apache.log4j.Logger;
<span style="color: navy; font-weight: bold;">public</span> <span style="color: navy; font-weight: bold;">class</span> MaxTemperatureMapper <span style="color: navy; font-weight: bold;">extends</span>
Mapper<LongWritable, Text, Text, IntWritable> {
<span style="color: navy; font-weight: bold;">private</span> <span style="color: navy; font-weight: bold;">static</span> <span style="color: navy; font-weight: bold;">final</span> <span style="color: navy; font-weight: bold;">int</span> MISSING = <span style="color: blue;">9999</span>;
<span style="color: navy; font-weight: bold;">static</span> Logger log = Logger.<span style="color: red;">getLogger</span>(MaxTemperatureMapper.<span style="color: red;">class</span>);
@Override
<span style="color: navy; font-weight: bold;">public</span> <span style="color: navy; font-weight: bold;">void</span> map(LongWritable key, Text value, Context context)
<span style="color: navy; font-weight: bold;">throws</span> IOException, InterruptedException {
System.<span style="color: red;">out</span>.<span style="color: red;">println</span>(<span style="color: blue;">"Map key:"</span>+key);
log.<span style="color: red;">setLevel</span>(Level.<span style="color: red;">INFO</span>);
log.<span style="color: red;">info</span>(<span style="color: blue;">"Map key:-"</span>+key);
log.<span style="color: red;">debug</span>(<span style="color: blue;">"Map key:-"</span>+key);
String lines = value.<span style="color: red;">toString</span>();
String []lineArr = lines.<span style="color: red;">split</span>(<span style="color: blue;">"\n"</span>);
<span style="color: navy; font-weight: bold;">int</span> lcount = lineArr.<span style="color: red;">length</span>;
<span style="color: navy; font-weight: bold;">for</span> (String line : lineArr) {
line = value.<span style="color: red;">toString</span>(); <span style="color: #008800; font-style: italic;">//convert a value to string</span>
String year = line.<span style="color: red;">substring</span>(<span style="color: blue;">15</span>, <span style="color: blue;">19</span>);
<span style="color: navy; font-weight: bold;">int</span> airTemperature;
<span style="color: navy; font-weight: bold;">try</span>{
<span style="color: navy; font-weight: bold;">if</span> (line.<span style="color: red;">charAt</span>(<span style="color: blue;">87</span>) == <span style="color: purple;">'+'</span>) { <span style="color: #008800; font-style: italic;">// parseInt doesn't like leading plus</span>
<span style="color: #008800; font-style: italic;">// signs</span>
airTemperature = Integer.<span style="color: red;">parseInt</span>(line.<span style="color: red;">substring</span>(<span style="color: blue;">88</span>, <span style="color: blue;">92</span>));
} <span style="color: navy; font-weight: bold;">else</span> {
airTemperature = Integer.<span style="color: red;">parseInt</span>(line.<span style="color: red;">substring</span>(<span style="color: blue;">87</span>, <span style="color: blue;">92</span>));
}
}<span style="color: navy; font-weight: bold;">catch</span>(NumberFormatException e){
log.<span style="color: red;">error</span>(<span style="color: blue;">"Error formatting number for given string.."</span>);
airTemperature = <span style="color: blue;">0</span>;
}
String quality = line.<span style="color: red;">substring</span>(<span style="color: blue;">92</span>, <span style="color: blue;">93</span>);<span style="color: #008800; font-style: italic;">//begin index inclusive, end index is exclusive</span>
<span style="color: navy; font-weight: bold;">if</span> (airTemperature != MISSING && quality.<span style="color: red;">matches</span>(<span style="color: blue;">"[01459]"</span>)) {
context.<span style="color: red;">write</span>(<span style="color: navy; font-weight: bold;">new</span> Text(year), <span style="color: navy; font-weight: bold;">new</span> IntWritable(airTemperature));
}
}
}
}
</pre>
</div>
<div class="MsoNormal">
<b><br /></b>
<b>MaxTemperatureReducer.java<o:p></o:p></b><br />
<b><br /></b></div>
</div>
<!-- HTML generated using hilite.me --><br />
<div style="background: #ffffff; border-width: .0.01em .0.01em .0.01em .8em; border: solid green; overflow: auto; padding: .2em .6em; width: auto;">
<pre style="line-height: 125%; margin: 0;"><span style="color: navy; font-weight: bold;">package</span> com.<span style="color: red;">HdMovie</span>.<span style="color: red;">customFormatter</span>;
<span style="color: navy; font-weight: bold;">import</span> java.io.IOException;
<span style="color: navy; font-weight: bold;">import</span> org.apache.hadoop.io.LongWritable;
<span style="color: navy; font-weight: bold;">import</span> org.apache.hadoop.io.Text;
<span style="color: navy; font-weight: bold;">import</span> org.apache.hadoop.mapreduce.InputSplit;
<span style="color: navy; font-weight: bold;">import</span> org.apache.hadoop.mapreduce.RecordReader;
<span style="color: navy; font-weight: bold;">import</span> org.apache.hadoop.mapreduce.TaskAttemptContext;
<span style="color: navy; font-weight: bold;">import</span> org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
<span style="color: navy; font-weight: bold;">public</span> <span style="color: navy; font-weight: bold;">class</span> NLinesInputFormat <span style="color: navy; font-weight: bold;">extends</span> FileInputFormat<LongWritable,Text> {
<span style="color: navy; font-weight: bold;">private</span> <span style="color: navy; font-weight: bold;">static</span> <span style="color: navy; font-weight: bold;">final</span> <span style="color: navy; font-weight: bold;">long</span> MAX_SPLIT_SIZE = <span style="color: blue;">8388608</span>; <span style="color: #008800; font-style: italic;">//8MB SPLIT</span>
@Override
<span style="color: navy; font-weight: bold;">public</span> RecordReader<LongWritable,Text> createRecordReader(InputSplit inputsplit,
TaskAttemptContext taskattemptcontext) <span style="color: navy; font-weight: bold;">throws</span> IOException,
InterruptedException {
<span style="color: navy; font-weight: bold;">return</span> <span style="color: navy; font-weight: bold;">new</span> NLinesRecordReader();
}
@Override
<span style="color: navy; font-weight: bold;">protected</span> <span style="color: navy; font-weight: bold;">long</span> computeSplitSize(<span style="color: navy; font-weight: bold;">long</span> blockSize, <span style="color: navy; font-weight: bold;">long</span> minSize, <span style="color: navy; font-weight: bold;">long</span> maxSize) {
<span style="color: navy; font-weight: bold;">return</span> <span style="color: navy; font-weight: bold;">super</span>.<span style="color: red;">computeSplitSize</span>(blockSize, minSize, MAX_SPLIT_SIZE);
}
}
</pre>
</div>
<div class="MsoNormal">
<b><span style="font-size: 12.0pt; line-height: 107%; mso-bidi-font-size: 11.0pt;"><br /></span></b></div>
<div class="MsoNormal">
<b><span style="font-size: 12.0pt; line-height: 107%; mso-bidi-font-size: 11.0pt;">NLinesRecordReader.java<o:p></o:p></span></b></div>
<div class="MsoNormal">
<b><span style="font-size: 12.0pt; line-height: 107%; mso-bidi-font-size: 11.0pt;"><br /></span></b></div>
</div>
<!-- HTML generated using hilite.me --><br />
<div style="background: #ffffff; border-width: .0.01em .0.01em .0.01em .8em; border: solid green; overflow: auto; padding: .2em .6em; width: auto;">
<pre style="line-height: 125%; margin: 0;"><span style="color: navy; font-weight: bold;">package</span> com.<span style="color: red;">HdMovie</span>.<span style="color: red;">customFormatter</span>;
<span style="color: navy; font-weight: bold;">import</span> java.io.IOException;
<span style="color: navy; font-weight: bold;">import</span> org.apache.hadoop.conf.Configuration;
<span style="color: navy; font-weight: bold;">import</span> org.apache.hadoop.fs.FSDataInputStream;
<span style="color: navy; font-weight: bold;">import</span> org.apache.hadoop.fs.FileSystem;
<span style="color: navy; font-weight: bold;">import</span> org.apache.hadoop.fs.Path;
<span style="color: navy; font-weight: bold;">import</span> org.apache.hadoop.io.LongWritable;
<span style="color: navy; font-weight: bold;">import</span> org.apache.hadoop.io.Text;
<span style="color: navy; font-weight: bold;">import</span> org.apache.hadoop.mapred.LineRecordReader.LineReader;
<span style="color: navy; font-weight: bold;">import</span> org.apache.hadoop.mapreduce.InputSplit;
<span style="color: navy; font-weight: bold;">import</span> org.apache.hadoop.mapreduce.RecordReader;
<span style="color: navy; font-weight: bold;">import</span> org.apache.hadoop.mapreduce.TaskAttemptContext;
<span style="color: navy; font-weight: bold;">import</span> org.apache.hadoop.mapreduce.lib.input.FileSplit;
<span style="color: navy; font-weight: bold;">public</span> <span style="color: navy; font-weight: bold;">class</span> NLinesRecordReader <span style="color: navy; font-weight: bold;">extends</span> RecordReader<LongWritable, Text>{
<span style="color: navy; font-weight: bold;">private</span> <span style="color: navy; font-weight: bold;">final</span> <span style="color: navy; font-weight: bold;">int</span> NLINESTOPROCESS = <span style="color: blue;">3</span>;
<span style="color: navy; font-weight: bold;">private</span> LineReader in;
<span style="color: navy; font-weight: bold;">private</span> LongWritable key;
<span style="color: navy; font-weight: bold;">private</span> Text value = <span style="color: navy; font-weight: bold;">new</span> Text();
<span style="color: navy; font-weight: bold;">private</span> <span style="color: navy; font-weight: bold;">long</span> start =<span style="color: blue;">0</span>;
<span style="color: navy; font-weight: bold;">private</span> <span style="color: navy; font-weight: bold;">long</span> end =<span style="color: blue;">0</span>;
<span style="color: navy; font-weight: bold;">private</span> <span style="color: navy; font-weight: bold;">long</span> pos =<span style="color: blue;">0</span>;
<span style="color: navy; font-weight: bold;">private</span> <span style="color: navy; font-weight: bold;">int</span> maxLineLength;
@Override
<span style="color: navy; font-weight: bold;">public</span> <span style="color: navy; font-weight: bold;">void</span> close() <span style="color: navy; font-weight: bold;">throws</span> IOException {
<span style="color: navy; font-weight: bold;">if</span> (in != <span style="color: navy; font-weight: bold;">null</span>) {
in.<span style="color: red;">close</span>();
}
}
@Override
<span style="color: navy; font-weight: bold;">public</span> LongWritable getCurrentKey() <span style="color: navy; font-weight: bold;">throws</span> IOException,InterruptedException {
<span style="color: navy; font-weight: bold;">return</span> key;
}
@Override
<span style="color: navy; font-weight: bold;">public</span> Text getCurrentValue() <span style="color: navy; font-weight: bold;">throws</span> IOException, InterruptedException {
<span style="color: navy; font-weight: bold;">return</span> value;
}
@Override
<span style="color: navy; font-weight: bold;">public</span> <span style="color: navy; font-weight: bold;">float</span> getProgress() <span style="color: navy; font-weight: bold;">throws</span> IOException, InterruptedException {
<span style="color: navy; font-weight: bold;">if</span> (start == end) {
<span style="color: navy; font-weight: bold;">return</span> <span style="color: blue;">0.0f</span>;
}
<span style="color: navy; font-weight: bold;">else</span> {
<span style="color: navy; font-weight: bold;">return</span> Math.<span style="color: red;">min</span>(<span style="color: blue;">1.0f</span>, (pos - start) / (<span style="color: navy; font-weight: bold;">float</span>)(end - start));
}
}
@Override
<span style="color: navy; font-weight: bold;">public</span> <span style="color: navy; font-weight: bold;">void</span> initialize(InputSplit genericSplit, TaskAttemptContext context)<span style="color: navy; font-weight: bold;">throws</span> IOException, InterruptedException {
FileSplit split = (FileSplit) genericSplit;
<span style="color: navy; font-weight: bold;">final</span> Path file = split.<span style="color: red;">getPath</span>();
Configuration conf = context.<span style="color: red;">getConfiguration</span>();
<span style="color: navy; font-weight: bold;">this</span>.<span style="color: red;">maxLineLength</span> = conf.<span style="color: red;">getInt</span>(<span style="color: blue;">"mapred.linerecordreader.maxlength"</span>,Integer.<span style="color: red;">MAX_VALUE</span>);
FileSystem fs = file.<span style="color: red;">getFileSystem</span>(conf);
start = split.<span style="color: red;">getStart</span>();
end= start + split.<span style="color: red;">getLength</span>();
<span style="color: navy; font-weight: bold;">boolean</span> skipFirstLine = <span style="color: navy; font-weight: bold;">false</span>;
FSDataInputStream filein = fs.<span style="color: red;">open</span>(split.<span style="color: red;">getPath</span>());
<span style="color: navy; font-weight: bold;">if</span> (start != <span style="color: blue;">0</span>){
skipFirstLine = <span style="color: navy; font-weight: bold;">true</span>;
--start;
filein.<span style="color: red;">seek</span>(start);
}
in = <span style="color: navy; font-weight: bold;">new</span> LineReader(filein,conf);
<span style="color: navy; font-weight: bold;">if</span>(skipFirstLine){
start += in.<span style="color: red;">readLine</span>(<span style="color: navy; font-weight: bold;">new</span> Text(),<span style="color: blue;">0</span>,(<span style="color: navy; font-weight: bold;">int</span>)Math.<span style="color: red;">min</span>((<span style="color: navy; font-weight: bold;">long</span>)Integer.<span style="color: red;">MAX_VALUE</span>, end - start));
}
<span style="color: navy; font-weight: bold;">this</span>.<span style="color: red;">pos</span> = start;
}
@Override
<span style="color: navy; font-weight: bold;">public</span> <span style="color: navy; font-weight: bold;">boolean</span> nextKeyValue() <span style="color: navy; font-weight: bold;">throws</span> IOException, InterruptedException {
<span style="color: navy; font-weight: bold;">if</span> (key == <span style="color: navy; font-weight: bold;">null</span>) {
key = <span style="color: navy; font-weight: bold;">new</span> LongWritable();
}
key.<span style="color: red;">set</span>(pos);
<span style="color: navy; font-weight: bold;">if</span> (value == <span style="color: navy; font-weight: bold;">null</span>) {
value = <span style="color: navy; font-weight: bold;">new</span> Text();
}
value.<span style="color: red;">clear</span>();
<span style="color: navy; font-weight: bold;">final</span> Text endline = <span style="color: navy; font-weight: bold;">new</span> Text(<span style="color: blue;">"\n"</span>);
<span style="color: navy; font-weight: bold;">int</span> newSize = <span style="color: blue;">0</span>;
<span style="color: navy; font-weight: bold;">for</span>(<span style="color: navy; font-weight: bold;">int</span> i=<span style="color: blue;">0</span>;i<NLINESTOPROCESS;i++){
Text v = <span style="color: navy; font-weight: bold;">new</span> Text();
<span style="color: navy; font-weight: bold;">while</span> (pos < end) {
newSize = in.<span style="color: red;">readLine</span>(v, maxLineLength,Math.<span style="color: red;">max</span>((<span style="color: navy; font-weight: bold;">int</span>)Math.<span style="color: red;">min</span>(Integer.<span style="color: red;">MAX_VALUE</span>, end-pos),maxLineLength));
value.<span style="color: red;">append</span>(v.<span style="color: red;">getBytes</span>(),<span style="color: blue;">0</span>, v.<span style="color: red;">getLength</span>());
value.<span style="color: red;">append</span>(endline.<span style="color: red;">getBytes</span>(),<span style="color: blue;">0</span>, endline.<span style="color: red;">getLength</span>());
<span style="color: navy; font-weight: bold;">if</span> (newSize == <span style="color: blue;">0</span>) {
<span style="color: navy; font-weight: bold;">break</span>;
}
pos += newSize;
<span style="color: navy; font-weight: bold;">if</span> (newSize < maxLineLength) {
<span style="color: navy; font-weight: bold;">break</span>;
}
}
}
<span style="color: navy; font-weight: bold;">if</span> (newSize == <span style="color: blue;">0</span>) {
key = <span style="color: navy; font-weight: bold;">null</span>;
value = <span style="color: navy; font-weight: bold;">null</span>;
<span style="color: navy; font-weight: bold;">return</span> <span style="color: navy; font-weight: bold;">false</span>;
} <span style="color: navy; font-weight: bold;">else</span> {
<span style="color: navy; font-weight: bold;">return</span> <span style="color: navy; font-weight: bold;">true</span>;
}
}
}
</pre>
</div>
<br />
<i>That's it from my side. Cheer up ....</i><br />
<i>Happy Learning.. !! :)</i></div>
Anonymoushttp://www.blogger.com/profile/10713264593334966481noreply@blogger.com3tag:blogger.com,1999:blog-3586645045303501566.post-90358894621429892542014-06-05T08:24:00.001-07:002014-06-06T06:12:29.493-07:00Apache Shiro-Part I -Basic Introduction<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="MsoNormal">
<b><span style="font-size: 14.0pt; line-height: 107%; mso-bidi-font-size: 11.0pt;">Apache
Shiro:<o:p></o:p></span></b><br />
<b><span style="font-size: 14.0pt; line-height: 107%; mso-bidi-font-size: 11.0pt;"><br /></span></b></div>
<div class="MsoNormal">
<div style="text-align: left;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><b>Introduction</b>: </span></div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: justify;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">Apache Shiro is an easy to use Java security framework. Shiro's predecessor was JSecurity which was submitted to Apache software Foundation in 2008. It provides robust functionalities associated with security in application ranging from smallest mobile application to largest web and enterprise applications. In short it handles the security related challenges to the following facets.</span></div>
<div style="text-align: justify;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><br /></span></div>
<br />
<ul style="text-align: left;">
<li><b style="font-family: Georgia, 'Times New Roman', serif; font-size: small;">Authentication</b></li>
<li><b style="font-family: Georgia, 'Times New Roman', serif; font-size: small;">Authorization</b></li>
<li><b style="font-family: Georgia, 'Times New Roman', serif; font-size: small;">Cryptography</b></li>
<li><b style="font-family: Georgia, 'Times New Roman', serif; font-size: small;">Session Management</b></li>
<li><b style="font-family: Georgia, 'Times New Roman', serif; font-size: small;">Web Integration</b></li>
</ul>
<br />
<br /></div>
<div class="MsoNormal">
<b style="color: #252525; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif; font-size: 14px; line-height: 14.979999542236328px;">Authentication</b></div>
<div class="MsoNormal">
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
It is a process of verifying users identity based on some kinds of proofs or identity that a system can understand and trust. Almost everything that is executing in system is based on the current user of an application which is known as subject in Shiro. It has a built in Remember Me feature that provides an ability to remember the users once they return to an application.</div>
<br />
<b>Authorization</b><br />
<br />
<div style="text-align: justify;">
It is mechanism of providing access control for a particular user. It determines what resources of an application can be granted to a particular user. For ex- is the current user is able to view financial transactions of the organization? Based on varying needs of an application, the authorization in shiro can be granted based on their roles and permissions associated with them. The permission and roles can be configured in variety of sources like Database, text based configuration file, LDAP etc. It provides support for wildcard permissions that helps to model fine grained access policies to an application. Furthermore authorization can be done based on AOP, JDK 1.5 annotations and JSP tag library.</div>
<br />
<b>Cryptography</b><br />
<br />
<div style="text-align: justify;">
Cryptography is a technique of protecting an information through an undesired access by hiding it or converting the data into non-understandable format. Shiro majorly focuses on 2 ways of cryptograph: Ciphers – that encrypt data like email with public and private key and Hashes- that irreversibly encrypts data like security password using message digests algorithms such as md5, SHA,SHA-256 etc.</div>
</div>
<div class="MsoNormal">
<span style="background: white; color: #252525; font-family: "Arial","sans-serif"; font-size: 10.5pt; line-height: 107%;"><br /></span>
<span style="background: white; color: #252525; font-family: "Arial","sans-serif"; font-size: 10.5pt; line-height: 107%;"></span><br />
<div class="MsoNormal">
<div style="text-align: justify;">
<b><span style="font-size: 14.0pt; line-height: 107%; mso-bidi-font-size: 11.0pt;">Shiro
Architecture<o:p></o:p></span></b></div>
<div style="text-align: justify;">
<b><span style="font-size: 14.0pt; line-height: 107%; mso-bidi-font-size: 11.0pt;"><br /></span></b></div>
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiHUo4y2D0CDyhKaJF6UYpYONh6Klcxaii6OvcENa4XQ0WR0ZvIoz2un9ZKsT3Sm5Orr2hj2pP6btFsx6fTGSUL6prv3nhk-oruB5Qn4Mk3E1YhBgcvhZrwfxheyIZ2xkqqctluwMfIB4w/s1600/shiro-architecture.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiHUo4y2D0CDyhKaJF6UYpYONh6Klcxaii6OvcENa4XQ0WR0ZvIoz2un9ZKsT3Sm5Orr2hj2pP6btFsx6fTGSUL6prv3nhk-oruB5Qn4Mk3E1YhBgcvhZrwfxheyIZ2xkqqctluwMfIB4w/s1600/shiro-architecture.png" /></a></div>
<div class="MsoNormal">
<div style="text-align: justify;">
<b><span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif; font-size: 14.0pt; line-height: 107%; mso-bidi-font-size: 11.0pt;"><br /></span></b></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="line-height: 107%;"><span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">The above diagram shows the basic functional mechanism of
Shiro embedded application. The application code will be integrated with shiro based
security mechanism. In order to achieve it, the application needs to invoke the
subject which will identity the interacting user to an application. Next the
subject will communicate with the security manager that manages all the
security related operations for the user. It is an umbrella object that
references many internal security related components. The security manager in
turn will communicate with configured realms in chain to verify the credentials
associated with the subject/current user. Basically Realm acts as a bridge
between shiro and application security data. It’s a security related data
access object. The below diagram shows
its detailed aspects.</span><span style="font-family: Arial, sans-serif; font-size: 10.5pt;"><o:p></o:p></span></span></div>
<div class="MsoNormal" style="text-align: justify;">
<span style="line-height: 107%;"><span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><br /></span></span></div>
</div>
<div class="MsoNormal">
<span style="font-family: "Arial","sans-serif"; font-size: 10.5pt; line-height: 107%;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiqF-eqhXJR15dThZReDtsnfvx0Pmf9QtFWClC5hbxMIhKp_4_SS5XEb6eRhQqLbekaTFVScniblypvewpIjqu7ExFFvAuOgu0MThrFngWfLVFN1mN7pZAFvnEdrLa92ghRhzitquYM10c/s1600/shiro-Architecture-detail.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiqF-eqhXJR15dThZReDtsnfvx0Pmf9QtFWClC5hbxMIhKp_4_SS5XEb6eRhQqLbekaTFVScniblypvewpIjqu7ExFFvAuOgu0MThrFngWfLVFN1mN7pZAFvnEdrLa92ghRhzitquYM10c/s1600/shiro-Architecture-detail.png" /></a></div>
<div class="MsoNormal">
<span style="font-family: "Arial","sans-serif"; font-size: 10.5pt; line-height: 107%;"><br /></span></div>
<div class="MsoNormal" style="text-indent: .5in;">
<span style="font-family: Arial, sans-serif;"><span style="font-size: 14px; line-height: 14.979999542236328px;">Fig: The detailed components of Shiro Architecture</span></span><br />
<span style="text-indent: 0.5in;"><br /></span>
<span style="text-indent: 0.5in;">Let’s look at basic example on implementation of Apache shiro.</span><br />
<span style="text-indent: 0.5in;"><br /></span>
<b>Step1: </b>Create a simple maven project and add the following dependencies:<br />
<br /></div>
<!-- HTML generated using hilite.me --><br />
<div style="background: #ffffff; border-width: .1em .1em .1em .8em; border: solid green; overflow: auto; padding: .2em .6em; width: auto;">
<pre style="line-height: 125%; margin: 0;"> <dependencies>
<dependency>
<groupId>org.apache.shiro</groupId>
<artifactId>shiro-core</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</pre>
</div>
<div class="MsoNormal">
<b><span style="font-size: 14.0pt; line-height: 107%; mso-bidi-font-size: 11.0pt;"><br /></span></b></div>
<div class="MsoNormal">
<div class="MsoNormal">
<b>Step 2:</b> Create shiro.ini file in /resources folder of your
project and add the below configuration.<o:p></o:p><br />
<br /></div>
<!-- HTML generated using hilite.me --><br />
<div style="background: #ffffff; border-width: .1em .1em .1em .8em; border: solid green; overflow: auto; padding: .2em .6em; width: auto;">
<pre style="line-height: 125%; margin: 0;">[users]
<span style="color: #008800; font-style: italic;"># user 'root' with password 'secret' and the 'admin' role</span>
root = secret, admin
guest = guest123, basic
<span style="color: #008800; font-style: italic;"># -----------------------------------------------------------------------------</span>
<span style="color: #008800; font-style: italic;"># Roles with assigned permissions</span>
<span style="color: #008800; font-style: italic;"># </span>
<span style="color: #008800; font-style: italic;"># Each line conforms to the format defined in the</span>
<span style="color: #008800; font-style: italic;"># org.apache.shiro.realm.text.TextConfigurationRealm#setRoleDefinitions JavaDoc</span>
<span style="color: #008800; font-style: italic;"># -----------------------------------------------------------------------------</span>
[roles]
<span style="color: #008800; font-style: italic;"># 'admin' role has all permissions, indicated by the wildcard '*'</span>
admin = *
basic = read
</pre>
</div>
<div class="MsoNormal">
<br /></div>
</div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
As shown in above
configuration file tag <b><span style="background: white; color: #7f9fbf; font-family: Consolas; font-size: 10.0pt; mso-highlight: white;">[users]</span></b><b><span style="color: #7f9fbf; font-family: Consolas; font-size: 10.0pt;"> </span></b>is enlisting
all the users with their current passwords and associated roles. Tag <b><span style="background: white; color: #7f9fbf; font-family: Consolas; font-size: 10.0pt; mso-highlight: white;">[roles]</span></b><b><span style="color: #7f9fbf; font-family: Consolas; font-size: 10.0pt;"> </span></b>will specify what permission can
be granted for the particular user. A
wildcard * simply indicates that the current user having particular role is granted all the permissions. <o:p></o:p><br />
<br />
<b>Step3: </b> Now we have defined configuration file, so we are set to write a sample code and execute it.</div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<!-- HTML generated using hilite.me --><br />
<div style="background: #ffffff; border-width: .1em .1em .1em .8em; border: solid green; overflow: auto; padding: .2em .6em; width: auto;">
<pre style="line-height: 125%; margin: 0;"><span style="color: #008800; font-style: italic;">/**</span>
<span style="color: #008800; font-style: italic;"> * A simple application showing how to use Shiro</span>
<span style="color: #008800; font-style: italic;"> * *</span>
<span style="color: #008800; font-style: italic;"> */</span>
<span style="color: navy; font-weight: bold;">public</span> <span style="color: navy; font-weight: bold;">class</span> HelloShiro{
<span style="color: navy; font-weight: bold;">private</span> <span style="color: navy; font-weight: bold;">static</span> <span style="color: navy; font-weight: bold;">final</span> <span style="color: navy; font-weight: bold;">transient</span> Logger log = LoggerFactory.<span style="color: red;">getLogger</span>(HelloShiro.<span style="color: red;">class</span>);
<span style="color: navy; font-weight: bold;">public</span> <span style="color: navy; font-weight: bold;">static</span> <span style="color: navy; font-weight: bold;">void</span> main(String[] args) {
<span style="color: #008800; font-style: italic;">// Use the shiro.ini file at the root of the classpath</span>
Factory<SecurityManager> factory = <span style="color: navy; font-weight: bold;">new</span> IniSecurityManagerFactory(<span style="color: blue;">"classpath:shiro.ini"</span>);
SecurityManager securityManager = factory.<span style="color: red;">getInstance</span>();
SecurityUtils.<span style="color: red;">setSecurityManager</span>(securityManager);
<span style="color: #008800; font-style: italic;">// get the currently executing user:</span>
Subject currentUser = SecurityUtils.<span style="color: red;">getSubject</span>();
<span style="color: #008800; font-style: italic;">// Do some stuff with a Session (no need for a web or EJB container!!!)</span>
Session session = currentUser.<span style="color: red;">getSession</span>();
session.<span style="color: red;">setAttribute</span>(<span style="color: blue;">"apiKey"</span>, <span style="color: blue;">"xyewldie"</span>);
String value = (String) session.<span style="color: red;">getAttribute</span>(<span style="color: blue;">"apiKey"</span>);
<span style="color: navy; font-weight: bold;">if</span> (value.<span style="color: red;">equals</span>(<span style="color: blue;">"apiKey "</span>)) {
log.<span style="color: red;">info</span>(<span style="color: blue;">"Retrieved the correct value! ["</span> + value + <span style="color: blue;">"]"</span>);
}
<span style="color: #008800; font-style: italic;">// login the current user so we can check against roles and permissions:</span>
<span style="color: navy; font-weight: bold;">if</span> (!currentUser.<span style="color: red;">isAuthenticated</span>()) {
UsernamePasswordToken token = <span style="color: navy; font-weight: bold;">new</span> UsernamePasswordToken(<span style="color: blue;">"root"</span>, <span style="color: blue;">"secret"</span>);
token.<span style="color: red;">setRememberMe</span>(<span style="color: navy; font-weight: bold;">true</span>);
<span style="color: navy; font-weight: bold;">try</span> {
currentUser.<span style="color: red;">login</span>(token);
} <span style="color: navy; font-weight: bold;">catch</span> (UnknownAccountException uae) {
log.<span style="color: red;">info</span>(<span style="color: blue;">"There is no user with username of "</span> + token.<span style="color: red;">getPrincipal</span>());
} <span style="color: navy; font-weight: bold;">catch</span> (IncorrectCredentialsException ice) {
log.<span style="color: red;">info</span>(<span style="color: blue;">"Password for account "</span> + token.<span style="color: red;">getPrincipal</span>() + <span style="color: blue;">" was incorrect!"</span>);
} <span style="color: navy; font-weight: bold;">catch</span> (LockedAccountException lae) {
log.<span style="color: red;">info</span>(<span style="color: blue;">"The account for username "</span> + token.<span style="color: red;">getPrincipal</span>() + <span style="color: blue;">" is locked. "</span> +
<span style="color: blue;">"Please contact your administrator to unlock it."</span>);
}
<span style="color: #008800; font-style: italic;">// ... catch more exceptions here (maybe custom ones specific to your application?</span>
<span style="color: navy; font-weight: bold;">catch</span> (AuthenticationException ae) {
<span style="color: #008800; font-style: italic;">//unexpected condition </span>
}
}
<span style="color: #008800; font-style: italic;">//Current user principal (in this case, a username):</span>
log.<span style="color: red;">info</span>(<span style="color: blue;">"User ["</span> + currentUser.<span style="color: red;">getPrincipal</span>() + <span style="color: blue;">"] logged in successfully."</span>);
<span style="color: #008800; font-style: italic;">//test a role:</span>
<span style="color: navy; font-weight: bold;">if</span> (currentUser.<span style="color: red;">hasRole</span>(<span style="color: blue;">"admin"</span>)) {
log.<span style="color: red;">info</span>(<span style="color: blue;">"Welcome Admin!"</span>);
} <span style="color: navy; font-weight: bold;">else</span> {
log.<span style="color: red;">info</span>(<span style="color: blue;">"Sorry! You are not administrator"</span>);
}
<span style="color: #008800; font-style: italic;">//test a typed permission (not instance-level)</span>
<span style="color: navy; font-weight: bold;">if</span> (currentUser.<span style="color: red;">isPermitted</span>(<span style="color: blue;">"read"</span>)) {
log.<span style="color: red;">info</span>(<span style="color: blue;">"You are allowed to read information"</span>);
} <span style="color: navy; font-weight: bold;">else</span> {
log.<span style="color: red;">info</span>(<span style="color: blue;">"Sorry, you can’t read information.."</span>);
}
<span style="color: #008800; font-style: italic;">//all done - log out!</span>
currentUser.<span style="color: red;">logout</span>();
System.<span style="color: red;">exit</span>(<span style="color: blue;">0</span>);
}
}
</pre>
</div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
</div>
<div class="MsoNormal">
<b><span style="font-size: 14.0pt; line-height: 107%; mso-bidi-font-size: 11.0pt;"><br /></span></b></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<div style="text-align: left;">
<i>Thats all from my sides !! Please wait for my next successive article on shiro partII .Till than enjoy up !! Cheers ..!!</i></div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<br /></div>
</div>
<div class="MsoNormal">
<b><span style="font-size: 14.0pt; line-height: 107%; mso-bidi-font-size: 11.0pt;"><br /></span></b></div>
<div class="MsoNormal">
<b><span style="font-size: 14.0pt; line-height: 107%; mso-bidi-font-size: 11.0pt;"><br /></span></b></div>
<div class="MsoNormal">
<b><span style="font-size: 14.0pt; line-height: 107%; mso-bidi-font-size: 11.0pt;"><br /></span></b></div>
<div class="MsoNormal">
<b><span style="font-size: 14.0pt; line-height: 107%; mso-bidi-font-size: 11.0pt;"><br /></span></b></div>
<div class="MsoNormal">
<b><span style="font-size: 14.0pt; line-height: 107%; mso-bidi-font-size: 11.0pt;"><br /></span></b></div>
<div class="MsoNormal">
<b><span style="font-size: 14.0pt; line-height: 107%; mso-bidi-font-size: 11.0pt;"><br /></span></b></div>
<div class="MsoNormal">
<b><span style="font-size: 14.0pt; line-height: 107%; mso-bidi-font-size: 11.0pt;"><br /></span></b></div>
</div>
</div>
Anonymoushttp://www.blogger.com/profile/10713264593334966481noreply@blogger.com0tag:blogger.com,1999:blog-3586645045303501566.post-45879057849510252602014-04-12T06:35:00.000-07:002014-06-17T02:40:56.275-07:00Job Chaining in Hadoop<div dir="ltr" style="text-align: left;" trbidi="on">
<div>
<div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";">Chaining is an instructional
procedure. As Hadoop is designed for batch processing of data, it is worth
important to know the execution of series of Jobs without manual
intervention. <o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";">In practical situations, not every
task can be solved using single map reduce program. We may need multiple
mappers & reducers to complete a specific task where the output of previous
map reduce program may be required as input to the successive mapper, & so
on.<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";">Mapper1 -->Reducer1->Mapper2
-->Reducer2-->Mapper3 -->Reducer3 ...<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"> Furthermore there might be
conditional dependencies existing across different jobs. If the output of
certain kinds of job is of X type, feed output to the Y job else feed output to
Z job. <o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"> Hadoop provides an easiest way
to chain job using <b>JobControl </b>class which construct a job control for a group of jobs. JobControl gives
flexibility to add collection of jobs, its job states, get ready, running,
waiting, & failed jobs. We add jobs using JobControl instance <b>addJob</b>(controlledJob1)
method. Any depending job can be added using addDependingJob(jobN)
method. <o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";">Any normal job has to be an instance
of <b>Job</b> class. This job has to be explicitly set as
ControlledJob in order to chain in <b>JobControl. </b><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";">Job job1 = JSONFileConvertJob(args);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";">ControlledJob cJob1 = new
ControlledJob(conf);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";">cJob1.setJob(job1);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";">JobControl jobctrl = new
JobControl("JobController");<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";">jobctrl.addJob(cJob1);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";">The <b>ControlledJob </b>encapsulates a MapReduce job and its
dependency. It monitors the states of the depending jobs and updates the
state of this job. <b>ControlledJob </b>provides various
information about job such as Job Id, Job Name etc. Furthermore it provides an
extensive control over a particular job such as setting Job Id, Job Name, Job
state, submitting job, killing job etc. The related interdependent groups of
jobs can be placed under ControlledJob which will be placed at JobControl
being a top level master. <o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";">Finally the <b>JobControl </b>instance
is run using <b>run()</b> method. We can use a thread to start
JobControl providing an instance of <b>JobRunner </b>having JobControl
instance as argument of Runnable JobRunner as below. <o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";">Thread jobRunnerThread = new
Thread(new JobRunner(jobControlInstance))<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";">jobRunnerThread.start()<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";">JobControl </span></b><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";">provides a method <b>allFinished() </b>to check
whether all the jobs are finished or not. We can provide a continuous loop to
get latest statics of running jobs periodically at certain interval using
Thread.sleep(sleepTime). Finally when all jobs are executed successfully,
JobControl <b>stop() </b>will be used<b> </b>to set the thread state to STOPPING so that the thread
will stop when it wakes up.<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";">Here is a simple example of job
chaining where the first job converts an input textFile of temperature data
into JSON file storing it in HDFS. The second Job takes the JSON file as input
at performs the map-reduce operation. <o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";">Add the below arguments at run
configuration of CustomFileConverterJob :<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<i><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";">sample.txt
hdfs://localhost/sequentialJobOutput/
hdfs://localhost/sequentialJobOutput/reduce/</span></i><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";">You can use the following data set
as sample.txt file.<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">0067011990999991950051507004+68750+023550FM-12+038299999V0203301N00671220001CN9999999N9+00001+99999999999</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">0043011990999991950051512004+68750+023550FM-12+038299999V0203201N00671220001CN9999999N9+00221+99999999999</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">0043011990999991950051518004+68750+023550FM-12+038299999V0203201N00261220001CN9999999N9-00111+99999999999</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">0043012650999991949032412004+62300+010750FM-12+048599999V0202701N00461220001CN0500001N9+01111+99999999999</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">0043012650999991949032418004+62300+010750FM-12+048599999V0202701N00461220001CN0500001N9+00781+99999999999</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";">Here the first argument will be the
simple input temperature driver data file, the second argument provides the
directory to store the output of the first job, which will be JSON file, &
the last argument will provide the directory to store reduced job output.
<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">public</span></b><span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <b><span style="color: #7f0055;">class</span></b> CustomFileConverterJob <b><span style="color: #7f0055;">extends</span></b> Configured <b><span style="color: #7f0055;">implements</span></b> Tool {</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> Configuration <span style="color: #0000c0;">conf</span> = <b><span style="color: #7f0055;">new</span></b> Configuration();</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <b><span style="color: #7f0055;">public</span></b> <b><span style="color: #7f0055;">int</span></b> run(String[]
args) <b><span style="color: #7f0055;">throws</span></b> Exception</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> {</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <b><span style="color: #7f0055;">if</span></b>(args.<span style="color: #0000c0;">length</span> !=3)
{</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">
System.<i><span style="color: #0000c0;">err</span></i>.println(<span style="color: #2a00ff;">"Usage: Temperature driver:</span></span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: #2a00ff; font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">
<Input file> <input path to
converted file> <outputpath>"</span><span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">);</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">
System.<i>exit</i>(-1);</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">
}</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <span style="color: #0000c0;">conf</span> = getConf();</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <span style="color: #3f7f5f;">/**</span></span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: #3f7f5f; font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">
* Add Jobs in chaining</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: #3f7f5f; font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">
*/</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">
Job job1 = JSONFileConvertJob(args);</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">
</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">
ControlledJob cJob1 = <b><span style="color: #7f0055;">new</span></b> ControlledJob(<span style="color: #0000c0;">conf</span>);</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">
cJob1.setJob(job1);</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <span style="color: #3f5fbf;">/**</span></span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: #3f5fbf; font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">
* JSON input file job</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: #3f5fbf; font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">
*/</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">
Job job2 = mapJobFromJSONInputFile(args);</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">
ControlledJob cJob2 = <b><span style="color: #7f0055;">new</span></b> ControlledJob(<span style="color: #0000c0;">conf</span>);</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">
cJob2.setJob(job2);</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">
JobControl jobctrl = <b><span style="color: #7f0055;">new</span></b> JobControl(<span style="color: #2a00ff;">"JobController"</span>);</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">
jobctrl.addJob(cJob1);</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">
jobctrl.addJob(cJob2);</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">
cJob2.addDependingJob(cJob1);</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> </span><br />
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> </span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">
Thread jobRunnerThread = <b><span style="color: #7f0055;">new</span></b> Thread(<b><span style="color: #7f0055;">new</span></b> JobRunner(jobctrl));</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">
jobRunnerThread.start();</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <b><span style="color: #7f0055;">while</span></b> (!jobctrl.allFinished()) {</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">
System.<i><span style="color: #0000c0;">out</span></i>.println(<span style="color: #2a00ff;">"Still running..."</span>);</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">
Thread.<i>sleep</i>(5000);</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">
}</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">
System.<i><span style="color: #0000c0;">out</span></i>.println(<span style="color: #2a00ff;">"done"</span>);</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">
jobctrl.stop();</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <b><span style="color: #7f0055;">return</span></b> 0;</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> }</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <span style="color: #3f5fbf;">/**</span></span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: #3f5fbf; font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">
* Deletes the specified file or directory</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: #3f5fbf; font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> */</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <b><span style="color: #7f0055;">public</span></b> <b><span style="color: #7f0055;">static</span></b> <b><span style="color: #7f0055;">void</span></b> deleteFileOrDirectory(String
inputPathOrFile) <b><span style="color: #7f0055;">throws</span></b> IOException{</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">
Configuration conf = <b><span style="color: #7f0055;">new</span></b> Configuration();</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">
conf.set(<span style="color: #2a00ff;">"fs.default.name"</span>, <span style="color: #2a00ff;">"hdfs://localhost:8020/"</span>);</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">
FileSystem fs = FileSystem.<i>get</i>(conf);</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">
Path path = <b><span style="color: #7f0055;">new</span></b> Path(inputPathOrFile);</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <b><span style="color: #7f0055;">if</span></b>(fs.exists(path)){</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">
fs.delete(path, <b><span style="color: #7f0055;">true</span></b>);</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">
}</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> }</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt; text-indent: 0.5in;">
<span style="color: #3f5fbf; font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">/**</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: #3f5fbf; font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> *
This Job takes input from JSON file</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: #3f5fbf; font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> *
Performs map reduce operation</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: #3f5fbf; font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> */</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <b><span style="color: #7f0055;">public</span></b> Job mapJobFromJSONInputFile(String[] args) <b><span style="color: #7f0055;">throws</span></b> Exception{</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <span style="color: #0000c0;">conf</span>.set(<span style="color: #2a00ff;">"jsonInput.start"</span>, <span style="color: #2a00ff;">"{"</span>);</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <span style="color: #0000c0;">conf</span>.set(<span style="color: #2a00ff;">"jsonInput.end"</span>, <span style="color: #2a00ff;">"}"</span>);</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">
Job job = <b><span style="color: #7f0055;">new</span></b> Job(<span style="color: #0000c0;">conf</span>);</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">
job.setJarByClass(CustomFileConverterJob.<b><span style="color: #7f0055;">class</span></b>);</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">
job.setJobName(<span style="color: #2a00ff;">"Process map reduce job from
JSON file"</span>);</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">
job.setMapperClass(MaxTemperatureJSONMapper.<b><span style="color: #7f0055;">class</span></b>);</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">
job.setReducerClass(MaxTemperatureReducer.<b><span style="color: #7f0055;">class</span></b>);</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">
job.setOutputKeyClass(Text.<b><span style="color: #7f0055;">class</span></b>);</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">
job.setOutputValueClass(IntWritable.<b><span style="color: #7f0055;">class</span></b>);</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">
job.setInputFormatClass(JsonInputFormat.<b><span style="color: #7f0055;">class</span></b>);</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">
FileInputFormat.<i>addInputPath</i>(job, <b><span style="color: #7f0055;">new</span></b> Path(args[1]+<span style="color: #2a00ff;">"part*"</span>));</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">
FileOutputFormat.<i>setOutputPath</i>(job,<b><span style="color: #7f0055;">new</span></b> Path(args[2]));</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">
</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <b><span style="color: #7f0055;">return</span></b> job;</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> }</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt; text-indent: 0.5in;">
<span style="color: #3f5fbf; font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">/**</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: #3f5fbf; font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> *
This Job takes any raw text file</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: #3f5fbf; font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> *
Converts it into JSON file</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: #3f5fbf; font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> */</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <b><span style="color: #7f0055;">public</span></b> Job <span style="background-color: white; background-position: initial initial; background-repeat: initial initial;">JSONFileConvertJob</span>(String[] args) <b><span style="color: #7f0055;">throws</span></b> IOException{</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">
Job job = <b><span style="color: #7f0055;">new</span></b> Job();</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">
job.setJarByClass(CustomFileConverterJob.<b><span style="color: #7f0055;">class</span></b>);</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">
job.setJobName(<span style="color: #2a00ff;">"JSON file converter job"</span>);</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">
job.setMapperClass(JSONFileConverterMapper.<b><span style="color: #7f0055;">class</span></b>);</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">
job.setReducerClass(MaxTemperatureReducer.<b><span style="color: #7f0055;">class</span></b>);</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">
job.setNumReduceTasks(0);</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">
job.setOutputKeyClass(IntWritable.<b><span style="color: #7f0055;">class</span></b>);</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">
job.setOutputValueClass(Text.<b><span style="color: #7f0055;">class</span></b>);</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">
FileInputFormat.<i>setInputPaths</i>(job, <b><span style="color: #7f0055;">new</span></b> Path(args[0]));</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <span style="color: #3f5fbf;">/**</span></span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: #3f5fbf; font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">
* Custom JSON OutputFormatter Class</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: #3f5fbf; font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">
* This class will assist you to write you custom JSON class</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: #3f5fbf; font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">
*/</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">
FileOutputFormat.<i>setOutputPath</i>(job, <b><span style="color: #7f0055;">new</span></b> Path(args[1]));</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <b><span style="color: #7f0055;">return</span></b> job;</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> }</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">}</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";">Here is the custom input
mapper file which is used to convert the sample.txt input file into JSON.<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">public</span></b><span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <b><span style="color: #7f0055;">class</span></b> JSONFileConverterMapper <b><span style="color: #7f0055;">extends</span></b> Mapper<LongWritable, Text,
LongWritable, Text> {</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <b><span style="color: #7f0055;">static</span></b> Logger <i><span style="color: #0000c0;">log</span></i> = Logger.<i>getLogger</i>(JSONFileConverterMapper.<b><span style="color: #7f0055;">class</span></b>);</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <b><span style="color: #7f0055;">private</span></b> String <span style="color: #0000c0;">line</span>;</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <b><span style="color: #7f0055;">private</span></b> String <span style="color: #0000c0;">year</span>;</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <b><span style="color: #7f0055;">private</span></b> <b><span style="color: #7f0055;">int</span></b> <span style="color: #0000c0;">airTemperature</span>;</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <b><span style="color: #7f0055;">private</span></b> String <span style="color: #0000c0;">quality</span>;</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <span style="color: #646464;">@Override</span></span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <b><span style="color: #7f0055;">public</span></b> <b><span style="color: #7f0055;">void</span></b> map(LongWritable
key, Text value, Context context) <b><span style="color: #7f0055;">throws</span></b>
IOException, InterruptedException{</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <span style="color: #0000c0;">line</span> = value.toString(); <span style="color: #3f7f5f;">//convert a value to string</span></span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <span style="color: #0000c0;">year</span> = <span style="color: #0000c0;">line</span>.substring(15,
19);</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <b><span style="color: #7f0055;">if</span></b> (<span style="color: #0000c0;">line</span>.charAt(87)
== <span style="color: #2a00ff;">'+'</span>) { <span style="color: #3f7f5f;">//
parseInt doesn't like leading plus</span></span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <span style="color: #3f7f5f;">// signs</span></span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <span style="color: #0000c0;">airTemperature</span> = Integer.<i>parseInt</i>(<span style="color: #0000c0;">line</span>.substring(88, 92));</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">
} <b><span style="color: #7f0055;">else</span></b> {</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <span style="color: #0000c0;">airTemperature</span> = Integer.<i>parseInt</i>(<span style="color: #0000c0;">line</span>.substring(87, 92));</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">
}</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <span style="color: #0000c0;">quality</span> = <span style="color: #0000c0;">line</span>.substring(92,
93);</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">
Gson gson = <b><span style="color: #7f0055;">new</span></b> Gson();</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">
JSONFileConverterMapper obj = <b><span style="color: #7f0055;">new</span></b> JSONFileConverterMapper();</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">
obj.<span style="color: #0000c0;">line</span> = <span style="color: #0000c0;">line</span>;</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">
obj.<span style="color: #0000c0;">airTemperature</span> = <span style="color: #0000c0;">airTemperature</span>;</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">
obj.<span style="color: #0000c0;">year</span> = <span style="color: #0000c0;">year</span>;</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">
obj.<span style="color: #0000c0;">quality</span> = <span style="color: #0000c0;">quality</span>;</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">
String json = gson.toJson(obj);</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> Text
jsonText = <b><span style="color: #7f0055;">new</span></b> Text();</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">
jsonText.set(json);</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">
IntWritable intt = <b><span style="color: #7f0055;">new</span></b> IntWritable();</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">
intt.set(123);</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">
context.write(<b><span style="color: #7f0055;">null</span></b>, jsonText);</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> }</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">}</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";">Here is the custom input
format reader used for parsing JSON string. <o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">public</span></b><span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <b><span style="color: #7f0055;">class</span></b> <span style="background-color: white;"><span style="background-position: initial initial; background-repeat: initial initial;">JsonParser</span> </span>{</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <b><span style="color: #7f0055;">public</span></b> <b><span style="color: #7f0055;">static</span></b> <b><span style="color: #7f0055;">class</span></b> JsonInputFormat <b><span style="color: #7f0055;">extends</span></b> TextInputFormat {</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <b><span style="color: #7f0055;">public</span></b> <b><span style="color: #7f0055;">static</span></b> <b><span style="color: #7f0055;">final</span></b> String <i><span style="color: #0000c0;">START_TAG_KEY</span></i> = <span style="color: #2a00ff;">"jsonInput.start"</span>;</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <b><span style="color: #7f0055;">public</span></b> <b><span style="color: #7f0055;">static</span></b> <b><span style="color: #7f0055;">final</span></b> String <i><span style="color: #0000c0;">END_TAG_KEY</span></i> = <span style="color: #2a00ff;">"jsonInput.end"</span>;</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <b><span style="color: #7f0055;">public</span></b> RecordReader<LongWritable,
Text> createRecordReader(</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> InputSplit
split, TaskAttemptContext context) {</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <b><span style="color: #7f0055;">return</span></b> <b><span style="color: #7f0055;">new</span></b> JsonRecordReader();</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> }</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <b><span style="color: #7f0055;">public</span></b> <b><span style="color: #7f0055;">static</span></b> <b><span style="color: #7f0055;">class</span></b> JsonRecordReader <b><span style="color: #7f0055;">extends</span></b></span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> RecordReader<<u>LongWritable</u>,
Text> {</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <b><span style="color: #7f0055;">private</span></b> <b><span style="color: #7f0055;">byte</span></b>[] <span style="color: #0000c0;">startTag</span>;</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <b><span style="color: #7f0055;">private</span></b> <b><span style="color: #7f0055;">byte</span></b>[] <span style="color: #0000c0;">endTag</span>;</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <b><span style="color: #7f0055;">private</span></b> <b><span style="color: #7f0055;">long</span></b> <span style="color: #0000c0;">start</span>;</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <b><span style="color: #7f0055;">private</span></b> <b><span style="color: #7f0055;">long</span></b> <span style="color: #0000c0;">end</span>;</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <b><span style="color: #7f0055;">private</span></b> FSDataInputStream <span style="color: #0000c0;">fsin</span>;</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <b><span style="color: #7f0055;">private</span></b> DataOutputBuffer <span style="color: #0000c0;">buffer</span> = <b><span style="color: #7f0055;">new</span></b> DataOutputBuffer();</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <b><span style="color: #7f0055;">private</span></b> LongWritable <span style="color: #0000c0;">key</span> = <b><span style="color: #7f0055;">new</span></b> LongWritable();</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <b><span style="color: #7f0055;">private</span></b> Text <span style="color: #0000c0;">value</span> = <b><span style="color: #7f0055;">new</span></b> Text();</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <span style="color: #646464;">@Override</span></span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <b><span style="color: #7f0055;">public</span></b> <b><span style="color: #7f0055;">void</span></b> initialize(InputSplit
split, TaskAttemptContext context)</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <b><span style="color: #7f0055;">throws</span></b> IOException, InterruptedException
{</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> Configuration
conf = context.getConfiguration();</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <span style="color: #0000c0;">startTag</span> = conf.get(<i><span style="color: #0000c0;">START_TAG_KEY</span></i>).getBytes(<span style="color: #2a00ff;">"utf-8"</span>);</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <span style="color: #0000c0;">endTag</span> = conf.get(<i><span style="color: #0000c0;">END_TAG_KEY</span></i>).getBytes(<span style="color: #2a00ff;">"utf-8"</span>);</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> FileSplit
fileSplit = (FileSplit) split;</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <span style="color: #3f7f5f;">// open the file and seek to the start of the split</span></span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <span style="color: #0000c0;">start</span> = fileSplit.getStart();</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <span style="color: #0000c0;">end</span> = <span style="color: #0000c0;">start</span> +
fileSplit.getLength();</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> Path
file = fileSplit.getPath();</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> FileSystem
fs = file.getFileSystem(conf);</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <span style="color: #0000c0;">fsin</span> = fs.open(fileSplit.getPath());</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <span style="color: #0000c0;">fsin</span>.seek(<span style="color: #0000c0;">start</span>);</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> }</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <span style="color: #646464;">@Override</span></span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <b><span style="color: #7f0055;">public</span></b> <b><span style="color: #7f0055;">boolean</span></b> nextKeyValue() <b><span style="color: #7f0055;">throws</span></b> IOException,</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> InterruptedException
{</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <b><span style="color: #7f0055;">if</span></b> (<span style="color: #0000c0;">fsin</span>.getPos()
< <span style="color: #0000c0;">end</span>) {</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <b><span style="color: #7f0055;">if</span></b> (readUntilMatch(<span style="color: #0000c0;">startTag</span>, <b><span style="color: #7f0055;">false</span></b>))
{</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <b><span style="color: #7f0055;">try</span></b> {</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <span style="color: #0000c0;">buffer</span>.write(<span style="color: #0000c0;">startTag</span>);</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <b><span style="color: #7f0055;">if</span></b> (readUntilMatch(<span style="color: #0000c0;">endTag</span>, <b><span style="color: #7f0055;">true</span></b>))
{</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <span style="color: #0000c0;">key</span>.set(<span style="color: #0000c0;">fsin</span>.getPos());</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <span style="color: #0000c0;">value</span>.set(<span style="color: #0000c0;">buffer</span>.getData(),
0,</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <span style="color: #0000c0;">buffer</span>.getLength());</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <b><span style="color: #7f0055;">return</span></b> <b><span style="color: #7f0055;">true</span></b>;</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> }</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> } <b><span style="color: #7f0055;">finally</span></b> {</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <span style="color: #0000c0;">buffer</span>.reset();</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> }</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> }</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> }</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <b><span style="color: #7f0055;">return</span></b> <b><span style="color: #7f0055;">false</span></b>;</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> }</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <span style="color: #646464;">@Override</span></span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <b><span style="color: #7f0055;">public</span></b> LongWritable getCurrentKey() <b><span style="color: #7f0055;">throws</span></b> IOException,</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> InterruptedException
{</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <b><span style="color: #7f0055;">return</span></b> <span style="color: #0000c0;">key</span>;</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> }</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <span style="color: #646464;">@Override</span></span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <b><span style="color: #7f0055;">public</span></b> Text getCurrentValue() <b><span style="color: #7f0055;">throws</span></b> IOException,</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> InterruptedException
{</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <b><span style="color: #7f0055;">return</span></b> <span style="color: #0000c0;">value</span>;</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> }</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <span style="color: #646464;">@Override</span></span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <b><span style="color: #7f0055;">public</span></b> <b><span style="color: #7f0055;">void</span></b> close() <b><span style="color: #7f0055;">throws</span></b> IOException {</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <span style="color: #0000c0;">fsin</span>.close();</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> }</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <span style="color: #646464;">@Override</span></span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <b><span style="color: #7f0055;">public</span></b> <b><span style="color: #7f0055;">float</span></b> getProgress() <b><span style="color: #7f0055;">throws</span></b> IOException {</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <b><span style="color: #7f0055;">return</span></b> (<span style="color: #0000c0;">fsin</span>.getPos()
- <span style="color: #0000c0;">start</span>) / (<b><span style="color: #7f0055;">float</span></b>)
(<span style="color: #0000c0;">end</span> - <span style="color: #0000c0;">start</span>);</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> }</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <b><span style="color: #7f0055;">private</span></b> <b><span style="color: #7f0055;">boolean</span></b> readUntilMatch(<b><span style="color: #7f0055;">byte</span></b>[] match, <b><span style="color: #7f0055;">boolean</span></b> withinBlock)</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <b><span style="color: #7f0055;">throws</span></b> IOException {</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <b><span style="color: #7f0055;">int</span></b> i = 0;</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <b><span style="color: #7f0055;">int</span></b> c = 0;</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <b><span style="color: #7f0055;">while</span></b> (<b><span style="color: #7f0055;">true</span></b>)
{</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <b><span style="color: #7f0055;">int</span></b> b = <span style="color: #0000c0;">fsin</span>.read();</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> System.<i><span style="color: #0000c0;">out</span></i>.println((<b><span style="color: #7f0055;">char</span></b>)b);</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> System.<i><span style="color: #0000c0;">out</span></i>.println((<b><span style="color: #7f0055;">char</span></b>)match[i]);</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> System.<i><span style="color: #0000c0;">out</span></i>.println((<b><span style="color: #7f0055;">char</span></b>)<span style="color: #0000c0;">startTag</span>[i]);</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <span style="color: #3f7f5f;">// end of file:</span></span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <b><span style="color: #7f0055;">if</span></b> (b == -1)</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <b><span style="color: #7f0055;">return</span></b> <b><span style="color: #7f0055;">false</span></b>;</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <span style="color: #3f7f5f;">// save to buffer:</span></span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <b><span style="color: #7f0055;">if</span></b> (withinBlock) {</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <b><span style="color: #7f0055;">if</span></b> (b == <span style="color: #0000c0;">startTag</span>[i])
{</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> c++;</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> }</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <span style="color: #0000c0;">buffer</span>.write(b);</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> }</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <span style="color: #3f7f5f;">// check if we're matching:</span></span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <b><span style="color: #7f0055;">if</span></b> (b == match[i]) {</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <b><span style="color: #7f0055;">if</span></b> (withinBlock) {</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <b><span style="color: #7f0055;">if</span></b> (c == 0) {</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> i++;</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> } <b><span style="color: #7f0055;">else</span></b> {</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> i
= 0;</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> c--;</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> }</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> }</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <b><span style="color: #7f0055;">else</span></b>{</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> i++;</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> }</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <b><span style="color: #7f0055;">if</span></b> (i >= match.<span style="color: #0000c0;">length</span>)</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <b><span style="color: #7f0055;">return</span></b> <b><span style="color: #7f0055;">true</span></b>;</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> } <b><span style="color: #7f0055;">else</span></b></span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> i
= 0;</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <span style="color: #3f7f5f;">// see if we've passed the stop point:</span></span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <b><span style="color: #7f0055;">if</span></b> (!withinBlock && i == 0
&& <span style="color: #0000c0;">fsin</span>.getPos() >= <span style="color: #0000c0;">end</span>)</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <b><span style="color: #7f0055;">return</span></b> <b><span style="color: #7f0055;">false</span></b>;</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> }</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> }</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> }</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> }</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">}</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";">Here is the custom input JSON mapper
file which is used to parse the JSON input string into individual
elements. <o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">public</span></b><span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <b><span style="color: #7f0055;">class</span></b> MaxTemperatureJSONMapper <b><span style="color: #7f0055;">extends</span></b></span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">
Mapper<LongWritable, Text, Text, IntWritable> {</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <b><span style="color: #7f0055;">private</span></b> <b><span style="color: #7f0055;">static</span></b> <b><span style="color: #7f0055;">final</span></b> <b><span style="color: #7f0055;">int</span></b> <i><u><span style="color: #0000c0;">MISSING</span></u></i> = 9999;</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <b><span style="color: #7f0055;">static</span></b> Logger <i><span style="color: #0000c0;">log</span></i> = Logger.<i>getLogger</i>(MaxTemperatureJSONMapper.<b><span style="color: #7f0055;">class</span></b>);</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <span style="color: #646464;">@Override</span></span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <b><span style="color: #7f0055;">public</span></b> <b><span style="color: #7f0055;">void</span></b> map(LongWritable
key, Text value, Context context)</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <b><span style="color: #7f0055;">throws</span></b> IOException, InterruptedException
{</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <i><span style="color: #0000c0;">log</span></i>.setLevel(Level.<i><span style="color: #0000c0;">INFO</span></i>);</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <i><span style="color: #0000c0;">log</span></i>.info(<span style="color: #2a00ff;">"Map
key:-"</span> + key);</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">
String line = value.toString();</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">
JSONObject myJson;</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <b><span style="color: #7f0055;">try</span></b> {</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">
myJson = <b><span style="color: #7f0055;">new</span></b> JSONObject(line);</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">
String year = myJson.getString(<span style="color: #2a00ff;">"year"</span>);</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <b><span style="color: #7f0055;">int</span></b> airTemperature = myJson.getInt(<span style="color: #2a00ff;">"airTemperature"</span>);</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">
String <u>quality</u> = myJson.getString(<span style="color: #2a00ff;">"quality"</span>);</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">
context.write(<b><span style="color: #7f0055;">new</span></b> Text(year), <b><span style="color: #7f0055;">new</span></b> IntWritable(airTemperature));</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">
} <b><span style="color: #7f0055;">catch</span></b> (JSONException e) {</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <i><span style="color: #0000c0;">log</span></i>.error(<span style="color: #2a00ff;">"JSON
conversion exception"</span>);</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">
e.printStackTrace();</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">
}</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> }</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">}</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";">Here is the Reducer class
implementation.<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">public</span></b><span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <b><span style="color: #7f0055;">class</span></b> MaxTemperatureReducer <b><span style="color: #7f0055;">extends</span></b></span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> Reducer<Text,
IntWritable, Text, IntWritable> {</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <span style="color: #646464;">@Override</span></span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <b><span style="color: #7f0055;">public</span></b> <b><span style="color: #7f0055;">void</span></b> reduce(Text
key, Iterable<IntWritable> values, Context context)</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <b><span style="color: #7f0055;">throws</span></b> IOException, InterruptedException
{</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <b><span style="color: #7f0055;">int</span></b> maxValue = Integer.<i><span style="color: #0000c0;">MIN_VALUE</span></i>;</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> <b><span style="color: #7f0055;">for</span></b> (IntWritable value : values) {</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> maxValue
= Math.<i>max</i>(maxValue, value.get());</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> }</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> context.write(key, <b><span style="color: #7f0055;">new</span></b> IntWritable(maxValue));</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"> }</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">}</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";">That's it on job chaining. Here I
have shown a simplest example of taking the raw text file as input to first
job, feeding the output- the JSON file as input to the second Job & perform
map-reduce operation on it. There are multiple other ways to chain a job in
hadoop. <o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<i><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";">Cheers </span></i><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<i><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";">Happy Learning :)</span></i><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"> <o:p></o:p></span></b></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal">
<br /></div>
</div>
</div>
</div>
Anonymoushttp://www.blogger.com/profile/10713264593334966481noreply@blogger.com0tag:blogger.com,1999:blog-3586645045303501566.post-6195148125886339382014-03-06T05:46:00.000-08:002014-04-01T02:39:05.875-07:00FUSE OSGI with CXF based web services <div dir="ltr" style="text-align: left;" trbidi="on">
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="MsoNormal">
<b><span style="font-size: 14.0pt; line-height: 107%; mso-bidi-font-size: 11.0pt;">FUSE OSGI:<o:p></o:p></span></b></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b><span style="font-size: 14.0pt; line-height: 107%; mso-bidi-font-size: 11.0pt;">Overview:<o:p></o:p></span></b></div>
<div class="MsoNormal">
<b><span style="background-position: initial initial; background-repeat: initial initial; font-family: Arial, sans-serif; font-size: 10pt; line-height: 107%;">JBoss Fuse</span></b><span class="apple-converted-space"><span style="background-position: initial initial; background-repeat: initial initial; font-family: Arial, sans-serif; font-size: 10pt; line-height: 107%;"> </span></span><span style="background-position: initial initial; background-repeat: initial initial; font-family: Arial, sans-serif; font-size: 10pt; line-height: 107%;">is an open source integration platform based on<span class="apple-converted-space"> </span></span>Apache
ServiceMix<span class="apple-converted-space"><span style="background-position: initial initial; background-repeat: initial initial; font-family: Arial, sans-serif; font-size: 10pt; line-height: 107%;"> </span></span><span style="background-position: initial initial; background-repeat: initial initial; font-family: Arial, sans-serif; font-size: 10pt; line-height: 107%;">that
supports<span class="apple-converted-space"> </span></span>JBI<span class="apple-converted-space"><span style="background-position: initial initial; background-repeat: initial initial; font-family: Arial, sans-serif; font-size: 10pt; line-height: 107%;"> </span></span><span style="background-position: initial initial; background-repeat: initial initial; font-family: Arial, sans-serif; font-size: 10pt; line-height: 107%;">and<span class="apple-converted-space"> </span></span>OSGi<span class="apple-converted-space"><span style="background-position: initial initial; background-repeat: initial initial; font-family: Arial, sans-serif; font-size: 10pt; line-height: 107%;"> </span></span><span style="background-position: initial initial; background-repeat: initial initial; font-family: Arial, sans-serif; font-size: 10pt; line-height: 107%;">for use in wide ranges of enterprise application.
It<span class="apple-converted-space"> </span>is robust SOA infrastructure
that provides a standardized methodology, server, and tools to integrate
components in mission-critical applications.<o:p></o:p></span></div>
<div class="MsoNormal">
Fuse ESB has the following layered architecture:<o:p></o:p></div>
<div style="margin-left: .5in; mso-list: l1 level1 lfo1; tab-stops: list .5in; text-indent: -.25in;">
<!--[if !supportLists]--><span style="font-family: Symbol; font-size: 10pt;">·<span style="font-family: 'Times New Roman'; font-size: 7pt;">
</span></span><!--[endif]--><strong><span style="font-family: Calibri, sans-serif;">Technology layer</span></strong><span style="font-family: Calibri, sans-serif;">—includes technologies such as JBI, JAX-WS, JAX-RS, JMS, Spring,
and JEE<o:p></o:p></span></div>
<div style="margin-left: .5in; mso-list: l1 level1 lfo1; tab-stops: list .5in; text-indent: -.25in;">
<!--[if !supportLists]--><span style="font-family: Symbol; font-size: 10pt;">·<span style="font-family: 'Times New Roman'; font-size: 7pt;">
</span></span><!--[endif]-->Fuse ESB kernel<span class="apple-converted-space"><b><span style="font-family: Calibri, sans-serif;"> </span></b></span><span style="font-family: Calibri, sans-serif;">— it is a wrapper layer around the OSGi container implementation,
which provides support for deploying the OSGi container as a runtime server.<o:p></o:p></span></div>
<div style="margin-left: .5in; mso-list: l1 level1 lfo1; tab-stops: list .5in; text-indent: -.25in;">
<!--[if !supportLists]--><span style="font-family: Symbol; font-size: 10pt;">·<span style="font-family: 'Times New Roman'; font-size: 7pt;">
</span></span><!--[endif]--><a href="http://fusesource.com/docs/esb/4.4.1/esb_deploy_osgi/framework.html">OSGi
framework<span class="apple-converted-space"><b><span style="color: #3333cc; font-family: "Calibri","sans-serif"; text-decoration: none; text-underline: none;"> </span></b></span></a><span style="font-family: Calibri, sans-serif;">—it implements OSGi
functionality, including managing dependencies and bundle lifecycles.<o:p></o:p></span></div>
<span style="font-family: Calibri, sans-serif;">The following
diagram shows architecture of fuse ESB.<o:p></o:p></span><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh4hyphenhypheniFXXrRKIh7agPIXxig0nwQoK-LTOmG93oHGw4mxBCbfaPPlgjfIQBZ3F4wcs2zzLf-38bvZMpUIB1VtNj6E9fgBHVZcq6GLM7fCrNE53rjdAVmcQJ_f_8nufvgVHPUfJ0zx_-Vac8/s1600/fuse-osgi.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh4hyphenhypheniFXXrRKIh7agPIXxig0nwQoK-LTOmG93oHGw4mxBCbfaPPlgjfIQBZ3F4wcs2zzLf-38bvZMpUIB1VtNj6E9fgBHVZcq6GLM7fCrNE53rjdAVmcQJ_f_8nufvgVHPUfJ0zx_-Vac8/s1600/fuse-osgi.png" height="171" width="400" /></a></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoListBulletCxSpFirst">
<!--[if !supportLists]--><span style="font-family: Symbol; font-size: 14.0pt; line-height: 107%; mso-bidi-font-family: Symbol; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: Symbol;">·<span style="font-family: 'Times New Roman'; font-size: 7pt; line-height: normal;">
</span></span><!--[endif]--><strong><span style="font-family: Calibri, sans-serif;">Console: </span></strong><strong><span style="font-family: Calibri, sans-serif; font-weight: normal;">It</span></strong><strong><span style="font-family: Calibri, sans-serif;"> </span></strong>manages
services, installs and manages applications and libraries, and interacts with
the Fuse ESB kernel runtime.<span style="font-size: 14.0pt; line-height: 107%; mso-bidi-font-size: 11.0pt;"><o:p></o:p></span></div>
<div class="MsoListBulletCxSpMiddle">
<!--[if !supportLists]--><strong><span style="font-family: Symbol; font-size: 14.0pt; font-weight: normal; line-height: 107%; mso-bidi-font-family: Symbol; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: Symbol;">·<span style="font-family: 'Times New Roman'; font-size: 7pt; line-height: normal;">
</span></span></strong><!--[endif]--><strong><span style="font-family: "Calibri","sans-serif"; mso-ascii-theme-font: minor-latin; mso-bidi-font-family: "Times New Roman"; mso-bidi-theme-font: minor-bidi; mso-hansi-theme-font: minor-latin;">Logging: </span></strong><strong><span style="font-family: "Calibri","sans-serif"; font-weight: normal; mso-ascii-theme-font: minor-latin; mso-bidi-font-family: "Times New Roman"; mso-bidi-font-weight: bold; mso-bidi-theme-font: minor-bidi; mso-hansi-theme-font: minor-latin;">Provides
a powerful logging system to display view and change log levels.</span></strong><strong><span style="font-family: "Calibri","sans-serif"; font-size: 14.0pt; font-weight: normal; line-height: 107%; mso-ascii-theme-font: minor-latin; mso-bidi-font-family: "Times New Roman"; mso-bidi-font-size: 11.0pt; mso-bidi-theme-font: minor-bidi; mso-hansi-theme-font: minor-latin;"><o:p></o:p></span></strong></div>
<div class="MsoListBulletCxSpMiddle">
<!--[if !supportLists]--><strong><span style="font-family: Symbol; font-size: 14.0pt; font-weight: normal; line-height: 107%; mso-bidi-font-family: Symbol; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: Symbol;">·<span style="font-family: 'Times New Roman'; font-size: 7pt; line-height: normal;">
</span></span></strong><!--[endif]--><strong><span style="font-family: "Calibri","sans-serif"; mso-ascii-theme-font: minor-latin; mso-bidi-font-family: "Times New Roman"; mso-bidi-theme-font: minor-bidi; mso-hansi-theme-font: minor-latin;">Deployer: </span></strong><strong><span style="font-family: "Calibri","sans-serif"; font-weight: normal; mso-ascii-theme-font: minor-latin; mso-bidi-font-family: "Times New Roman"; mso-bidi-font-weight: bold; mso-bidi-theme-font: minor-bidi; mso-hansi-theme-font: minor-latin;">It
supports hot deployment of OSGI bundles, upon updating or deletion changes are
automatically reflected.</span></strong><strong><span style="font-family: "Calibri","sans-serif"; font-size: 14.0pt; font-weight: normal; line-height: 107%; mso-ascii-theme-font: minor-latin; mso-bidi-font-family: "Times New Roman"; mso-bidi-font-size: 11.0pt; mso-bidi-theme-font: minor-bidi; mso-hansi-theme-font: minor-latin;"><o:p></o:p></span></strong></div>
<div class="MsoListBulletCxSpMiddle">
<!--[if !supportLists]--><strong><span style="font-family: Symbol; font-size: 14.0pt; font-weight: normal; line-height: 107%; mso-bidi-font-family: Symbol; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: Symbol;">·<span style="font-family: 'Times New Roman'; font-size: 7pt; line-height: normal;">
</span></span></strong><!--[endif]--><strong><span style="font-family: Calibri, sans-serif;">Spring DM: </span></strong><strong><span style="font-family: Calibri, sans-serif; font-weight: normal;">Simplifies building
spring application that runs in an OSGI. </span></strong><strong><span style="font-family: "Calibri","sans-serif"; font-size: 14.0pt; font-weight: normal; line-height: 107%; mso-ascii-theme-font: minor-latin; mso-bidi-font-family: "Times New Roman"; mso-bidi-font-size: 11.0pt; mso-bidi-theme-font: minor-bidi; mso-hansi-theme-font: minor-latin;"><o:p></o:p></span></strong></div>
<div class="MsoListBulletCxSpMiddle">
<br /></div>
<div class="MsoListBulletCxSpMiddle">
<br /></div>
<div class="MsoListBulletCxSpLast">
<b><span style="font-size: 14.0pt; line-height: 107%; mso-bidi-font-size: 11.0pt;">Installation:<o:p></o:p></span></b></div>
<div class="MsoNormal">
Fuse can be easily installed into windows systems.<o:p></o:p></div>
<div class="MsoNormal">
Go to <a href="http://fusesource.com/downloads/"><b>http://fusesource.com/downloads/</b></a><b><o:p></o:p></b></div>
<div class="MsoNormal">
Search for <b>Fuse ESB Enterprise, </b>download windows installer
& install it in the same way as other applications are installed into
windows.<o:p></o:p></div>
<div class="MsoNormal">
I suppose the installation is
done at “C:\FuseESBEnterprise-7.0.1”, where you will see all the fuse ESB
related installation folder and files. <o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b><span style="font-size: 12.0pt; line-height: 107%; mso-bidi-font-size: 11.0pt;">FUSE ESB
Configuration:<o:p></o:p></span></b></div>
<div class="MsoNormal">
All the OSGI configuration files are located at <code><i><span style="color: #990033; font-size: 10.0pt; line-height: 107%; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin;">InstallDir</span></i></code><code><span style="color: #990033; font-family: "Lucida Console"; font-size: 9.0pt; line-height: 107%; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin;">/etc</span></code><span class="apple-converted-space"> directory. </span>A configuration is a list
of name-value pairs read from a<span class="apple-converted-space"> </span><code><span style="color: #990033; font-family: "Lucida Console"; font-size: 9.0pt; line-height: 107%; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin;">.cfg</span></code><span class="apple-converted-space"> </span>file in fuse.<o:p></o:p></div>
<div class="MsoNormal">
<b>org.apache.karaf.features.cfg:
</b>This contains configuration of list of features available in fuse. While running <b>Fuse</b>, it will look for this configuration file to load all the
features. If you want your custom
feature to be added in fuse, then you need to add a custom feature file in the <b>featuresRepositories</b> section as below.<o:p></o:p></div>
<div class="MsoNormal">
featuresRepositories=\<o:p></o:p></div>
<div class="MsoNormal">
mvn:org.apache.karaf.assemblies.features/standard/2.2.5.fuse-70-084/xml/features,\<o:p></o:p></div>
<div class="MsoNormal" style="text-indent: .5in;">
<a href="file:///C:/FuseESBEnterprise-7.0.1/etc/custom-features.xml"><b>file:///C:/FuseESBEnterprise-7.0.1/etc/custom-features.xml</b></a><b><o:p></o:p></b></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
In above example, I have added custom-features.xml feature
file to a feature repository section. This feature file will contain all of my
project specific bundles & other features which are not natively available
in fuse such as hibernate features, spring features, Junit features, cache
features which are required in your application to deploy a bundle. <o:p></o:p></div>
<div class="MsoNormal">
The features are described in a features XML descriptor.<span class="apple-converted-space"><span style="font-family: Verdana, sans-serif; font-size: 8.5pt; line-height: 107%;"> <o:p></o:p></span></span></div>
<div class="MsoNormal">
<span class="apple-converted-space"><span style="font-family: Verdana, sans-serif; font-size: 10pt; line-height: 107%;">Here is an example of <b>custom-features.xml</b>
file:<o:p></o:p></span></span></div>
<div class="MsoNormal">
<span class="apple-converted-space"><span style="font-family: Verdana, sans-serif; font-size: 10pt; line-height: 107%;"><br /></span></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhXF1VIfa7yDujYmSc9pdiMrmQCZY_myoxYwTvO4qx4rUd9j7uKcCZVdN2WUlOR_tV0IGXk-npf4BWX6ZsKiYYAe7asFTEt2hgajK6d1DBWdeO6owNJhIXwqzxcOLjAfCkQZCxY2gb-ZK8/s1600/feature-xml.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhXF1VIfa7yDujYmSc9pdiMrmQCZY_myoxYwTvO4qx4rUd9j7uKcCZVdN2WUlOR_tV0IGXk-npf4BWX6ZsKiYYAe7asFTEt2hgajK6d1DBWdeO6owNJhIXwqzxcOLjAfCkQZCxY2gb-ZK8/s1600/feature-xml.png" /></a></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
Here, you can see the feature file that contains the feature
named “<b>hibernate</b>”, then <b><bundle></bundle> </b>tag which
is used to include the specific feature file. For ex- if I need a hibernate jar
to be included in my bundle, I am giving a reference name.<o:p></o:p></div>
<div class="MsoNormal">
It is important here to understand that some features are
provided through fuse itself. The <b>mvn:org.hibernate/com.springsource.org.hibernate/3.3.2.GA
</b>is provided by fuse itself. However all the features that are needed in
your application, might not be provided from fuse. In that case you need to
install it through your system directory itself. <o:p></o:p></div>
<div class="MsoNormal">
<b><bundle>wrap:file:///C:/FuseESBEnterprise-7.0.1/lib/ext/Juint/junit/4.7/junit-4.7.jar</bundle>
</b>is an example of installing a bundle through the file system.<o:p></o:p></div>
<div class="MsoNormal">
To install a bundle through <b>mvn</b> repository, we use a command: <b>mvn:groupId/ArtificatId/Version. </b>The last 2 bundles common &
group are an example of installing application specific bundle through maven
repository.<o:p></o:p></div>
<div class="MsoNormal" style="text-indent: .5in;">
<br /></div>
<div class="MsoNormal">
<b><span style="font-size: 12.0pt; line-height: 107%; mso-bidi-font-size: 11.0pt;">Enable
Debugging:<o:p></o:p></span></b></div>
<div class="MsoNormal">
You can enable debugging in a fuse by editing property /bin/<b>karaf.bat </b>or in <b>fuseesb.bat<o:p></o:p></b></div>
<div class="MsoNormal" style="margin-bottom: 11pt;">
<span style="background-position: initial initial; background-repeat: initial initial; font-family: Arial, sans-serif; font-size: 10pt;">KARAF_DEBUG=<b>true<o:p></o:p></b></span></div>
<div class="MsoNormal" style="margin-bottom: 11pt;">
<span style="background-position: initial initial; background-repeat: initial initial; font-family: Arial, sans-serif; font-size: 10pt;">set <b>DEFAULT_JAVA_DEBUG_OPTS</b>=-Xdebug -Xnoagent
-Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=</span><span style="color: #a61c00; font-family: "Arial","sans-serif"; font-size: 10.0pt;">5005<o:p></o:p></span></div>
<div class="MsoNormal">
Here <b>5005</b> is a debug port allocated for fuse.<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b><span style="font-size: 12.0pt; line-height: 107%; mso-bidi-font-size: 11.0pt;">Configuring HttpPort:</span> <o:p></o:p></b></div>
<div class="MsoNormal">
Open /etc/<b>system.properties</b> , modify the port
number<o:p></o:p></div>
<div class="MsoNormal">
<b><span style="background-position: initial initial; background-repeat: initial initial; font-family: Arial, sans-serif; font-size: 10pt; line-height: 107%;">org.osgi.service.http.port=8181<o:p></o:p></span></b></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b><span style="background-position: initial initial; background-repeat: initial initial; font-family: Arial, sans-serif; font-size: 12pt; line-height: 107%;">Starting
fuse:<o:p></o:p></span></b></div>
<div class="MsoNormal">
You can start fuse by running
a <b>fuseesb.bat</b> file located at <b>/bin </b>directory. By default fuse start
deploying native bundles first which are around 218. After that an application
specific custom bundles will be deployed. All the deployed bundled are seen at <b>\data\cache</b> directory. You can monitor
the progress of deployment through a log file which is created at <b>\data\log </b>directory. The log file
greatly helps us to roll out exiting deployment errors & informations.<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b><span style="font-size: 12.0pt; line-height: 107%; mso-bidi-font-size: 11.0pt;">Modifying
an Existing Maven web service Project to work with fuse:<o:p></o:p></span></b></div>
<div class="MsoNormal">
An existing modular maven project can be easily deployed at
fuse with some minor changes at <b>POM</b>
file.<o:p></o:p></div>
<div class="MsoListBulletCxSpFirst" style="margin-left: .5in; mso-add-space: auto; mso-list: l2 level1 lfo3; tab-stops: .5in;">
<!--[if !supportLists]--><span style="font-family: Wingdings; mso-bidi-font-family: Wingdings; mso-fareast-font-family: Wingdings;">ð<span style="font-family: 'Times New Roman'; font-size: 7pt;">
</span></span><!--[endif]--><b>Modify a
POM to generate bundle: </b> To configure
a maven to generate bundle we need basically 2 things :<o:p></o:p></div>
<div class="MsoListBulletCxSpMiddle" style="margin-left: 1.0in; mso-add-space: auto; mso-list: l2 level2 lfo3; tab-stops: .5in;">
<!--[if !supportLists]--><span style="font-family: "Courier New"; mso-fareast-font-family: "Courier New";">o<span style="font-family: 'Times New Roman'; font-size: 7pt;">
</span></span><!--[endif]--> Change
the POM's package type to bundle: <b><packaging>bundle</packaging></b><o:p></o:p></div>
<div class="MsoListBulletCxSpMiddle" style="margin-left: 1.0in; mso-add-space: auto; mso-list: l2 level2 lfo3; tab-stops: .5in;">
<!--[if !supportLists]--><span style="font-family: "Courier New"; mso-fareast-font-family: "Courier New";">o<span style="font-family: 'Times New Roman'; font-size: 7pt;">
</span></span><!--[endif]-->Add the Maven bundle plug-in:<o:p></o:p></div>
<div>
<br /></div>
<br />
<div class="MsoListBulletCxSpMiddle" style="margin-left: .5in; mso-add-space: auto; mso-list: none; tab-stops: .5in; text-align: justify; text-indent: 0in;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiW_2jvpBgXtymkzeCnfwIFN16JdQKN73pRLVp88DFX-hebGTqh2XSaH_-OTVDrLiEeDf5qGMUFB8TGERaGsman7hAWDAbK6DEavUNaKGOCkY7ztGrxXKFYoABBSNYqb1dfzf6nSVcS3zk/s1600/add-maven-bundle-plugin.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiW_2jvpBgXtymkzeCnfwIFN16JdQKN73pRLVp88DFX-hebGTqh2XSaH_-OTVDrLiEeDf5qGMUFB8TGERaGsman7hAWDAbK6DEavUNaKGOCkY7ztGrxXKFYoABBSNYqb1dfzf6nSVcS3zk/s1600/add-maven-bundle-plugin.png" /></a>All dependent
packages that are required for an application bundle need to be explicitly
mentioned at <b><Import-Package></b> section.
For example for a web service project that uses Apache <span style="text-transform: uppercase;">cxf</span> component need to include the following dependent
packages.<o:p></o:p></div>
<div class="MsoListBulletCxSpMiddle" style="margin-left: .75in; mso-add-space: auto; mso-list: none; tab-stops: .5in;">
<!--[if gte vml 1]><v:shape id="Picture_x0020_6"
o:spid="_x0000_s1028" type="#_x0000_t75" style='position:absolute;left:0;
text-align:left;margin-left:37.5pt;margin-top:9.05pt;width:306pt;height:216.75pt;
z-index:251659264;visibility:visible;mso-wrap-style:square;
mso-width-percent:0;mso-height-percent:0;mso-wrap-distance-left:9pt;
mso-wrap-distance-top:0;mso-wrap-distance-right:9pt;
mso-wrap-distance-bottom:0;mso-position-horizontal:absolute;
mso-position-horizontal-relative:text;mso-position-vertical:absolute;
mso-position-vertical-relative:text;mso-width-percent:0;mso-height-percent:0;
mso-width-relative:page;mso-height-relative:page'>
<v:imagedata src="file:///C:\Users\PREMS~1.BIS\AppData\Local\Temp\msohtmlclip1\01\clip_image007.png"
o:title=""/>
<w:wrap type="through"/>
</v:shape><![endif]--><!--[if !vml]--><!--[endif]--><b><o:p></o:p></b></div>
<div class="MsoListBulletCxSpLast" style="margin-left: 1.0in; mso-add-space: auto; mso-list: none; tab-stops: .5in; text-indent: 0in;">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj_OD8uZf1fApw4zJOwNWiEuNNIiAhwsjchea0J6k2f1IdHOUtchrlTSwiOGLImq1u2sEEUCkGB20uiVEGtzqUVb9VVpAte89_dI1XS5iMSvRWlVkghTqHlHJSMX9_crZA8fa7Z2wfbbX8/s1600/import-package.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj_OD8uZf1fApw4zJOwNWiEuNNIiAhwsjchea0J6k2f1IdHOUtchrlTSwiOGLImq1u2sEEUCkGB20uiVEGtzqUVb9VVpAte89_dI1XS5iMSvRWlVkghTqHlHJSMX9_crZA8fa7Z2wfbbX8/s1600/import-package.png" /></a></div>
<br />
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<o:p> </o:p> </div>
<div class="MsoNormal" style="margin-left: .5in;">
Apart from this, if your
application is based on Hibernate & Spring, you need to include those
packages as well inside import section. Further-more all our application
specific components are required to be included. These all imports are
mandatory for <b>maven-bundle-plugin </b>to
generate <b>Manifest.Mf </b>file which can
be seen inside the bundle at: <o:p></o:p></div>
<div class="MsoNormal" style="margin-left: .5in;">
<b>data\cache\bundleName\version0.0\bundle.jar\META-INF\
</b>location<o:p></o:p></div>
<div class="MsoNormal" style="margin-left: .5in;">
While application is exposed
through a client, the fuse will use Manifest.Mf file to read and locate related
information about this specific bundle. <o:p></o:p></div>
<div class="MsoNormal" style="margin-left: .5in;">
In <b><Export-Package></b> section, we provide those package which are
required outside of this bundle & useful to other bundle. The exported
package of bundle can be imported by other bundles if they are dependent on
those packages.<o:p></o:p></div>
<div class="MsoNormal" style="margin-left: .5in;">
<!--[if gte vml 1]><v:shape id="Picture_x0020_8"
o:spid="_x0000_s1027" type="#_x0000_t75" style='position:absolute;left:0;
text-align:left;margin-left:0;margin-top:27.3pt;width:513.75pt;height:483.75pt;
z-index:251660288;visibility:visible;mso-wrap-style:square;
mso-width-percent:0;mso-height-percent:0;mso-wrap-distance-left:9pt;
mso-wrap-distance-top:0;mso-wrap-distance-right:9pt;
mso-wrap-distance-bottom:0;mso-position-horizontal:left;
mso-position-horizontal-relative:margin;mso-position-vertical:absolute;
mso-position-vertical-relative:text;mso-width-percent:0;mso-height-percent:0;
mso-width-relative:margin;mso-height-relative:margin'>
<v:imagedata src="file:///C:\Users\PREMS~1.BIS\AppData\Local\Temp\msohtmlclip1\01\clip_image008.png"
o:title=""/>
<w:wrap type="through" anchorx="margin"/>
</v:shape><![endif]--><!--[if !vml]--><!--[endif]-->Here is a sample POM:<o:p></o:p></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgCvAuJez_MKm5sQdubcgMidfl3N0EnHwDPA8wtF-nwTlhojCDl0ksWQ_FGTigYbQEAL-TZM78IkbXg4902r3RQf466KPcDtyynCbbKOYaxOSjFihcgWjszYcNUroa9wGlE2dPQh7zGNFg/s1600/pom-1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgCvAuJez_MKm5sQdubcgMidfl3N0EnHwDPA8wtF-nwTlhojCDl0ksWQ_FGTigYbQEAL-TZM78IkbXg4902r3RQf466KPcDtyynCbbKOYaxOSjFihcgWjszYcNUroa9wGlE2dPQh7zGNFg/s1600/pom-1.png" /></a></div>
<div class="MsoNormal" style="margin-left: .5in;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEifYPDE9lw_k8bdyTTcctdUJNLNukXm4l5vC1qVgmsLNLyrBjOAHM1-80OePEOk2OGjeDsEjiG4SvDcS8soHX6BsnXswqIRiFKlpn5HUzYTb6DLzLUAgU54cRDuvIDrOhpY-tmYryrBDhw/s1600/pom-2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEifYPDE9lw_k8bdyTTcctdUJNLNukXm4l5vC1qVgmsLNLyrBjOAHM1-80OePEOk2OGjeDsEjiG4SvDcS8soHX6BsnXswqIRiFKlpn5HUzYTb6DLzLUAgU54cRDuvIDrOhpY-tmYryrBDhw/s1600/pom-2.png" /></a></div>
<div class="MsoNormal" style="margin-left: .5in;">
<br /></div>
<div class="MsoNormal" style="margin-left: .5in;">
<br /></div>
<div class="MsoNormal" style="margin-left: .5in;">
<br /></div>
<div class="MsoNormal" style="margin-left: .5in;">
<!--[if gte vml 1]><v:shape id="Picture_x0020_9"
o:spid="_x0000_s1026" type="#_x0000_t75" style='position:absolute;left:0;
text-align:left;margin-left:0;margin-top:0;width:7in;height:485.25pt;
z-index:251661312;visibility:visible;mso-wrap-style:square;
mso-width-percent:0;mso-height-percent:0;mso-wrap-distance-left:9pt;
mso-wrap-distance-top:0;mso-wrap-distance-right:9pt;
mso-wrap-distance-bottom:0;mso-position-horizontal:left;
mso-position-horizontal-relative:margin;mso-position-vertical:absolute;
mso-position-vertical-relative:text;mso-width-percent:0;mso-height-percent:0;
mso-width-relative:margin;mso-height-relative:margin'>
<v:imagedata src="file:///C:\Users\PREMS~1.BIS\AppData\Local\Temp\msohtmlclip1\01\clip_image010.png"
o:title=""/>
<w:wrap type="through" anchorx="margin"/>
</v:shape><![endif]--><!--[if !vml]--><!--[endif]--><o:p></o:p></div>
<div class="MsoNormal">
<b><span style="font-size: 12.0pt; line-height: 107%; mso-bidi-font-size: 11.0pt;">Few useful FUSE
ESB commands:<o:p></o:p></span></b></div>
<div class="MsoNormal">
<b>Installing a new bundle:<o:p></o:p></b></div>
<div class="MsoListBulletCxSpFirst">
The following
commands install a new bundle through a file and maven repository respectively.<o:p></o:p></div>
<div class="MsoListBulletCxSpMiddle">
<!--[if !supportLists]--><span style="font-family: Symbol; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;">·<span style="font-family: 'Times New Roman'; font-size: 7pt;">
</span></span><!--[endif]--><b>osgi:install</b>
-s file:D:/fuse-test/test/common/target/test.jar<o:p></o:p></div>
<div class="MsoListBulletCxSpMiddle">
<!--[if !supportLists]--><span style="font-family: Symbol; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;">·<span style="font-family: 'Times New Roman'; font-size: 7pt;">
</span></span><!--[endif]--><b>osgi:install</b>
mvn:com.test.plan/plan/0.0.1-plan<o:p></o:p></div>
<div class="MsoListBulletCxSpMiddle">
<!--[if !supportLists]--><span style="font-family: Symbol; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;">·<span style="font-family: 'Times New Roman'; font-size: 7pt;">
</span></span><!--[endif]--><b>list: </b>Provides
list of all installed bundles in the system<o:p></o:p></div>
<div class="MsoListBulletCxSpMiddle">
<!--[if !supportLists]--><span style="font-family: Symbol; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;">·<span style="font-family: 'Times New Roman'; font-size: 7pt;">
</span></span><!--[endif]--><o:p> </o:p></div>
<div class="MsoListBulletCxSpMiddle">
<!--[if !supportLists]--><span style="font-family: Symbol; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;">·<span style="font-family: 'Times New Roman'; font-size: 7pt;">
</span></span><!--[endif]--><b>osgi:start
: </b>Starts a specific bundle . Eg: osgi:start 130 will start bundle number 130<b><o:p></o:p></b></div>
<div class="MsoListBulletCxSpMiddle">
<!--[if !supportLists]--><span style="font-family: Symbol; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;">·<span style="font-family: 'Times New Roman'; font-size: 7pt;">
</span></span><!--[endif]--><b>osgi:stop
: </b>Stops a specific bundle<b><o:p></o:p></b></div>
<div class="MsoListBulletCxSpMiddle">
<!--[if !supportLists]--><span style="font-family: Symbol; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;">·<span style="font-family: 'Times New Roman'; font-size: 7pt;">
</span></span><!--[endif]--><b>osgi:uninstall:
</b>Uninstalls a bundle with provided bundle id. Eg: osgi:uninstall 130<b><o:p></o:p></b></div>
<div class="MsoListBulletCxSpMiddle">
<!--[if !supportLists]--><span style="font-family: Symbol; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;">·<span style="font-family: 'Times New Roman'; font-size: 7pt;">
</span></span><!--[endif]--><b>osgi:stop:
</b>Stops a bundle Eg: osgi:stop 130<b><o:p></o:p></b></div>
<div class="MsoListBulletCxSpMiddle">
<!--[if !supportLists]--><span style="font-family: Symbol; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;">·<span style="font-family: 'Times New Roman'; font-size: 7pt;">
</span></span><!--[endif]--><b>osgi:bundle-level:
</b>Gets or sets the start level of a given bundle.<b><o:p></o:p></b></div>
<div class="MsoListBulletCxSpMiddle">
<!--[if !supportLists]--><span style="font-family: Symbol; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;">·<span style="font-family: 'Times New Roman'; font-size: 7pt;">
</span></span><!--[endif]--><b>osgi:headers:</b>
Displays OSGi headers of a specified bundle.<b><o:p></o:p></b></div>
<div class="MsoListBulletCxSpMiddle">
<!--[if !supportLists]--><span style="font-family: Symbol; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;">·<span style="font-family: 'Times New Roman'; font-size: 7pt;">
</span></span><!--[endif]--><b>osgi:refresh:
</b>Refreshes the bundle.<b><o:p></o:p></b></div>
<div class="MsoListBulletCxSpMiddle">
<!--[if !supportLists]--><span style="font-family: Symbol; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;">·<span style="font-family: 'Times New Roman'; font-size: 7pt;">
</span></span><!--[endif]--><b>osgi:resolve:
</b>Resolves the bundle.<b><o:p></o:p></b></div>
<div class="MsoListBulletCxSpMiddle">
<!--[if !supportLists]--><span style="font-family: Symbol; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;">·<span style="font-family: 'Times New Roman'; font-size: 7pt;">
</span></span><!--[endif]--><b>osgi:restart:
</b>Restarts a bundle.<b><o:p></o:p></b></div>
<div class="MsoListBulletCxSpMiddle">
<!--[if !supportLists]--><span style="font-family: Symbol; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;">·<span style="font-family: 'Times New Roman'; font-size: 7pt;">
</span></span><!--[endif]--><b>osgi:shutdown:
</b>Shuts down the OSGI framework.<b><o:p></o:p></b></div>
<div class="MsoListBulletCxSpMiddle">
<!--[if !supportLists]--><span style="font-family: Symbol; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;">·<span style="font-family: 'Times New Roman'; font-size: 7pt;">
</span></span><!--[endif]--><b>osgi:update:
</b>Updates the bundle.<b><o:p></o:p></b></div>
<div class="MsoListBulletCxSpMiddle">
<!--[if !supportLists]--><span style="font-family: Symbol; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;">·<span style="font-family: 'Times New Roman'; font-size: 7pt;">
</span></span><!--[endif]-->commandName<b>
–help: </b>Displays the online help for command X<b><o:p></o:p></b></div>
<div class="MsoListBulletCxSpMiddle">
<br /></div>
<div class="MsoListBulletCxSpMiddle">
<br /></div>
<div class="MsoListBulletCxSpMiddle">
When you hit
a command <b>list </b>at console, it will
list all the bundles with their <b>bundle
id</b> & their <b>states – </b>Active,
started, Stopped etc.<o:p></o:p></div>
<div class="MsoListBulletCxSpMiddle">
<br /></div>
<div class="MsoListBulletCxSpLast">
<b><span style="font-size: 14.0pt; line-height: 107%; mso-bidi-font-size: 11.0pt;">Changing default root URL:</span> <o:p></o:p></b></div>
<div style="margin-bottom: 11.0pt; margin-left: 0in; margin-right: 0in; margin-top: 6.0pt;">
By default CXF based web services in Fuse OSGI publishes an endpoint URL
with <b>/cxf</b> extension. For example if
your project is hosted as 8181 port, web service will be invoked through <a href="http://localhost:8181/cxf/YourWebservice?wsdl">http://localhost:8181/<b>cxf</b>/YourWebservice?wsdl</a>.<o:p></o:p></div>
<div style="margin-bottom: 11.0pt; margin-left: 0in; margin-right: 0in; margin-top: 6.0pt;">
This feature is often messy, because I do not want endpoint URL root name
to be <b>cxf. </b>Instead I would be happy
if I can update the name related an application.
In sort I would like a name such as <a href="http://localhost:8181/yourApplication/YourWebservice?wsdl">http://localhost:8181/yourApplication/YourWebservice?wsdl</a>.<o:p></o:p></div>
<div style="margin-bottom: 11.0pt; margin-left: 0in; margin-right: 0in; margin-top: 6.0pt;">
To do this, fuse does not provide a default mechanism. Instead we need to
add one file named <o:p></o:p></div>
<div style="margin-bottom: 11.0pt; margin-left: 0in; margin-right: 0in; margin-top: 6.0pt;">
<b>org.apache.cxf.osgi.cfg, </b>place
it in <b>/etc directory</b> and add the
following line to the file.<o:p></o:p></div>
<div style="margin-bottom: 11.0pt; margin-left: 1.0in; margin-right: 0in; margin-top: 6.0pt;">
<i>org.apache.cxf.servlet.context=/yourApplication<o:p></o:p></i></div>
<div style="margin-bottom: 11.0pt; margin-left: 0in; margin-right: 0in; margin-top: 6.0pt;">
<br /></div>
<div style="margin-bottom: 11.0pt; margin-left: 0in; margin-right: 0in; margin-top: 6.0pt;">
This will override the default endpoint root URL name provided by the CXF
component.<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoListBulletCxSpFirst" style="margin-bottom: 0.0001pt; text-indent: 0in;">
<b> <o:p></o:p></b></div>
<div class="MsoListBulletCxSpLast" style="margin-bottom: 0.0001pt;">
<b><span style="font-size: 14.0pt; mso-bidi-font-size: 11.0pt;">Troubleshooting: <o:p></o:p></span></b></div>
<div class="MsoNormal">
If two application server are using same port Example –
Jboss & Fuse, you will get the following messy message at the fuse console:
<o:p></o:p></div>
<div class="MsoNormal" style="text-indent: .5in;">
<i>Caused
by: java.io.IOException: Cannot bind to URL [rmi://localhost:1099/karaf-root]<o:p></o:p></i></div>
<div class="MsoNormal" style="text-indent: .5in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
This means existing port 1099 is already in use by some other
application.<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Verdana","sans-serif"; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman"; mso-bidi-font-weight: bold;">In<b> /etc </b>directory</span><span style="font-family: "Verdana","sans-serif"; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman";">
check the configuration file <b>org.apache.karaf.management.cfg
</b>and update the following property.</span><b><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"><br />
<!--[if !supportLineBreakNewLine]--><br />
<!--[endif]--></span></b><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><span style="font-family: "Verdana","sans-serif"; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman";">rmiRegistryPort </span></b><span style="font-family: "Verdana","sans-serif"; font-size: 10.0pt; mso-bidi-font-family: "Times New Roman";">= 1100</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
Update the same configuration to <b>system.properties
</b>file too.<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoListBulletCxSpFirst" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoListBulletCxSpMiddle" style="mso-list: none; tab-stops: .5in; text-indent: 0in;">
<br /></div>
<div class="MsoNormal">
</div>
<div class="MsoListBulletCxSpLast" style="mso-list: none; tab-stops: .5in; text-indent: 0in;">
<br /></div>
</div>
Anonymoushttp://www.blogger.com/profile/10713264593334966481noreply@blogger.com0tag:blogger.com,1999:blog-3586645045303501566.post-11445106123559736732014-01-17T13:50:00.000-08:002014-01-17T14:01:21.712-08:00Running C with GCC compiler in windows with Netbeans IDE<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="text-align: justify;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">This pretty simple layman question, but still some tricky to install GCC compiler in windows, making functional with C or any thing else C++, Fortan etc.</span></div>
<div style="font-size: 20px; text-align: justify;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><br /></span></div>
<div style="text-align: justify;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">Recently, i need to run program for OpenMP (For parallel programming ), parrallel thread executed in order to complete my course syallabus as a part of Advance computer architecture. So little time, it took to initially figure out how to install it, & work for it with GCC. Prior to it, it was never been with GCC, all we have is turbo C++ Blue screen, in college time. But now that was obsolete, say working to as similar as in early 90's. So need change there. So here it goes.</span></div>
<div style="text-align: justify;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><br /></span></div>
<div style="text-align: justify;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">Installing on window there is: MinGw( www.mingw.org/) compiler system that seems fine. It give you the windows installation manager</span></div>
<div style="text-align: justify;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">package from where you can install all the required package one by one exactly as similar as linux way.</span><br />
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><br /></span>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEizSb1bU3CYzRhGgiEVWfaSNOGKAW8hcFVCwlUGjbklg27T29UCDW51xIm5XlkE-WcORfqPTygJxtBPqnJjTbW8duCcFizl_COBu9PSLXQyP8u48bwFdIjQfctgJm8WlQxVGlBzF-KGVnc/s1600/214731498_6f8689786c.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEizSb1bU3CYzRhGgiEVWfaSNOGKAW8hcFVCwlUGjbklg27T29UCDW51xIm5XlkE-WcORfqPTygJxtBPqnJjTbW8duCcFizl_COBu9PSLXQyP8u48bwFdIjQfctgJm8WlQxVGlBzF-KGVnc/s1600/214731498_6f8689786c.jpg" height="320" width="230" /></a></div>
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><br /></span></div>
<div style="text-align: justify;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><br /></span></div>
<div style="text-align: justify;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">Download and Run MinGw installation manager.</span></div>
<div style="text-align: justify;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">We need to install following packages as mandatory for C/C++ .</span></div>
<div style="text-align: justify;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">1)<span style="color: orange;"> MinGw-Developer tool</span></span></div>
<div style="text-align: justify;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">2)<span style="color: orange;"> mingGW32-base [This is required for C]</span></span></div>
<div style="text-align: justify;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">3) <span style="color: orange;">mingGwGcc-G++ [This is for C++]4) msys-base [It include core basic utility functions]</span></span></div>
<div style="text-align: justify;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><br /></span></div>
<div style="text-align: justify;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><br /></span></div>
<div style="text-align: justify;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">After installation of all those package, </span></div>
<div style="text-align: justify;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">Create a new project in NetBeans</span></div>
<div style="text-align: justify;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">Select tab C/C++ Applications </span></div>
<div style="text-align: justify;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><br /></span></div>
<div style="text-align: justify;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><br /></span></div>
<div style="text-align: justify;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">The general package structure will be created. </span></div>
<div style="text-align: justify;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">Now you have some tricky task. Those are setting environmental variable that is [Path] variable for MinGw and msys in your </span></div>
<div style="text-align: justify;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">windows maching (Right Click <span style="color: orange;">My Computer-->Properties->Advanced Properties-->Environment Variable</span>)</span></div>
<div style="text-align: justify;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><br /></span></div>
<div style="text-align: justify;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">You need to set the path variable upto the bin directory. For ex : If your MinGw is installed as C:\MinGw then</span></div>
<div style="text-align: justify;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">path will be <span style="color: orange;">C:\MinGW\bin</span> , </span></div>
<div style="text-align: justify;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">similarly for mySys it would be <span style="color: orange;">C:\MinGW\msys\1.0\bin </span></span></div>
<div style="text-align: justify;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">Note that place semicolon(;) before and after of these variable entries in path variable .</span></div>
<div style="text-align: justify;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><br /></span></div>
<div style="text-align: justify;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">Next you need to set configuration in you netbeans. For that. </span></div>
<div style="text-align: justify;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">Go to Tools -->Options-->C/C++ tab</span></div>
<div style="text-align: justify;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><br /></span></div>
<div style="text-align: justify;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">There most probably, [Make command] tab will be not mentioned explicitly, you need to mention it ,</span></div>
<div style="text-align: justify;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">browse the button and select <span style="color: orange;">C:\MinGW\msys\1.0\bin\make.exe</span> file of MySys. </span></div>
<div style="text-align: justify;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><br /></span></div>
<div style="text-align: justify;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">Check all associated variable as well , if they are set correctly. </span></div>
<div style="text-align: justify;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">Finally build the project , if it is build successfully, Congratulations.. !! </span></div>
<div style="text-align: justify;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">You are done. ..</span></div>
<div style="text-align: justify;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><br /></span></div>
<div style="text-align: justify;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><br /></span></div>
<div style="text-align: justify;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><br /></span></div>
<div style="text-align: justify;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><br /></span></div>
<div style="text-align: justify;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><br /></span></div>
<div style="text-align: justify;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><br /></span></div>
<div style="text-align: justify;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><br /></span></div>
<div style="text-align: justify;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><br /></span></div>
<div style="text-align: justify;">
<i><span style="color: #783f04; font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><br /></span></i></div>
<div style="text-align: justify;">
<i><span style="color: orange; font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">Cheers.. !!</span></i></div>
<div style="text-align: justify;">
<i><span style="color: orange; font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">Happy Learning. !!!</span></i></div>
<div style="text-align: justify;">
<br /></div>
</div>
Anonymoushttp://www.blogger.com/profile/10713264593334966481noreply@blogger.com0tag:blogger.com,1999:blog-3586645045303501566.post-8850770377694262072014-01-07T10:42:00.003-08:002014-01-07T10:42:59.941-08:00How to fix this window is not genuine error in windows 7 <div dir="ltr" style="text-align: left;" trbidi="on">
Guys, the problem was, since so many months i was getting this error, i used to always cancel "windows not genuine message" & then run my computer.<br />
Today, it was extreme !! Normally i don't care for desktop background & it was always black because of windows not genuine, As i changed at set the windows background wall, after some time, it automatically changed my background old nasty black background. So it was quite hectic. I thought , common get rid of this.<br />
<br />
So here is the one step solution.<br />
<br />
<span style="color: orange;">>> Run command line as "Administrator"</span><br />
<span style="color: orange;">>>Then type "SLMGR -REARM" </span><br />
<br />
After some time you will get, command executed successfully message which ask you to restart the system.<br />
<br />
Restart it , You will never get "Not genuine windows message" !!<br />
<br />
Happy Learning<br />
Cheers ..</div>
Anonymoushttp://www.blogger.com/profile/10713264593334966481noreply@blogger.com0tag:blogger.com,1999:blog-3586645045303501566.post-42023855499737331502014-01-07T10:37:00.000-08:002014-01-07T10:37:09.279-08:00Making a bootable windows 7 disk from file<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">Making a bootable windows 7 disk from the copied files from windows 7 disk:</span><br />
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">-----------------------------------------------------------------------------------------</span><br />
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">Guys, this was really a hectic task , if you are not aligned with the proper techniques to make bootalbe windows. Last night, it wasted by whole night too. </span><br />
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">The problem was my brother's OS get crashed, now I don't have bootable DVD, only all i have is , windows splitted copied files. </span><br />
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">So my first choice was Nero, I didn't have Nero too, downloaded Nero 14 trial for 15 days , tried to make bootable with it, but it sucked me, all it allowed was to allow burning maximum file size of 200MB. :( </span><br />
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">My Next try was Nero 7, Okey it was very difficult to get if from internet for free, finally got it, from some where, a cracked version, Installed and tried to make bootable DVD for windows 7 , again it sucked me, it only allowed me to make a bootable file that exceeds no more than 2GB, I was having 3.4GB of windows 7 raw file. :( What to do !!!</span><br />
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">Wasted one night !!</span><br />
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">Next I came up with the solution, found a very good developer tool known as Image burn (http://www.imgburn.com/) having a file size of just 3.3 MB, & was awesome. !!! Can not imagine, such a decent and best tool !! </span><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg1YP4FIzfihM4tk0IxX-NswAW7UswG435PM5cjTpWDpvSPZFWpLueH1C2teh2mjSR6lHa8542xHbzfo3SIiYZKjjjF-wuMc7fk9rYAbpZlqjUUSYHMJqL23b_OHQwyKUmwfKmVXCJ0Kps/s1600/ImageBurn.png" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg1YP4FIzfihM4tk0IxX-NswAW7UswG435PM5cjTpWDpvSPZFWpLueH1C2teh2mjSR6lHa8542xHbzfo3SIiYZKjjjF-wuMc7fk9rYAbpZlqjUUSYHMJqL23b_OHQwyKUmwfKmVXCJ0Kps/s1600/ImageBurn.png" height="219" width="320" /></span></a></div>
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">All you need to do is :</span><br />
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><span style="color: orange;">=></span> Click the ‘Write files/folders to disc’ button.</span><br />
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><span style="color: orange;">=></span>Insert a writable DVD disc [The message in status bar should say ready]</span><br />
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><span style="color: orange;">=></span>Add the installation source folder and files </span><br />
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><span style="color: orange;">=></span>On Boot tab, Locate your Boot file for windows7 generally it is located inside /Boot folder with the name etfsboot.com</span><br />
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">[Note: this is important don't miss it.]</span><br />
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><span style="color: orange;">=></span>Enter ‘Microsoft Corporation’ in the ‘Developer ID’ field.</span><br />
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><span style="color: orange;">=></span>Enter ’07C0′ in the ‘Load Segment’ field.</span><br />
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><span style="color: orange;">=></span>Enter ‘8‘ in the ‘Sectors To Load‘ field.</span><br />
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">You are done, finally click on Build Button. Yes !! </span><br />
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">Cheers.. !! Your bootable CD is ready .. !! </span><br />
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><br /></span>
<br /></div>
Anonymoushttp://www.blogger.com/profile/10713264593334966481noreply@blogger.com0tag:blogger.com,1999:blog-3586645045303501566.post-29106124906904169562014-01-04T14:12:00.000-08:002014-01-04T14:15:27.850-08:00Making USB Pendrive bootable for windows 7 set up<div dir="ltr" style="text-align: left;" trbidi="on">
Got a quick sort of problem today, needed to make a bootable pen drive for windows 7 from the file stored in my computer !!<br />
<br />
<br />
So here is what i did !!<br />
1) Run as system Administration in command<br />
2) Navigate to <b>cd c:\windows\system32</b><br />
3) Type: <b>DISKPART</b> <br />
4) Type: <b>LIST DISK</b> (All the drives including your USB will be listed)<br />
5) Type : SELECT DISK yourDiskName (Your usb disk name as it is show by list disk)<br />
<br />
After selecting disk type following commands sequentially:<br />
<br />
CLEAN<br />
CREATE PARTITION PRIMARY<br />
SELECT PARTITION 1<br />
ACTIVE<br />
FORMAT FS=NTFS QUICK (quick will enable you to format faster)<br />
(it may take a couple minutes, depending on the USB drive size)<br />
<br />
Than type:<br />
ASSIGN<br />
EXIT<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh3lw-nWuIerA1qRJwKBYW2C8QA5P3F7vlz9TTJSdTDxbAwSUmuLglng8k7oiabzGWEwl9crAtia7BRAlZaEfYumC3e4axHgZmyLCHWbcUneU4pNLhrPcguY3XHRWaAYnVqsLUhWbv3QzY/s1600/images.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh3lw-nWuIerA1qRJwKBYW2C8QA5P3F7vlz9TTJSdTDxbAwSUmuLglng8k7oiabzGWEwl9crAtia7BRAlZaEfYumC3e4axHgZmyLCHWbcUneU4pNLhrPcguY3XHRWaAYnVqsLUhWbv3QzY/s1600/images.jpg" /></a></div>
<br />
<br />
Now open a command prompt and go to the directory where <b>BOOTSECT.EXE</b> file is located for your windows 7 file.<br />
<br />
After navigating to the directory : type<br />
<br />
<b>BOOTSECT.EXE /NT60 H</b>: (Here h is the usb drive name)<br />
<br />
If all thing are executed successfully, Congratulations your pen drive has become bootable now. Now you can copy the windows files directly into your usb drive.<br />
<br />
<br /></div>
Anonymoushttp://www.blogger.com/profile/10713264593334966481noreply@blogger.com0tag:blogger.com,1999:blog-3586645045303501566.post-9951667734602094982013-11-22T04:39:00.000-08:002013-11-22T04:39:32.376-08:00 Jmeter for performance Testing<div dir="ltr" style="text-align: left; font-family:"Times New Roman", Times, serif;" trbidi="on">
<div dir="ltr" style="margin-bottom: 0pt; margin-top: 0pt;">
<span style="font-family: Arial;"><span style="font-size: 15px; line-height: 17px; white-space: pre-wrap;"><b>Running Soap services in Jmeter for performance testing:</b></span></span><br />
<span style="font-family: Arial;"><span style="font-size: 15px; line-height: 17px; white-space: pre-wrap;"><br /></span></span>
<span style="font-family: Arial;"><span style="font-size: 15px; line-height: 17px; white-space: pre-wrap;">Apache JMeter is an Apache project that can be used as a load testing tool for analyzing and measuring the performance of a variety of services, with a focus on web applications. </span></span><br />
<span style="font-family: Arial;"><span style="font-size: 15px; line-height: 17px; white-space: pre-wrap;"><br /></span></span>
<span style="font-family: Arial;"><span style="font-size: 15px; line-height: 17px; white-space: pre-wrap;">Apache JMeter may be used to test performance both on static and dynamic resources (Files, Web dynamic languages - PHP, Java, ASP.NET, etc. -, Java Objects, Data Bases and Queries, FTP Servers and more). It can be used to simulate a heavy load on a server, group of servers, network or object to test its strength or to analyze overall performance under different load types. You can use it to make a graphical analysis of performance or to test your server/script/object behavior under heavy concurrent load.</span></span><br />
<span style="font-family: Arial;"><span style="font-size: 15px; line-height: 17px; white-space: pre-wrap;"><br /></span></span>
<span style="font-family: Arial;"><span style="font-size: 15px; line-height: 17px; white-space: pre-wrap;">Apache JMeter features include:</span></span><br />
<span style="font-family: Arial;"><span style="font-size: 15px; line-height: 17px; white-space: pre-wrap;">Ability to load and performance test many different server/protocol types:</span></span><br />
<span style="font-family: Arial;"><span style="font-size: 15px; line-height: 17px; white-space: pre-wrap;">Web - HTTP, HTTPS</span></span><br />
<span style="font-family: Arial;"><span style="font-size: 15px; line-height: 17px; white-space: pre-wrap;">SOAP</span></span><br />
<span style="font-family: Arial;"><span style="font-size: 15px; line-height: 17px; white-space: pre-wrap;">FTP</span></span><br />
<span style="font-family: Arial;"><span style="font-size: 15px; line-height: 17px; white-space: pre-wrap;">Database via JDBC</span></span><br />
<span style="font-family: Arial;"><span style="font-size: 15px; line-height: 17px; white-space: pre-wrap;">LDAP</span></span><br />
<span style="font-family: Arial;"><span style="font-size: 15px; line-height: 17px; white-space: pre-wrap;">Message-oriented middleware (MOM) via JMS</span></span><br />
<span style="font-family: Arial;"><span style="font-size: 15px; line-height: 17px; white-space: pre-wrap;">Mail - SMTP(S), POP3(S) and IMAP(S)</span></span><br />
<span style="font-family: Arial;"><span style="font-size: 15px; line-height: 17px; white-space: pre-wrap;">Native commands or shell scripts</span></span><br />
<span style="font-family: Arial;"><span style="font-size: 15px; line-height: 17px; white-space: pre-wrap;">TCP</span></span><br />
<span style="font-family: Arial;"><span style="font-size: 15px; line-height: 17px; white-space: pre-wrap;"><br /></span></span>
<br />
<span style="font-family: Arial;"><span style="font-size: 15px; line-height: 17px; white-space: pre-wrap;"><br /></span></span>
<span style="font-family: Arial;"><span style="font-size: 15px; line-height: 17px; white-space: pre-wrap;">Adding thread user in test plan </span></span><br />
<span style="color: orange; font-family: Arial;"><span style="font-size: 15px; line-height: 17px; white-space: pre-wrap;"><b>Add >>Thread >> Thread group</b></span></span><br />
<span style="font-family: Arial;"><span style="font-size: 15px; line-height: 17px; white-space: pre-wrap;"><br /></span></span>
<span style="color: orange; font-family: Arial;"><span style="font-size: 15px; line-height: 17px; white-space: pre-wrap;"><b>Step1:</b></span></span><br />
<span style="font-family: Arial;"><span style="font-size: 15px; line-height: 17px; white-space: pre-wrap;">>> Give thread group names</span></span><br />
<span style="font-family: Arial;"><span style="font-size: 15px; line-height: 17px; white-space: pre-wrap;">>> Number of threads [How many instances of the service file you wanted to run for performance testing]</span></span><br />
<span style="font-family: Arial;"><span style="font-size: 15px; line-height: 17px; white-space: pre-wrap;">>> Ramp up time [This is the time need to initialize all the threads in system]</span></span><br />
<span style="color: orange; font-family: Arial;"><span style="font-size: 15px; line-height: 17px; white-space: pre-wrap;"><b>Step2:</b></span></span><br />
<span style="font-family: Arial;"><span style="font-size: 15px; line-height: 17px; white-space: pre-wrap;">>>Right click on thread group >>Add >>Sampler >>Soap XML/RPC request</span></span><br />
<span style="font-family: Arial;"><span style="font-size: 15px; line-height: 17px; white-space: pre-wrap;">>>Give name to the service in [name] box .</span></span><br />
<span style="font-family: Arial;"><span style="font-size: 15px; line-height: 17px; white-space: pre-wrap;">>>Give full url of the service for ex- [http://localhost:8181/testService]</span></span><br />
<span style="font-family: Arial;"><span style="font-size: 15px; line-height: 17px; white-space: pre-wrap;">>>Copy wsdl file content into [soap/xml-RPC Data] field</span></span><br />
<span style="font-family: Arial;"><span style="font-size: 15px; line-height: 17px; white-space: pre-wrap;"><br /></span></span>
<span style="font-family: Arial;"><span style="font-size: 15px; line-height: 17px; white-space: pre-wrap;">>>Save it. [You are done]. </span></span><br />
<span style="font-family: Arial;"><span style="font-size: 15px; line-height: 17px; white-space: pre-wrap;"><br /></span></span>
<span style="color: orange; font-family: Arial;"><span style="font-size: 15px; line-height: 17px; white-space: pre-wrap;"><b>Step3:</b></span></span><br />
<span style="font-family: Arial;"><span style="font-size: 15px; line-height: 17px; white-space: pre-wrap;">>>Add a listener to view the performance of your service or program. There are varieties of listener. These 2 are good for analyzing the soap services performance. </span></span><br />
<span style="font-family: Arial;"><span style="font-size: 15px; line-height: 17px; white-space: pre-wrap;">1) View Result tree </span></span><br />
<span style="font-family: Arial;"><span style="font-size: 15px; line-height: 17px; white-space: pre-wrap;">2) Aggregate report </span></span><br />
<span style="font-family: Arial;"><span style="font-size: 15px; line-height: 17px; white-space: pre-wrap;"><br /></span></span>
<span style="font-family: Arial;"><span style="font-size: 15px; line-height: 17px; white-space: pre-wrap;">You can add various types of result as : </span></span><br />
<span style="font-family: Arial;"><span style="font-size: 15px; line-height: 17px; white-space: pre-wrap;">>>Right click on your newly added soap/ xml-rpc request >> add >> listener</span></span><br />
<span style="font-family: Arial;"><span style="font-size: 15px; line-height: 17px; white-space: pre-wrap;"><br /></span></span>
<span style="color: orange; font-family: Arial;"><span style="font-size: 15px; line-height: 17px; white-space: pre-wrap;"><b>Step4:</b></span></span><br />
<span style="font-family: Arial;"><span style="font-size: 15px; line-height: 17px; white-space: pre-wrap;">Run the project and view the result in listener.</span></span><br />
<span style="font-family: Arial;"><span style="font-size: 15px; line-height: 17px; white-space: pre-wrap;"><br /></span></span>
<span style="font-family: Arial;"><span style="font-size: 15px; line-height: 17px; white-space: pre-wrap;"><br /></span></span>
<span style="font-family: Arial;"><span style="font-size: 15px; line-height: 17px; white-space: pre-wrap;">Returning the the node value of xml service as a variable:</span></span><br />
<span style="font-family: Arial;"><span style="font-size: 15px; line-height: 17px; white-space: pre-wrap;">you can return the xml node value into a Jmeter variable & use it at other different places by various types of postProcessors. </span></span><br />
<span style="font-family: Arial;"><span style="font-size: 15px; line-height: 17px; white-space: pre-wrap;">For returning simple node value into a variable you can use regular expression extractor as below.</span></span><br />
<span style="font-family: Arial;"><span style="font-size: 15px; line-height: 17px; white-space: pre-wrap;">>>Right click on Soap-xml/rpc request </span></span><br />
<span style="font-family: Arial;"><span style="font-size: 15px; line-height: 17px; white-space: pre-wrap;">>>Add >>Post Processor >> Regular expression extractor</span></span><br />
<span style="font-family: Arial;"><span style="font-size: 15px; line-height: 17px; white-space: pre-wrap;">>>Give Reference name [this will act as your variable] for ex - myVar</span></span><br />
<span style="font-family: Arial;"><span style="font-size: 15px; line-height: 17px; white-space: pre-wrap;">>>In regular expression box type <nodeName>(.*?) </nodeName></span></span><br />
<span style="font-family: Arial;"><span style="font-size: 15px; line-height: 17px; white-space: pre-wrap;">(.*?) is a regular expression which will return any value in between <nodeName> tag.</span></span><br />
<span style="font-family: Arial;"><span style="font-size: 15px; line-height: 17px; white-space: pre-wrap;">>> In template add $1$</span></span><br />
<span style="font-family: Arial;"><span style="font-size: 15px; line-height: 17px; white-space: pre-wrap;">>>Save it.</span></span><br />
<span style="font-family: Arial; font-size: 15px; line-height: 17px; white-space: pre-wrap;">>>Now you can use myVar at any other place as ${myVar}</span><br />
<span style="font-family: Arial; font-size: 15px; line-height: 17px; white-space: pre-wrap;"><br /></span>
<span style="font-family: Arial; font-size: 15px; line-height: 17px; white-space: pre-wrap;"><br /></span>
<span style="color: orange; font-family: Arial;"><span style="font-size: 15px; line-height: 17px; white-space: pre-wrap;"><i>Happy Learning </i></span></span><br />
<span style="color: orange; font-family: Arial;"><span style="font-size: 15px; line-height: 17px; white-space: pre-wrap;"><i>Cheers !!</i></span></span><br />
<span style="font-family: Arial;"><span style="font-size: 15px; line-height: 17px; white-space: pre-wrap;"><br /></span></span>
<span style="font-family: Arial;"><span style="font-size: 15px; line-height: 17px; white-space: pre-wrap;"><br /></span></span>
<span style="font-family: Arial;"><span style="font-size: 15px; line-height: 17px; white-space: pre-wrap;"><br /></span></span>
<span style="font-family: Arial;"><span style="font-size: 15px; line-height: 17px; white-space: pre-wrap;"><br /></span></span>
<span style="font-family: Arial;"><span style="font-size: 15px; line-height: 17px; white-space: pre-wrap;"><br /></span></span>
<span style="font-family: Arial;"><span style="font-size: 15px; line-height: 17px; white-space: pre-wrap;"><br /></span></span>
<span style="font-family: Arial;"><span style="font-size: 15px; line-height: 17px; white-space: pre-wrap;"><br /></span></span>
</div>
</div>Anonymoushttp://www.blogger.com/profile/10713264593334966481noreply@blogger.com0tag:blogger.com,1999:blog-3586645045303501566.post-11862136627765779142013-11-09T23:06:00.000-08:002013-11-09T23:23:54.289-08:00Using Regular expressions in notepad++<div dir="ltr" style="text-align: left;" trbidi="on">
<b>--Using Regular expressions in a practical life --</b><br />
<br />
Hey Guys, Today i was writing a post & come with a particular problem. The problem was , I was writing 108 names of God Surya. I wrote them one by one in every new line in notepad. Later I thought I forgot to add OM as a prefix to each name. Now what to do? I can not type each name & add one by one.<br />
<br />
So for that I thought to use techniques of regular expression & add them in intelligent way. So what I did was, I opened that file into Notepad++ .<br />
Then pressed Ctrl+H to open find & replace box . At the search mode, i selected the option "Regular Expression" .<br />
<br />
<span style="color: orange;">Now at "Find what" box - I typed "^" ==>This indicates beginning of each line </span><br />
<span style="color: orange;">and at "Replace with box" - I typed "OM ". Finally I clicked on Replace all. </span><br />
<br />
That's it. In one shot, i did my whole changes. Wow it was fantastic.<br />
<br />
Similarly, if you have text like<br />
word1<br />
word2<br />
word3<br />
<br />
and you wanted to make some thing like -<br />
test: "word1"<br />
test: "word2"<br />
test: "word3"<br />
<br />
<span style="color: orange;">All you need to do is </span><br />
<span style="color: orange;">Search = ^([a-Za-z0-9]+)$</span><br />
<span style="color: orange;">Replace= test:"\1"</span><br />
<br />
<br />
This is just a very simple example of using regular expression in notepad++. You can do much better things related to matching & replacing various types of patterns by using regular expressions.<br />
<br />
Happy Learning.. ..!!<br />
<br />
<br />
<br />
<br />
<br /></div>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-45593891-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'stats.g.doubleclick.net/dc.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>Anonymoushttp://www.blogger.com/profile/10713264593334966481noreply@blogger.com0tag:blogger.com,1999:blog-3586645045303501566.post-13260089961631057242013-09-14T02:34:00.000-07:002013-11-09T23:24:17.686-08:00Setting up apache maven <div dir="ltr" style="text-align: left;" trbidi="on">
<div class="" main="">
<b>Abstract:</b>
Apache Maven has been build to resolve your day to day problems for adding many dependencies that exists in project from various source. Basically, In java you have many dependency to be added to the system. So, It becomes very difficult to manage them by searching Jar files & adding manually to project.
<br />
For example - You may need Spring Jars in your project, than after some time you may need Struts Jar. To bring all them in common place in library in your project manually is very complicated & length task. The Maven helps you to add Jars for you making central repository.<br />
All you need to do is add/Modify the POM.XML file.
<br />
<b>Installation:</b>
<br />
<pre>1) Download the latest version of apache maven </pre>
<pre>http://maven.apache.org/download.cgi</pre>
<pre>currently the version is 3.1.0.
2) Extract the tar or zipped folder & Preferably place it at
"C:\Program Files\Apache Software Foundation" location
Now add <span style="color: orange;">M2_HOME </span>an environmental variable , & set the path to where it is placed.
If you are using windows 7, Follow
Right click on Mycomputer--> Properties -->Advanced System Settings -->Environmental variables
In User variables section
</pre>
<pre>Click new ==>Set variable name to -->M2_HOME
SET variable value to -->
<span style="color: orange;">C:\Program Files\Apache Software Foundation\apache-maven-3.1.0</span>
(Path of maven folder)
In the same dialog box -- Add new variable M2
SET PATH TO : <span style="color: orange;">%M2_HOME%\bin</span>
Now add the same M2 varialle to the end of your path variable too.
Make sure you have JAVA_HOME variable set to Java jdk path
<span style="color: orange;">C:\Program Files\JAVA\jdk1.7.0_17
</span>SET THE PATH VARIBLE TO its bin directory as
%JAVA_HOME%\bin
Open a command terminal & type :
<b><span style="color: orange;">mvn --version</span></b></pre>
<pre><b> </b>
It will show you the current version. That's all folks, you get Maven Installed.</pre>
<pre></pre>
<pre>In Next Post, I will show you how to create project through Maven add dependency to it. </pre>
<pre></pre>
<pre>Stay tuned.</pre>
<pre>Happy Learning. :)
</pre>
<pre></pre>
<pre>
</pre>
</div>
</div>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-45593891-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'stats.g.doubleclick.net/dc.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>Anonymoushttp://www.blogger.com/profile/10713264593334966481noreply@blogger.com0tag:blogger.com,1999:blog-3586645045303501566.post-45154184367882391202013-08-25T23:58:00.001-07:002013-11-09T23:36:17.012-08:00Most Useful Eclipse Shortcuts for Java<div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="margin-bottom: 4pt; margin-left: 4pt; margin-top: 0pt; text-align: left;">
<h4>
<span style="color: orange;"><span style="line-height: 29px;"><br /></span><span style="line-height: 29px;">1) Ctrl + Shift + R. -->Open any file quickly</span></span></h4>
<h4>
<span style="color: orange;"><span style="line-height: 29px;">2) Open a type (e.g.: a class, an interface) without clicking through interminable list of packages: </span><span style="line-height: 29px;">Ctrl + Shift + T</span></span></h4>
<h4>
<span style="color: orange;"><span style="line-height: 29px;">3) Go directly to a member (method, variable) of a huge class file,</span><span style="line-height: 29px;"> Ctrl + O</span><span style="line-height: 29px;">Ctrl + Shift + ↓ or Ctrl + Shift + ↑, ==>to move up & down</span></span></h4>
<h4>
<span style="color: orange;"><span style="line-height: 29px;">4) Ctrl + L, enter line number. </span></span></h4>
<h4>
<span style="color: orange;"><span style="line-height: 29px;">5) Go to a supertype/subtype: Ctrl + T.</span><span style="line-height: 29px;"><br /></span><span style="line-height: 29px;">6) Help ⇒ Help → Help Contents → Java Development User Guide → Reference → Menus and Actions</span></span></h4>
</div>
</div>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-45593891-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'stats.g.doubleclick.net/dc.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script></div>
Anonymoushttp://www.blogger.com/profile/10713264593334966481noreply@blogger.com0tag:blogger.com,1999:blog-3586645045303501566.post-57636428062616774382013-07-24T05:28:00.001-07:002013-11-09T23:24:54.544-08:00Some useful Linux commands on Ubuntu <script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-42913967-1', 'deep-developers.blogspot.in');
ga('send', 'pageview');
</script>
<div dir="ltr" style="text-align: left; font-size:17px;" trbidi="on">
<b>Some useful Linux commands on ubuntu: </b><br />
<br />
<b>-r </b> (Recursive , it applies to all directory & sub directories )<br />
Changing the Permission of the file .<br />
<b>chmod -r 777</b> /var/www/chicagoKid<br />
<br />
<br />
<br />
<b>Configuring Automatic DHCP when it is not configured by default when internet is not working :</b><br />
<br />
<b>ifconfig</b> - a //Check IP is shown or not<br />
<br />
In order to configure DHCP address you will need to edit the 'interfaces' file /etc/network/interfaces .<br />
<br />
auto eth0<br />
iface eth0 inet dhcp<br />
<br />
ctrl+c => cancel<br />
ctrl+o ==>writer out //in terminal<br />
Ctrl+x ⇒ Exit or quit .<br />
<br />
<br />
Go to<b> /etc/init.d/networking restart </b> // To restart network services<br />
<br />
1) you can use editor vi or <b>gedit </b>to open any file.<br />
2) User <b>sudo </b>whenever you need permission.<br />
<br />
if you are required to be owner for all time, just open terminal and type<br />
<b>sudo nautilus</b><br />
<br />
<b>search </b>test.com<br />
<br />
<br />
Check the ubuntu wheter 32 bit or 64 bit:<br />
<b>uname </b>-a<br />
Result for 32-bit Ubuntu:<br />
i386 GNU/Linux<br />
whereas the 64-bit Ubuntu will show:<br />
x86_64 x86_64 GNU/Linux<br />
<br />
<b>file /sbin/init</b><br />
<br />
Creating Directory:<br />
<br />
sudo <b>mkdir </b>-p /usr/local/java<br />
<br />
Some useful commands:<br />
--<b>help </b><br />
<b>info</b><br />
<b>pwd </b>: print working directory<br />
<b>ls </b>~ → Shows file in your home directory<br />
<b>CD </b>(Change Directory)<br />
"cd /" ⇒ Naviagate to root.<br />
cd ~ ⇒ Navigate to home<br />
cd .. ⇒ one level up<br />
cd - ⇒ Previous directory<br />
<br />
<b>cd ~/Desktop</b> ⇒ will move you to desktop directory<br />
<br />
<br />
CP(Copy):<br />
1) <b>cp </b>file foo ==>Copy file & name it foo<br />
2) <b>cp </b>-r directory foo == >Copy recursively the directory & paste into foo directory.<br />
<br />
<b>MV</b>(Move):<br />
Ex-<br />
mv foo ~/Desktop ==>Moves file foo to desktop<br />
<br />
<b>RM(Remove): </b><br />
rm: Use this command to remove or delete a file in your directory.<br />
<br />
<b>rmdir</b>: The removes empty directory. To delete all directroy & its content use -r (recursive options)<br />
<br />
<b>mkdir </b>⇒ Make directory<br />
<b>man </b>: ⇒ Lists Manual of other commands<br />
eg : man mv ⇒ Will bring mv manual<br />
sudo: The sudo command is used to perform file operations on files that the Root User would only be allowed to change.<br />
<b>df </b>: File system disk spaces usages -h(human readable ) -s means "Summary"<br />
<b>free</b>: tells amount of free and used space -m(using megabytes)<br />
<b>top </b>('table of processes') : Displays running processes and system resources.<br />
whatis<br />
<b>tab </b>: Auto completes any command<br />
<br />
<br />
Paste into terminal:<br />
ctrl+v does not work ⇒ User <b>ctrl+Shift+v</b><br />
<br />
<b>History </b>: Lists command that you already typed<br />
<br />
Add new user:<br />
<b>adduser </b>newuserName<br />
<b>passwd </b>yourNewPassword<br />
<div>
<br /></div>
</div>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-45593891-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'stats.g.doubleclick.net/dc.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>Anonymoushttp://www.blogger.com/profile/10713264593334966481noreply@blogger.com0tag:blogger.com,1999:blog-3586645045303501566.post-25605685983729934332013-06-23T02:19:00.000-07:002013-11-09T23:25:11.976-08:00PHPUnit - Unit Testing in PHP<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-42913967-1', 'deep-developers.blogspot.in');
ga('send', 'pageview');
</script>
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif;"><br /></span>
<span style="font-family: Verdana, sans-serif;"><br /></span>
<span style="font-family: Verdana, sans-serif;">Guys, How many of you are familiar with unit testing in PHP? Well coming to PHP, every would say Yeah every one does it, through echo or die and exit; testing individual modules or functions. Many of us has perception that my code works well so there is no need to test it.</span><br />
<span style="font-family: Verdana, sans-serif;"><br /></span></div>
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif;">Well, if you are inline across with same idea, it's what we are not been addicted of the advantages of unit testing frameworks. Instead of testing manually each and every case all time, why not we do it through automation in unit tests right? Further more , When you are under going for a product development, it really comes handy when you are required to know, how much resource a particular module is taking up. Will this module be influencing the other modules performance too? All these things has to be analyzed carefully for a successful product development at each at every stage.</span></div>
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif;"><br /></span></div>
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif;">The one which am I talking here is about PHPUnit testing framework which was initially inspired JUnit testing framework for Java. Well if you are PHP Geek, or amateur , you would not take much time to learn this framework and use it . Here I'm going to write basics about PHPUnit and simple example to demonstrate its usage. Without further ado lets dive into it.</span></div>
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif;"><br /></span></div>
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif;"><span style="font-size: 16px; line-height: 24px;"><a href="http://phpunit.de/manual/3.0/en/installation.html" target="_blank">PHPUnit</a> should be installed using the <a href="http://pear.php.net/" target="_blank">PEAR installer</a></span><span style="line-height: 24px;">. You need to bother about all those. I would suggest you to download <a href="http://www.apachefriends.org/en/xampp-windows.html" target="_blank">XAMPP </a>with latest version with PHP version 5.4+ . Below 5.3.3 the PHPUnit does not work. </span></span></div>
<br />
<div 24px="" font-family:="" line-height:="" sans-serif="" style="text-align: justify; word-spacing: 18px;" verdana="">
<br /></div>
<span style="font-family: Verdana, sans-serif;"></span><br />
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif;"><span style="line-height: 24px;">I am assuming this article for windows users, Linux users can have slightly different commands. After Installation of XAMPP, there are slight updates required to be done in the pear package. </span></span></div>
<span style="font-family: Verdana, sans-serif;">
</span>
<br />
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif; line-height: 24px;"><br /></span></div>
<span style="font-family: Verdana, sans-serif;"></span><br />
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif;"><span style="line-height: 24px;">Go command line installation directory of PHP, Run it as Administrator.</span></span></div>
<span style="font-family: Verdana, sans-serif;">
</span>
<br />
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif; line-height: 24px;">If you have installed your XAMMP in F drive: </span></div>
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif; line-height: 24px;">do the following:</span></div>
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif; line-height: 24px;">1) Type: <b>F: </b> then press Enter</span></div>
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif; line-height: 24px;"> you will be directed to F drive , then type </span></div>
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif; line-height: 24px;"><b> CD F:\xampp\php></b> </span></div>
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif; line-height: 24px;">Here you will run the PEAR command to for updating and installing some dependent package of PHPUnit. </span></div>
<br />
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif; line-height: 24px;"><br /></span></div>
<span style="font-family: Verdana, sans-serif;"></span><br />
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif;"><span style="line-height: 24px;">First one is </span><span style="font-size: 11pt; line-height: 115%;">installing - </span><span style="font-size: 10.5pt; line-height: 115%;">PHP_CodeCoverage</span><span style="line-height: 24px;">" package that does not come with the xampp itself. So install it type : </span></span></div>
<span style="font-family: Verdana, sans-serif;">
</span>
<br />
<span style="font-family: Consolas;"><span style="font-size: 14px; white-space: pre;">pear channel-discover pear.phpunit.de
pear channel-discover components.ez.no
pear install phpunit/PHP_CodeCoverage</span></span>
<br />
<pre style="background-position: initial initial; background-repeat: initial initial; line-height: 13.5pt; text-align: justify; vertical-align: baseline;"><span style="font-family: Verdana, sans-serif; line-height: 24px; text-align: justify;">Press the enter , it will be installed automatically. </span></pre>
<br />
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif; line-height: 24px;"><br /></span></div>
<span style="font-family: Verdana, sans-serif;"></span><br />
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif;"><span style="line-height: 24px;">If you face any problem, then you need to make sure that your pear package is up to date. To update the Pear package type: </span></span></div>
<span style="font-family: Verdana, sans-serif;">
</span>
<br />
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif; line-height: 24px;"><b>pear update-channels</b> </span></div>
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif; line-height: 24px;">It will update your pear package, the repeat the same above command.</span></div>
<br />
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif; line-height: 24px;"><br /></span></div>
<span style="font-family: Verdana, sans-serif;"></span><br />
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif;"><span style="line-height: 24px;">You might face some problems relating to update too. Update may be failed because of caching problems. If you find like so , clear the cache of pear as </span></span></div>
<span style="font-family: Verdana, sans-serif;">
</span>
<br />
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif; line-height: 24px;"><b>pear clear-cache</b></span></div>
<br />
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif; font-weight: bold; line-height: 24px;"><br /></span></div>
<span style="font-family: Verdana, sans-serif;"></span><br />
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif;"><span style="line-height: 24px;">That's it you are done with the installation, now for testing your script all you need to do is </span></span></div>
<span style="font-family: Verdana, sans-serif;">
</span>
<br />
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif; line-height: 24px;">Type the command </span></div>
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif; line-height: 24px;"><b>phpunit "FullAbsolutePathOfYourFile" </b></span></div>
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif; line-height: 24px;">Example : <span style="color: #6fa8dc;">F:\xam\php></span><span style="color: magenta;">phpunit</span> "F:\xam\htdocs\test\PersonTest.php" </span></div>
<br />
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif; line-height: 24px;"><br /></span></div>
<span style="font-family: Verdana, sans-serif;"></span><br />
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif;"><span style="line-height: 24px;"><br /></span></span></div>
<span style="font-family: Verdana, sans-serif;">
</span>
<br />
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif;"><span style="line-height: 24px;">Here i will show you how will you write the test script for you actual class being tested. </span></span></div>
<span style="font-family: Verdana, sans-serif;">
</span>
<br />
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif; line-height: 24px;"><br /></span></div>
<span style="font-family: Verdana, sans-serif;"></span><br />
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif;"><span style="line-height: 24px;">Before you dive into details for testing, you need to understand basic idea about it. The basic idea about testing in a very nutshell is very simple. Take an example; you have a certain class having function to add 2 numbers that returns sum of it. Now, we need to ensure that the sum is correct ie. 2+3 should yield 5. So the sum = 5 is the result we expect from that function. That means in our testing class we need to write our testing which compares our expected output with the real output of the function. If the expected out put comes equal with that, our test result passes. That's it, all about the testing. This is the very generalized concept in a nutshell. </span></span></div>
<span style="font-family: Verdana, sans-serif;">
</span>
<br />
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif; line-height: 24px;"><br /></span></div>
<span style="font-family: Verdana, sans-serif;"></span><br />
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif;"><span style="line-height: 24px;">Lets understand it by our example: We have a class person, when he talks, we should expect the result as Wecome guys or some thing else whatever may be , but we do not expect the sound like MEW as cat right? </span></span></div>
<span style="font-family: Verdana, sans-serif;">
</span>
<br />
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif; line-height: 24px;"><br /></span></div>
<span style="font-family: Verdana, sans-serif;"></span><br />
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif;"><b style="line-height: 24px;">Person.php</b></span></div>
<span style="font-family: Verdana, sans-serif;">
</span>
<br />
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif; line-height: 24px;"><?php</span></div>
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif; line-height: 24px;">class Person{</span></div>
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif; line-height: 24px;"> protected $name;</span></div>
<br />
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif; line-height: 24px;"><br /></span></div>
<span style="font-family: Verdana, sans-serif;"></span><br />
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif;"><span style="line-height: 24px;"> public function getName() {</span></span></div>
<span style="font-family: Verdana, sans-serif;">
</span>
<br />
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif; line-height: 24px;"> return $this->name;</span></div>
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif; line-height: 24px;"> }</span></div>
<br />
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif; line-height: 24px;"><br /></span></div>
<span style="font-family: Verdana, sans-serif;"></span><br />
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif;"><span style="line-height: 24px;"> public function setName($name) {</span></span></div>
<span style="font-family: Verdana, sans-serif;">
</span>
<br />
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif; line-height: 24px;"> $this->name = $name;</span></div>
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif; line-height: 24px;"> }</span></div>
<br />
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif; line-height: 24px;"><br /></span></div>
<span style="font-family: Verdana, sans-serif;"></span><br />
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif;"><span style="line-height: 24px;"> public function talk() {</span></span></div>
<span style="font-family: Verdana, sans-serif;">
</span>
<br />
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif; line-height: 24px;"> return "Welcome guys !";</span></div>
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif; line-height: 24px;"> }</span></div>
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif; line-height: 24px;">}</span></div>
<br />
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif; line-height: 24px;"><br /></span></div>
<span style="font-family: Verdana, sans-serif;"></span><br />
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif;"><span style="line-height: 24px;">?></span></span></div>
<span style="font-family: Verdana, sans-serif;">
</span>
<br />
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif; line-height: 24px;"><br /></span></div>
<span style="font-family: Verdana, sans-serif;"></span><br />
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif;"><span style="line-height: 24px;">So we would like to write UnitTesting Class for this function, which ensures that only man has spoken and not an animal. To do so, we write a class PersonTest which must extend </span><span style="line-height: 24px;"><b>PHPUnit_Framework_TestCase </b>class</span></span></div>
<span style="font-family: Verdana, sans-serif;">
</span>
<br />
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif; line-height: 24px;"><br /></span></div>
<span style="font-family: Verdana, sans-serif;"></span><br />
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif;"><b style="line-height: 24px;">PersonTest.php</b></span></div>
<span style="font-family: Verdana, sans-serif;">
</span>
<br />
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif; line-height: 24px;"><?php</span></div>
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif; line-height: 24px;">class PersonTest extends PHPUnit_Framework_TestCase</span></div>
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif; line-height: 24px;">{</span></div>
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif;"><br /></span></div>
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif;"> // test the talk method</span></div>
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif;"> public function testTalk() {</span></div>
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif;"> // make an instance of the person</span></div>
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif;"> $p<span style="line-height: 24px;">erson</span>= new <span style="line-height: 24px;">Person</span>();</span></div>
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif;"> // use assertEquals to ensure the greeting is what you</span></div>
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif;"> $expected = "<span style="line-height: 24px;">Welcome guys !</span>";</span></div>
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif;"> $actual = $p<span style="line-height: 24px;">erson</span>->talk();</span></div>
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif;"> $this-><b>assertEquals</b>($expected, $actual);</span></div>
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif;"><br /></span></div>
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif;"><br /></span></div>
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif;"> }</span></div>
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif;">}</span></div>
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif;"><br /></span></div>
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif;">?></span></div>
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif;"><br /></span></div>
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif;"><b>assertEquals </b>is a method built in PHPUnit testing framework class which will compare if both the output are equal. There are many methods. </span></div>
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif;"><br /></span></div>
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif;">Now run this <span style="line-height: 24px;">PersonTest.php class through command line as </span><span style="line-height: 24px;"> </span></span></div>
<br />
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif; line-height: 24px;"><br /></span></div>
<span style="font-family: Verdana, sans-serif;"></span><br />
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif;"><span style="color: #6fa8dc; line-height: 24px;">F:\xam\php></span><span style="color: magenta; line-height: 24px;">phpunit</span><span style="line-height: 24px;"> "F:\xam\htdocs\test\PersonTest.php" </span></span></div>
<span style="font-family: Verdana, sans-serif;">
</span>
<br />
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif; line-height: 24px;"><br /></span></div>
<span style="font-family: Verdana, sans-serif;"></span><br />
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif;"><span style="line-height: 24px;">you will see the output something similar to as below. </span></span></div>
<span style="font-family: Verdana, sans-serif;">
</span>
<br />
<div class="separator" style="clear: both; text-align: justify;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjvVXOW1uIoM8xbHlhz_RFYf7uFWgj18sjwkXlqEEcDve3-o9hSLAcAheUevM9KXnlJvl-pLpyZwBvx4BJRBmkwjSU7n7VEmkVYI1PCfAI8a4AXASdyYYCsCJGcl3nJE1qCFNUvk-7y_As/s1600/unitTest.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><span style="font-family: Verdana, sans-serif;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjvVXOW1uIoM8xbHlhz_RFYf7uFWgj18sjwkXlqEEcDve3-o9hSLAcAheUevM9KXnlJvl-pLpyZwBvx4BJRBmkwjSU7n7VEmkVYI1PCfAI8a4AXASdyYYCsCJGcl3nJE1qCFNUvk-7y_As/s1600/unitTest.png" /></span></a></div>
<br />
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif; line-height: 24px;"><br /></span></div>
<span style="font-family: Verdana, sans-serif;"></span><br />
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif;">That's it You are done with the unit testing with PHP. Wow. !! Congrats.</span></div>
<span style="font-family: Verdana, sans-serif;">
</span>
<br />
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif;"><br /></span></div>
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif;">Couple of things to note.</span></div>
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif;"><br /></span></div>
<div style="border: 0px; font-size: 14px; line-height: 1.5em; padding: 0px 0px 1em; vertical-align: baseline;">
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif;"><span style="color: #5f5e5e;">I</span>f test is successful, you will see the little dot there. For every test run there will be a character indicating the result. The characters are as follows:</span></div>
</div>
<ul style="border: 0px; font-size: 14px; line-height: 1.5em; list-style: none; margin: 0px 0px 0px 2em; padding: 0px 0px 1em; vertical-align: baseline;">
<li style="border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; list-style: disc !important; margin: 0px; padding: 0px; vertical-align: baseline;"><span style="font-family: Verdana, sans-serif;">. – Printed when a test succeeds.</span></li>
<li style="border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; list-style: disc !important; margin: 0px; padding: 0px; vertical-align: baseline;"><span style="font-family: Verdana, sans-serif;">F – Printed when an assertion fails.</span></li>
<li style="border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; list-style: disc !important; margin: 0px; padding: 0px; vertical-align: baseline;"><span style="font-family: Verdana, sans-serif;">E – Printed when an error occurs while running the test.</span></li>
<li style="border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; list-style: disc !important; margin: 0px; padding: 0px; vertical-align: baseline;"><span style="font-family: Verdana, sans-serif;">S – Printed when the test has been skipped.</span></li>
<li style="border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; list-style: disc !important; margin: 0px; padding: 0px; vertical-align: baseline;"><span style="font-family: Verdana, sans-serif;">I – Printed when the test is marked as being incomplete</span></li>
</ul>
<div>
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif; font-size: 14px; line-height: 21px;"><br /></span></div>
</div>
<div>
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif; font-size: 14px; line-height: 21px;">This is just an introduction to PHPUnit testing, you need to dive more detail on it. Please do refer an official PHPUnit testing <a href="http://phpunit.de/manual/3.0/en/installation.html" target="_blank">manual here for further detail</a>. </span></div>
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif; font-size: 14px; line-height: 21px;"><br /></span></div>
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif;"><span style="font-size: 14px; line-height: 21px;">Don't forgot to send your feedback enjoy up. !!!</span></span></div>
<div style="text-align: justify;">
<br /></div>
</div>
<div>
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif; font-size: 14px; line-height: 21px;"><br /></span></div>
</div>
<div>
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif; font-size: 14px; line-height: 21px;"><br /></span></div>
</div>
<div>
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif; font-size: 14px; line-height: 21px;"><br /></span></div>
</div>
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif; line-height: 24px;"> </span></div>
<div style="text-align: justify;">
<br /></div>
<br />
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif; font-weight: bold; line-height: 24px;"><br /></span></div>
<span style="font-family: Verdana, sans-serif;"></span><br />
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif;"><span style="line-height: 24px;"> </span><span style="line-height: 24px;"> </span></span></div>
<span style="font-family: Verdana, sans-serif;">
</span>
<br />
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif; line-height: 24px;"><br /></span></div>
<span style="font-family: Verdana, sans-serif;"></span><br />
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif;"><span style="line-height: 24px;"><br /></span></span></div>
<span style="font-family: Verdana, sans-serif;">
</span>
<br />
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif;"><span style="line-height: 24px;"><br /></span></span></div>
<span style="font-family: Verdana, sans-serif;">
</span>
<br />
<div style="text-align: justify;">
<span style="font-family: Verdana, sans-serif; line-height: 24px;"><br /></span></div>
<div style="font-family: Verdana, sans-serif; text-align: justify;">
<span style="line-height: 24px;"><br /></span></div>
<div style="font-family: Verdana, sans-serif; text-align: justify;">
<span style="line-height: 24px;"><br /></span></div>
<div style="font-family: Verdana, sans-serif; text-align: justify;">
<span style="line-height: 24px;"><br /></span></div>
<div style="text-align: justify;">
<span style="font-family: Verdana; line-height: 24px;"><br /></span></div>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-45593891-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'stats.g.doubleclick.net/dc.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>Anonymoushttp://www.blogger.com/profile/10713264593334966481noreply@blogger.com0tag:blogger.com,1999:blog-3586645045303501566.post-88895368685059245462013-04-12T08:44:00.000-07:002013-11-09T23:38:29.999-08:00CSS tricks on styling fonts<div dir="ltr" style="text-align: left;" trbidi="on">
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-42913967-1', 'deep-developers.blogspot.in');
ga('send', 'pageview');
</script>
<h2>
Styling CSS using External Fonts:</h2>
This might be simple thing if you know the tricks on how to add desired fonts to the web server, but some times if you are new to this situation, it may stuck you for a while.<br />
<br />
Take a simple example, the client want to have <b>Helvetica </b>font into his site<span style="font-family: Arial, Helvetica, verdana;"><span style="font-size: 12px;"><b style="color: #555555;">. </b>You may be smarter enough to add the helvetica font like </span></span><br />
<span style="color: #0b5394; font-family: Arial, Helvetica, verdana; font-size: 12px;"><br /></span>
<span style="color: orange; font-family: Arial, Helvetica, verdana; font-size: 12px;">.myClass{</span><br />
<span style="font-family: Arial, Helvetica, verdana;"><span style="color: orange; font-size: 12px;"> font-family: helvitica;</span></span><br />
<span style="font-family: Arial, Helvetica, verdana;"><span style="color: orange; font-size: 12px;">}</span></span><br />
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<span style="font-family: Arial, Helvetica, verdana;"><span style="font-size: 12px;">But it will not work, because Helvetica is not enlisted in default font list. Your browser will try to find the source for Helvetica font, when it does not find it , by default it will take <b>Arial font </b>which is some what similar to it but not exact.</span></span></div>
<div style="text-align: left;">
<span style="font-family: Arial, Helvetica, verdana;"><span style="font-size: 12px;"><br /></span></span>
</div>
<span style="font-family: Arial, Helvetica, verdana;"><span style="font-size: 12px;">Another thing to notice is , <b>Helvetica </b>is not a free font , you need to pay ($30- $50) for it. Wow, now what to do !!! </span></span><br />
<span style="font-family: Arial, Helvetica, verdana;"><span style="font-size: 12px;">Often every one loves Google, so hit the search for Helvetica font. When you find it , download . This might be in the form of<b> fontName.ttf </b>extension, again you can not use this font for the web purpose because it is not web compatible format . So you need to convert this into web compatible formats like - <b>.eot, .svg, .woff, & .ttf </b>too. For achieving this task, you can get some online web sites where you can submit your font & get the converted file attachment back with the compatible fonts.</span></span><br />
<br />
<br />
<div style="text-align: left;">
<span style="font-family: Arial, Helvetica, verdana;"><span style="font-size: 12px;">Obviously, you don't want to loose money for just a font, if you are freelance. So hold down, take a glass of water & long breathe. Here is the way.</span></span></div>
<span style="font-family: Arial, Helvetica, verdana;"><span style="font-size: 12px;"><br /></span></span>
<span style="font-family: Arial, Helvetica, verdana;"><span style="font-size: 12px;">You can use this site-<span style="color: orange;"> </span></span></span><a href="http://www.fontsquirrel.com/tools/webfont-generator"><span style="color: orange;">http://www.fontsquirrel.com/tools/webfont-generator</span></a><span style="font-family: Arial, Helvetica, verdana; font-size: 12px;"><span style="color: orange;"> </span> , Add the font here & Convert.</span><br />
<span style="font-family: Arial, Helvetica, verdana; font-size: 12px;"><br /></span>
<span style="font-family: Arial, Helvetica, verdana; font-size: 12px;"><br /></span>
<span style="font-family: Arial, Helvetica, verdana; font-size: 12px;">After converting & getting all the useful web fonts , you can add these fonts to your web server in some directory or create your own directory & name if <b>fonts/ .</b></span><br />
<span style="font-family: Arial, Helvetica, verdana; font-size: 12px;"><b><br /></b></span>
<span style="font-family: Arial, Helvetica, verdana;"><span style="font-size: 12px;">Now After doing this task, all you need is, to add below script to the <b>top of your css file </b>as below<b>.</b></span></span><br />
<span style="color: #0b5394; font-family: Arial, Helvetica, verdana;"><span style="font-size: 12px;"><b><br /></b></span></span>
<span style="font-family: Arial, Helvetica, verdana;"><span style="font-size: 12px;"></span></span><br />
<div>
<span style="color: orange; font-family: Arial, Helvetica, verdana;">@font-face {</span></div>
<div>
<span style="color: orange; font-family: Arial, Helvetica, verdana;">font-family: 'Helvetica';</span></div>
<div>
<span style="color: orange; font-family: Arial, Helvetica, verdana;">src: url('fonts/helvetica.eot');</span></div>
<div>
<span style="color: orange; font-family: Arial, Helvetica, verdana;">src: url('fonts/helvetica.eot?#iefix') format('embedded-opentype'),</span></div>
<div>
<span style="color: orange; font-family: Arial, Helvetica, verdana;">url('fonts/helvetica.woff') format('woff'),</span></div>
<div>
<span style="color: orange; font-family: Arial, Helvetica, verdana;">url('fonts/helvetica.ttf') format('truetype'),</span></div>
<div>
<span style="color: orange; font-family: Arial, Helvetica, verdana;">url('fonts/helvetica.svg#helvetica') format('svg');</span></div>
<div>
<span style="color: orange; font-family: Arial, Helvetica, verdana;">font-weight: normal;</span></div>
<div>
<span style="color: orange; font-family: Arial, Helvetica, verdana;">font-style: normal;</span></div>
<div>
<span style="color: orange; font-family: Arial, Helvetica, verdana;">}</span></div>
<div>
<div style="color: #0b5394;">
<span style="font-family: Arial, Helvetica, verdana;"><br /></span></div>
<span style="color: #e69138;"><span style="font-family: Arial, Helvetica, verdana;">A simple example of using </span><span style="background-color: white; font-family: Arial, Helvetica, verdana; font-size: 12px; font-weight: bold;"> </span><span style="background-color: white; font-family: Arial, Helvetica, verdana; font-size: 12px; font-weight: bold;">Helvetica Neue CE35 Thin</span><span style="background-color: white; font-family: Arial, Helvetica, verdana; font-size: 12px; font-weight: bold;"> font </span></span><br />
<span style="color: #e69138;"><span style="background-color: white; font-family: Arial, Helvetica, verdana; font-size: 12px; font-weight: bold;"><br /></span></span>
<br />
<div class="separator" style="clear: both; color: #0b5394; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEil-sApfy3W7kPQ8dnTL1FpgLCoQEEadwl0AcLs8k7MK87tOYky9kF0OwASY93cZU10c5NaOqbzvYS5MIijZecFWUwaOxoOxulYnpKMGoVJvppNR3Dvi12eu0heSBTRMKqbnWey0YZVYO0/s1600/mta.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-left: 1em;"><img border="0" height="227" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEil-sApfy3W7kPQ8dnTL1FpgLCoQEEadwl0AcLs8k7MK87tOYky9kF0OwASY93cZU10c5NaOqbzvYS5MIijZecFWUwaOxoOxulYnpKMGoVJvppNR3Dvi12eu0heSBTRMKqbnWey0YZVYO0/s1600/mta.png" width="320" /></a></div>
<div style="color: #0b5394;">
<span style="font-family: Arial, Helvetica, verdana;"><br /></span></div>
</div>
<div style="color: #0b5394;">
<span style="font-family: Arial, Helvetica, verdana;"><br /></span></div>
<span style="font-family: Arial, Helvetica, verdana;"><br /></span>
<span style="font-family: Arial, Helvetica, verdana;"><br /></span>
<span style="font-family: Arial, Helvetica, verdana;"><br /></span>
<span style="font-family: Arial, Helvetica, verdana;"><br /></span>
<span style="font-family: Arial, Helvetica, verdana;"><br /></span>
<span style="font-family: Arial, Helvetica, verdana;"><br /></span>
<span style="font-family: Arial, Helvetica, verdana;"><br /></span>
<span style="font-family: Arial, Helvetica, verdana;"><br /></span>
<span style="font-family: Arial, Helvetica, verdana;"><br /></span>
<span style="font-family: Arial, Helvetica, verdana;"><br /></span>
<span style="font-family: Arial, Helvetica, verdana;"><br /></span>
<br />
<br />
<span style="font-family: Arial, Helvetica, verdana;">
Now your helvetica font has become fully functional . Include this css file & style your document with the font name give at the top.<b> </b></span><br />
<span style="font-family: Arial, Helvetica, verdana;"><span style="color: #0b5394; font-weight: bold;"><br /></span></span>
<span style="font-family: Arial, Helvetica, verdana;">Note: you can give any name of your desire, to the font you have newly added, But don't forget to give the same name while styling the document with classes or IDS. </span><br />
<span style="font-family: Arial, Helvetica, verdana;"><br /></span>
<span style="font-family: Arial, Helvetica, verdana;"><br /></span><br />
<span style="font-family: Arial, Helvetica, verdana;">I hope this document will be surely helpful ,when you get drown into styling the fonts. Any feed backs, & suggestions are hearty welcomed. Enjoy up..!!!</span><br />
<span style="font-family: Arial, Helvetica, verdana;"><br /></span>
<span style="font-family: Arial, Helvetica, verdana;"><br /></span>
<span style="font-family: Arial, Helvetica, verdana;"><br /></span>
<br />
<br />
<br />
<span style="color: #0b5394; font-family: Arial, Helvetica, verdana;"><span style="font-size: 12px;"><br /></span></span>
<span style="color: #0b5394; font-family: Arial, Helvetica, verdana;"><span style="font-size: 12px;"><br /></span></span>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-45593891-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'stats.g.doubleclick.net/dc.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script></div>
Anonymoushttp://www.blogger.com/profile/10713264593334966481noreply@blogger.com0tag:blogger.com,1999:blog-3586645045303501566.post-74371748831251149852013-03-20T05:46:00.001-07:002013-11-09T23:33:55.411-08:00Dynamic Data with Modal Pop Using Jquery<div dir="ltr" style="text-align: left;" trbidi="on">
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-42913967-1', 'deep-developers.blogspot.in');
ga('send', 'pageview');
</script>
<br />
<div dir="ltr" style="text-align: left;" trbidi="on">
You might be interested in getting Pop up window with dynamic data from the Database. One of the common usage you may come up with is: <br />
Suppose you have a student record table, where you are storing detail information about the student. Then you will be obviously having the View student functionality in your application. Here you want to display all the detailed information about student. It's good choice to display all the information about the student, but unfortunately your window size is fixed, so you need to display only important fields of the student record such as Student Name, Address, Contact Number, & Faculty.<br />
<br />
Displaying only necessary information has two advantages - One when you look at the student display page, you should not feel like it is too complex, & second important thing: the lesser you display the content , the more faster will be the students records executed.<br />
So, When you wanted to view the complete details of student, Just give a link to a student name or Id. When it is clicked display the modal pop up with complete detailed information about the student. Couldn't this quite interesting?<br />
<br />
Okey, Diving deep into coding, it pretty easier. Lets check it out.<br />
<br />
Say you have list of names & when click on any name, you want to display pop up with his complete details.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgkEDqPStOEfIqVNiD0OlNZmiSPTls8cbkifPvWgDl-tC1OukGS3sHgVM8cnOyvAvbDNVHJ1qdgZYvfyGBFjxTLU3Yy6dJGBtZpHCEM50s-Qf1jEnwDl2c-3HxhZOFI09Xr8Cyw2ujsN-A/s1600/user.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em; text-align: left;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgkEDqPStOEfIqVNiD0OlNZmiSPTls8cbkifPvWgDl-tC1OukGS3sHgVM8cnOyvAvbDNVHJ1qdgZYvfyGBFjxTLU3Yy6dJGBtZpHCEM50s-Qf1jEnwDl2c-3HxhZOFI09Xr8Cyw2ujsN-A/s1600/user.png" /></a></div>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
So here you have queried through DB & inside loop you have some thing like-<br />
<span style="color: orange;"> <td></span><br />
<span style="color: orange;"> <a href="#" onclick="pop_up('<?php echo $customer['user_id']; ?>')" ></span><br />
<span style="color: orange;"> <?php echo $customer['first_name']." ".$customer['last_name'];?></span><br />
<span style="color: orange;"> </a></span><br />
<span style="color: orange;"></td></span><br />
<span style="color: blue;"><br /></span>
When you click on any name, we are passing an <b>Id </b>inside a <span style="color: blue;"> </span> java script function <span style="color: blue;">pop_up()</span> .<br />
So the pop up function will receive an Id & through where , I will Post the id to Php Script using Jquery.<br />
The Php will select the required data & return back to the same page. <br />
<br />
<span style="color: orange;"><script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js"> </script></span><br />
<span style="color: orange;"><br /></span>
<br />
<div>
<span style="color: orange;"><script type="text/javascript"></span></div>
<span style="color: orange;"><br /></span>
<span style="color: orange;"><br /></span>
<span style="color: orange;">function pop_up(id){</span><br />
<span style="color: orange;"><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>var url = "customer_complete_datail.php?id="+id</span><br />
<span style="color: orange;"><span class="Apple-tab-span" style="white-space: pre;"> </span>$.post(url, function(data) {</span><br />
<span style="color: orange;"><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span> </span><br />
<span style="color: orange;"><span class="Apple-tab-span" style="white-space: pre;"> </span> </span><br />
<span style="color: orange;"><span class="Apple-tab-span" style="white-space: pre;"> </span> $('#overlay_form').html(data); //Setting the content of html </span><br />
<span style="color: orange;"><span class="Apple-tab-span" style="white-space: pre;"> </span> </span><br />
<span style="color: orange;"><span class="Apple-tab-span" style="white-space: pre;"> </span>});</span><br />
<span style="color: orange;"><span class="Apple-tab-span" style="white-space: pre;"> </span>//open popup</span><br />
<span style="color: orange;"><span class="Apple-tab-span" style="white-space: pre;"> </span>$("#overlay_form").fadeIn(1000);</span><br />
<span style="color: orange;"><span class="Apple-tab-span" style="white-space: pre;"> </span>positionPopup();</span><br />
<span class="Apple-tab-span" style="color: orange; white-space: pre;"> </span><br />
<span style="color: orange;"><span class="Apple-tab-span" style="white-space: pre;"> </span>}</span><br />
<span style="color: orange;"><br />
function positionPopup(){</span><br />
<span style="color: orange;"><span class="Apple-tab-span" style="white-space: pre;"> </span>if(!$("#overlay_form").is(':visible')){</span><br />
<span style="color: orange;"><span class="Apple-tab-span" style="white-space: pre;"> </span>return;</span><br />
<span style="color: orange;"><span class="Apple-tab-span" style="white-space: pre;"> </span>}</span><br />
<span style="color: orange;"><span class="Apple-tab-span" style="white-space: pre;"> </span>$("#overlay_form").css({</span><br />
<span style="color: orange;"><span class="Apple-tab-span" style="white-space: pre;"> </span>left:263,</span><br />
<span style="color: orange;"><span class="Apple-tab-span" style="white-space: pre;"> </span>top:145,</span><br />
<span style="color: orange;"><span class="Apple-tab-span" style="white-space: pre;"> </span>position:'absolute'</span><br />
<span style="color: orange;"><span class="Apple-tab-span" style="white-space: pre;"> </span>});</span><br />
<span style="color: orange;"><span class="Apple-tab-span" style="white-space: pre;"> </span>}</span><br />
<span style="color: orange;"> <span class="Apple-tab-span" style="white-space: pre;"> </span>function close_cd()</span><br />
<span style="color: orange;"><span class="Apple-tab-span" style="white-space: pre;"> </span>{</span><br />
<span style="color: orange;"><span class="Apple-tab-span" style="white-space: pre;"> </span>$("#overlay_form").fadeOut(500); //Closing the opened window</span><br />
<span style="color: orange;"><span class="Apple-tab-span" style="white-space: pre;"> </span>}</span><br />
<span style="color: orange;"></script></span><br />
<span style="color: #0b5394;"><br /></span>
<b>Just create the space using DIV for holding you dynamic data </b><br />
<br />
<span style="color: orange;"><br /></span>
<span style="color: orange;"><div id="overlay_form" style="display:none;"></span><br />
<span style="color: orange;"> </div></span><br />
<span style="color: blue;"><br /></span>
Give some styles in html head section for Pop up Model:<br />
<br />
<span style="color: orange;"><style></span><br />
<span style="color: orange;"><span class="Apple-tab-span" style="white-space: pre;"> </span> #overlay_form{</span><br />
<span style="color: orange;"><span class="Apple-tab-span" style="white-space: pre;"> </span>position: absolute;</span><br />
<span style="color: orange;"><span class="Apple-tab-span" style="white-space: pre;"> </span>border: 5px solid gray;</span><br />
<span style="color: orange;"><span class="Apple-tab-span" style="white-space: pre;"> </span>padding: 2px 24px 2px 2px;</span><br />
<span style="color: orange;"><span class="Apple-tab-span" style="white-space: pre;"> </span>background: white;</span><br />
<span style="color: orange;"><span class="Apple-tab-span" style="white-space: pre;"> </span>left:263px;</span><br />
<span style="color: orange;"><span class="Apple-tab-span" style="white-space: pre;"> </span>top:145px;</span><br />
<span style="color: orange;"><span class="Apple-tab-span" style="white-space: pre;"> </span>/*width: 321px;*/</span><br />
<span style="color: orange;"><span class="Apple-tab-span" style="white-space: pre;"> </span>/*height: 400px;*/</span><br />
<span class="Apple-tab-span" style="color: orange; white-space: pre;"> </span><br />
<span style="color: orange;"><span class="Apple-tab-span" style="white-space: pre;"> </span>}</span><br />
<span style="color: orange;"><span class="Apple-tab-span" style="white-space: pre;"> </span>#pop{</span><br />
<span style="color: orange;"><span class="Apple-tab-span" style="white-space: pre;"> </span>display: block;</span><br />
<span style="color: orange;"><span class="Apple-tab-span" style="white-space: pre;"> </span>border: 1px solid gray;</span><br />
<span style="color: orange;"><span class="Apple-tab-span" style="white-space: pre;"> </span>width: 65px;</span><br />
<span style="color: orange;"><span class="Apple-tab-span" style="white-space: pre;"> </span>text-align: center;</span><br />
<span style="color: orange;"><span class="Apple-tab-span" style="white-space: pre;"> </span>padding: 6px;</span><br />
<span style="color: orange;"><span class="Apple-tab-span" style="white-space: pre;"> </span>border-radius: 5px;</span><br />
<span style="color: orange;"><span class="Apple-tab-span" style="white-space: pre;"> </span>text-decoration: none;</span><br />
<span style="color: orange;"><span class="Apple-tab-span" style="white-space: pre;"> </span>margin: 0 auto;</span><br />
<span style="color: orange;"><span class="Apple-tab-span" style="white-space: pre;"> </span>}</span><br />
<span style="color: orange;"></style></span><br />
<span style="color: orange;"><br />
Here is the Page (customer_complete_detail.php) that we are referencing & getting the whole content:</span><br />
<span style="color: orange;"><br /></span>
<span style="color: orange;"><br /></span>
<span style="color: orange;"><?php</span><br />
<span style="color: orange;">session_start();</span><br />
<span style="color: orange;">include_once '../config/connect.php';<span class="Apple-tab-span" style="white-space: pre;"> </span></span><br />
<span style="color: orange;">include_once 'helper.php';</span><br />
<span style="color: orange;">$Helper_admin = new Helper_admin();</span><br />
<span style="color: orange;"><br />
$id = $_REQUEST['id'];</span><br />
<span style="color: orange;">$customerDetail = $Helper_admin->getCustomerDetailById($id);</span><br />
<span style="color: orange;">?></span><br />
<span style="color: orange;"><html xmlns="http://www.w3.org/1999/xhtml"></span><br />
<span style="color: orange;"><head></span><br />
<span style="color: orange;"> <title>Customer Details</title></span><br />
<span style="color: orange;"> <style type="text/css"></span><br />
<span style="color: orange;"> .formLayout</span><br />
<span style="color: orange;"> {</span><br />
<span style="color: orange;"> background-color: #f3f3f3;</span><br />
<span style="color: orange;"> border: solid 1px #a1a1a1;</span><br />
<span style="color: orange;"> padding: 10px;</span><br />
<span style="color: orange;"> width: 300px;</span><br />
<span style="color: orange;"> }</span><br />
<span style="color: orange;"> </span><br />
<span style="color: orange;"> .formLayout label, .formLayout input</span><br />
<span style="color: orange;"> {</span><br />
<span style="color: orange;"> display: block;</span><br />
<span style="color: orange;"> width: 120px;</span><br />
<span style="color: orange;"> float: left;</span><br />
<span style="color: orange;"> margin-bottom: 10px;</span><br />
<span style="color: orange;"> }</span><br />
<span style="color: orange;"><br /></span>
<span style="color: orange;"> .formLayout label</span><br />
<span style="color: orange;"> {</span><br />
<span style="color: orange;"> text-align: right;</span><br />
<span style="color: orange;"> padding-right: 20px;</span><br />
<span style="color: orange;"> }</span><br />
<span style="color: orange;"> .pop_up_form{clear:both;}</span><br />
<span style="color: orange;"><br /></span>
<span style="color: orange;"> br</span><br />
<span style="color: orange;"> {</span><br />
<span style="color: orange;"> clear: left;</span><br />
<span style="color: orange;"> }</span><br />
<span style="color: orange;"> </style></span><br />
<span style="color: orange;"></head></span><br />
<span style="color: orange;"><body></span><br />
<span style="color: orange;"> <div class="formLayout"></span><br />
<span style="color: orange;"> <h4 class="h4_account">Customer Details</h4></span><br />
<span style="color: orange;"> <div class="pop_up_form"></span><br />
<span style="color: orange;"><span class="Apple-tab-span" style="white-space: pre;"> </span> <label>First Name:</label></span><br />
<span style="color: orange;"><span class="Apple-tab-span" style="white-space: pre;"> </span> <label><?php echo $customerDetail->first_name; ?></label></span><br />
<span style="color: orange;"><span class="Apple-tab-span" style="white-space: pre;"> </span> <br></span><br />
<span style="color: orange;"><span class="Apple-tab-span" style="white-space: pre;"> </span> <label>Last Name:</label></span><br />
<span style="color: orange;"><span class="Apple-tab-span" style="white-space: pre;"> </span> <label><?php echo $customerDetail->last_name; ?></label><br></span><br />
<span style="color: orange;"><span class="Apple-tab-span" style="white-space: pre;"> </span> </span><br />
<span style="color: orange;"><span class="Apple-tab-span" style="white-space: pre;"> </span> <label>Contact No.:</label></span><br />
<span style="color: orange;"><span class="Apple-tab-span" style="white-space: pre;"> </span> <label><?php echo $customerDetail->contact_no; ?></label><br></span><br />
<span style="color: orange;"><span class="Apple-tab-span" style="white-space: pre;"> </span> </span><br />
<span style="color: orange;"><span class="Apple-tab-span" style="white-space: pre;"> </span> <label>Email:</label></span><br />
<span style="color: orange;"><span class="Apple-tab-span" style="white-space: pre;"> </span> <label><?php echo $customerDetail->user_email; ?></label><br></span><br />
<span style="color: orange;"><span class="Apple-tab-span" style="white-space: pre;"> </span> </span><br />
<span style="color: orange;"><span class="Apple-tab-span" style="white-space: pre;"> </span> <label>Current Location:</label></span><br />
<span style="color: orange;"><span class="Apple-tab-span" style="white-space: pre;"> </span> <label><?php echo $customerDetail->current_location; ?></label><br></span><br />
<span style="color: orange;"><span class="Apple-tab-span" style="white-space: pre;"> </span> </span><br />
<span style="color: orange;"><span class="Apple-tab-span" style="white-space: pre;"> </span> <label>City:</label></span><br />
<span style="color: orange;"><span class="Apple-tab-span" style="white-space: pre;"> </span> <label><?php echo $customerDetail->city ; ?></label><br></span><br />
<span style="color: orange;"><span class="Apple-tab-span" style="white-space: pre;"> </span> </span><br />
<span style="color: orange;"><span class="Apple-tab-span" style="white-space: pre;"> </span> <label>State:</label></span><br />
<span style="color: orange;"><span class="Apple-tab-span" style="white-space: pre;"> </span> <label><?php echo $customerDetail->state ; ?></label><br></span><br />
<span style="color: orange;"><span class="Apple-tab-span" style="white-space: pre;"> </span> </span><br />
<span style="color: orange;"><span class="Apple-tab-span" style="white-space: pre;"> </span> <label>Country:</label></span><br />
<span style="color: orange;"><span class="Apple-tab-span" style="white-space: pre;"> </span> <label><?php echo $customerDetail->country ; ?></label><br></span><br />
<span style="color: orange;"><span class="Apple-tab-span" style="white-space: pre;"> </span> </span><br />
<span style="color: orange;"><span class="Apple-tab-span" style="white-space: pre;"> </span> <label>Zip:</label></span><br />
<span style="color: orange;"><span class="Apple-tab-span" style="white-space: pre;"> </span> <label><?php echo $customerDetail->zip ; ?></label><br></span><br />
<span style="color: orange;"> </div></span><br />
<span style="color: orange;"> <div></span><br />
<span style="color: orange;"> <a href= 'javascript:void(0)' onclick="close_cd()" id='close_cd'>Close</a></span><br />
<span style="color: orange;"> </div> </span><br />
<span style="color: orange;"> </span><br />
<span style="color: orange;"> </div></span><br />
<span style="color: orange;"> </span><br />
<span style="color: orange;"></body></span><br />
<span style="color: orange;"></html></span><br />
<span style="color: #0c343d;"><br /></span>
<b>So you are almost done. !!! Hurray ..</b><br />
<b><br /></b>
Here is the output when you click on one of the name :<br />
<br />
<div class="separator" style="clear: both; text-align: left;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg72y4G8QNfwkmEw3fqbv4nbIYRUIEB4OzrAOopkiksXqa0wPD6p00F79_dKAIRy050hysGO6S7sNQC7Y3mGUXsR5am2aBXX9w4b_HhrdqsUyqejT4Cbxbga9oXn2MaAbdwzpNEU_fZAaQ/s1600/pop.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg72y4G8QNfwkmEw3fqbv4nbIYRUIEB4OzrAOopkiksXqa0wPD6p00F79_dKAIRy050hysGO6S7sNQC7Y3mGUXsR5am2aBXX9w4b_HhrdqsUyqejT4Cbxbga9oXn2MaAbdwzpNEU_fZAaQ/s1600/pop.png" /></a></div>
<br />
<span style="color: orange;"><i><br /></i>
</span><br />
<b><i><span style="color: orange;">Any Questions.. Queries.. Don't forget write out !!!</span></i></b><br />
<b><i><span style="color: orange;">Rock up.. :) !</span></i></b><br />
<br />
<b><br /></b>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br /></div>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-45593891-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'stats.g.doubleclick.net/dc.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script></div>
Anonymoushttp://www.blogger.com/profile/10713264593334966481noreply@blogger.com4tag:blogger.com,1999:blog-3586645045303501566.post-33887907147137103442012-12-09T10:59:00.000-08:002013-11-09T23:26:28.687-08:00Resume Writing<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-42913967-1', 'deep-developers.blogspot.in');
ga('send', 'pageview');
</script>
<div dir="ltr" style="text-align: left;" trbidi="on">
Resume writing is one of the major challenging task. Whether you are an experienced person or a fresher, your profile plays an important role in hunting the good job. There may be thousands of resumes listed in front of desk with company HR. Among them, they will shortlist only few. In this context, an effective resume plays a significant role. Now the question is <i>what makes the resume to be an effective one? </i>Are there any specific criteria for a resume to become distinguished. Yes, of course, we will discuss about the same here. <br />
<br />
I would like to focus this topic of resume, specially for freshers, though it might be help for experienced users too. There are different names given for this title - some of them call it as <b>CV(</b>Curriculum Vitae<b>) </b>or <b>Profile </b>or <b>Resume</b>. Profile is the common term used for CV as well as Resume. Lets us first differentiate between the<br />
CV and Resume.<br />
<b>CV : - </b>This is the common term used in case of experienced person.<br />
<b>Resume :- </b>The freshers profile or a person having experience less than 2-3 years of work experience, we call it as Resume.<br />
<br />
<b>Some Common Rules while writing Resume:</b><br />
1) If you are a fresher, don't complicate your resume more. Make it as simple as possible with some of effective points to be highlighted that differentiates you from others.<br />
2) Do not decorate your resumes by putting underlines, stylish fonts etc.<br />
3) Use common font at all places like; Times New Roman, Calibri etc with font size 10-12. You can highlight the most important keywords of your Resume by making it <b>Bold.</b><br />
4) The freshers resume should not go beyond two pages.<br />
5) If you are good at technical side though,<i> if you feel that you have less marks </i>in comparison to others , do not show the marks percentage in resume. Some times it works, there may come a situation when less expert people than you may bring higher marks. While shortlisting, your resume might not be shortlisted because of the same.<br />
6) Keep the most important part of your resume in your first page of resume.<br />
<br />
Though there are various methods & styles of writing Resumes , The very common can have the following format.<br />
<br />
<b>1)</b> Put your <b>name</b> & <b>contact </b>details at top of the page, like below:<br />
Name: ...........................................<br />
Contact Number: ...........................................<br />
Email: ...........................................<br />
<br />
<b>Remember </b>that, always provide <b>only one Email Id. </b>As your email id should look professional, like yourname.cast@domain.com. you should not provide an email id that looks an informal like punk14@rockstar.com etc. While giving the <b>contact number, </b>you can give alternative contact numbers too. Do not place address details & other details here.<br />
<br />
<b>2) </b>Next most important part of your resume is your <b>Objective. </b>This is the one entity, which distinguishes you from others.<b> Objective </b>may be different for different platforms & working domains. However, if you are unsure about on which specific platform you are going to work, you can write general objective.<br />
For example your <b>general objective</b> might be: <i>Seeking a position to utilize my skills & abilities in an organization that offers professional growth by being resourceful, innovate,& flexible.</i><br />
This does not gone to help you if your applying for only specific platform, in this case your <b>specific objective </b>will be helpful. For example - if you are applying for a position of .Net programmer , you objective can be - "<i>To become an excellent <b>.Net expert</b> in an IT Industry</i> ".<br />
<br />
3) In next section you can show your most distinguished expertise, Strength ,& important events that you have handled during your college life or till the your carrier as below.<br />
<b>a) Strength: "</b>Self confident, Accept & believe that <b><i>nothing is impossible</i> </b>if done with full dedication & hard labor".<br />
<b>b) Important Events : </b><br />
<b>c) Technical Skills :</b><br />
<b>d) Educational Details:</b><br />
While writing your educational degrees, write your highest qualification at the top & then follow sequentially.<br />
two degrees are enough to be shown in resume. Masters , Bachelors // Or Bachelors //Intermediate.<br />
<br />
4) Next you can have your final project & other external project summaries.<br />
<br />
This all contents must be present in first page.Most of the time, HR does not have the time too look for your second or last page. S/He will sort our your resume based on first page summary only.<br />
<br />
5) In Second page you can show the following details :<br />
<br />
<b>a) </b>Hobbies<br />
<b>b) </b>Personal Details:<br />
Do not repeat you name again here.if it is previously mentioned, it may contain -<br />
Date of Birth:<br />
Gender:<br />
Language Known:<br />
Nationality:<br />
Marital Status:<br />
<br />
<b>c)</b> Address Details: Temporary & Permanent<br />
<b>d) </b>Declaration:This is also an important thing. It ensure that the mentioned details in the resume are correct. You can write the declaration as:<br />
<span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"><i>I hereby declare that the
information above provided is true to the best of my knowledge. If the
information provided is appeared to be false, the concerned authorities are
liable to take any action.</i></span><br />
<span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"><i><br /></i></span>
<span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"><b>e) </b><i> </i>Place of resume written, Date ,& Signature at the right side has to be written. Note that some companies do not accept your resume until & unless it is signed. For ex -</span><br />
<br />
<div class="MsoNormal">
Place:
XYZ( Bangalore)<o:p></o:p></div>
<div class="MsoNormal">
Date: 09 ,Dec,2012 <span style="text-align: right;">Signature:</span></div>
<div class="MsoNormal">
<span style="text-align: right;"><br /></span></div>
<div class="MsoNormal">
I have attached my resume demo sample.
<a href="https://groups.google.com/d/msg/docs-public/msi7OJjs81s/8o2__UWgT-UJ">Download It.</a>
</div>
<div class="MsoNormal">
<span style="text-align: right;"><br /></span></div>
<div class="MsoNormal">
<span style="text-align: right;">This completes the resume. Though there are so many things that needs to be considered, I hope you will really get some idea & clue regarding the resume writing. I shared the things, what ever I knew & experience d from my company & Institute where I learned.</span></div>
<div class="MsoNormal">
<span style="text-align: right;"><i>Your comments, suggestions ,& any improvements to this topic are hearty welcomed.</i></span></div>
<div class="MsoNormal">
<span style="text-align: right;"><br /></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<br />
<br />
<br />
<br />
<br />
<i><br /></i>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br /></div>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-45593891-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'stats.g.doubleclick.net/dc.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>Anonymoushttp://www.blogger.com/profile/10713264593334966481noreply@blogger.com0tag:blogger.com,1999:blog-3586645045303501566.post-16446179020100451402012-11-26T04:28:00.003-08:002013-11-09T23:10:31.492-08:00Printing content of specific div using Javascript<div dir="ltr" style="text-align: left;" trbidi="on">
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-42913967-1', 'deep-developers.blogspot.in');
ga('send', 'pageview');
</script>
<br />
<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="text-align: left;">
<div style="text-align: justify;">
Problem:</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Guys you came across a situation, where you need to print a specific part of a Html or Php Page. When you try to execute this command in javascript :</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<span style="color: orange;">"window.print();"</span></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
It will print your whole page. It gives a lot problem if you do not know how to print the specific content.</div>
<div style="text-align: justify;">
For ex - In your Html page , say there is a coupon banner which needs to printed by user. Now How to do that ?</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
You can do it by 2 ways :</div>
<div style="text-align: justify;">
Solution 1)</div>
<div style="text-align: justify;">
Using CSS to display only the content which is under print & hiding rest of others.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<span style="color: orange;"> <style type="text/css" media="print" ></span></div>
<div style="text-align: justify;">
<span style="color: orange;"> .nonPrintable{display:none;} /*class for the div or any element we do not want to print*/</span></div>
<div style="text-align: justify;">
<span style="color: orange;"></style></span></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
==>Here , while you specify ----media="print"---- inside <style> tag, it indicates that , this css will be applied only when you are printing some content.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Solution 2)</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
The next method that can be commonly applied with most of the browser is using "Javascript".</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
The idea behind this is :</div>
<div style="text-align: justify;">
While you Hit the print command, Just dynamically create a new pop up page from the existing page content(the content you need to print) & then print the page. Very simple.. Just check it out.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<span style="color: orange;"><script type="text/javascript"><!--</span></div>
<div style="text-align: justify;">
<span style="color: orange;">function print_specific_div_content()</span></div>
<div style="text-align: justify;">
<span style="color: orange;">{</span></div>
<div style="text-align: justify;">
<span style="color: orange;"> //alert("Hello world");</span></div>
<div style="text-align: justify;">
<span style="color: orange;"> var content = "<html>";</span></div>
<div style="text-align: justify;">
<span style="color: orange;"> content += document.getElementById("coupon_deal_id").innerHTML ;</span></div>
<div style="text-align: justify;">
<span style="color: orange;"> content += "</body>";</span></div>
<div style="text-align: justify;">
<span style="color: orange;"> content += "</html>";</span></div>
<br />
<div style="text-align: justify;">
<span style="color: orange;"><br /></span></div>
<div style="text-align: justify;">
<span style="color: orange;"> var printWin = window.open('','','left=0,top=0,width=1000,height=500,toolbar=0,scrollbars=0,status =0');</span></div>
<br />
<div style="text-align: justify;">
<span style="color: orange;"> printWin.document.write(content);</span></div>
<div style="text-align: justify;">
<span style="color: orange;"> printWin.document.close();</span></div>
<div style="text-align: justify;">
<span style="color: orange;"> printWin.focus();</span></div>
<div style="text-align: justify;">
<span style="color: orange;"> printWin.print();</span></div>
<div style="text-align: justify;">
<span style="color: orange;"> printWin.close();</span></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<span style="color: orange;">}</span></div>
<br />
<div style="text-align: justify;">
<span style="color: orange;"><br /></span></div>
<div style="text-align: justify;">
<span style="color: orange;"></script></span></div>
<br />
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<body></div>
<div style="text-align: justify;">
<div>Here comes your dummy other content </div></div>
<div style="text-align: justify;">
<div id= "coupon_deal_id"></div>
<div style="text-align: justify;">
Only this content you want to print.......</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
</div> </div>
<div style="text-align: justify;">
<span style="color: orange;"> <button type="button" onclick="print_specific_div_content()" >Print Coupon </button> </span></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
</body></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
------Just check out the flow-----------------</div>
<div style="text-align: justify;">
1) When you click on Print coupon button , the control will go into print_specific_div_content() function.</div>
<div style="text-align: justify;">
Then in content variable you are writing entire new html page, there you can add any content or items that you want to display with printed item. For ex - You can add the current Date inside that. </div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
2) After creating a content, just you are creating an instance of window using </div>
<div style="text-align: justify;">
var printWin = window.open(.......).</div>
<div style="text-align: justify;">
</div>
<div style="text-align: justify;">
==>Then you are setting some required parameters of window such as Height & width.</div>
<div style="text-align: justify;">
==>Then you write the content to that window using printWin.document.write(content);</div>
<div style="text-align: justify;">
==>then execute the print command printWin.print();</div>
<div style="text-align: justify;">
==>& finally , close the window.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Simple...</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Just Rock on .. Use this function where ever you want the function to print the part of the page.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br /></div>
</div>
</div>
</div>
Anonymoushttp://www.blogger.com/profile/10713264593334966481noreply@blogger.com5tag:blogger.com,1999:blog-3586645045303501566.post-77002926198982492672012-07-04T20:56:00.000-07:002013-11-09T23:26:49.921-08:00Retrieving Records in Php MySQL (Concept on Code Reusability)<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-42913967-1', 'deep-developers.blogspot.in');
ga('send', 'pageview');
</script>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-42913967-1', 'deep-developers.blogspot.in');
ga('send', 'pageview');
</script>
<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div style="text-align: justify;">
<span style="text-align: left;"><b>USING MULTIDIMENSIONAL ARRAY TO FETCH MYSQL RECORDS IN PHP:</b> </span>
</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
You may be pretty big fan of Php-Mysql, & if you are the application development geek or at all the new learner, you will be frequently involved in retrieving the data from database. As following a general pattern, if you have 10 places to retrieve/display the record , you will write the same fetch query-giving field names of the table for 10 time as I used to do the same. This is some what quite tedious task to write the same query again & again Like in this way :</div>
<br />
<br />
$query = msyql_query($yourSql);<br />
while($row = mysql_fetch_array($query))<br />
{<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>$field1_value = $row['field1'];<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>$field2_value = $row['field2'];<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
}<br />
<br />
The limitation of this type of pattern is:<br />
1) You can not display the field values or records execpt inside this while loop.<br />
2) If you have 10 places like this to show records, you will struggle writing the same query for 10 times, specifying field names , variables names & all.<br />
<br />
Infact this type of pattern was quite irritating to me also. If you are familar with joomla JDatabase features, it returns you all of the table records in multidimensional array with one single function $db->loadAssocList();<br />
<br />
I was inspired with this type of joomla feature & thought why not to implement the same feature, using core php only?<br />
<br />
So , here goes the function to retrieve MySQL records in multidimensional array format so that you can use it any where. All you need to do is just pass the the table name & your where condition for selecting the records from table.<br />
<br />
Check it out.<br />
<br />
<br />
<br />
<br />
function getAllDataDetails($table, $where)<br />
{<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> if($where != '')<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> <span class="Apple-tab-span" style="white-space: pre;"> </span>$sql = "SELECT * FROM $table WHERE $where";<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> }<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> else<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> <span class="Apple-tab-span" style="white-space: pre;"> </span>$sql = "SELECT * FROM $table" ;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> }<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> <br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> $resultArray = array();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> $row_num = 0 ;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> <br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> $query = mysql_query($sql);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> <br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> //count the number of fields in table<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> $num_fields = mysql_num_fields( $query);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> //(resource,index) //returns filed name at particular index<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> //Get the field names<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> <br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> while($row = mysql_fetch_array($query))<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> <span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> for($field_index = 0 ; $field_index < $num_fields ; $field_index++)<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> <span class="Apple-tab-span" style="white-space: pre;"> </span>$field_name = mysql_field_name($query, $field_index) ; //firstly it will hold first field ,then 2nd etc<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>$resultArray[$row_num][$field_name] = $row[$field_name];<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> }<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> <br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> $row_num++;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> }<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> <br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> return $resultArray;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> <br />
}<br />
<br />
<br />
Now for displaying the records just call the above function:<br />
<br />
$table_name = "myTable";<br />
$where_condition = "where id > 10 ORDER BY id";<br />
$tableRecordDetails = getAllDataDetails($table_name,$where_condition);<br />
<br />
//
tableRecordDetails will be the multidimensional array<br />
<br />
Now all you need to do is loop through an array , i am the pretty big fan of using foreach() loop pattern.<br />
<br />
foreach($tableRecordDetails as $tableData )<br />
{<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>//here goes your table records for ex-<br />
$id = $tableData[fieldName1]; //this will be the field name of your table<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>$name = $tableData [fieldname2]; <br />
<br />
}<br />
<br />
<br />
No one would be happier than me , if you code,copy, paste or customize the code & implement it in your web application. If you hava any queries, donot forget to post comment or you can directly reach to me at <b>prem.singh.nepal@gmail.com</b><br />
<br />
Thank you<br />
Have a Browsing moment ahead<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
</div>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-45593891-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'stats.g.doubleclick.net/dc.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>Anonymoushttp://www.blogger.com/profile/10713264593334966481noreply@blogger.com0tag:blogger.com,1999:blog-3586645045303501566.post-10912623568683561852012-04-19T06:35:00.001-07:002014-04-01T02:33:54.288-07:00A glance at Android Development<div dir="ltr" style="text-align: left;" trbidi="on">
<html>
<head>
<title>Developer Site| Android Development|Opportunities</title>
</head>
<body>
<div dir="ltr" style="text-align: left;" trbidi="on">
<span style=" font-family: 'lucida grande', tahoma, verdana, arial, sans-serif; font-size: 14px; line-height: 14px;"><h1>
<b>Grow with Android..........</b></h1>
</span><br />
<h2>
<b>Develop For Development</b></h2>
<br />
<span style=" font-family: 'lucida grande', tahoma, verdana, arial, sans-serif; font-size: 14px; line-height: 14px;">Almost 40-60% of market share has been taken up by Android Market. So, it is wisefull to grasp up with android development.</span><br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhlewzgwbUJ3fY3-8tkgac4yuTkSX1EtpZRGt-Idb05fBZ0YyI23G2wI7lHk24tCljR0jhsNQMgIOy7B-w_jmiZNZBULQSXyz-XfsPg6YhzAA0B-pD-zkkp6_ICSmnt99YkNPZiIp1j1_M/s1600/androidImg.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhlewzgwbUJ3fY3-8tkgac4yuTkSX1EtpZRGt-Idb05fBZ0YyI23G2wI7lHk24tCljR0jhsNQMgIOy7B-w_jmiZNZBULQSXyz-XfsPg6YhzAA0B-pD-zkkp6_ICSmnt99YkNPZiIp1j1_M/s320/androidImg.jpg" width="224" /></a></div>
<span style=" font-family: 'lucida grande', tahoma, verdana, arial, sans-serif; font-size: 14px; line-height: 14px;">Android is really easy to learn, if you have a good concept on any one of object oriented language C++, php or in fact java. </span><br />
<span class="text_exposed_show" style=" display: inline; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif; font-size: 14px; line-height: 14px;">Android is nothing but implementation of java classes.</span><br />
<span class="text_exposed_show" style=" display: inline; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif; font-size: 14px; line-height: 14px;">My focus to learn android is why because :<br /><br />Android is An Open Platform for Mobile Development.<br /><br />A Linux operating system kernel that provides the low-level interface with the hardware, memory, management, and process control, all optimized for mobile devices.<br /><br />Has powerful APIs, excellent documentation, a thriving developer community, and no development or distribution costs. As mobile devices continue to increase in popularity, this is an exciting opportunity to create innovative mobile phone applications no matter what your development background.<br /><br />Alternative options are Iphone (Apple ) & Windows(Mango) Currently rising, but these are fully proprietary hardware and software platform. while Android is an open source software stack produced and supported by the Open Handset Alliance(OHA) and designed to operate on any handset that meets the requirements.<br /><br />The Open Handset Alliance (OHA) is a collection of more than 30 technology companies including hardware manufacturers, mobile carriers, and software developers.<br /><br />Android provides a lightweight relational database for each application using SQLite. It can easily communicate with Php & MySQL at server side. So you can really beautify your application using Client - server Architecture & Store- Forward Architectures too.<br /><br />No liscensing fee... , Its really easy & Awesome...<br /><br />Get Start your Android Journey today... (<a href="http://developer.android.com/" rel="nofollow nofollow" style="color: #3b5998; cursor: pointer; text-decoration: none;" target="_blank">http://developer.android.com/</a>)<br />Wish you all the Best......<br /><a href="mailto:prem.singh.nepal@gmail.com" target="_blank">Let us join Hands together</a>.... </span>
</div>
</body></html>
</div>
Anonymoushttp://www.blogger.com/profile/10713264593334966481noreply@blogger.com0