Package org.apache.nutch.crawl
Class Generator
java.lang.Object
org.apache.hadoop.conf.Configured
org.apache.nutch.util.NutchTool
org.apache.nutch.crawl.Generator
- All Implemented Interfaces:
Configurable,Tool
Generates a subset of a CrawlDb to fetch. This version allows to generate
fetchlists for several segments in one go. Unlike in the initial version
(OldGenerator), the IP resolution is done ONLY on the entries which have been
selected for fetching. The URLs are partitioned by IP, domain or host within
a segment. We can choose separately how to count the URLs i.e. by domain or
host to limit the entries.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classUpdate the CrawlDB so that the next generate won't include the same URLs.static classstatic classSort fetch lists by hash of URL.static classstatic classSelects entries due for fetch.static classstatic classstatic classSelect and invert subset due for fetch.static classCollect until limit is reached. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringprotected static final org.slf4j.LoggerFields inherited from class org.apache.nutch.util.NutchTool
currentJob, currentJobNum, numJobs, results, status -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionPath[]Path[]generate(Path dbDir, Path segments, int numLists, long topN, long curTime, boolean filter, boolean force) Deprecated.Path[]generate(Path dbDir, Path segments, int numLists, long topN, long curTime, boolean filter, boolean norm, boolean force, int maxNumSegments, String expr) This signature should be used in the instance that no hostdb is available.Path[]generate(Path dbDir, Path segments, int numLists, long topN, long curTime, boolean filter, boolean norm, boolean force, int maxNumSegments, String expr, String hostdb) Generate fetchlists in one or more segments.static Stringstatic voidGenerate a fetchlist from the crawldb.intRuns the tool, using a map of arguments.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
-
LOG
protected static final org.slf4j.Logger LOG -
GENERATE_UPDATE_CRAWLDB
- See Also:
-
GENERATOR_MIN_SCORE
- See Also:
-
GENERATOR_MIN_INTERVAL
- See Also:
-
GENERATOR_RESTRICT_STATUS
- See Also:
-
GENERATOR_FILTER
- See Also:
-
GENERATOR_NORMALISE
- See Also:
-
GENERATOR_MAX_COUNT
- See Also:
-
GENERATOR_COUNT_MODE
- See Also:
-
GENERATOR_COUNT_VALUE_DOMAIN
- See Also:
-
GENERATOR_COUNT_VALUE_HOST
- See Also:
-
GENERATOR_TOP_N
- See Also:
-
GENERATOR_CUR_TIME
- See Also:
-
GENERATOR_DELAY
- See Also:
-
GENERATOR_MAX_NUM_SEGMENTS
- See Also:
-
GENERATOR_EXPR
- See Also:
-
GENERATOR_HOSTDB
- See Also:
-
GENERATOR_MAX_COUNT_EXPR
- See Also:
-
GENERATOR_FETCH_DELAY_EXPR
- See Also:
-
-
Constructor Details
-
Generator
public Generator() -
Generator
-
-
Method Details
-
generate
public Path[] generate(Path dbDir, Path segments, int numLists, long topN, long curTime) throws IOException, InterruptedException, ClassNotFoundException - Parameters:
dbDir- Crawl database directorysegments- Segments directorynumLists- Number of fetch lists (partitions) per segment or number of fetcher map tasks. (One fetch list partition is fetched in one fetcher map task.)topN- Number of top URLs to be selectedcurTime- Current time in milliseconds- Returns:
- Path to generated segment or null if no entries were selected
- Throws:
IOException- if an I/O exception occurs.InterruptedException- if a thread is waiting, sleeping, or otherwise occupied, and the thread is interrupted, either before or during the activity.ClassNotFoundException- if runtime class(es) are not available- See Also:
-
generate
@Deprecated public Path[] generate(Path dbDir, Path segments, int numLists, long topN, long curTime, boolean filter, boolean force) throws IOException, InterruptedException, ClassNotFoundException Deprecated.since 1.19 usegenerate(Path, Path, int, long, long, boolean, boolean, boolean, int, String, String)orgenerate(Path, Path, int, long, long, boolean, boolean, boolean, int, String)in the instance that no hostdb is availableThis is an old signature used for compatibility - does not specify whether or not to normalise and set the number of segments to 1- Parameters:
dbDir- Crawl database directorysegments- Segments directorynumLists- Number of fetch lists (partitions) per segment or number of fetcher map tasks. (One fetch list partition is fetched in one fetcher map task.)topN- Number of top URLs to be selectedcurTime- Current time in millisecondsfilter- whether to apply filtering operationforce- if true, and the target lockfile exists, consider it valid. If false and the target file exists, throw an IOException.- Returns:
- Path to generated segment or null if no entries were selected
- Throws:
IOException- if an I/O exception occurs.InterruptedException- if a thread is waiting, sleeping, or otherwise occupied, and the thread is interrupted, either before or during the activity.ClassNotFoundException- if runtime class(es) are not available- See Also:
-
generate
public Path[] generate(Path dbDir, Path segments, int numLists, long topN, long curTime, boolean filter, boolean norm, boolean force, int maxNumSegments, String expr) throws IOException, InterruptedException, ClassNotFoundException This signature should be used in the instance that no hostdb is available. Generate fetchlists in one or more segments. Whether to filter URLs or not is read from the "generate.filter" property set for the job from command-line. If the property is not found, the URLs are filtered. Same for the normalisation.- Parameters:
dbDir- Crawl database directorysegments- Segments directorynumLists- Number of fetch lists (partitions) per segment or number of fetcher map tasks. (One fetch list partition is fetched in one fetcher map task.)topN- Number of top URLs to be selectedcurTime- Current time in millisecondsfilter- whether to apply filtering operationnorm- whether to apply normalization operationforce- if true, and the target lockfile exists, consider it valid. If false and the target file exists, throw an IOException.maxNumSegments- maximum number of segments to generateexpr- a Jexl expression to use in the Generator job.- Returns:
- Path to generated segment or null if no entries were selected
- Throws:
IOException- if an I/O exception occurs.InterruptedException- if a thread is waiting, sleeping, or otherwise occupied, and the thread is interrupted, either before or during the activity.ClassNotFoundException- if runtime class(es) are not available- See Also:
-
generate
public Path[] generate(Path dbDir, Path segments, int numLists, long topN, long curTime, boolean filter, boolean norm, boolean force, int maxNumSegments, String expr, String hostdb) throws IOException, InterruptedException, ClassNotFoundException Generate fetchlists in one or more segments. Whether to filter URLs or not is read from the "generate.filter" property set for the job from command-line. If the property is not found, the URLs are filtered. Same for the normalisation.- Parameters:
dbDir- Crawl database directorysegments- Segments directorynumLists- Number of fetch lists (partitions) per segment or number of fetcher map tasks. (One fetch list partition is fetched in one fetcher map task.)topN- Number of top URLs to be selectedcurTime- Current time in millisecondsfilter- whether to apply filtering operationnorm- whether to apply normalization operationforce- if true, and the target lockfile exists, consider it valid. If false and the target file exists, throw an IOException.maxNumSegments- maximum number of segments to generateexpr- a Jexl expression to use in the Generator job.hostdb- name of a hostdb from which to execute Jexl expressions in a bid to determine the maximum URL count and/or fetch delay per host.- Returns:
- Path to generated segment or null if no entries were selected
- Throws:
IOException- if an I/O exception occurs.InterruptedException- if a thread is waiting, sleeping, or otherwise occupied, and the thread is interrupted, either before or during the activity.ClassNotFoundException- if runtime class(es) are not available- See Also:
-
generateSegmentName
-
main
Generate a fetchlist from the crawldb.- Parameters:
args- array of arguments for this job- Throws:
Exception- if there is an error running the job
-
run
-
run
Description copied from class:NutchToolRuns the tool, using a map of arguments. May return results, or null.- 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
-
generate(Path, Path, int, long, long, boolean, boolean, boolean, int, String, String)orgenerate(Path, Path, int, long, long, boolean, boolean, boolean, int, String)in the instance that no hostdb is available