You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by mr...@apache.org on 2008/04/01 14:01:16 UTC
svn commit: r643369 - in
/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene:
MultiIndex.java SearchIndex.java
Author: mreutegg
Date: Tue Apr 1 05:00:13 2008
New Revision: 643369
URL: http://svn.apache.org/viewvc?rev=643369&view=rev
Log:
JCR-1326: Log path of missing node when re-indexing fails
Modified:
jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/MultiIndex.java
jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SearchIndex.java
Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/MultiIndex.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/MultiIndex.java?rev=643369&r1=643368&r2=643369&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/MultiIndex.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/MultiIndex.java Tue Apr 1 05:00:13 2008
@@ -26,6 +26,11 @@
import org.apache.jackrabbit.uuid.Constants;
import org.apache.jackrabbit.uuid.UUID;
import org.apache.jackrabbit.util.Timer;
+import org.apache.jackrabbit.spi.Path;
+import org.apache.jackrabbit.spi.PathFactory;
+import org.apache.jackrabbit.spi.commons.name.PathFactoryImpl;
+import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
+import org.apache.jackrabbit.spi.commons.conversion.DefaultNamePathResolver;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.lucene.document.Document;
@@ -80,6 +85,11 @@
private static final Logger log = LoggerFactory.getLogger(MultiIndex.class);
/**
+ * A path factory.
+ */
+ private static final PathFactory PATH_FACTORY = PathFactoryImpl.getInstance();
+
+ /**
* Default name of the redo log file
*/
private static final String REDO_LOG = "redo.log";
@@ -368,7 +378,7 @@
* workspace.
* @throws IllegalStateException if this index is not empty.
*/
- void createInitialIndex(ItemStateManager stateMgr, NodeId rootId)
+ void createInitialIndex(ItemStateManager stateMgr, NodeId rootId, Path rootPath)
throws IOException {
// only do an initial index if there are no indexes at all
if (indexNames.size() == 0) {
@@ -377,7 +387,7 @@
// traverse and index workspace
executeAndLog(new Start(Action.INTERNAL_TRANSACTION));
NodeState rootState = (NodeState) stateMgr.getItemState(rootId);
- createIndex(rootState, stateMgr);
+ createIndex(rootState, rootPath, stateMgr);
executeAndLog(new Commit(getTransactionId()));
scheduleFlushTask();
} catch (Exception e) {
@@ -1011,7 +1021,7 @@
* @throws ItemStateException if an node state cannot be found.
* @throws RepositoryException if any other error occurs
*/
- private void createIndex(NodeState node, ItemStateManager stateMgr)
+ private void createIndex(NodeState node, Path path, ItemStateManager stateMgr)
throws IOException, ItemStateException, RepositoryException {
NodeId id = node.getNodeId();
if (excludedIDs.contains(id)) {
@@ -1022,8 +1032,26 @@
List children = node.getChildNodeEntries();
for (Iterator it = children.iterator(); it.hasNext();) {
NodeState.ChildNodeEntry child = (NodeState.ChildNodeEntry) it.next();
- NodeState childState = (NodeState) stateMgr.getItemState(child.getId());
- createIndex(childState, stateMgr);
+ Path childPath = PATH_FACTORY.create(path, child.getName(),
+ child.getIndex(), false);
+ NodeState childState;
+ try {
+ childState = (NodeState) stateMgr.getItemState(child.getId());
+ } catch (NoSuchItemStateException e) {
+ NamePathResolver resolver = new DefaultNamePathResolver(
+ handler.getContext().getNamespaceRegistry());
+ log.error("Node {} ({}) has missing child '{}' ({})",
+ new Object[]{
+ resolver.getJCRPath(path),
+ node.getNodeId().getUUID().toString(),
+ resolver.getJCRName(child.getName()),
+ child.getId().getUUID().toString()
+ });
+ throw e;
+ }
+ if (childState != null) {
+ createIndex(childState, childPath, stateMgr);
+ }
}
}
Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SearchIndex.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SearchIndex.java?rev=643369&r1=643368&r2=643369&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SearchIndex.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SearchIndex.java Tue Apr 1 05:00:13 2008
@@ -35,7 +35,10 @@
import org.apache.jackrabbit.extractor.TextExtractor;
import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.spi.Path;
+import org.apache.jackrabbit.spi.PathFactory;
import org.apache.jackrabbit.spi.commons.name.NameConstants;
+import org.apache.jackrabbit.spi.commons.name.PathFactoryImpl;
import org.apache.jackrabbit.spi.commons.query.DefaultQueryNodeFactory;
import org.apache.jackrabbit.spi.commons.query.qom.QueryObjectModelTree;
import org.apache.jackrabbit.uuid.UUID;
@@ -147,6 +150,27 @@
public static final long DEFAULT_EXTRACTOR_TIMEOUT = 100;
/**
+ * The path of the root node.
+ */
+ private static final Path ROOT_PATH;
+
+ /**
+ * The path <code>/jcr:system</code>.
+ */
+ private static final Path JCR_SYSTEM_PATH;
+
+ static {
+ PathFactory factory = PathFactoryImpl.getInstance();
+ ROOT_PATH = factory.create(NameConstants.ROOT);
+ try {
+ JCR_SYSTEM_PATH = factory.create(ROOT_PATH, NameConstants.JCR_SYSTEM, false);
+ } catch (RepositoryException e) {
+ // should never happen, path is always valid
+ throw new InternalError(e.getMessage());
+ }
+ }
+
+ /**
* The actual index
*/
private MultiIndex index;
@@ -428,8 +452,15 @@
index = new MultiIndex(indexDir, this, excludedIDs, nsMappings);
if (index.numDocs() == 0) {
- index.createInitialIndex(
- context.getItemStateManager(), context.getRootId());
+ Path rootPath;
+ if (excludedIDs.isEmpty()) {
+ // this is the index for jcr:system
+ rootPath = JCR_SYSTEM_PATH;
+ } else {
+ rootPath = ROOT_PATH;
+ }
+ index.createInitialIndex(context.getItemStateManager(),
+ context.getRootId(), rootPath);
}
if (consistencyCheckEnabled
&& (index.getRedoLogApplied() || forceConsistencyCheck)) {