Advertisement
Guest User

Untitled

a guest
May 25th, 2015
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. public class SampleDistributedCache
  2. {
  3. public static class DCMapper extends Mapper<Object, Text, Text, IntWritable>
  4. {
  5. //Get the list of uris for the files added in DC
  6. Path[] uris = DistributedCache.getLocalCacheFiles(context.getConfiguration());
  7. try{
  8. BufferedReader readBuff = new BufferedReader(new FileReader(uris[0].toString()));
  9. String line;
  10. while ((line=readBuff.readLine())!=null)
  11. {
  12. System.out.println(line);
  13. }
  14. readBuff.close();
  15. }
  16. catch (Exception e)
  17. {
  18. System.out.println(e.toString());
  19. }
  20. }
  21.  
  22.  
  23. public static void main(String[] args) throws Exception {
  24. DistributedCache.addCacheFile(new URI("hdfs://yournamenode/configFile.cfg"),job.getConfiguration());
  25. }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement