Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

This improves the way Nutch is erroring out, at least for local mode. #830

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 21 additions & 16 deletions src/java/org/apache/nutch/crawl/Injector.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,23 +130,28 @@ public static class InjectMapper

@Override
public void setup(Context context) {
Configuration conf = context.getConfiguration();
boolean normalize = conf.getBoolean(CrawlDbFilter.URL_NORMALIZING, true);
boolean filter = conf.getBoolean(CrawlDbFilter.URL_FILTERING, true);
filterNormalizeAll = conf.getBoolean(URL_FILTER_NORMALIZE_ALL, false);
if (normalize) {
scope = conf.get(URL_NORMALIZING_SCOPE, URLNormalizers.SCOPE_INJECT);
urlNormalizers = new URLNormalizers(conf, scope);
}
interval = conf.getInt("db.fetch.interval.default", 2592000);
if (filter) {
filters = new URLFilters(conf);
try {
Configuration conf = context.getConfiguration();
boolean normalize = conf.getBoolean(CrawlDbFilter.URL_NORMALIZING, true);
boolean filter = conf.getBoolean(CrawlDbFilter.URL_FILTERING, true);
filterNormalizeAll = conf.getBoolean(URL_FILTER_NORMALIZE_ALL, false);
if (normalize) {
scope = conf.get(URL_NORMALIZING_SCOPE, URLNormalizers.SCOPE_INJECT);
urlNormalizers = new URLNormalizers(conf, scope);
}
interval = conf.getInt("db.fetch.interval.default", 2592000);
if (filter) {
filters = new URLFilters(conf);
}
scfilters = new ScoringFilters(conf);
scoreInjected = conf.getFloat("db.score.injected", 1.0f);
curTime = conf.getLong("injector.current.time",
System.currentTimeMillis());
url404Purging = conf.getBoolean(CrawlDb.CRAWLDB_PURGE_404, false);
} catch (Exception e) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exception is very vague. I would suggest we figure out what types of Exception's are thrown then catch and raise them instead. What do you think @HiranChaudhuri ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would not know how to define what types of Exceptions can be thrown. Be aware that logging needs to happen for checked and unchecked exceptions. And be aware you cannot see all the code: It loads plugins. Your catch method needs to be compatible to all existing and future code.

So I do not know how to make the catch block any more concise than it is right now. If you can, please show me.

LOG.error("Could not configure InjectMapper", e);
throw e;
}
scfilters = new ScoringFilters(conf);
scoreInjected = conf.getFloat("db.score.injected", 1.0f);
curTime = conf.getLong("injector.current.time",
System.currentTimeMillis());
url404Purging = conf.getBoolean(CrawlDb.CRAWLDB_PURGE_404, false);
}

/* Filter and normalize the input url */
Expand Down