Ok, enough talkin', let's get to business...
To define our project setup and job packaging tasks, we'll use Gradle buid tool which is more modern substitution for Maven. Version of Cascading that we use here is 2.5.
But first, let's examine our 3 target environments....
Environments
IDE
Within our IDE, we want to run Cascading jobs in Hadoop local mode. This requires that all dependency libs (Cascading, Hadoop, and possibly some other ones) are included in classpath when executing Cascading jobs there. So, our build script should take care to generate IDE-specific project files that include all mentioned dependencies for job runs.Command Line Interface (CLI)
Most of examples found out there show how to trigger hadoop mapreduce jobs via command line interface - via "hadoop jar myjobapp.jar..." command (or "yarn jar myjobapp.jar ..." in newer versions of Hadoop).Since we're using Cascading here, we need to package somehow Cascading jars together with our custom code for these commands to work. There are couple of ways to do this, but it seems that bundling them all into one jar ("fat jar") is the most popular one.
To construct the "fat jar" we just create regular jar from all our custom classes, and also add 3rd party libs to it. There are 2 way how we can add these libs:
- by placing them under internal "lib" folder of the fat jar
- by extracting all classes from them, and add them in unpackaged form to same fat jar
One more thing - we don't need to package Hadoop libraries since they are already present when jobs are run on Hadoop.
Oozie
Unlike hadoop/yarn CLI commands, Oozie doesn't recognize fat jars containing internal lib folder with dependency libs, so our Cascading app's jar packaged in that way would not be able to run when triggered by Oozie.On the other hand, the second approach of building fat jars is good to go, and fortunately, there is Gradle plugin to help us with that - Gradle Shadow.
Same as CLI approach, we don't want to package Hadoop libraries for already mentioned reason.
Build script
As said, we'll use Gradle as our build tool.First, let's define our project dependencies in build script (build.gradle).
As already mentioned, we need to somehow mark separately Hadoop libraries because we have to exclude them when packaging our job applications for CLI/Oozie enviroments. We'll do that by defining custom Gradle configuration using:
configurations {
hadoopProvided
}
And finally define dependencies for that configuration (we'll add slf4j/logback dependencies also for proper logging when running within an IDE):
hadoopProvided(
"org.apache.hadoop:hadoop-client:${hadoopVersion}",
"commons-httpclient:commons-httpclient:3.1",
"org.slf4j:slf4j-api:${slf4jVersion}",
"org.slf4j:jcl-over-slf4j:${slf4jVersion}",
"org.slf4j:log4j-over-slf4j:${slf4jVersion}",
"ch.qos.logback:logback-classic:1.0.+"
)
For everything to work correctly, we have to add that configuration to main sourceSet, and also register that configuration to be included in generated IDEA/Eclipse projects. Take a look at GitHub project to see how it is done inside the build script.
Cascading libraries are added to standard "compile" configuration:
compile (
"cascading:cascading-core:${cascadingVersion}",
"cascading:cascading-local:${cascadingVersion}",
"cascading:cascading-hadoop2-mr1:${cascadingVersion}"
)
Using special Gradle plugins for Intellij IDEA and Eclipse support, we can generate IDE-specific project files. Project files generation tasks are called by:
gradle idea
or
gradle eclipse
To package our job application as "fat jar" with all dependency classes extracted from their original jars, we have to include Gradle Shadow plugin (version 0.9.0-M1 currently) into project via:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.github.jengelman.gradle.plugins:shadow:0.9.0-M1'
}
}
apply plugin: 'shadow'
"Fat jar" is constructed by calling:
gradle shadowJar
and end result can be seen at path:
<project-dir>/build/libs/<appname>-<appversion>-all.jarComplete build script is available here, as part of my cascading-wordcount GitHub project.
In the next part of this post, we'll look at how to execute simple Cascading job within all 3 environments.
This information you provided in the blog that was really unique I love it!!, Thanks for sharing such a great blog..Keep posting..
ReplyDeleteHadoop Training Institutes in Chennai
nice post and it may be more useful to the hadoop learners keep blogging...
ReplyDeleteHadoop training in Velachery
Thanks for sharing this informative blog. If anyone wants to get Big Data Training Chennai visit fita academy located at Chennai, which offers best Hadoop Training Chennai with years of experienced professionals.
ReplyDeleteDay by day I am getting new things and learn new concept through your blogs, I am feeling so confidants, and thanks for your informative blog keep your post as updated one...
ReplyDeleteInformatica courses in Chennai
Thanks for splitting your comprehension with us. It’s really useful to me & I hope it helps the people who in need of this vital information.
ReplyDeleteIf anyone focuses the Best ccna training in Chennai get here .
Cloud Computing Training
ReplyDeleteI have read your blog and i got a very useful and knowledgeable information from your blog.its really a very nice article.You have done a great job . If anyone want to get real time Cloud Computing Course in Chennai, Please visit FITA academy located at Chennai Velachery which offer best Cloud Computing Training in Chennai.
I learn a worthful information by this training.This makes very helpful for future reference.All the doubts are very clearly explained in this article.Thank you very much.
ReplyDeleteVMWare course chennai | VMWare certification in chennai | VMWare certification chennai
I am following your blog from the beginning, it was so distinct & I had a chance to collect conglomeration of information that helps me a lot to improvise myself.
ReplyDeleteWeb design training in Chennai
Thanks Admin for sharing such a useful post, I hope it’s useful to many individuals for developing their skill to get strong career soon.
ReplyDeleteRegards,
ccna training institute in Chennai|ccna institutes in Chennai|ccna courses in Chennai
All are saying the same thing repeatedly, but in your blog I had a chance to get some useful and unique information, I love your writing style very much, I would like to suggest your blog in my dude circle, so keep on updates…
ReplyDeleteRegards
Angularjs course in chennai|Angularjs training center in Chennai|Angularjs training in chennai
Really Good blog post.provided a helpful information.I hope that you will post more updates like this
ReplyDeleteBig data hadoop online Course
I feel really happy to have seen your webpage and look forward to so many more entertaining times reading here. Thanks once more for all the details. Best Selenium Training in Bangalore
ReplyDeleteYour blog is interesting for readers.you have developed your blog information's with such a wonderful ideas and which is very much useful for the readers.i enjoyed your post and i need some more articles also please update soon.
ReplyDeleteangularjs classes in bangalore
angularjs tutorial in bangalore
AngularJS Training in Nolambur
AngularJS Training in Saidapet
The information you have deliver here is really useful to make my knowledge good. Thanks for your heavenly post.
ReplyDeleteBig Data Hadoop Training In Chennai | Big Data Hadoop Training In anna nagar | Big Data Hadoop Training In omr | Big Data Hadoop Training In porur | Big Data Hadoop Training In tambaram | Big Data Hadoop Training In velachery
i'm honest natured you take conveyance of to selfishness in your message. It makes you stand dependancy out from numerous helper essayists that can't uphold over the top climate content remembering you. Download Fifa 19 Torrent
ReplyDeleteClick Here
ReplyDeleteGo To
Visit US
Website
Click Here
ReplyDeleteWebsite
Goto
Click Here To Open
Website Page
Software Development Life Cycle, is a set of steps used to create software applications.Software Development Life Cycle
ReplyDeleteLooking to attract your dream life? These best law of attraction books show you how to use the law of attraction to manifest money, love, .Law-Of-Attraction-Books-Manifest-Your-Desires
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteThis comment has been removed by the author.
ReplyDelete