Nutch 的配置文件.doc

  1. 1、本文档共14页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
Nutch 的配置文件

Nutch 的配置 Nutch的配置文件主要有三类: 1.Hadoop的配置文件,Hadoop-default.xml和Hadoop-site.xml。 2.Nutch的配置文件,Nutch-default.xml和Nutch-site.xml。 3.Nutch的插件的配置文件,这些插件的配置文件在加载插件的时候由插件自行加载,如filter的配置文件。 ? 配置文件的加载顺序决定了配置文件的优先级,先加载的配置文件优先级低,后加载的配置文件优先级高,优先级低的配置会被优先级高的配置覆盖。因此,了解Nutch配置文件加载的顺序对学习使用Nutch是非常必要的。下面我们通过对Nutch源代码的分析来看看Nutch加载配置文件的过程。 ? Nutch1.0使用入门(一) 介绍了Nutch主要命令--crawl的使用,下面我们就从crawl的main类(org.apache.nutch.crawl.Crawl)的main方法开始分析: ? Crawl类main方法中加载配置文件的源码如下: ? Configuration conf = NutchConfiguration.create(); conf.addResource(crawl-tool.xml); JobConf job = new NutchJob(conf); ? 上面代码中,生成了一个NutchConfiguration类的对象,NutchConfiguration是Nutch管理自己配置文件的类,Configuration是Hadoop管理自己配置文件的类。下面我们进入NutchConfiguration类的create()方法。 ? /** Create a {@link Configuration} for Nutch. */ public static Configuration create() { Configuration conf = new Configuration(); addNutchResources(conf); return conf; } ? create()方法中,先生成了一个Configuration类的对象。请看Configuration类中的源码: ? /** A new configuration. */ public Configuration() { this(true); } /** A new configuration where the behavior of reading from the default * resources can be turned off. * * If the parameter {@code loadDefaults} is false, the new instance * will not load resources from the default files. * @param loadDefaults specifies whether to load from the default files */ public Configuration(boolean loadDefaults) { if (LOG.isDebugEnabled()) { LOG.debug(StringUtils.stringifyException(new IOException(config()))); } if (loadDefaults) { resources.add(hadoop-default.xml); resources.add(hadoop-site.xml); } } ? 由上面代码可以看出,在创建Configuration对象的时候,会依次加载hadoop-default.xml和hadoop-site.xml这两个配置文件。所以Hadoop-site.xml中的配置会覆盖hadoop-default.xml中的配置。了解完Hadoop配置文件的加载,我们回到刚才的create()方法里面。创建了Configuration对象后,将调用addNutchResources(conf)方法。 ? /** Add the standard Nutch resources to {@link Configuration}. */ public static Configuration addNutchResources(Configuration conf) { conf.ad

文档评论(0)

xcs88858 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

版权声明书
用户编号:8130065136000003

1亿VIP精品文档

相关文档