Package org.apache.nutch.crawl
Class Injector
java.lang.Object
org.apache.hadoop.conf.Configured
org.apache.nutch.util.NutchTool
org.apache.nutch.crawl.Injector
- All Implemented Interfaces:
Configurable,Tool
Injector takes a flat text file of URLs (or a folder containing text files)
and merges ("injects") these URLs into the CrawlDb. Useful for bootstrapping
a Nutch crawl. The URL files contain one URL per line, optionally followed by
custom metadata separated by tabs with the metadata key separated from the
corresponding value by '='.
Note, that some metadata keys are reserved:
- nutch.score
- allows to set a custom score for a specific URL
- nutch.fetchInterval
- allows to set a custom fetch interval for a specific URL
- nutch.fetchInterval.fixed
- allows to set a custom fetch interval for a specific URL that is not changed by AdaptiveFetchSchedule
Example:
http://www.nutch.org/ \t nutch.score=10 \t nutch.fetchInterval=2592000 \t userType=open_source
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classInjectMapper reads the CrawlDb seeds are injected into the plain-text seed files and parses each line into the URL and metadata.static classCombine multiple new entries for a url. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic Stringmetadata key reserved for setting a custom fetchInterval for a specific URLstatic Stringmetadata key reserved for setting a fixed custom fetchInterval for a specific URLstatic Stringmetadata key reserved for setting a custom score for a specific URLstatic final Stringproperty to pass value of command-line option -filterNormalizeAll to mapperFields inherited from class org.apache.nutch.util.NutchTool
currentJob, currentJobNum, numJobs, results, status -
Constructor Summary
Constructors -
Method Summary
Methods inherited from class org.apache.nutch.util.NutchTool
getProgress, getStatus, killJob, setConf, stopJobMethods inherited from class org.apache.hadoop.conf.Configured
getConfMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.hadoop.conf.Configurable
getConf, setConf
-
Field Details
-
URL_FILTER_NORMALIZE_ALL
property to pass value of command-line option -filterNormalizeAll to mapper- See Also:
-
nutchScoreMDName
metadata key reserved for setting a custom score for a specific URL -
nutchFetchIntervalMDName
metadata key reserved for setting a custom fetchInterval for a specific URL -
nutchFixedFetchIntervalMDName
metadata key reserved for setting a fixed custom fetchInterval for a specific URL
-
-
Constructor Details
-
Injector
public Injector() -
Injector
-
-
Method Details
-
inject
public void inject(Path crawlDb, Path urlDir) throws IOException, ClassNotFoundException, InterruptedException -
inject
public void inject(Path crawlDb, Path urlDir, boolean overwrite, boolean update) throws IOException, ClassNotFoundException, InterruptedException -
inject
public void inject(Path crawlDb, Path urlDir, boolean overwrite, boolean update, boolean normalize, boolean filter, boolean filterNormalizeAll) throws IOException, ClassNotFoundException, InterruptedException -
usage
public void usage() -
main
- Throws:
Exception
-
run
-
run
Programmatic entry point forNutchToolcallers.- Specified by:
runin classNutchTool- Parameters:
args- aMapof arguments to be run with the toolcrawlId- a crawl identifier to associate with the tool invocation- Returns:
- Map results object if tool executes successfully otherwise null
- Throws:
Exception- if there is an error during the tool execution
-