private void executeShutdown() { if (resolutionIndex != null) { for (String link : urlsToResolve) { toResolveStore store = new toResolveStore(); store.setPKey(link); resolutionIndex.put(store); } } }
/** Default constructor for the DNS resolver thread */ public DnsResolver() { dnsCache = new ConcurrentHashMap<String, InetAddress>(); urlsToResolve = new LinkedBlockingQueue<String>(); CrawlerDrone.addLog("DNS Resolver starting......"); resolutionIndex = CrawlerDrone.bdb.getPrimaryIndex( storage.BDBWrapper.DB_TO_RESOLVE_STORE, String.class, toResolveStore.class); if (resolutionIndex != null) { EntityCursor<toResolveStore> previousUnresolved = resolutionIndex.entities(); for (toResolveStore item : previousUnresolved) { urlsToResolve.add(item.getPKey()); } previousUnresolved.close(); try { CrawlerDrone.bdb .getEnvironment() .truncateDatabase(null, storage.BDBWrapper.DB_TO_RESOLVE_STORE, false); } catch (DatabaseNotFoundException e) { // Nothing to restore } } CrawlerDrone.addLog("DNS Resolver started."); }