Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2017
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.78 KB | None | 0 0
  1. Adding the Jar into the job.addFileToClassPath("/home/anji/web/simple-json.jar").
  2. You can use on of the three options to put the org.json.* classes into your cluster:
  3. Pack the org.json.* classes into your jar file (can easily be done using GUI IDE). This is the option I used in my answer
  4. Put the jar file containing org.json.* classes on each of the cluster nodes into one of the CLASSPATH directories
  5. (see yarn.application.classpath)
  6. Put the jar file containing org.json.* into HDFS (hdfs dfs -put <org.json jar> <hdfs path>)
  7. and use job.addFileToClassPath call for this jar file to be available for all of the tasks executing your job on the cluster.
  8. In my answer you should add job.addFileToClassPath(new Path("<jar_file_on_hdfs_location>")); to the main
  9. ======================================================================================================
  10. ======================================================================================================
  11. The mapper code is completely abstracted from the csv format now. It received an custom writable object as an input. The key is the txnid and the value is the TxnRecordWritable. And it retrieves the required fields by calling getter methods.
  12. Reducer code remains same as in the earlier post.
  13. Let's export the driver, mapper and reducers code into a jar file called groupings.jar
  14. Now we will run the program as follows.
  15. We will need to add the dataformts.jar file to the HADOOP_CLASSPATH first for the driver code to find it. And pass it in -libjars option to be added to classpath of the map and reduce jvms.
  16. export HADOOP_CLASSPATH=$HADOOP_CLASSPATH:/root/localrepo/dataformats.jar
  17. Let's run the program now.
  18. yarn jar grouping.jar com.bigdataleap.samples.customs.GroupingDriver
  19. -libjars /root/lab/programs/dataformats.jar
  20. /lab/mr/txns /lab/output/gr3
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement