fixes to internal RWI usage if RWI is switched off (NPE etc)

pull/1/head
Michael Peter Christen 12 years ago
parent 3834829b37
commit e8f7b85b98

@ -1122,11 +1122,12 @@ public final class Protocol
// evaluate result
List<URIMetadataNode> container = new ArrayList<URIMetadataNode>();
if (docList.size() == 0) {
if (docList == null || docList.size() == 0) {
Network.log.logInfo("SEARCH (solr), returned 0 out of " + docList.getNumFound() + " documents from " + (target == null ? "shard" : ("peer " + target.hash + ":" + target.getName())) + " query = " + solrQuery.toString()) ;
} else {// create containers
Network.log.logInfo("SEARCH (solr), returned " + docList.size() + " out of " + docList.getNumFound() + " documents from " + (target == null ? "shard" : ("peer " + target.hash + ":" + target.getName()))) ;
return 0;
}
Network.log.logInfo("SEARCH (solr), returned " + docList.size() + " out of " + docList.getNumFound() + " documents from " + (target == null ? "shard" : ("peer " + target.hash + ":" + target.getName())));
int term = count;
for (final SolrDocument doc: docList) {
if ( term-- <= 0 ) {
@ -1192,7 +1193,6 @@ public final class Protocol
event.addExpectedRemoteReferences(-count);
Network.log.logInfo("remote search (solr): peer " + target.getName() + " sent " + container.get(0).size() + "/" + docList.size() + " references");
}
}
return docList.size();
}

@ -197,6 +197,8 @@ public final class RankingProcess extends Thread {
@Override
public void run() {
if (query.getSegment().termIndex() == null) return; // nothing to do; this index is not used
// do a search
oneFeederStarted();

@ -224,7 +224,7 @@ public final class SearchEvent {
// start a local RWI search concurrently
if (this.remote || this.peers.mySeed().getBirthdate() < noRobinsonLocalRWISearch) {
// we start the local search only if this peer is doing a remote search or when it is doing a local search and the peer is old
this.rankingProcess.start();
if (query.getSegment().connectedRWI()) this.rankingProcess.start();
}
if (this.remote) {
@ -270,7 +270,7 @@ public final class SearchEvent {
if ( generateAbstracts ) {
// we need the results now
try {
this.rankingProcess.join();
if (query.getSegment().connectedRWI()) this.rankingProcess.join();
} catch ( final Throwable e ) {
}
// compute index abstracts
@ -278,7 +278,7 @@ public final class SearchEvent {
int maxcount = -1;
long mindhtdistance = Long.MAX_VALUE, l;
byte[] wordhash;
assert this.rankingProcess.searchContainerMap() != null;
assert !query.getSegment().connectedRWI() || this.rankingProcess.searchContainerMap() != null;
if (this.rankingProcess.searchContainerMap() != null) {
for (final Map.Entry<byte[], ReferenceContainer<WordReference>> entry : this.rankingProcess.searchContainerMap().entrySet()) {
wordhash = entry.getKey();
@ -303,7 +303,7 @@ public final class SearchEvent {
// give process time to accumulate a certain amount of data
// before a reading process wants to get results from it
try {
this.rankingProcess.join(100);
if (query.getSegment().connectedRWI()) this.rankingProcess.join(100);
} catch ( final Throwable e ) {
}
// this will reduce the maximum waiting time until results are available to 100 milliseconds

Loading…
Cancel
Save