From dbc2e039bb0fb0741265e893f6f01139379dcae7 Mon Sep 17 00:00:00 2001 From: orbiter Date: Mon, 2 Oct 2006 09:40:18 +0000 Subject: [PATCH] added time-out option parameter to call hierarchy git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@2691 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- htroot/xml/snippet.java | 2 +- htroot/yacy/search.java | 2 +- source/de/anomic/plasma/plasmaSnippetCache.java | 12 +++++++----- source/de/anomic/plasma/plasmaSwitchboard.java | 2 +- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/htroot/xml/snippet.java b/htroot/xml/snippet.java index d206d1328..421e76ad2 100644 --- a/htroot/xml/snippet.java +++ b/htroot/xml/snippet.java @@ -39,7 +39,7 @@ public class snippet { // do the search Set queryHashes = plasmaSearchQuery.words2hashes(query); - plasmaSnippetCache.Snippet snippet = switchboard.snippetCache.retrieveSnippet(url, queryHashes, true, 260); + plasmaSnippetCache.Snippet snippet = switchboard.snippetCache.retrieveSnippet(url, queryHashes, true, 260, 10000); prop.put("status",snippet.getSource()); if (snippet.getSource() < 11) { //prop.put("text", (snippet.exists()) ? snippet.getLineMarked(queryHashes) : "unknown"); diff --git a/htroot/yacy/search.java b/htroot/yacy/search.java index e5d9469aa..0ff673dfa 100644 --- a/htroot/yacy/search.java +++ b/htroot/yacy/search.java @@ -202,7 +202,7 @@ public final class search { while ((acc.hasMoreElements()) && (i < squery.wantedResults)) { urlentry = acc.nextElement(); if (includesnippet) { - snippet = sb.snippetCache.retrieveSnippet(urlentry.url(), squery.queryHashes, false, 260); + snippet = sb.snippetCache.retrieveSnippet(urlentry.url(), squery.queryHashes, false, 260, 1000); } else { snippet = null; } diff --git a/source/de/anomic/plasma/plasmaSnippetCache.java b/source/de/anomic/plasma/plasmaSnippetCache.java index c0ad8218a..fc057ecde 100644 --- a/source/de/anomic/plasma/plasmaSnippetCache.java +++ b/source/de/anomic/plasma/plasmaSnippetCache.java @@ -166,7 +166,7 @@ public class plasmaSnippetCache { return retrieveFromCache(hashes, indexURL.urlHash(url)) != null; } - public Snippet retrieveSnippet(URL url, Set queryhashes, boolean fetchOnline, int snippetMaxLength) { + public Snippet retrieveSnippet(URL url, Set queryhashes, boolean fetchOnline, int snippetMaxLength, int timeout) { // heise = "0OQUNU3JSs05" if (queryhashes.size() == 0) { //System.out.println("found no queryhashes for URL retrieve " + url); @@ -196,7 +196,7 @@ public class plasmaSnippetCache { // if not found try to download it if ((resource == null) && (fetchOnline)) { // download resource using the crawler - plasmaHTCache.Entry entry = loadResourceFromWeb(url, 5000); + plasmaHTCache.Entry entry = loadResourceFromWeb(url, timeout); // getting resource metadata (e.g. the http headers for http resources) if (entry != null) docInfo = entry.getDocumentInfo(); @@ -552,7 +552,7 @@ public class plasmaSnippetCache { urlstring = urlentry.url().toNormalform(); if ((urlstring.matches(urlmask)) && (!(existsInCache(urlentry.url(), queryhashes)))) { - new Fetcher(urlentry.url(), queryhashes).start(); + new Fetcher(urlentry.url(), queryhashes, (int) maxTime).start(); i++; } } @@ -561,14 +561,16 @@ public class plasmaSnippetCache { public class Fetcher extends Thread { URL url; Set queryhashes; - public Fetcher(URL url, Set queryhashes) { + int timeout; + public Fetcher(URL url, Set queryhashes, int timeout) { if (url.getHost().endsWith(".yacyh")) return; this.url = url; this.queryhashes = queryhashes; + this.timeout = timeout; } public void run() { log.logFine("snippetFetcher: try to get URL " + url); - plasmaSnippetCache.Snippet snippet = retrieveSnippet(url, queryhashes, true, 260); + plasmaSnippetCache.Snippet snippet = retrieveSnippet(url, queryhashes, true, 260, timeout); if (snippet.line == null) log.logFine("snippetFetcher: cannot get URL " + url + ". error(" + snippet.source + "): " + snippet.error); else diff --git a/source/de/anomic/plasma/plasmaSwitchboard.java b/source/de/anomic/plasma/plasmaSwitchboard.java index 8b33ed27a..939e2e21f 100644 --- a/source/de/anomic/plasma/plasmaSwitchboard.java +++ b/source/de/anomic/plasma/plasmaSwitchboard.java @@ -2078,7 +2078,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser URL wordURL; if (urlstring.matches(query.urlMask)) { //.* is default if (includeSnippets) { - snippet = snippetCache.retrieveSnippet(url, query.queryHashes, false, 260); + snippet = snippetCache.retrieveSnippet(url, query.queryHashes, false, 260, 1000); } else { snippet = null; }