http://www.mediawiki.org/wiki/Special:Code/MediaWiki/57689
Revision: 57689 Author: rainman Date: 2009-10-14 00:03:34 +0000 (Wed, 14 Oct 2009) Log Message: ----------- Option SearcherPool.excludeHosts to include certain hosts from rotation on a local searcher Modified Paths: -------------- branches/lucene-search-2.1/src/org/wikimedia/lsearch/search/CachedSearchable.java branches/lucene-search-2.1/src/org/wikimedia/lsearch/search/SearcherCache.java Modified: branches/lucene-search-2.1/src/org/wikimedia/lsearch/search/CachedSearchable.java =================================================================== --- branches/lucene-search-2.1/src/org/wikimedia/lsearch/search/CachedSearchable.java 2009-10-13 23:20:41 UTC (rev 57688) +++ branches/lucene-search-2.1/src/org/wikimedia/lsearch/search/CachedSearchable.java 2009-10-14 00:03:34 UTC (rev 57689) @@ -54,6 +54,7 @@ try{ searchable.close(); } catch(Exception e){ + log.error(e.getMessage(), e); SearcherCache.getInstance().reInitializeRemote(iid,host); throw new IOException(e.getMessage()); } @@ -64,6 +65,7 @@ try{ return searchable.doc(i); } catch(Exception e){ + log.error(e.getMessage(), e); SearcherCache.getInstance().reInitializeRemote(iid,host); throw new IOException(e.getMessage()); } @@ -74,6 +76,7 @@ try{ return searchable.doc(i,sel); } catch(Exception e){ + log.error(e.getMessage(), e); SearcherCache.getInstance().reInitializeRemote(iid,host); throw new IOException(e.getMessage()); } @@ -84,6 +87,7 @@ try{ return searchable.docs(i); } catch(Exception e){ + log.error(e.getMessage(), e); SearcherCache.getInstance().reInitializeRemote(iid,host); throw new IOException(e.getMessage()); } @@ -94,6 +98,7 @@ try{ return searchable.docs(i,sel); } catch(Exception e){ + log.error(e.getMessage(), e); SearcherCache.getInstance().reInitializeRemote(iid,host); throw new IOException(e.getMessage()); } @@ -106,6 +111,7 @@ try{ return searchable.docFreq(term); } catch(Exception e){ + log.error(e.getMessage(), e); SearcherCache.getInstance().reInitializeRemote(iid,host); throw new IOException(e.getMessage()); } @@ -116,7 +122,7 @@ try{ return searchable.docFreqs(terms); } catch(Exception e){ - e.printStackTrace(); + log.error(e.getMessage(), e); SearcherCache.getInstance().reInitializeRemote(iid,host); throw new IOException(e.getMessage()); } @@ -127,7 +133,7 @@ try{ return searchable.explain(weight,doc); } catch(Exception e){ - e.printStackTrace(); + log.error(e.getMessage(), e); SearcherCache.getInstance().reInitializeRemote(iid,host); throw new IOException(e.getMessage()); } @@ -142,6 +148,7 @@ log.debug("called maxDoc(), returning cached value: "+maxDocCached); return maxDocCached; } catch(Exception e){ + log.error(e.getMessage(), e); SearcherCache.getInstance().reInitializeRemote(iid,host); throw new IOException(e.getMessage()); } @@ -152,6 +159,7 @@ try{ return searchable.rewrite(query); } catch(Exception e){ + log.error(e.getMessage(), e); SearcherCache.getInstance().reInitializeRemote(iid,host); throw new IOException(e.getMessage()); } @@ -162,6 +170,7 @@ try{ searchable.search(weight,filter,results); } catch(Exception e){ + log.error(e.getMessage(), e); SearcherCache.getInstance().reInitializeRemote(iid,host); throw new IOException(e.getMessage()); } @@ -172,6 +181,7 @@ try{ return searchable.search(weight,filter,n,sort); } catch(Exception e){ + log.error(e.getMessage(), e); SearcherCache.getInstance().reInitializeRemote(iid,host); throw new IOException(e.getMessage()); } @@ -182,6 +192,7 @@ try{ return searchable.search(weight,filter,n); } catch(Exception e){ + log.error(e.getMessage(), e); SearcherCache.getInstance().reInitializeRemote(iid,host); throw new IOException(e.getMessage()); } Modified: branches/lucene-search-2.1/src/org/wikimedia/lsearch/search/SearcherCache.java =================================================================== --- branches/lucene-search-2.1/src/org/wikimedia/lsearch/search/SearcherCache.java 2009-10-13 23:20:41 UTC (rev 57688) +++ branches/lucene-search-2.1/src/org/wikimedia/lsearch/search/SearcherCache.java 2009-10-14 00:03:34 UTC (rev 57689) @@ -223,6 +223,9 @@ /** deployment has been tried at least once for these */ protected static Set<String> initialWarmup = Collections.synchronizedSet(new HashSet<String>()); + /** hosts excluded in lsearch.conf - don't use these unless they are the only ones */ + protected static Set<String> excludedHosts = Collections.synchronizedSet(new HashSet<String>()); + protected boolean initialDeploymentRunning = false; /** Number of threads to use for initial deployment */ @@ -336,6 +339,9 @@ HashSet<String> hosts = new HashSet<String>(); hosts.addAll(pools.keySet()); hosts.removeAll(hostsDeploying.keySet()); + // remove the hosts excluded by configuration + if(!hosts.equals(excludedHosts)) + hosts.removeAll(excludedHosts); // get hosts for which this index is out of rotation Set<String> takenOut = outOfRotation.get(iid.toString()); if(takenOut != null) @@ -624,6 +630,12 @@ specialPoolSizes.put( parts[0].trim(), new Integer(parts[1].trim())); } } + String[] excluded = config.getArray("SearcherPool", "excludedHosts"); + if(excluded != null){ + for(String s : excluded) + excludedHosts.add(s.trim()); + log.info("Excluding hosts: "+excludedHosts); + } initialDeploymentThreads = config.getInt("SearcherPool", "initThreads",1); if(initialize){ initialDeploymentRunning = true; _______________________________________________ MediaWiki-CVS mailing list MediaWiki-CVS@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs