DistributedCache使用
DistributedCache使用:
1.import包
import org.apache.hadoop.filecache.DistributedCache;
DistributedCache.addCacheFile(new Path(args[++i]).toUri(), job.getConfiguration());
Configuration conf = context.getConfiguration();Path [] pathwaysFiles = new Path[0];try {pathwaysFiles = DistributedCache.getLocalCacheFiles(conf);}catch (IOException ioe) {System.err.println("Caught exception while getting cached files: " + StringUtils.stringifyException(ioe));}for (Path pathwaysFile : pathwaysFiles) {try {BufferedReader fis = new BufferedReader(new FileReader(pathwaysFile.toString()));String pathway = null;while ((pathway = fis.readLine()) != null) {String [] p = pathway.split(" ");pathways.add(p);}}catch (IOException ioe) {}}
/ifshk4/HDFS/hadoop/hadoop12/tmp/mapred/local/taskTracker/archive/compute-7-0.local/user/hadoop/kipu/expression_head.txt/expression_head.txt
/tmp/hadoop/bin/hadoop jar kipu.jar org.bgi.kipu.kipu /user/hadoop/kipu/expression_final.txt /user/hadoop/kipu/output/ -pathways /user/hadoop/kipu/pathways_final.txt -head /user/hadoop/kipu/expression_head.txt
job.getConfiguration().set("kipu.head.path", args[i]);
pathwaysFile.toString().contains(conf.get("kipu.head.path"))