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

FetchDNS: Keep dnsjava selector thread out of ToePool #444

Merged
merged 2 commits into from
Nov 27, 2021
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 @@ -51,8 +51,6 @@
import org.springframework.context.ApplicationEvent;
import org.springframework.context.Lifecycle;
import org.springframework.context.support.AbstractApplicationContext;
import org.xbill.DNS.DClass;
import org.xbill.DNS.Lookup;

/**
* CrawlController collects all the classes which cooperate to
Expand Down Expand Up @@ -289,10 +287,6 @@ public void start() {

sExit = CrawlStatus.FINISHED_ABNORMAL;

// force creation of DNS Cache now -- avoids CacheCleaner in toe-threads group
// also cap size at 1 (we never wanta cached value; 0 is non-operative)
Lookup.getDefaultCache(DClass.IN).setMaxEntries(1);

reserveMemory = new LinkedList<byte[]>();
for(int i = 0; i < RESERVE_BLOCKS; i++) {
reserveMemory.add(new byte[RESERVE_BLOCK_SIZE]);
Expand Down
13 changes: 13 additions & 0 deletions modules/src/main/java/org/archive/modules/fetcher/FetchDNS.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,19 @@ public class FetchDNS extends Processor {

private static Logger logger = Logger.getLogger(FetchDNS.class.getName());

static {
// cap size at 1 (we never want a cached value; 0 is non-operative)
Lookup.getDefaultCache(DClass.IN).setMaxEntries(1);

// do a dummy lookup to force the creation of dnsjava NIO selector thread
// ensures it doesn't end up in the toe-threads group
try {
new Lookup("localhost").run();
} catch (TextParseException e) {
throw new RuntimeException(e);
}
}

// Defaults.
private short ClassType = DClass.IN;
private short TypeType = Type.A;
Expand Down