Question: Lab 4 1 : Using ToolRunner and Passing Parameters Files and Directories Used in this Exercise Eclipse project: toolrunner Java files: AverageReducer.java ( Reducer from
Lab : Using ToolRunner and Passing Parameters
Files and Directories Used in this Exercise
Eclipse project: toolrunner
Java files:
AverageReducer.java Reducer from AverageWordLength
LetterMapper.java Mapper from AverageWordLength
AvgWordLength.java driver from AverageWordLength
Exercise directory: ~workspacetoolrunner
In this Exercise, you will implement a driver using ToolRunner.
Follow the steps below to start with the Average Word Length program you wrote in an earlier lab, and modify the driver to use ToolRunner. Then modify the Mapper to reference a Boolean parameter called caseSensitive; if true, the mapper should treat upper and lower case letters as different; if false or unset, all letters should be converted to lower case.
Modify the Average Word Length Driver to use Toolrunner
Copy the Reducer, Mapper and driver code you completed in the Writing Java MapReduce Programs lab earlier, in the averagewordlength project.
Copying Source Files
You can use Eclipse to copy a Java source file from one project or package to another by rightclicking on the file and selecting Copy, then rightclicking the new package and selecting Paste. If the packages have different names eg if you copy from averagewordlength.solution to toolrunner.stubs Eclipse will automatically change the package directive at the top of the file. If you copy the file using a file browser or the shell, you will have to do that manually.
Modify the AvgWordLength driver to use ToolRunner. Refer to the slides for details.
a Implement the run method
b Modify main to call run
Jar your solution and test it before continuing; it should continue to function exactly as it did before. Refer to the Writing a Java MapReduce Program lab for how to assemble and test if you need a reminder.
Modify the Mapper to use a configuration parameter
Modify the LetterMapper class to
a Override the setup method to get the value of a configuration parameter called caseSensitive, and use it to set a member variable indicating whether to do case sensitive or case insensitive processing.
b In the map method, choose whether to do case sensitive processing leave the letters asis or insensitive processing convert all letters to lowercase based on that variable.
Pass a parameter programmatically
Modify the drivers run method to set a Boolean configuration parameter called caseSensitive. Hint: Use the Configuration.setBoolean method.
Test your code twice, once passing false and once passing true. When set to true, your final output should have both upper and lower case letters; when false, it should have only lower case letters. Hint: Remember to rebuild your Jar file to test changes to your code. Pass a parameter as a runtime parameter
Submit:
a Code when you set caseSensitive true
b Ouput when caseSensitive true
name the file partprogramaticallytrue
a Code when you set caseSensitive false
b Ouput when caseSensitive false
name the file partprogramaticallyfalse
Comment out the code that sets the parameter programmatically. Eclipse hint: Select the code to comment and then select Source Toggle Comment Test again, this time passing the parameter value using D on the Hadoop command line, eg:
$ hadoop jar toolrunner.jar stubs.AvgWordLength
DcaseSensitivetrue shakespeare toolrunnerout
Hint: you may need to use the following in your driver class:
Job job new JobgetConf;
Submit:
a Code when you set caseSensitive false
b Both the outputs:
i Ouput when caseSensitive true
name the file parttoolrunnertrue
ii Ouput when caseSensitive false
name the file parttoolrunnerfalse
Test passing both true and false to confirm the parameter works correctly.
Submission:
Please submit and from above. When submitting the code, remember the following:
Create a jar file of the final version of the project and submit your jar file after you have tested. Any jar files which do not execute ie have compilation errors will automatically be given a
Also when you create your jar file, make sure you have the following checked:
Export Java source files and resources and
Export generated class files and resources"
I need help with figuring out the proper code needed for all steps of the project. Thanks!
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
