jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alexparvule...@apache.org
Subject svn commit: r1214749 - in /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core: RepositoryImpl.java SearchManager.java query/QueryHandlerContext.java query/lucene/MultiIndex.java query/lucene/SearchIndex.java
Date Thu, 15 Dec 2011 13:43:45 GMT
Author: alexparvulescu
Date: Thu Dec 15 13:43:45 2011
New Revision: 1214749

URL: http://svn.apache.org/viewvc?rev=1214749&view=rev
Log:
JCR-3162 Index update overhead on cluster slave due to JCR-905
 - rollback

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SearchManager.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/QueryHandlerContext.java
    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/RepositoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java?rev=1214749&r1=1214748&r2=1214749&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java
Thu Dec 15 13:43:45 2011
@@ -605,7 +605,7 @@ public class RepositoryImpl extends Abst
         if (systemSearchMgr == null) {
             if (repConfig.isSearchEnabled()) {
                 systemSearchMgr = new SearchManager(
-                        null, context,
+                        context,
                         repConfig,
                         getWorkspaceInfo(wspName).itemStateMgr,
                         context.getInternalVersionManager().getPersistenceManager(),
@@ -1853,7 +1853,6 @@ public class RepositoryImpl extends Abst
                     // search manager is lazily instantiated in order to avoid
                     // 'chicken & egg' bootstrap problems
                     searchMgr = new SearchManager(
-                            getName(),
                             context,
                             config,
                             itemStateMgr, persistMgr,

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SearchManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SearchManager.java?rev=1214749&r1=1214748&r2=1214749&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SearchManager.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SearchManager.java
Thu Dec 15 13:43:45 2011
@@ -111,21 +111,20 @@ public class SearchManager implements Sy
     /**
      * Creates a new <code>SearchManager</code>.
      *
-     * @param workspace          the workspace name
-     * @param repositoryContext  the repository context        
-     * @param qhf                the query handler factory
-     * @param itemMgr            the shared item state manager.
-     * @param pm                 the underlying persistence manager.
-     * @param rootNodeId         the id of the root node.
-     * @param parentMgr          the parent search manager or <code>null</code>
if
-     *                           there is no parent search manager.
-     * @param excludedNodeId     id of the node that should be excluded from
-     *                           indexing. Any descendant of that node will also be
-     *                           excluded from indexing.
+     * @param config         the search configuration.
+     * @param nsReg          the namespace registry.
+     * @param ntReg          the node type registry.
+     * @param itemMgr        the shared item state manager.
+     * @param pm             the underlying persistence manager.
+     * @param rootNodeId     the id of the root node.
+     * @param parentMgr      the parent search manager or <code>null</code> if
+     *                       there is no parent search manager.
+     * @param excludedNodeId id of the node that should be excluded from
+     *                       indexing. Any descendant of that node will also be
+     *                       excluded from indexing.
      * @throws RepositoryException if the search manager cannot be initialized
      */
     public SearchManager(
-            String workspace,
             RepositoryContext repositoryContext,
             QueryHandlerFactory qhf,
             SharedItemStateManager itemMgr,
@@ -168,9 +167,10 @@ public class SearchManager implements Sy
         }
 
         // initialize query handler
-        this.handler = qhf.getQueryHandler(new QueryHandlerContext(workspace,
-                repositoryContext, itemMgr, pm, rootNodeId, parentHandler,
-                excludedNodeId));
+        this.handler = qhf.getQueryHandler(new QueryHandlerContext(
+                repositoryContext,
+                itemMgr, pm, rootNodeId,
+                parentHandler, excludedNodeId));
     }
 
     /**
@@ -332,6 +332,10 @@ public class SearchManager implements Sy
                 long type = e.getType();
                 if (type == Event.NODE_ADDED) {
                     addedNodes.put(e.getChildId(), e);
+                    // quick'n dirty fix for JCR-905
+                    if (e.isExternal()) {
+                        removedNodes.add(e.getChildId());
+                    }
                     if (e.isShareableChildNode()) {
                         // simply re-index shareable nodes
                         removedNodes.add(e.getChildId());

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/QueryHandlerContext.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/QueryHandlerContext.java?rev=1214749&r1=1214748&r2=1214749&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/QueryHandlerContext.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/QueryHandlerContext.java
Thu Dec 15 13:43:45 2011
@@ -22,7 +22,6 @@ import org.apache.jackrabbit.core.Cachin
 import org.apache.jackrabbit.core.HierarchyManager;
 import org.apache.jackrabbit.core.NamespaceRegistryImpl;
 import org.apache.jackrabbit.core.RepositoryContext;
-import org.apache.jackrabbit.core.cluster.ClusterNode;
 import org.apache.jackrabbit.core.id.NodeId;
 import org.apache.jackrabbit.core.nodetype.NodeTypeRegistry;
 import org.apache.jackrabbit.core.persistence.PersistenceManager;
@@ -37,11 +36,6 @@ import org.apache.jackrabbit.core.state.
 public class QueryHandlerContext {
 
     /**
-     * The workspace
-     */
-    private final String workspace;
-
-    /**
      * Repository context.
      */
     private final RepositoryContext repositoryContext;
@@ -84,26 +78,22 @@ public class QueryHandlerContext {
     /**
      * Creates a new context instance.
      *
-     * @param workspace          the workspace name.
-     * @param repositoryContext  the repository context.
-     * @param stateMgr           provides persistent item states.
-     * @param pm                 the underlying persistence manager.
-     * @param rootId             the id of the root node.
-     * @param parentHandler      the parent query handler or <code>null</code>
it
-     *                           there is no parent handler.
-     * @param excludedNodeId     id of the node that should be excluded from
-     *                           indexing. Any descendant of that node is also
-     *                           excluded from indexing.
+     * @param stateMgr         provides persistent item states.
+     * @param pm               the underlying persistence manager.
+     * @param rootId           the id of the root node.
+     * @param parentHandler    the parent query handler or <code>null</code>
it
+     *                         there is no parent handler.
+     * @param excludedNodeId   id of the node that should be excluded from
+     *                         indexing. Any descendant of that node is also
+     *                         excluded from indexing.
      */
     public QueryHandlerContext(
-            String workspace,
             RepositoryContext repositoryContext,
             SharedItemStateManager stateMgr,
             PersistenceManager pm,
             NodeId rootId,
             QueryHandler parentHandler,
             NodeId excludedNodeId) {
-        this.workspace = workspace;
         this.repositoryContext = repositoryContext;
         this.stateMgr = stateMgr;
         this.hmgr = new CachingHierarchyManager(rootId, stateMgr);
@@ -211,17 +201,4 @@ public class QueryHandlerContext {
         return repositoryContext.getExecutor();
     }
 
-    /**
-     * Returns the cluster node instance of this repository, or
-     * <code>null</code> if clustering is not enabled.
-     * 
-     * @return cluster node
-     */
-    public ClusterNode getClusterNode() {
-        return repositoryContext.getClusterNode();
-    }
-
-    public String getWorkspace() {
-        return workspace;
-    }
 }

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=1214749&r1=1214748&r2=1214749&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
Thu Dec 15 13:43:45 2011
@@ -266,13 +266,14 @@ public class MultiIndex {
         merger.setMergeFactor(handler.getMergeFactor());
         merger.setMinMergeDocs(handler.getMinMergeDocs());
 
+        IndexingQueueStore store = new IndexingQueueStore(indexDir);
+
         // initialize indexing queue
-        this.indexingQueue = new IndexingQueue(new IndexingQueueStore(indexDir));
+        this.indexingQueue = new IndexingQueue(store);
 
         // open persistent indexes
-        Iterator<IndexInfo> iterator = indexNames.iterator();
-        while (iterator.hasNext()) {
-            IndexInfo info = iterator.next();
+        for (Iterator<?> it = indexNames.iterator(); it.hasNext(); ) {
+            IndexInfo info = (IndexInfo) it.next();
             String name = info.getName();
             // only open if it still exists
             // it is possible that indexNames still contains a name for
@@ -385,11 +386,10 @@ public class MultiIndex {
                 executeAndLog(new Start(Action.INTERNAL_TRANSACTION));
                 NodeState rootState = (NodeState) stateMgr.getItemState(rootId);
                 count = createIndex(rootState, rootPath, stateMgr, count);
-                checkIndexingQueue(true);
                 executeAndLog(new Commit(getTransactionId()));
                 log.debug("Created initial index for {} nodes", count);
                 releaseMultiReader();
-                safeFlush();
+                scheduleFlushTask();
             } catch (Exception e) {
                 String msg = "Error indexing workspace";
                 IOException ex = new IOException(msg);
@@ -397,7 +397,6 @@ public class MultiIndex {
                 throw ex;
             } finally {
                 reindexing = false;
-                scheduleFlushTask();
             }
         } else {
             throw new IllegalStateException("Index already present");
@@ -1168,8 +1167,7 @@ public class MultiIndex {
     private void commitVolatileIndex() throws IOException {
 
         // check if volatile index contains documents at all
-        int volatileIndexDocuments = volatileIndex.getNumDocuments();
-        if (volatileIndexDocuments > 0) {
+        if (volatileIndex.getNumDocuments() > 0) {
 
             long time = System.currentTimeMillis();
             // create index
@@ -1187,7 +1185,7 @@ public class MultiIndex {
             resetVolatileIndex();
 
             time = System.currentTimeMillis() - time;
-            log.debug("Committed in-memory index containing {} documents in {}ms.", volatileIndexDocuments,
time);
+            log.debug("Committed in-memory index in " + time + "ms.");
         }
     }
 
@@ -1300,7 +1298,7 @@ public class MultiIndex {
             }
         }
     }
-
+    
     void safeFlush() throws IOException{
         synchronized (updateMonitor) {
             updateInProgress = true;

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=1214749&r1=1214748&r2=1214749&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
Thu Dec 15 13:43:45 2011
@@ -41,25 +41,11 @@ import javax.xml.parsers.ParserConfigura
 
 import org.apache.jackrabbit.core.HierarchyManager;
 import org.apache.jackrabbit.core.SessionImpl;
-import org.apache.jackrabbit.core.cluster.ChangeLogRecord;
-import org.apache.jackrabbit.core.cluster.ClusterNode;
-import org.apache.jackrabbit.core.cluster.ClusterRecord;
-import org.apache.jackrabbit.core.cluster.ClusterRecordDeserializer;
-import org.apache.jackrabbit.core.cluster.ClusterRecordProcessor;
-import org.apache.jackrabbit.core.cluster.LockRecord;
-import org.apache.jackrabbit.core.cluster.NamespaceRecord;
-import org.apache.jackrabbit.core.cluster.NodeTypeRecord;
-import org.apache.jackrabbit.core.cluster.PrivilegeRecord;
-import org.apache.jackrabbit.core.cluster.WorkspaceRecord;
 import org.apache.jackrabbit.core.fs.FileSystem;
 import org.apache.jackrabbit.core.fs.FileSystemException;
 import org.apache.jackrabbit.core.fs.FileSystemResource;
 import org.apache.jackrabbit.core.fs.local.LocalFileSystem;
 import org.apache.jackrabbit.core.id.NodeId;
-import org.apache.jackrabbit.core.journal.Journal;
-import org.apache.jackrabbit.core.journal.JournalException;
-import org.apache.jackrabbit.core.journal.Record;
-import org.apache.jackrabbit.core.journal.RecordIterator;
 import org.apache.jackrabbit.core.query.AbstractQueryHandler;
 import org.apache.jackrabbit.core.query.ExecutableQuery;
 import org.apache.jackrabbit.core.query.QueryHandler;
@@ -68,7 +54,6 @@ import org.apache.jackrabbit.core.query.
 import org.apache.jackrabbit.core.query.lucene.directory.FSDirectoryManager;
 import org.apache.jackrabbit.core.query.lucene.hits.AbstractHitCollector;
 import org.apache.jackrabbit.core.session.SessionContext;
-import org.apache.jackrabbit.core.state.ItemState;
 import org.apache.jackrabbit.core.state.ItemStateException;
 import org.apache.jackrabbit.core.state.ItemStateManager;
 import org.apache.jackrabbit.core.state.NoSuchItemStateException;
@@ -562,7 +547,6 @@ public class SearchIndex extends Abstrac
             }
             index.createInitialIndex(context.getItemStateManager(),
                     context.getRootId(), rootPath);
-            checkPendingJournalChanges(context);
         }
         if (consistencyCheckEnabled
                 && (index.getRedoLogApplied() || forceConsistencyCheck)) {
@@ -2493,46 +2477,6 @@ public class SearchIndex extends Abstrac
         this.redoLogFactoryClass = className;
     }
 
-    /**
-     * In the case of an initial index build operation, this checks if there are
-     * some new nodes pending in the journal and tries to preemptively delete
-     * them, to keep the index consistent.
-     * 
-     * See JCR-3162
-     * 
-     * @param context
-     * @throws IOException
-     */
-    private void checkPendingJournalChanges(QueryHandlerContext context) {
-        ClusterNode cn = context.getClusterNode();
-        if (cn == null) {
-            return;
-        }
-
-        List<NodeId> addedIds = new ArrayList<NodeId>();
-        long rev = cn.getRevision();
-
-        List<ChangeLogRecord> changes = getChangeLogRecords(rev, context.getWorkspace());
-        Iterator<ChangeLogRecord> iterator = changes.iterator();
-        while (iterator.hasNext()) {
-            ChangeLogRecord record = iterator.next();
-            for (ItemState state : record.getChanges().addedStates()) {
-                if (!state.isNode()) {
-                    continue;
-                }
-                addedIds.add((NodeId) state.getId());
-            }
-        }
-        if (!addedIds.isEmpty()) {
-            Collection<NodeState> empty = Collections.emptyList();
-            try {
-                updateNodes(addedIds.iterator(), empty.iterator());
-            } catch (Exception e) {
-                log.error(e.getMessage(), e);
-            }
-        }
-    }
-
     //----------------------------< internal >----------------------------------
 
     /**
@@ -2546,79 +2490,4 @@ public class SearchIndex extends Abstrac
             throw new IOException("query handler closed and cannot be used anymore.");
         }
     }
-
-    /**
-     * Polls the underlying journal for events of the type ChangeLogRecord that
-     * happened after a given revision, on a given workspace.
-     *
-     * @param revision
-     *            starting revision
-     * @param workspace
-     *            the workspace name
-     * @return
-     */
-    private List<ChangeLogRecord> getChangeLogRecords(long revision,
-            final String workspace) {
-        log.debug(
-                "Get changes from the Journal for revision {} and workspace {}.",
-                revision, workspace);
-        ClusterNode cn = getContext().getClusterNode();
-        if (cn == null) {
-            return Collections.emptyList();
-        }
-        Journal journal = cn.getJournal();
-        final List<ChangeLogRecord> events = new ArrayList<ChangeLogRecord>();
-        ClusterRecordDeserializer deserializer = new ClusterRecordDeserializer();
-        RecordIterator records = null;
-        try {
-            records = journal.getRecords(revision);
-            while (records.hasNext()) {
-                Record record = records.nextRecord();
-                if (!record.getProducerId().equals(cn.getId())) {
-                    continue;
-                }
-                ClusterRecord r = null;
-                try {
-                    r = deserializer.deserialize(record);
-                } catch (JournalException e) {
-                    log.error(
-                            "Unable to read revision '" + record.getRevision()
-                                    + "'.", e);
-                }
-                if (r == null) {
-                    continue;
-                }
-                r.process(new ClusterRecordProcessor() {
-                    public void process(ChangeLogRecord record) {
-                        String eventW = record.getWorkspace();
-                        if (eventW != null ? eventW.equals(workspace) : workspace == null)
{
-                            events.add(record);
-                        }
-                    }
-
-                    public void process(LockRecord record) {
-                    }
-
-                    public void process(NamespaceRecord record) {
-                    }
-
-                    public void process(NodeTypeRecord record) {
-                    }
-
-                    public void process(PrivilegeRecord record) {
-                    }
-
-                    public void process(WorkspaceRecord record) {
-                    }
-                });
-            }
-        } catch (JournalException e1) {
-            log.error(e1.getMessage(), e1);
-        } finally {
-            if (records != null) {
-                records.close();
-            }
-        }
-        return events;
-    }
 }



Mime
View raw message