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

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

@ -41,9 +41,17 @@ import org.apache.solr.common.SolrInputDocument;
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 int commitWithinMs; // max time (in ms) before a commit will happen
protected AbstractSolrConnector() {
this.server = null;
this.commitWithinMs = 180000;
@ -90,8 +98,11 @@ public class AbstractSolrConnector implements SolrConnector {
@Override
public long getSize() {
try {
final SolrDocumentList list = query("*:*", 0, 1);
return list.getNumFound();
final QueryResponse rsp = this.server.query(catchallQuery);
if (rsp == null) return 0;
final SolrDocumentList docs = rsp.getResults();
if (docs == null) return 0;
return docs.getNumFound();
} catch (final Throwable e) {
Log.logException(e);
return 0;

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

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

@ -114,7 +114,13 @@ public class EmbeddedSolrConnector extends AbstractSolrConnector implements Solr
public SolrConfig getConfig() {
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
public synchronized void close() {
super.close();

Loading…
Cancel
Save