在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 使用的更多相关文章

  1. 【8.0.0_r4】AMS分析(十六)(ActivityManagerService.java上)

    代码位于frameworks/base/services/core/java/com/android/server/am/,一共有七十个文件. Java源码位于package com.android. ...

  2. 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 * ...

  3. 【linux】free命令中cached和buffers的区别

    一.命令 [root@localhost ~]# free -m total used free shared buffers cached Mem: 7869 7651 218 1 191 5081 ...

  4. 使用Pip安装distribute、nose、virtualenv

    1 安装distribute sudo pip install distribute 2 安装nose sudo pip install nose 3 安装virtualenv sudo pip in ...

  5. 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后 ...

  6. 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] -------------------------- ...

  7. hive中order by,sort by, distribute by, cluster by作用以及用法

    1. order by     Hive中的order by跟传统的sql语言中的order by作用是一样的,会对查询的结果做一次全局排序,所以说,只有hive的sql中制定了order by所有的 ...

  8. cached过高导致内存溢出 java head space

     最近公司线上遇到老是内存溢出检查后发现cached过高 命令:free -m 命令:sync    //将缓存写入硬盘   cat /etc/redhat-release 这个是查看系统版本的命令c ...

  9. Linux Buffers和Cached的区别(转)

    在linux下使用free命令查看内存使用情况,有buffers和cached两项,以下是它们的区别: buffers是为块设备设计的缓冲.比如磁盘读写,把分散的写操作集中进行,减少磁盘I/O,从而提 ...

随机推荐

  1. IRGAN:A Minimax Game for Unifying Generative and Discriminative Information Retrieval Models

    https://arxiv.org/pdf/1705.10513.pdf 论文阅读笔记: https://www.cnblogs.com/liaohuiqiang/p/9694277.html htt ...

  2. 微服务,ApiGateway 与 Kong

    一. 微服务 二. Api Gateway 三. Kong 的使用 一. 微服务 对于一些传统的 大型项目,传统的方式会有一些缺陷,比如说 新人熟悉系统成本高(因为整个系统作为一个整体,彼此会有一定的 ...

  3. 【Objective-C】OC中KVO的基本概念和使用方法

    基本概念: 键值观察是一种使用获取其他对象的特定属性变化的通知机制. 控制器层的绑定技术就是严重依赖键值观察获得模型层和控制器层的变化通知的. 对于不依赖控制器层类的应用程序,键值观察提供了一种简化的 ...

  4. [nginx]编译安装及安全优化

    nginx配置-最后整理版 nginx_upstream_check_module nginx-module-vts nginx打补丁 nginx编译安装 - 下载 cd /usr/local/src ...

  5. [svc]Linux中Swap与Memory内存简单介绍

    swap区域是干嘛的 cpu 内存(不常用到的进程swap区) 磁盘 当内存没有可用的,就必须要把内存中不经常运行的程序给踢出去.但是踢到哪里去,这时候swap就出现了. 背景介绍 对于Linux来说 ...

  6. C++标准库及其保留字(关键字)——附:C++标准文档

    引言        C++到目前共发布了4个国际标准:ISO/IEC 14882:1998.ISO/IEC 14882:2003.ISO/IEC 14882:2011.ISO/IEC 14882:20 ...

  7. 10-free-must-read-books-machine-learning-data-science

    Spring. Rejuvenation. Rebirth. Everything’s blooming. And, of course, people want free ebooks. With ...

  8. SQL server 存储过程实现统计赋值

    @EmptyCount int output 参数 declare  @strCount nvarchar(max); 声明变量 取值语句: set @strCount='select @Count= ...

  9. windows操作系统自带的TCP端口转发

    假定需要通过192.168.1.8的14941端口连接192.168.1.118的1494端口,则需要在192.168.1.8主机的命令行输入如下语句netsh  interface ipv6 ins ...

  10. (转)Windows7安装OpenSSH

    (转自:http://blog.sina.com.cn/s/blog_4a0a8b5d01015b0n.html) OpenSSH很老了,所以... 最开始只是因为openSSH启动不了,才用的Mob ...