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

Add support for forced queue assignment and parallel queues #286

Merged
merged 2 commits into from
Oct 11, 2019
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
*/
package org.archive.crawler.frontier;

import org.apache.commons.lang.StringUtils;
import org.archive.modules.CrawlURI;
import org.archive.net.UURI;
import org.archive.net.PublicSuffixes;

/**
Expand All @@ -32,9 +34,34 @@ public class AssignmentLevelSurtQueueAssignmentPolicy extends
private static final long serialVersionUID = -1533545293624791702L;

@Override
public String getClassKey(CrawlURI cauri) {
String candidate = super.getClassKey(cauri);
candidate = PublicSuffixes.reduceSurtToAssignmentLevel(candidate);
public String getClassKey(CrawlURI curi) {
if(getDeferToPrevious() && !StringUtils.isEmpty(curi.getClassKey())) {
return curi.getClassKey();
}

UURI basis = curi.getPolicyBasisUURI();
String candidate = super.getClassKey(curi);
candidate = PublicSuffixes.reduceSurtToAssignmentLevel(candidate);

if(!StringUtils.isEmpty(getForceQueueAssignment())) {
candidate = getForceQueueAssignment();
}

// all whois urls in the same queue
if (curi.getUURI().getScheme().equals("whois")) {
return "whois...";
}

if(StringUtils.isEmpty(candidate)) {
return DEFAULT_CLASS_KEY;
}
if(getParallelQueues()>1) {
int subqueue = getSubqueue(basis,getParallelQueues());
if (subqueue>0) {
candidate += "+"+subqueue;
}
}

return candidate;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,19 +90,19 @@ public String getClassKey(CrawlURI curi) {
if(getDeferToPrevious() && !StringUtils.isEmpty(curi.getClassKey())) {
return curi.getClassKey();
}

UURI basis = curi.getPolicyBasisUURI();
String candidate = getCoreKey(basis);

if(!StringUtils.isEmpty(getForceQueueAssignment())) {
return getForceQueueAssignment();
candidate = getForceQueueAssignment();
}

// all whois urls in the same queue
if (curi.getUURI().getScheme().equals("whois")) {
return "whois...";
}

UURI basis = curi.getPolicyBasisUURI();
String candidate = getCoreKey(basis);

if(StringUtils.isEmpty(candidate)) {
return DEFAULT_CLASS_KEY;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ public void setGroupMaxNovelUrls(long max) {
* being force-retired (if the Frontier supports this). Note that if your
* queues combine URIs that are different with regard to the quota category,
* the retirement may hold back URIs not in the same quota category. Default
* is false.
* is true.
*/
{
setForceRetire(true);
Expand Down