Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
Skip remote Solr search if last try showed error As the solr servlet may not be available (e.g. no public search page, old version, individual access setting) a /solr/select error is remembered in the seed.dna of the remote peer. This is not permanent, as flag is not stored and the seed is reloaded on several occasions, it is just a memory of the recent past status. Might also be set to "not available" on time-out of last try.
reger2614fa7aeb14
diff --git a/source/net/yacy/peers/DHTSelection.java b/source/net/yacy/peers/DHTSelection.javaindex 4d4ab6b4a..8c348c696 100644--- a/source/net/yacy/peers/DHTSelection.java+++ b/source/net/yacy/peers/DHTSelection.java@@ -104,6 +104,7 @@ public class DHTSelection {if (seed == null) continue;if (omit != null && omit.contains(seed)) continue; // sort out peers that are target for DHTif (seed.isLastSeenTimeout(3600000)) continue; // do not ask peers that had not been seen more than one hour (happens during a startup situation)+ if (!seed.getFlagSolrAvailable()) continue; // extra peers always use solr direct, skip if solr interface is not availableif (!seed.getFlagAcceptRemoteIndex() && seed.matchPeerTags(wordhashes)) seedSelection.dec(seed, r.nextInt(10) + 2); // robinson peers with matching peer tagsif (seed.getFlagRootNode()) seedSelection.dec(seed, r.nextInt(30) + 6); // root nodes (fast peers)if (seed.getAge() < minage) seedSelection.dec(seed, r.nextInt(15) + 3); // young peers (with fresh info)diff --git a/source/net/yacy/peers/Protocol.java b/source/net/yacy/peers/Protocol.javaindex 8dc91bfb5..356d8456a 100644--- a/source/net/yacy/peers/Protocol.java+++ b/source/net/yacy/peers/Protocol.java@@ -1048,6 +1048,10 @@ public final class Protocol {} else {try {final boolean myseed = target == event.peers.mySeed();+ if (!myseed && !target.getFlagSolrAvailable()) { // skip if peer.dna has flag that last try resulted in error+ Network.log.info("SEARCH skip (solr), remote Solr interface not accessible, peer=" + target.getName());+ return -1;+ }final String address = myseed ? "localhost:" + target.getPort() : target.getPublicAddress();final int solrtimeout = Switchboard.getSwitchboard().getConfigInt(SwitchboardConstants.FEDERATED_SERVICE_SOLR_INDEXING_TIMEOUT, 6000);Thread remoteRequest = new Thread() {@@ -1073,17 +1077,20 @@ public final class Protocol {if (remoteRequest.isAlive()) {try {remoteRequest.interrupt();} catch (Throwable e) {}Network.log.info("SEARCH failed (solr), remote Peer: " + target.getName() + "/" + target.getPublicAddress() + " does not answer (time-out)");+ target.setFlagSolrAvailable(false || myseed);return -1; // give up, leave remoteRequest abandoned.}// no need to close this here because that sends a commit to remote solr which is not wanted here} catch (final Throwable e) {Network.log.info("SEARCH failed (solr), remote Peer: " + target.getName() + "/" + target.getPublicAddress() + " (" + e.getMessage() + ")");+ target.setFlagSolrAvailable(false || localsearch);return -1;}}if (rsp[0] == null || docList[0] == null) {Network.log.info("SEARCH failed (solr), remote Peer: " + target.getName() + "/" + target.getPublicAddress() + " returned null");+ target.setFlagSolrAvailable(false || localsearch);return -1;}diff --git a/source/net/yacy/peers/RemoteSearch.java b/source/net/yacy/peers/RemoteSearch.javaindex bcf5d39e3..067f83160 100644--- a/source/net/yacy/peers/RemoteSearch.java+++ b/source/net/yacy/peers/RemoteSearch.java@@ -211,10 +211,10 @@ public class RemoteSearch extends Thread {if (!Switchboard.getSwitchboard().getConfigBool(SwitchboardConstants.DEBUG_SEARCH_REMOTE_SOLR_OFF, false)) {final SolrQuery solrQuery = event.query.solrQuery(event.getQuery().contentdom, start == 0, event.excludeintext_image);for (Seed s: robinsonPeers) {- Thread t = solrRemoteSearch(event, solrQuery, start, count, s, targets, blacklist);- event.nodeSearchThreads.add(t);+ Thread t = solrRemoteSearch(event, solrQuery, start, count, s, targets, blacklist);+ event.nodeSearchThreads.add(t);+ }}- }// start search to YaCy DHT peersif (!Switchboard.getSwitchboard().getConfigBool(SwitchboardConstants.DEBUG_SEARCH_REMOTE_DHT_OFF, false)) {@@ -309,7 +309,10 @@ public class RemoteSearch extends Thread {// check own peer statusif (event.peers.mySeed() == null || event.peers.mySeed().getPublicAddress() == null) { return null; }// prepare seed targets and threads- if (targetPeer != null && targetPeer.hash != null && event.preselectedPeerHashes != null) targetPeer.setAlternativeAddress(event.preselectedPeerHashes.get(ASCII.getBytes(targetPeer.hash)));+ if (targetPeer != null && targetPeer.hash != null && event.preselectedPeerHashes != null) {+ if (!targetPeer.getFlagSolrAvailable()) return null; // solr interface not avail.+ targetPeer.setAlternativeAddress(event.preselectedPeerHashes.get(ASCII.getBytes(targetPeer.hash)));+ }Thread solr = new Thread() {@Overridepublic void run() {diff --git a/source/net/yacy/peers/Seed.java b/source/net/yacy/peers/Seed.javaindex 41d08bd8a..68e255ab6 100644--- a/source/net/yacy/peers/Seed.java+++ b/source/net/yacy/peers/Seed.java@@ -171,6 +171,7 @@ public class Seed implements Cloneable, Comparable<Seed>, Comparator<Seed>public static final String SEEDLISTURL = "seedURL";public static final String NEWS = "news"; // news attachmentpublic static final String DCT = "dct"; // disconnect time+ public static final String SOLRAVAILABLE ="SorlAvail"; // field to remember if remotePeer solr interface is avail./** zero-value */private static final String ZERO = "0";@@ -837,6 +838,31 @@ public class Seed implements Cloneable, Comparable<Seed>, Comparator<Seed>return getFlag(FLAG_SSL_AVAILABLE);}+ /**+ * remembers status of remote Solr interface dynamicly+ * should not be used for the local peer+ * @param value+ */+ public final void setFlagSolrAvailable(final boolean value) {+ if (value)+ this.dna.put(Seed.SOLRAVAILABLE, "OK");+ else+ this.dna.put(Seed.SOLRAVAILABLE, "NA");+ }++ /**+ * gets the last set result for remote solr status+ *+ * @return if status unknown it returns true+ */+ public final boolean getFlagSolrAvailable() {+ // field is indented to deal with 3 states+ // null = never checked, "OK" and "NA" for not available+ String solravail = this.dna.get(Seed.SOLRAVAILABLE);+ boolean my = (solravail != null) && ("NA".equals(solravail));+ return !my;+ }+public final void setUnusedFlags() {for ( int i = 4; i < 20; i++ ) {setFlag(i, false);