Distribute Cached 使用
在Kettle中说到Pentaho的MapReduce要用到它,就查了一下关于它的资料,以下是从官方查到的内容,记录一下。
DistributedCache: 一些比较小的需要共享的文件或者jar包,我们先存到hdfs上,然后在MapReduce线程当中进行共享,直接用了。
// Setting up the cache for the application
1. Copy the requisite files to the FileSystem:
$ bin/hadoop fs -copyFromLocal lookup.dat /myapp/lookup.dat
$ bin/hadoop fs -copyFromLocal map.zip /myapp/map.zip
$ bin/hadoop fs -copyFromLocal mylib.jar /myapp/mylib.jar
$ bin/hadoop fs -copyFromLocal mytar.tar /myapp/mytar.tar
$ bin/hadoop fs -copyFromLocal mytgz.tgz /myapp/mytgz.tgz
$ bin/hadoop fs -copyFromLocal mytargz.tar.gz /myapp/mytargz.tar.gz
2. Setup the application's JobConf:
JobConf job = new JobConf(); // #lookup.dat 表示给前面的这个文件取一个别名,类似sql里面的as别名一样 DistributedCache.addCacheFile(new URI("/myapp/lookup.dat#lookup.dat"),
job);
DistributedCache.addCacheArchive(new URI("/myapp/map.zip", job);
DistributedCache.addFileToClassPath(new Path("/myapp/mylib.jar"), job);
DistributedCache.addCacheArchive(new URI("/myapp/mytar.tar", job);
DistributedCache.addCacheArchive(new URI("/myapp/mytgz.tgz", job);
DistributedCache.addCacheArchive(new URI("/myapp/mytargz.tar.gz", job);
3. Use the cached files in the Mapper
or Reducer:
public static class MapClass extends MapReduceBase
implements Mapper<K, V, K, V> {
private Path[] localArchives;
private Path[] localFiles;
public void configure(JobConf job) {
// Get the cached archives/files
localArchives = DistributedCache.getLocalCacheArchives(job);
localFiles = DistributedCache.getLocalCacheFiles(job);
}
public void map(K key, V value,
OutputCollector<K, V> output, Reporter reporter)
throws IOException {
// Use data from the cached archives/files here
// ...
// ...
output.collect(k, v);
}
}
查看代码了才知道其实它根本不是什么缓存,它只不过是在配置文件中的指定属性记录下相应的值,然后在mapreduce的时候,调用配置文件里面的属性值,然后取得需要的文件盒jar包。
Distribute Cached 使用的更多相关文章
- 【8.0.0_r4】AMS分析(十六)(ActivityManagerService.java上)
代码位于frameworks/base/services/core/java/com/android/server/am/,一共有七十个文件. Java源码位于package com.android. ...
- Failure to find xxx in xxx was cached in the local repository, resolution will not be reattempted until the update interval of nexus has elapsed or updates are forced @ xxx
问题: 在linux服务器上使用maven编译war时报错: 16:41:35 [FATAL] Non-resolvable parent POM for ***: Failure to find * ...
- 【linux】free命令中cached和buffers的区别
一.命令 [root@localhost ~]# free -m total used free shared buffers cached Mem: 7869 7651 218 1 191 5081 ...
- 使用Pip安装distribute、nose、virtualenv
1 安装distribute sudo pip install distribute 2 安装nose sudo pip install nose 3 安装virtualenv sudo pip in ...
- yum install 安装时报yum doesn't have enough cached data to continue.
yum install 安装时报yum doesn't have enough cached data to continue. 安装epel,yum -y install epel-release后 ...
- Maven-010-maven 编译报错:Failure to ... in ... was cached in the local repository, resolution will not be reattempted until the update interval of nexus has elapsed or updates are forced.
今晚在编译 maven 项目的时候,命令行报错,出现 Failure to ... in ... 类似错误,详细的错误信息如下所示: [INFO] -------------------------- ...
- hive中order by,sort by, distribute by, cluster by作用以及用法
1. order by Hive中的order by跟传统的sql语言中的order by作用是一样的,会对查询的结果做一次全局排序,所以说,只有hive的sql中制定了order by所有的 ...
- cached过高导致内存溢出 java head space
最近公司线上遇到老是内存溢出检查后发现cached过高 命令:free -m 命令:sync //将缓存写入硬盘 cat /etc/redhat-release 这个是查看系统版本的命令c ...
- Linux Buffers和Cached的区别(转)
在linux下使用free命令查看内存使用情况,有buffers和cached两项,以下是它们的区别: buffers是为块设备设计的缓冲.比如磁盘读写,把分散的写操作集中进行,减少磁盘I/O,从而提 ...
随机推荐
- Ubuntu 13.04开机亮度调节
终于把我的T430换成Ubuntu,本来还打算等几天13.10,想想反正能升级,趁着101长假就抓紧换了吧~` 总体来说遇到的问题不是很多,可能是Thinkpad在Linux或者ubuntu的方面做的 ...
- [转]python数据持久存储:pickle模块的基本使用
python的pickle模块实现了基本的数据序列和反序列化.通过pickle模块的序列化操作我们能够将程序中运行的对象信息保存到文件中去,永久存储:通过pickle模块的反序列化操作,我们能够从文件 ...
- [golang] Glide 包管理
一.概述 golang的包管理工具有很多,本篇幅主要介绍glide进行包管理. 二.安装及命令介绍 go get github.com/Masterminds/glide glide create|i ...
- springboot 中使用Druid 数据源提供数据库监控
一.springboot 中注册 Servlet/Filter/Listener 的方式有两种,1 通过代码注册 ServletRegistrationBean. FilterRegistration ...
- ansible 批量推送公钥
这里我们使用ansible的playbook 的功能来推送秘钥 使用方法参见:http://blog.csdn.net/magedu_linux/article/details/48529645 这里 ...
- asp.net core在linux上的部署调试
双十一买了阿里云的LINUX服务器三年¥720 把自己的niunan.net一系列网站都部署上去 用jexus来部署,部署时发现头一个网站没问题,但是后一个网站部署就有问题..输入域名打不开,但JEX ...
- 【硅谷问道】 WWDC 17: 开发者的最初观感
[硅谷问道] WWDC 17: 开发者的最初观感 前言 每年的 WWDC 都是 iOS 开发者集体高潮的时刻.第一天的 WWDC 带来了全新的 iOS 11.MacOS.tvOS 和 watchOS, ...
- (原)docker的一个“Driver aufs failed to remove...”问题的解决
1. /var/lib/docker/aufs/mnt下的目录不能乱删! /var/lib/docker/aufs/diff下的目录删了就死了!!!!!2. 尽量不要用docker tag -f 这 ...
- MyBean - 单实例插件改进和VCL插件的改进
BeanFactory中添加VclOwners:TComponent属性, 在getBean创建VCL插件的时候,Tcomponent.Create(VclOwners) 这样在清理DLL时就会释 ...
- 在CentOS6.5上安装/启动PostgreSQL
CentOS install PostgreSQL yum install postgresql-server Start PostgreSQL service postgresql initdb # ...