Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
http timeouts von alten httpc wieder gesetzt
danielr7a35126e913c
diff --git a/source/de/anomic/http/HttpClient.java b/source/de/anomic/http/HttpClient.javaindex fc6402bd1..5703745c0 100644--- a/source/de/anomic/http/HttpClient.java+++ b/source/de/anomic/http/HttpClient.java@@ -174,6 +174,17 @@ public abstract class HttpClient {public static byte[] wget(final String uri, final String vhost) {return wget(uri, null, vhost);}++ /**+ * Gets a page (as raw bytes) aborting after timeout+ *+ * @param uri+ * @param timeout in milliseconds+ * @return+ */+ public static byte[] wget(final String uri, final int timeout) {+ return wget(uri, null, null, timeout);+ }/*** Gets a page (as raw bytes) with specified header@@ -196,8 +207,21 @@ public abstract class HttpClient {* @assert uri != null*/public static byte[] wget(final String uri, httpHeader header, final String vhost) {+ return wget(uri, header, vhost, 10000);+ }++ /**+ * Gets a page (as raw bytes) addressing vhost at host in uri with specified header and timeout+ *+ * @param uri+ * @param header+ * @param vhost+ * @param timeout in milliseconds+ * @return+ */+ public static byte[] wget(final String uri, httpHeader header, final String vhost, int timeout) {assert uri != null : "precondition violated: uri != null";- final HttpClient client = HttpFactory.newClient();+ final HttpClient client = HttpFactory.newClient(null, timeout);// set headerheader = addHostHeader(header, vhost);diff --git a/source/de/anomic/index/indexRepositoryReference.java b/source/de/anomic/index/indexRepositoryReference.javaindex 492438e08..41d8a4893 100644--- a/source/de/anomic/index/indexRepositoryReference.java+++ b/source/de/anomic/index/indexRepositoryReference.java@@ -257,7 +257,7 @@ public final class indexRepositoryReference {yacyURL newUrl = new yacyURL(newUrlStr, null);// doing a http head request to test if the url is correct- HttpClient client = HttpFactory.newClient();+ HttpClient client = HttpFactory.newClient(null, 30000);client.setProxy(proxyConfig);HttpResponse res = null;try {diff --git a/source/de/anomic/tools/loaderThreads.java b/source/de/anomic/tools/loaderThreads.javaindex b547d8cc1..6c62b00df 100644--- a/source/de/anomic/tools/loaderThreads.java+++ b/source/de/anomic/tools/loaderThreads.java@@ -141,7 +141,7 @@ public class loaderThreads {public void run() {try {- page = HttpClient.wget(url.toString());+ page = HttpClient.wget(url.toString(), timeout);loaded = true;process.feed(page);if (process.status() == loaderCore.STATUS_FAILED) {diff --git a/source/de/anomic/yacy/yacyClient.java b/source/de/anomic/yacy/yacyClient.javaindex d0b9d21e5..bd2e50508 100644--- a/source/de/anomic/yacy/yacyClient.java+++ b/source/de/anomic/yacy/yacyClient.java@@ -236,6 +236,7 @@ public final class yacyClient {/*** send data to the server named by vhost+ ** @param address address of the server* @param vhost name of the server at address which should respond* @param post data to send (name-value-pairs)@@ -243,7 +244,20 @@ public final class yacyClient {* @throws IOException*/private static byte[] wput(final String url, String vhost, final Map<String, ?> post) throws IOException {- HttpClient client = HttpFactory.newClient(null, 3600000); // abort after 1 hour+ return wput(url, vhost, post, 10000);+ }+ /**+ * send data to the server named by vhost+ *+ * @param address address of the server+ * @param vhost name of the server at address which should respond+ * @param post data to send (name-value-pairs)+ * @param timeout in milliseconds+ * @return response body+ * @throws IOException+ */+ private static byte[] wput(final String url, String vhost, final Map<String, ?> post, final int timeout) throws IOException {+ HttpClient client = HttpFactory.newClient(null, timeout);client.setProxy(proxyConfig());// address vhost@@ -363,7 +377,8 @@ public final class yacyClient {// send requesttry {- final byte[] result = wput("http://" + target.getClusterAddress() + "/yacy/urls.xml", target.getHexHash() + ".yacyh", post);+ /* a long time-out is needed */+ final byte[] result = wput("http://" + target.getClusterAddress() + "/yacy/urls.xml", target.getHexHash() + ".yacyh", post, 60000);rssReader reader = rssReader.parse(result);if (reader == null) {@@ -439,7 +454,7 @@ public final class yacyClient {// send requestHashMap<String, String> result = null;try {- result = nxTools.table(postToFile(target, "search.html", post), "UTF-8");+ result = nxTools.table(wput("http://" + target.getClusterAddress() + "/yacy/search.html", target.getHexHash() + ".yacyh", post, 60000), "UTF-8");} catch (IOException e) {yacyCore.log.logInfo("SEARCH failed, Peer: " + target.hash + ":" + target.getName() + " (" + e.getMessage() + "), score=" + target.selectscore + ", DHTdist=" + yacyDHTAction.dhtDistance(target.hash, wordhashes.substring(0, 12)));//yacyCore.peerActions.peerDeparture(target, "search request to peer created io exception: " + e.getMessage());@@ -724,7 +739,7 @@ public final class yacyClient {try {// TODO is targetAddress == url.getHost()?final yacyURL url = new yacyURL("http://" + targetAddress + "/yacy/transfer.html", null);- final byte[] content = wput("http://" + targetAddress + "/yacy/transfer.html", url.getHost(), post);+ final byte[] content = wput("http://" + targetAddress + "/yacy/transfer.html", url.getHost(), post, 20000);final HashMap<String, String> result = nxTools.table(content, "UTF-8");return result;} catch (Exception e) {diff --git a/source/de/anomic/yacy/yacyPeerActions.java b/source/de/anomic/yacy/yacyPeerActions.javaindex 65e0dded7..93b3cd05d 100644--- a/source/de/anomic/yacy/yacyPeerActions.java+++ b/source/de/anomic/yacy/yacyPeerActions.java@@ -186,7 +186,7 @@ public class yacyPeerActions {yacyCore.log.logInfo("BOOTSTRAP: seed-list URL " + seedListFileURL + " too old (" + (header.age() / 86400000) + " days)");} else {ssc++;- final byte[] content = HttpClient.wget(url.toString(), reqHeader);+ final byte[] content = HttpClient.wget(url.toString(), reqHeader, null, bootstrapLoadTimeout);seedList = nxTools.strings(content, "UTF-8");enu = seedList.iterator();lc = 0;diff --git a/source/de/anomic/yacy/yacyVersion.java b/source/de/anomic/yacy/yacyVersion.javaindex e755b612d..0b0a0e178 100644--- a/source/de/anomic/yacy/yacyVersion.java+++ b/source/de/anomic/yacy/yacyVersion.java@@ -328,7 +328,7 @@ public final class yacyVersion implements Comparator<yacyVersion>, Comparable<yaFile storagePath = plasmaSwitchboard.getSwitchboard().releasePath;// load fileFile download = new File(storagePath, release.url.getFileName());- HttpClient client = HttpFactory.newClient(null, 60000);+ HttpClient client = HttpFactory.newClient(null, 300000);HttpResponse res = null;try {res = client.GET(release.url.toString());