force a commit in advance of a search for the administrator to get most

recent results even if commit time is high and an indexing is ongoing.
pull/1/head
Michael Peter Christen 12 years ago
parent 3b48c78190
commit 8e1248ffe3

@ -62,6 +62,10 @@ public class index {
}
}
if (authorizedAccess) {
sb.index.fulltext().commit(); // call this only as superuser to prevent that this can be misused for DoS
}
boolean global = (post == null) ? true : post.get("resource", "global").equals("global");
final boolean focus = (post == null) ? true : post.get("focus", "1").equals("1");

@ -111,7 +111,8 @@ public class yacysearch {
"network.unit.description",
"") : env.getConfig(SwitchboardConstants.GREETING, "");
final String client = header.get(HeaderFramework.CONNECTION_PROP_CLIENTIP); // the search client who initiated the search
if (authenticated) sb.index.fulltext().commit();
// get query
final String originalquerystring =
(post == null) ? "" : post.get("query", post.get("search", "")).trim();

@ -33,7 +33,6 @@ import net.yacy.cora.storage.ARC;
import net.yacy.cora.storage.ConcurrentARC;
import net.yacy.kelondro.util.MemoryControl;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.client.solrj.util.ClientUtils;
import org.apache.solr.common.SolrDocument;

@ -69,6 +69,8 @@ import org.apache.solr.common.SolrInputDocument;
public final class Fulltext implements Iterable<byte[]> {
private static final long forcedCommitTimeout = 3000; // wait this time until a next forced commit is executed
// class objects
private final File location;
private Index urlIndexFile;
@ -77,6 +79,7 @@ public final class Fulltext implements Iterable<byte[]> {
private ArrayList<HostStat> statsDump;
private final MirrorSolrConnector solr;
private final SolrConfiguration solrScheme;
private long forcedCommitTime;
protected Fulltext(final File path, final SolrConfiguration solrScheme) {
this.location = path;
@ -86,6 +89,7 @@ public final class Fulltext implements Iterable<byte[]> {
this.statsDump = null;
this.solr = new MirrorSolrConnector(1000, 1000, 100);
this.solrScheme = solrScheme;
this.forcedCommitTime = 0;
}
protected void connectUrlDb(final String tablename, final boolean useTailCache, final boolean exceed134217727) {
@ -191,7 +195,10 @@ public final class Fulltext implements Iterable<byte[]> {
}
public void commit() {
if (this.forcedCommitTime + forcedCommitTimeout < System.currentTimeMillis()) return;
this.forcedCommitTime = Long.MAX_VALUE - forcedCommitTimeout; // set the time high to prevent that other processes get to this point meanwhile
this.solr.commit();
this.forcedCommitTime = System.currentTimeMillis(); // set the exact time
}
/**

Loading…
Cancel
Save