knguyen 2004/08/27 18:05:06 CEST
Modified files: (Branch: JAHIA-4-0-BRANCH)
src/java/org/jahia/services/search JahiaSearchBaseService.java
Log:
- Search index in load balancing can be shared for multiple Searcher ( read ) and
one single Indexer ( write )
Revision Changes Path
1.42.2.8 +61 -17
jahia/src/java/org/jahia/services/search/JahiaSearchBaseService.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/jahia/src/java/org/jahia/services/search/JahiaSearchBaseService.java.diff?r1=1.42.2.7&r2=1.42.2.8&f=h
Index: JahiaSearchBaseService.java
===================================================================
RCS file:
/home/cvs/repository/jahia/src/java/org/jahia/services/search/Attic/JahiaSearchBaseService.java,v
retrieving revision 1.42.2.7
retrieving revision 1.42.2.8
diff -u -r1.42.2.7 -r1.42.2.8
--- JahiaSearchBaseService.java 26 Aug 2004 16:29:41 -0000 1.42.2.7
+++ JahiaSearchBaseService.java 27 Aug 2004 16:05:06 -0000 1.42.2.8
@@ -93,6 +93,9 @@
private Thread backgroundIndexingThread;
private boolean indexingThreadActivated = true;
+ private boolean localIndexing = true;
+
+
/**
* Constructor
* Client should always call getInstance() method
@@ -137,9 +140,31 @@
SEARCH_INDEX_ORDERS_CACHE);
indexOrdersCache.registerListener(this);
- searchIndexesDiskPath = jSettings.getJahiaVarDiskPath()
- + File.separator
- + searchIndexesDir;
+ String val = org.jahia.bin.Jahia.getStaticServletConfig()
+ .getInitParameter("org.apache.lucene.searchIndexRootDir");
+ if ( val != null ){
+ if ( val.startsWith("/") ){
+ searchIndexesDiskPath = org.jahia.bin.Jahia.
+ getStaticServletConfig()
+ .getServletContext().getRealPath(val);
+ } else {
+ searchIndexesDiskPath = val;
+ }
+ } else {
+ // the default
+ searchIndexesDiskPath = jSettings.getJahiaVarDiskPath()
+ + File.separator
+ + searchIndexesDir;
+ }
+ logger.debug("Search index Root Dir: " + searchIndexesDiskPath);
+
+ val = org.jahia.bin.Jahia.getStaticServletConfig()
+ .getInitParameter("org.apache.lucene.localIndexing");
+ if ( val != null && "0".equals(val)){
+ this.localIndexing = false;
+ this.indexingThreadActivated = false;
+ logger.debug("Local indexing disabled !!!!");
+ }
File f = new File(searchIndexesDiskPath);
// Create lucene search index repository if not exists.
@@ -150,18 +175,17 @@
// now let's remove any stale lock files if there were some.
removeStaleLockFiles(searchIndexesDiskPath);
- backgroundIndexingThread = new Thread(theObject,
- "Background content indexing");
- backgroundIndexingThread.start(); // start background thread
+ if ( this.indexingThreadActivated ){
+ backgroundIndexingThread = new Thread(theObject,
+ "Background content indexing");
+ backgroundIndexingThread.start(); // start background thread
+ }
logger.debug("Initialized");
-
}
}
private void configureSystemProperties(){
- //int test = org.apache.lucene.search.BooleanQuery.getMaxClauseCount();
- int test = 0;
Enumeration enum = org.jahia.bin.Jahia.getStaticServletConfig()
.getInitParameterNames();
String name = "";
@@ -176,8 +200,6 @@
}
}
}
- test = org.apache.lucene.search.BooleanQuery.getMaxClauseCount();
- test = 2;
}
public synchronized void shutdown() throws JahiaException {
@@ -213,7 +235,9 @@
return;
indObj.setBeAdded (false);
if (indObj.beforeRemovingFromSearchEngine ()) {
- indexOrders.add(indObj);
+ if ( this.localIndexing ){
+ indexOrders.add(indObj);
+ }
indexOrdersCache.put(indObj.getKey(),indObj);
}
notifyAll ();
@@ -414,7 +438,9 @@
Object[] value = (Object[]) values.get (languageCode);
addedField.setValues (value);
if (addedField.beforeAddingToSearchEngine ()) {
- indexOrders.add(addedField);
+ if ( this.localIndexing ){
+ indexOrders.add(addedField);
+ }
indexOrdersCache.put(addedField.getKey(),addedField);
}
}
@@ -437,7 +463,9 @@
RemovedField rField = new RemovedField (aField);
rField.setBeAdded (false);
if (rField.beforeRemovingFromSearchEngine ()) {
- indexOrders.add (rField);
+ if ( this.localIndexing ){
+ indexOrders.add(rField);
+ }
indexOrdersCache.put (rField.getKey(),rField);
}
@@ -458,7 +486,9 @@
RemovedField rField = new RemovedField (contentField);
rField.setBeAdded (false);
if (rField.beforeRemovingFromSearchEngine ()) {
- indexOrders.add (rField);
+ if ( this.localIndexing ){
+ indexOrders.add(rField);
+ }
indexOrdersCache.put (rField.getKey(),rField);
}
@@ -550,6 +580,11 @@
// start the chrono...
long startTime = JahiaChrono.getInstance ().start ();
+ if ( !this.localIndexing ){
+ logger.info("Ignore re-indexing the site because local indexing is
disabled !");
+ return false;
+ }
+
RAMDirectory ramDir = new RAMDirectory ();
IndexWriter writer = null;
IndexReader reader = null;
@@ -664,6 +699,11 @@
*/
public boolean optimizeIndex (int siteID) {
+ if ( !this.localIndexing ){
+ logger.info("Ignore optimizing search index because local indexing is
disabled !");
+ return false;
+ }
+
IndexWriter writer = null;
boolean result = false;
@@ -1149,14 +1189,18 @@
* @param entryKey Object
*/
- public void onCachePut (String cacheName, Object entryKey, Object entryValue){
+ public synchronized void onCachePut (String cacheName, Object entryKey, Object
entryValue){
+ if ( !this.localIndexing ){
+ return;
+ }
logger.debug("Search Cache listener :" + cacheName + entryKey.toString());
if ( this.SEARCH_INDEX_ORDERS_CACHE.equals(cacheName)
&& entryKey != null && entryValue != null ){
CacheEntry cacheEntry = (CacheEntry)entryValue;
this.indexOrders.add(cacheEntry.getObject());
logger.debug("Search Cache listener : added value in indexOrders");
- indexQueue();
+ this.notifyAll();
+ //indexQueue();
}
}