From c7afa8bc4878beb5bcde977104138f7d57f0e57c Mon Sep 17 00:00:00 2001 From: orbiter Date: Tue, 10 Jul 2012 12:01:20 +0200 Subject: [PATCH] using SwitchboardConstants for solr attributes --- htroot/IndexControlRWIs_p.java | 5 ++- htroot/IndexFederated_p.java | 43 ++++++++++--------- source/net/yacy/search/Switchboard.java | 16 +++---- .../net/yacy/search/SwitchboardConstants.java | 9 +++- source/net/yacy/search/query/QueryParams.java | 3 +- 5 files changed, 43 insertions(+), 33 deletions(-) diff --git a/htroot/IndexControlRWIs_p.java b/htroot/IndexControlRWIs_p.java index 6a5249392..e71f8714e 100644 --- a/htroot/IndexControlRWIs_p.java +++ b/htroot/IndexControlRWIs_p.java @@ -61,6 +61,7 @@ import net.yacy.peers.Seed; import net.yacy.peers.dht.PeerSelection; import net.yacy.repository.Blacklist.BlacklistType; import net.yacy.search.Switchboard; +import net.yacy.search.SwitchboardConstants; import net.yacy.search.index.Segment; import net.yacy.search.query.QueryParams; import net.yacy.search.query.RWIProcess; @@ -92,7 +93,7 @@ public class IndexControlRWIs_p { prop.put("result", ""); prop.put("cleanup", post == null || post.containsKey("maxReferencesLimit") ? 1 : 0); prop.put("cleanup_solr", sb.index.getRemoteSolr() == null - || !sb.getConfigBool("federated.service.solr.indexing.enabled", false) ? 0 : 1); + || !sb.getConfigBool(SwitchboardConstants.FEDERATED_SERVICE_SOLR_INDEXING_ENABLED, false) ? 0 : 1); // switch off all optional forms/lists prop.put("searchresult", 0); @@ -158,7 +159,7 @@ public class IndexControlRWIs_p { segment.clear(); } if ( post.get("deleteSolr", "").equals("on") - && sb.getConfigBool("federated.service.solr.indexing.enabled", false) ) { + && sb.getConfigBool(SwitchboardConstants.FEDERATED_SERVICE_SOLR_INDEXING_ENABLED, false) ) { try { sb.index.getRemoteSolr().clear(); } catch ( final Exception e ) { diff --git a/htroot/IndexFederated_p.java b/htroot/IndexFederated_p.java index 474eca52f..906448d7c 100644 --- a/htroot/IndexFederated_p.java +++ b/htroot/IndexFederated_p.java @@ -37,6 +37,7 @@ import net.yacy.cora.services.federated.solr.SolrConnector; import net.yacy.cora.storage.ConfigurationSet; import net.yacy.kelondro.logging.Log; import net.yacy.search.Switchboard; +import net.yacy.search.SwitchboardConstants; import net.yacy.search.index.SolrField; import de.anomic.server.serverObjects; import de.anomic.server.serverSwitch; @@ -51,14 +52,14 @@ public class IndexFederated_p { if (post != null && post.containsKey("set")) { // yacy String localindex = post.get("yacy.indexing", "off"); - env.setConfig("federated.service.yacy.indexing.engine", localindex); + env.setConfig(SwitchboardConstants.FEDERATED_SERVICE_YACY_INDEXING_ENGINE, localindex); // solr - final boolean solrWasOn = sb.index.getRemoteSolr() != null && env.getConfigBool("federated.service.solr.indexing.enabled", true); + final boolean solrWasOn = sb.index.getRemoteSolr() != null && env.getConfigBool(SwitchboardConstants.FEDERATED_SERVICE_SOLR_INDEXING_ENABLED, true); final boolean solrIsOnAfterwards = post.getBoolean("solr.indexing.solrremote"); - env.setConfig("federated.service.solr.indexing.enabled", solrIsOnAfterwards); - String solrurls = post.get("solr.indexing.url", env.getConfig("federated.service.solr.indexing.url", "http://127.0.0.1:8983/solr")); - int commitWithinMs = post.getInt("solr.indexing.commitWithinMs", env.getConfigInt("federated.service.solr.indexing.commitWithinMs", 180000)); + env.setConfig(SwitchboardConstants.FEDERATED_SERVICE_SOLR_INDEXING_ENABLED, solrIsOnAfterwards); + String solrurls = post.get("solr.indexing.url", env.getConfig(SwitchboardConstants.FEDERATED_SERVICE_SOLR_INDEXING_URL, "http://127.0.0.1:8983/solr")); + int commitWithinMs = post.getInt("solr.indexing.commitWithinMs", env.getConfigInt(SwitchboardConstants.FEDERATED_SERVICE_SOLR_INDEXING_COMMITWITHINMS, 180000)); boolean lazy = post.getBoolean("solr.indexing.lazy"); final BufferedReader r = new BufferedReader(new InputStreamReader(new ByteArrayInputStream(UTF8.getBytes(solrurls)))); final StringBuilder s = new StringBuilder(); @@ -76,12 +77,12 @@ public class IndexFederated_p { s.setLength(s.length() - 1); } solrurls = s.toString().trim(); - env.setConfig("federated.service.solr.indexing.url", solrurls); - env.setConfig("federated.service.solr.indexing.commitWithinMs", commitWithinMs); - env.setConfig("federated.service.solr.indexing.lazy", lazy); - env.setConfig("federated.service.solr.indexing.sharding", post.get("solr.indexing.sharding", env.getConfig("federated.service.solr.indexing.sharding", "modulo-host-md5"))); - final String schemename = post.get("solr.indexing.schemefile", env.getConfig("federated.service.solr.indexing.schemefile", "solr.keys.default.list")); - env.setConfig("federated.service.solr.indexing.schemefile", schemename); + env.setConfig(SwitchboardConstants.FEDERATED_SERVICE_SOLR_INDEXING_URL, solrurls); + env.setConfig(SwitchboardConstants.FEDERATED_SERVICE_SOLR_INDEXING_COMMITWITHINMS, commitWithinMs); + env.setConfig(SwitchboardConstants.FEDERATED_SERVICE_SOLR_INDEXING_LAZY, lazy); + env.setConfig(SwitchboardConstants.FEDERATED_SERVICE_SOLR_INDEXING_SHARDING, post.get("solr.indexing.sharding", env.getConfig(SwitchboardConstants.FEDERATED_SERVICE_SOLR_INDEXING_SHARDING, "modulo-host-md5"))); + final String schemename = post.get("solr.indexing.schemefile", env.getConfig(SwitchboardConstants.FEDERATED_SERVICE_SOLR_INDEXING_SCHEMEFILE, "solr.keys.default.list")); + env.setConfig(SwitchboardConstants.FEDERATED_SERVICE_SOLR_INDEXING_SCHEMEFILE, schemename); if (solrWasOn) { // switch off @@ -91,7 +92,7 @@ public class IndexFederated_p { if (solrIsOnAfterwards) { // switch on - final boolean usesolr = sb.getConfigBool("federated.service.solr.indexing.enabled", false) & solrurls.length() > 0; + final boolean usesolr = sb.getConfigBool(SwitchboardConstants.FEDERATED_SERVICE_SOLR_INDEXING_ENABLED, false) & solrurls.length() > 0; try { if (usesolr) { SolrConnector solr = new ShardSolrConnector(solrurls, ShardSelection.Method.MODULO_HOST_MD5, 10000, true); @@ -154,7 +155,7 @@ public class IndexFederated_p { } // write scheme - final String schemename = sb.getConfig("federated.service.solr.indexing.schemefile", "solr.keys.default.list"); + final String schemename = sb.getConfig(SwitchboardConstants.FEDERATED_SERVICE_SOLR_INDEXING_SCHEMEFILE, "solr.keys.default.list"); int c = 0; boolean dark = false; @@ -183,14 +184,14 @@ public class IndexFederated_p { // fill attribute fields // allowed values are: classic, solr, off // federated.service.yacy.indexing.engine = classic - prop.put("yacy.indexing.engine.classic.checked", env.getConfig("federated.service.yacy.indexing.engine", "classic").equals("classic") ? 1 : 0); - prop.put("yacy.indexing.engine.solr.checked", env.getConfig("federated.service.yacy.indexing.engine", "classic").equals("solr") ? 1 : 0); - prop.put("yacy.indexing.engine.off.checked", env.getConfig("federated.service.yacy.indexing.engine", "classic").equals("off") ? 1 : 0); - prop.put("solr.indexing.solrremote.checked", env.getConfigBool("federated.service.solr.indexing.enabled", false) ? 1 : 0); - prop.put("solr.indexing.url", env.getConfig("federated.service.solr.indexing.url", "http://127.0.0.1:8983/solr").replace(",", "\n")); - prop.put("solr.indexing.commitWithinMs", env.getConfigInt("federated.service.solr.indexing.commitWithinMs", 180000)); - prop.put("solr.indexing.lazy.checked", env.getConfigBool("federated.service.solr.indexing.lazy", true) ? 1 : 0); - prop.put("solr.indexing.sharding", env.getConfig("federated.service.solr.indexing.sharding", "modulo-host-md5")); + prop.put("yacy.indexing.engine.classic.checked", env.getConfig(SwitchboardConstants.FEDERATED_SERVICE_YACY_INDEXING_ENGINE, "classic").equals("classic") ? 1 : 0); + prop.put("yacy.indexing.engine.solr.checked", env.getConfig(SwitchboardConstants.FEDERATED_SERVICE_YACY_INDEXING_ENGINE, "classic").equals("solr") ? 1 : 0); + prop.put("yacy.indexing.engine.off.checked", env.getConfig(SwitchboardConstants.FEDERATED_SERVICE_YACY_INDEXING_ENGINE, "classic").equals("off") ? 1 : 0); + prop.put("solr.indexing.solrremote.checked", env.getConfigBool(SwitchboardConstants.FEDERATED_SERVICE_SOLR_INDEXING_ENABLED, false) ? 1 : 0); + prop.put("solr.indexing.url", env.getConfig(SwitchboardConstants.FEDERATED_SERVICE_SOLR_INDEXING_URL, "http://127.0.0.1:8983/solr").replace(",", "\n")); + prop.put("solr.indexing.commitWithinMs", env.getConfigInt(SwitchboardConstants.FEDERATED_SERVICE_SOLR_INDEXING_COMMITWITHINMS, 180000)); + prop.put("solr.indexing.lazy.checked", env.getConfigBool(SwitchboardConstants.FEDERATED_SERVICE_SOLR_INDEXING_LAZY, true) ? 1 : 0); + prop.put("solr.indexing.sharding", env.getConfig(SwitchboardConstants.FEDERATED_SERVICE_SOLR_INDEXING_SHARDING, "modulo-host-md5")); prop.put("solr.indexing.schemefile", schemename); // return rewrite properties diff --git a/source/net/yacy/search/Switchboard.java b/source/net/yacy/search/Switchboard.java index f5df9f977..46e0472b0 100644 --- a/source/net/yacy/search/Switchboard.java +++ b/source/net/yacy/search/Switchboard.java @@ -394,12 +394,12 @@ public final class Switchboard extends serverSwitch // prepare a solr index profile switch list final File solrBackupProfile = new File("defaults/solr.keys.list"); final String schemename = - getConfig("federated.service.solr.indexing.schemefile", "solr.keys.default.list"); + getConfig(SwitchboardConstants.FEDERATED_SERVICE_SOLR_INDEXING_SCHEMEFILE, "solr.keys.default.list"); final File solrWorkProfile = new File(getDataPath(), "DATA/SETTINGS/" + schemename); if ( !solrWorkProfile.exists() ) { Files.copy(solrBackupProfile, solrWorkProfile); } - final boolean solrlazy = getConfigBool("federated.service.solr.indexing.lazy", true); + final boolean solrlazy = getConfigBool(SwitchboardConstants.FEDERATED_SERVICE_SOLR_INDEXING_LAZY, true); final SolrConfiguration backupScheme = new SolrConfiguration(solrBackupProfile, solrlazy); this.solrScheme = new SolrConfiguration(solrWorkProfile, solrlazy); @@ -408,9 +408,9 @@ public final class Switchboard extends serverSwitch this.solrScheme.fill(backupScheme, true); // set up the solr interface - final String solrurls = getConfig("federated.service.solr.indexing.url", "http://127.0.0.1:8983/solr"); - final boolean usesolr = getConfigBool("federated.service.solr.indexing.enabled", false) & solrurls.length() > 0; - int commitWithinMs = getConfigInt("federated.service.solr.indexing.commitWithinMs", 180000); + final String solrurls = getConfig(SwitchboardConstants.FEDERATED_SERVICE_SOLR_INDEXING_URL, "http://127.0.0.1:8983/solr"); + final boolean usesolr = getConfigBool(SwitchboardConstants.FEDERATED_SERVICE_SOLR_INDEXING_ENABLED, false) & solrurls.length() > 0; + int commitWithinMs = getConfigInt(SwitchboardConstants.FEDERATED_SERVICE_SOLR_INDEXING_COMMITWITHINMS, 180000); if (usesolr && solrurls != null && solrurls.length() > 0) { try { @@ -2413,8 +2413,8 @@ public final class Switchboard extends serverSwitch return new indexingQueueEntry(in.queueEntry, in.documents, null); } - boolean localSolr = this.index.getLocalSolr() != null && getConfig("federated.service.yacy.indexing.engine", "classic").equals("solr"); - boolean remoteSolr = this.index.getRemoteSolr() != null && getConfigBool("federated.service.solr.indexing.enabled", false); + boolean localSolr = this.index.getLocalSolr() != null && getConfig(SwitchboardConstants.FEDERATED_SERVICE_YACY_INDEXING_ENGINE, "classic").equals("solr"); + boolean remoteSolr = this.index.getRemoteSolr() != null && getConfigBool(SwitchboardConstants.FEDERATED_SERVICE_SOLR_INDEXING_ENABLED, false); if (localSolr || remoteSolr) { // send the documents to solr for ( final Document doc : in.documents ) { @@ -2452,7 +2452,7 @@ public final class Switchboard extends serverSwitch } // check if we should accept the document for our index - if (!getConfig("federated.service.yacy.indexing.engine", "classic").equals("classic")) { + if (!getConfig(SwitchboardConstants.FEDERATED_SERVICE_YACY_INDEXING_ENGINE, "classic").equals("classic")) { if ( this.log.isInfo() ) { this.log.logInfo("Not Condensed Resource '" + in.queueEntry.url().toNormalform(false, true) diff --git a/source/net/yacy/search/SwitchboardConstants.java b/source/net/yacy/search/SwitchboardConstants.java index e9fd74dd2..24c955997 100644 --- a/source/net/yacy/search/SwitchboardConstants.java +++ b/source/net/yacy/search/SwitchboardConstants.java @@ -287,10 +287,17 @@ public final class SwitchboardConstants { public static final String REMOTESEARCH_MAXCOUNT_DEFAULT = "network.unit.remotesearch.maxcount"; public static final String REMOTESEARCH_MAXTIME_DEFAULT = "network.unit.remotesearch.maxtime"; - public static final String REMOTESEARCH_MAXCOUNT_USER = "remotesearch.maxcount"; public static final String REMOTESEARCH_MAXTIME_USER = "remotesearch.maxtime"; + public static final String FEDERATED_SERVICE_SOLR_INDEXING_ENABLED = "federated.service.solr.indexing.enabled"; + public static final String FEDERATED_SERVICE_SOLR_INDEXING_URL = "federated.service.solr.indexing.url"; + public static final String FEDERATED_SERVICE_SOLR_INDEXING_COMMITWITHINMS = "federated.service.solr.indexing.commitWithinMs"; + public static final String FEDERATED_SERVICE_SOLR_INDEXING_SHARDING = "federated.service.solr.indexing.sharding"; + public static final String FEDERATED_SERVICE_SOLR_INDEXING_SCHEMEFILE = "federated.service.solr.indexing.schemefile"; + public static final String FEDERATED_SERVICE_SOLR_INDEXING_LAZY = "federated.service.solr.indexing.lazy"; + public static final String FEDERATED_SERVICE_YACY_INDEXING_ENGINE = "federated.service.yacy.indexing.engine"; + /** *

public static final String CRAWLER_THREADS_ACTIVE_MAX = "crawler.MaxActiveThreads"

*

Name of the setting how many active crawler-threads may maximal be running on the same time

diff --git a/source/net/yacy/search/query/QueryParams.java b/source/net/yacy/search/query/QueryParams.java index cad564c07..0663bc45c 100644 --- a/source/net/yacy/search/query/QueryParams.java +++ b/source/net/yacy/search/query/QueryParams.java @@ -386,7 +386,8 @@ public final class QueryParams { private static String seps = "'.,/&_"; static {seps += '"';} - public static Collection[] cleanQuery(String querystring) { + @SuppressWarnings("unchecked") + public static Collection[] cleanQuery(String querystring) { // returns three sets: a query set, a exclude set and a full query set final Collection query_include_words = new ArrayList(); final Collection query_exclude_words = new ArrayList();