[Bedework-commit] indexer r99 -
releases/bedework-3.8/src/org/bedework/indexer/crawler
svnadmin at bedework.org
svnadmin at bedework.org
Fri Apr 27 16:36:23 EDT 2012
Author: douglm
Date: 2012-04-27 16:36:22 -0400 (Fri, 27 Apr 2012)
New Revision: 99
Modified:
releases/bedework-3.8/src/org/bedework/indexer/crawler/Crawl.java
releases/bedework-3.8/src/org/bedework/indexer/crawler/ProcessorBase.java
Log:
Further solr related updates
Modified: releases/bedework-3.8/src/org/bedework/indexer/crawler/Crawl.java
===================================================================
--- releases/bedework-3.8/src/org/bedework/indexer/crawler/Crawl.java 2012-04-27 20:36:20 UTC (rev 98)
+++ releases/bedework-3.8/src/org/bedework/indexer/crawler/Crawl.java 2012-04-27 20:36:22 UTC (rev 99)
@@ -6,9 +6,9 @@
Version 2.0 (the "License"); you may not use this file
except in compliance with the License. You may obtain a
copy of the License at:
-
+
http://www.apache.org/licenses/LICENSE-2.0
-
+
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -18,9 +18,12 @@
*/
package org.bedework.indexer.crawler;
+import org.bedework.calfacade.BwSystem;
import org.bedework.calfacade.exc.CalFacadeException;
import org.bedework.calsvc.indexing.BwIndexLuceneDefs;
import org.bedework.calsvc.indexing.BwIndexer;
+import org.bedework.calsvc.indexing.BwIndexerFactory;
+import org.bedework.calsvci.CalSvcI;
import org.bedework.indexer.CalSys;
import edu.rpi.sss.util.DateTimeUtil;
@@ -55,7 +58,7 @@
public class Crawl extends CalSys {
private String indexBuildLocation;
- private String indexBuildLocationPrefix;
+ //private String indexBuildLocationPrefix;
protected long batchDelay;
protected long entityDelay;
@@ -107,6 +110,12 @@
public List<String> infoLines = new ArrayList<String>();
}
+ static class Indexes {
+ String publicIndex;
+
+ String userIndex;
+ }
+
/**
* @return CrawlResult
* @throws CalFacadeException
@@ -114,20 +123,8 @@
public CrawlResult crawl() throws CalFacadeException {
CrawlResult cr = new CrawlResult();
- /* First set up a new directory - see if new exists - if so delete */
- String newPath = getPath(indexBuildLocation,
- BwIndexLuceneDefs.newIndexname);
+ Indexes idxs = newIndexes(cr);
- boolean newExisted = exists(newPath);
-
- outInfo(cr, "About to build directories at " + newPath);
-
- if (newExisted) {
- remove(newPath);
- }
-
- create(newPath);
-
/* Now we can reindex into the new directory */
UserProcessor uproc = new UserProcessor("User",
@@ -135,7 +132,7 @@
2000, // batchDelay,
100, // entityDelay,
skipPaths,
- newPath,
+ idxs.userIndex,
userThreads,
maxUserThreads);
uproc.start("/" + getUserCalendarRoot());
@@ -145,7 +142,7 @@
2000, // batchDelay,
100, // entityDelay,
skipPaths,
- newPath,
+ idxs.publicIndex,
publicThreads,
maxPublicThreads);
pproc.start("/" + getPublicCalendarRoot());
@@ -156,6 +153,57 @@
cr.infoLines.addAll(uproc.getStats().statsList());
cr.infoLines.addAll(pproc.getStats().statsList());
+ endIndexing(cr, idxs);
+
+ return cr;
+ }
+
+ private Indexes newIndexes(final CrawlResult cr) throws CalFacadeException {
+ Indexes idxs = new Indexes();
+
+ /* First set up a new directory - see if new exists - if so delete */
+ idxs.userIndex = getPath(indexBuildLocation,
+ BwIndexLuceneDefs.newIndexname);
+
+ boolean newExisted = exists(idxs.userIndex);
+
+ outInfo(cr, "About to build directories at " + idxs.userIndex);
+
+ if (newExisted) {
+ remove(idxs.userIndex);
+ }
+
+ create(idxs.userIndex);
+
+ CalSvcI svci = getAdminSvci();
+
+ BwSystem sys = svci.getSysparsHandler().get();
+
+ if (!sys.getUseSolr()) {
+ idxs.publicIndex = idxs.userIndex;
+ return idxs;
+ }
+
+ // Switch public indexes.
+
+ String defName = sys.getSolrDefaultCore();
+
+ idxs.publicIndex = defName + "-" + DateTimeUtil.isoDateTime();
+
+ BwIndexer idx = BwIndexerFactory.getIndexer(true, adminAccount, true, sys,
+ idxs.publicIndex,
+ sys.getSolrCoreAdmin());
+
+ idx.newIndex(idxs.publicIndex);
+
+ return idxs;
+ }
+
+ private void endIndexing(final CrawlResult cr,
+ final Indexes idxs) throws CalFacadeException {
+ /* If it's lucene both public and user are the same.
+ */
+
/* Rename directories */
String oldPath = getPath(indexBuildLocation,
BwIndexLuceneDefs.oldIndexname);
@@ -179,15 +227,15 @@
outErr(cr, "Unable to rename current index at " + currentPath +
" to " + oldPath);
- return cr;
+ return;
}
}
- outInfo(cr, "About to rename directories from " + newPath +
+ outInfo(cr, "About to rename directories from " + idxs.userIndex +
" to " + currentPath);
- if (!rename(newPath, currentPath)) {
- outErr(cr, "Unable to rename new index at " + newPath +
+ if (!rename(idxs.userIndex, currentPath)) {
+ outErr(cr, "Unable to rename new index at " + idxs.userIndex +
" to " + currentPath +
" attempting to rename old back to current");
if (!rename(oldPath, currentPath)) {
@@ -196,11 +244,25 @@
" from " + oldPath);
}
- return cr;
+ return;
}
+ CalSvcI svci = getAdminSvci();
+
+ BwSystem sys = svci.getSysparsHandler().get();
+
+ if (!sys.getUseSolr()) {
+ cr.ok = true;
+ return;
+ }
+
+ BwIndexer idx = BwIndexerFactory.getIndexer(true, adminAccount, true, sys,
+ idxs.publicIndex,
+ sys.getSolrCoreAdmin());
+
+ idx.swapIndex(idxs.publicIndex, sys.getSolrDefaultCore());
+
cr.ok = true;
- return cr;
}
private void outInfo(final CrawlResult cr, final String msg) {
Modified: releases/bedework-3.8/src/org/bedework/indexer/crawler/ProcessorBase.java
===================================================================
--- releases/bedework-3.8/src/org/bedework/indexer/crawler/ProcessorBase.java 2012-04-27 20:36:20 UTC (rev 98)
+++ releases/bedework-3.8/src/org/bedework/indexer/crawler/ProcessorBase.java 2012-04-27 20:36:22 UTC (rev 99)
@@ -6,9 +6,9 @@
Version 2.0 (the "License"); you may not use this file
except in compliance with the License. You may obtain a
copy of the License at:
-
+
http://www.apache.org/licenses/LICENSE-2.0
-
+
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -27,8 +27,8 @@
import org.bedework.indexer.CalSys;
import org.bedework.indexer.EntityIndexerThread;
import org.bedework.indexer.IndexStats;
+import org.bedework.indexer.IndexStats.StatType;
import org.bedework.indexer.ThreadPool;
-import org.bedework.indexer.IndexStats.StatType;
import java.util.ArrayList;
import java.util.Collection;
@@ -118,6 +118,7 @@
return tpool;
}
+ @Override
public String getCurrentPath() throws CalFacadeException {
return currentPath;
}
@@ -216,7 +217,9 @@
}
return BwIndexerFactory.getIndexer(publick, principal,
- true, getSyspars(), indexRootPath);
+ true, getSyspars(),
+ indexRootPath,
+ null);
}
@Override
More information about the Bedework-commit
mailing list