@Test public void externalChangeNullContext() throws Exception { observer.contentChanged(INITIAL_CONTENT, CommitInfo.EMPTY_EXTERNAL); verifyZeroInteractions(queue); }
@Override public void contentChanged(@NotNull NodeState after, @NotNull CommitInfo info) { if (excludes(after, info)) { return; } CommitContext commitContext = (CommitContext) info.getInfo().get(CommitContext.NAME); IndexedPaths indexedPaths = (IndexedPaths) commitContext.get(LuceneDocumentHolder.NAME); commitContext.remove(LuceneDocumentHolder.NAME); log.trace("Received indexed paths {}", indexedPaths); int droppedCount = 0; int indexedCount = 0; TimerStats.Context ctx = timer.time(); Set<String> indexPaths = Sets.newHashSet(); for (IndexedPathInfo indexData : indexedPaths) { String path = indexData.getPath(); NodeState indexedNode = null; for (String indexPath : indexData.getIndexPaths()) { IndexDefinition defn = indexTracker.getIndexDefinition(indexPath); if (defn == null) { continue; } if (indexedNode == null) { indexedNode = NodeStateUtils.getNode(after, path); } if (!indexedNode.exists()) { continue; } IndexDefinition.IndexingRule indexingRule = defn.getApplicableIndexingRule(indexedNode); if (indexingRule == null) { log.debug("No indexingRule found for path {} for index {}", path, indexPath); continue; } indexPaths.add(indexPath); try { Document doc = new LuceneDocumentMaker(defn, indexingRule, path).makeDocument(indexedNode); if (doc != null) { if (indexingQueue.add(LuceneDoc.forUpdate(indexPath, path, doc))) { indexedCount++; } else { droppedCount++; } } } catch (Exception e) { log.warn("Ignoring making LuceneDocument for path {} for index {} due to exception", path, indexPath, e); } } } if (droppedCount > 0) { log.warn("Dropped [{}] docs from indexing as queue is full", droppedCount); } added.mark(indexedCount); ctx.stop(); log.debug("Added {} documents for {} indexes from external changes", indexedCount, indexPaths.size()); }
ExternalIndexObserver implements Observer, Filter { @Override public void contentChanged(@NotNull NodeState after, @NotNull CommitInfo info) { if (excludes(after, info)) { return; } CommitContext commitContext = (CommitContext) info.getInfo().get(CommitContext.NAME); IndexedPaths indexedPaths = (IndexedPaths) commitContext.get(LuceneDocumentHolder.NAME); commitContext.remove(LuceneDocumentHolder.NAME); log.trace("Received indexed paths {}", indexedPaths); int droppedCount = 0; int indexedCount = 0; TimerStats.Context ctx = timer.time(); Set<String> indexPaths = Sets.newHashSet(); for (IndexedPathInfo indexData : indexedPaths) { String path = indexData.getPath(); NodeState indexedNode = null; for (String indexPath : indexData.getIndexPaths()) { IndexDefinition defn = indexTracker.getIndexDefinition(indexPath); if (defn == null) { continue; } if (indexedNode == null) { indexedNode = NodeStateUtils.getNode(after, path); } if (!indexedNode.exists()) { continue; } IndexDefinition.IndexingRule indexingRule = defn.getApplicableIndexingRule(indexedNode); if (indexingRule == null) { log.debug("No indexingRule found for path {} for index {}", path, indexPath); continue; } indexPaths.add(indexPath); try { Document doc = new LuceneDocumentMaker(defn, indexingRule, path).makeDocument(indexedNode); if (doc != null) { if (indexingQueue.add(LuceneDoc.forUpdate(indexPath, path, doc))) { indexedCount++; } else { droppedCount++; } } } catch (Exception e) { log.warn("Ignoring making LuceneDocument for path {} for index {} due to exception", path, indexPath, e); } } } if (droppedCount > 0) { log.warn("Dropped [{}] docs from indexing as queue is full", droppedCount); } added.mark(indexedCount); ctx.stop(); log.debug("Added {} documents for {} indexes from external changes", indexedCount, indexPaths.size()); } }
ExternalIndexObserver implements Observer, Filter { @Override public void contentChanged(@NotNull NodeState after, @NotNull CommitInfo info) { if (excludes(after, info)) { return; } CommitContext commitContext = (CommitContext) info.getInfo().get(CommitContext.NAME); IndexedPaths indexedPaths = (IndexedPaths) commitContext.get(LuceneDocumentHolder.NAME); commitContext.remove(LuceneDocumentHolder.NAME); log.trace("Received indexed paths {}", indexedPaths); int droppedCount = 0; int indexedCount = 0; TimerStats.Context ctx = timer.time(); Set<String> indexPaths = Sets.newHashSet(); for (IndexedPathInfo indexData : indexedPaths) { String path = indexData.getPath(); NodeState indexedNode = null; for (String indexPath : indexData.getIndexPaths()) { IndexDefinition defn = indexTracker.getIndexDefinition(indexPath); if (defn == null) { continue; } if (indexedNode == null) { indexedNode = NodeStateUtils.getNode(after, path); } if (!indexedNode.exists()) { continue; } IndexDefinition.IndexingRule indexingRule = defn.getApplicableIndexingRule(indexedNode); if (indexingRule == null) { log.debug("No indexingRule found for path {} for index {}", path, indexPath); continue; } indexPaths.add(indexPath); try { Document doc = new LuceneDocumentMaker(defn, indexingRule, path).makeDocument(indexedNode); if (doc != null) { if (indexingQueue.add(LuceneDoc.forUpdate(indexPath, path, doc))) { indexedCount++; } else { droppedCount++; } } } catch (Exception e) { log.warn("Ignoring making LuceneDocument for path {} for index {} due to exception", path, indexPath, e); } } } if (droppedCount > 0) { log.warn("Dropped [{}] docs from indexing as queue is full", droppedCount); } added.mark(indexedCount); ctx.stop(); log.debug("Added {} documents for {} indexes from external changes", indexedCount, indexPaths.size()); } ExternalIndexObserver(IndexingQueue indexingQueue, IndexTracker indexTracker, StatisticsProvider statisticsProvider); }
ExternalIndexObserver implements Observer, Filter { @Override public void contentChanged(@NotNull NodeState after, @NotNull CommitInfo info) { if (excludes(after, info)) { return; } CommitContext commitContext = (CommitContext) info.getInfo().get(CommitContext.NAME); IndexedPaths indexedPaths = (IndexedPaths) commitContext.get(LuceneDocumentHolder.NAME); commitContext.remove(LuceneDocumentHolder.NAME); log.trace("Received indexed paths {}", indexedPaths); int droppedCount = 0; int indexedCount = 0; TimerStats.Context ctx = timer.time(); Set<String> indexPaths = Sets.newHashSet(); for (IndexedPathInfo indexData : indexedPaths) { String path = indexData.getPath(); NodeState indexedNode = null; for (String indexPath : indexData.getIndexPaths()) { IndexDefinition defn = indexTracker.getIndexDefinition(indexPath); if (defn == null) { continue; } if (indexedNode == null) { indexedNode = NodeStateUtils.getNode(after, path); } if (!indexedNode.exists()) { continue; } IndexDefinition.IndexingRule indexingRule = defn.getApplicableIndexingRule(indexedNode); if (indexingRule == null) { log.debug("No indexingRule found for path {} for index {}", path, indexPath); continue; } indexPaths.add(indexPath); try { Document doc = new LuceneDocumentMaker(defn, indexingRule, path).makeDocument(indexedNode); if (doc != null) { if (indexingQueue.add(LuceneDoc.forUpdate(indexPath, path, doc))) { indexedCount++; } else { droppedCount++; } } } catch (Exception e) { log.warn("Ignoring making LuceneDocument for path {} for index {} due to exception", path, indexPath, e); } } } if (droppedCount > 0) { log.warn("Dropped [{}] docs from indexing as queue is full", droppedCount); } added.mark(indexedCount); ctx.stop(); log.debug("Added {} documents for {} indexes from external changes", indexedCount, indexPaths.size()); } ExternalIndexObserver(IndexingQueue indexingQueue, IndexTracker indexTracker, StatisticsProvider statisticsProvider); @Override boolean excludes(@NotNull NodeState root, @NotNull CommitInfo info); @Override void contentChanged(@NotNull NodeState after, @NotNull CommitInfo info); }
ExternalIndexObserver implements Observer, Filter { @Override public void contentChanged(@NotNull NodeState after, @NotNull CommitInfo info) { if (excludes(after, info)) { return; } CommitContext commitContext = (CommitContext) info.getInfo().get(CommitContext.NAME); IndexedPaths indexedPaths = (IndexedPaths) commitContext.get(LuceneDocumentHolder.NAME); commitContext.remove(LuceneDocumentHolder.NAME); log.trace("Received indexed paths {}", indexedPaths); int droppedCount = 0; int indexedCount = 0; TimerStats.Context ctx = timer.time(); Set<String> indexPaths = Sets.newHashSet(); for (IndexedPathInfo indexData : indexedPaths) { String path = indexData.getPath(); NodeState indexedNode = null; for (String indexPath : indexData.getIndexPaths()) { IndexDefinition defn = indexTracker.getIndexDefinition(indexPath); if (defn == null) { continue; } if (indexedNode == null) { indexedNode = NodeStateUtils.getNode(after, path); } if (!indexedNode.exists()) { continue; } IndexDefinition.IndexingRule indexingRule = defn.getApplicableIndexingRule(indexedNode); if (indexingRule == null) { log.debug("No indexingRule found for path {} for index {}", path, indexPath); continue; } indexPaths.add(indexPath); try { Document doc = new LuceneDocumentMaker(defn, indexingRule, path).makeDocument(indexedNode); if (doc != null) { if (indexingQueue.add(LuceneDoc.forUpdate(indexPath, path, doc))) { indexedCount++; } else { droppedCount++; } } } catch (Exception e) { log.warn("Ignoring making LuceneDocument for path {} for index {} due to exception", path, indexPath, e); } } } if (droppedCount > 0) { log.warn("Dropped [{}] docs from indexing as queue is full", droppedCount); } added.mark(indexedCount); ctx.stop(); log.debug("Added {} documents for {} indexes from external changes", indexedCount, indexPaths.size()); } ExternalIndexObserver(IndexingQueue indexingQueue, IndexTracker indexTracker, StatisticsProvider statisticsProvider); @Override boolean excludes(@NotNull NodeState root, @NotNull CommitInfo info); @Override void contentChanged(@NotNull NodeState after, @NotNull CommitInfo info);  }