more auto-commit calls when a search interface is opened, but not when a

search is done there to prevent blocking during search-time.
pull/1/head
Michael Peter Christen 12 years ago
parent 3d3d654e88
commit a87811bc38

@ -75,12 +75,13 @@ public class HostBrowser {
prop.put("result", "You are not allowed to use this page. Please ask an administrator for permission.");
return prop;
}
String path = post == null ? "" : post.get("path", "").trim();
if (admin && path.length() == 0 && sb.crawler.getActiveSize() > 0) sb.index.fulltext().commit();
if (post == null || env == null) {
return prop;
}
String path = post.get("path", "").trim();
int p = path.lastIndexOf('/');
if (p < 0 && path.length() > 0) path = path + "/"; else if (p > 7) path = path.substring(0, p + 1); // the search path shall always end with "/"
if (path.length() > 0 && (

@ -62,7 +62,7 @@ public class index {
}
}
if (authorizedAccess) {
if (authorizedAccess && sb.crawler.getActiveSize() > 0) {
sb.index.fulltext().commit(); // call this only as superuser to prevent that this can be misused for DoS
}

@ -34,7 +34,7 @@ import net.yacy.server.serverSwitch;
public class yacyinteractive {
public static serverObjects respond(@SuppressWarnings("unused") final RequestHeader header, serverObjects post, final serverSwitch env) {
public static serverObjects respond(final RequestHeader header, serverObjects post, final serverSwitch env) {
final Switchboard sb = (Switchboard) env;
final serverObjects prop = new serverObjects();
@ -47,6 +47,9 @@ public class yacyinteractive {
prop.put("promoteSearchPageGreeting.homepage", sb.getConfig(SwitchboardConstants.GREETING_HOMEPAGE, ""));
prop.put("promoteSearchPageGreeting.smallImage", sb.getConfig(SwitchboardConstants.GREETING_SMALL_IMAGE, ""));
final boolean admin = sb.verifyAuthentication(header);
if (admin && sb.crawler.getActiveSize() > 0) sb.index.fulltext().commit();
final String query = (post == null) ? "" : post.get("query", "");
final String startRecord = (post == null) ? "0" : post.get("startRecord", "");
final String maximumRecords = (post == null) ? "10" : post.get("maximumRecords", "");

@ -111,14 +111,13 @@ 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();
final String originalquerystring = (post == null) ? "" : post.get("query", post.get("search", "")).trim();
String querystring = originalquerystring.replace('+', ' ').replace('*', ' ').trim();
CacheStrategy snippetFetchStrategy =
(post == null) ? null : CacheStrategy.parse(post.get("verify", "cacheonly"));
CacheStrategy snippetFetchStrategy = (post == null) ? null : CacheStrategy.parse(post.get("verify", "cacheonly"));
if (authenticated && originalquerystring.length() == 0 && sb.crawler.getActiveSize() > 0) sb.index.fulltext().commit();
final servletProperties prop = new servletProperties();
prop.put("topmenu", sb.getConfigBool("publicTopmenu", true) ? 1 : 0);

@ -183,6 +183,14 @@ public final class CrawlSwitchboard {
return new CrawlProfile(m);
}
public int getActiveSize() {
return this.profilesActiveCrawls.size();
}
public int getPassiveSize() {
return this.profilesPassiveCrawls.size();
}
public Set<byte[]> getActive() {
return this.profilesActiveCrawls.keySet();
}

Loading…
Cancel
Save