DistributedCache使用:
1.import包
import org.apache.hadoop.filecache.DistributedCache;
2.加到Cache中
DistributedCache.addCacheFile(new Path(args[++i]).toUri(), job.getConfiguration());
3.Map或Reduce中调用
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) {
}
}
DistributeCche的存储路径:
/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
这个路径其实是当前map/reduce任务的本地路径再加上hdfs上的路径,
因此当然会跟执行任务时输入的参数不一致啦。
因此在DistributeCache中有多个文件的时候可以用以下方法判断:
1.将参数的内容放到conf中去:
job.getConfiguration().set("kipu.head.path", args[i]);
2.用contains来判断
pathwaysFile.toString().contains(conf.get("kipu.head.path"))
分享到:
相关推荐
DistributedCache类使用!
使用AppFabric或Redis存储序列化对象的小测试 在此之后你可以运行 DistributedCacheCLI.exe 这会: 插入 1,000 个对象, 再读一遍, 两分钟后,对象将过期。 安装 要安装这个简单的 DistributedCache 客户端,...
.net 分布式缓存中间件 方便实现缓存的分布式,集群,负载均衡,故障自动转移,并兼容多种缓存存储的分布式缓存中间件。 用于解决分布式架构中的分布式缓存环节。
签出distributedcache软件包(如果没有),并使用maven构建工具进行构建。 签出distributedcache_process1程序包。 run main方法存在于distributedcache_process1包中。 主类-com.indix.dc.process1.App#main
分布式缓存实现分布式缓存
微软 分布式 缓存 Velocity CTP3 使用介绍: http://blog.csdn.net/yangjian15/archive/2009/12/18/5033248.aspx
使用IDistributedCache而不是字节数组使用强类型对象的额外添加的逻辑。 有两个版本,有关详细信息,请参见下表。 信息 版本 依存关系 信息 Microsoft已声明不推荐使用此依赖项。 这仍然是预览版本。 代码示例 用...
1. Hadoop简介2.... Hadoop在yahoo的应用附录A: 云计算在线监测平台附录B: Hadoop安装、运行、使用说明附录C:使用DistributedCache的MapReduce程序附录D:使用ChainMapper和ChainReducer的MapReduce程序
1. Hadoop简介2.... Hadoop在yahoo的应用附录A: 云计算在线监测平台附录B: Hadoop安装、运行、使用说明附录C:使用DistributedCache的MapReduce程序附录D:使用ChainMapper和ChainReducer的MapReduce程序
服务器之间的 JVM/进程间通信 此应用程序需要在节点之间进行协调,并确保其中一个且只有一个执行 System.out.println("We are started!") 此应用程序在不同节点/机器... 可以使用 git clone 命令将源代码导入到您的 IDE
8.Coherence企业级缓存(七) 性能调优.pdf
使用 CompositeInputFormat 的先决条件: 您要加入的所有文件已排序他们都有相同的加入密钥文件太大,无法使用 DistributedCache 加入如果你有 n 个文件按它们的连接键排序,你可以很容易地将它们组合起来,从每个...
Nuget: Microsoft.Extensions.Caching.Redis public IDistributedCache _distributedCache;
DistributedCache 是一个提供给Map/Reduce框架的工具,用来缓存文件(text, archives, jars and so on)文件的默认访问协议为(hdfs://). DistributedCache将拷贝缓存的文件到Slave节点在任何Job在节点上执行之前。 ...
5.2.1 Reduce侧的联结 5.2.2 基于DistributedCache的复制联结 5.2.3 半联结:map侧过滤后在reduce侧联结 5.3 创建一个Bloom filter 5.3.1 Bloom filter做了什么 5.3.2 实现一个Bloom filter 5.3.3 Hadoop 0.20...
高阶MapReduce5.1 链接MapReduce 作业5.1.1 顺序链接MapReduce作业5.1.2 具有复杂依赖的MapReduce链接5.1.3 预处理和后处理阶段的链接5.2 联结不同来源的数据5.2.1 Reduce侧的联结5.2.2 基于DistributedCache的复制...
开源地址:http://git.oschina.net/chejiangyi/XXF.BaseService.DistributedCache 方便实现缓存的分布式,集群,负载均衡,故障自动转移,并兼容多种缓存存储的分布式缓存中间件。 用于解决分布式架构中的分布式缓存...
895.2.1 Reduce侧的联结 905.2.2 基于DistributedCache的复制联结 985.2.3 半联结:map侧过滤后在reduce侧联结 1015.3 创建一个Bloom filter 1025.3.1 Bloom filter做了什么 1025.3.2 实现一个Bloom filter 1045.3.3...
865.1.3 预处理和后处理阶段的链接 865.2 联结不同来源的数据 895.2.1 Reduce侧的联结 905.2.2 基于DistributedCache的复制联结 985.2.3 半联结:map侧过滤后在reduce侧联结 1015.3 创建一个Bloom filter...
nebulex:Elixir的内存中和分布式缓存工具包