Merge branch 'master' of ssh://git@gitorious.org/yacy/rc1.git

pull/1/head
Michael Peter Christen 12 years ago
commit da851c6071

@ -41,6 +41,14 @@ import org.apache.solr.common.SolrInputDocument;
public class AbstractSolrConnector implements SolrConnector { public class AbstractSolrConnector implements SolrConnector {
private final static SolrQuery catchallQuery = new SolrQuery();
static {
catchallQuery.setQuery("*:*");
catchallQuery.setFields(YaCySchema.id.name());
catchallQuery.setRows(1);
catchallQuery.setStart(0);
}
protected SolrServer server; protected SolrServer server;
protected int commitWithinMs; // max time (in ms) before a commit will happen protected int commitWithinMs; // max time (in ms) before a commit will happen
@ -90,8 +98,11 @@ public class AbstractSolrConnector implements SolrConnector {
@Override @Override
public long getSize() { public long getSize() {
try { try {
final SolrDocumentList list = query("*:*", 0, 1); final QueryResponse rsp = this.server.query(catchallQuery);
return list.getNumFound(); if (rsp == null) return 0;
final SolrDocumentList docs = rsp.getResults();
if (docs == null) return 0;
return docs.getNumFound();
} catch (final Throwable e) { } catch (final Throwable e) {
Log.logException(e); Log.logException(e);
return 0; return 0;

@ -173,6 +173,7 @@ public class RetrySolrConnector implements SolrConnector {
while (System.currentTimeMillis() < t) try { while (System.currentTimeMillis() < t) try {
return this.solrConnector.getSize(); return this.solrConnector.getSize();
} catch (final Throwable e) { } catch (final Throwable e) {
try {Thread.sleep(10);} catch (final InterruptedException e1) {}
continue; continue;
} }
return 0; return 0;

@ -2930,8 +2930,9 @@ public final class Switchboard extends serverSwitch
return "no DHT distribution: not enabled (per setting)"; return "no DHT distribution: not enabled (per setting)";
} }
final Segment indexSegment = this.index; final Segment indexSegment = this.index;
if ( indexSegment.urlMetadata().size() < 10 ) { int size = indexSegment.urlMetadata().size();
return "no DHT distribution: loadedURL.size() = " + indexSegment.urlMetadata().size(); if ( size < 10 ) {
return "no DHT distribution: loadedURL.size() = " + size;
} }
if ( indexSegment.termIndex().sizesMax() < 100 ) { if ( indexSegment.termIndex().sizesMax() < 100 ) {
return "no DHT distribution: not enough words - wordIndex.size() = " return "no DHT distribution: not enough words - wordIndex.size() = "

@ -115,6 +115,12 @@ public class EmbeddedSolrConnector extends AbstractSolrConnector implements Solr
return this.defaultCore.getSolrConfig(); return this.defaultCore.getSolrConfig();
} }
@Override
public long getSize() {
// do some magic here to prevent the super.getSize() call which is a bad hack
return super.getSize();
}
@Override @Override
public synchronized void close() { public synchronized void close() {
super.close(); super.close();

Loading…
Cancel
Save