private static JournalProperty getEntry(CommitContext cc, String name){ Object o = cc.get(name); if (o == null){ return null; } checkArgument(o instanceof JournalProperty, "CommitContext entry for name [%s] " + "having value [%s] is not of type JournalEntry", name, o); return (JournalProperty) o; }
private LuceneDocumentHolder getDocumentHolder(CommitContext commitContext){ LuceneDocumentHolder holder = (LuceneDocumentHolder) commitContext.get(LuceneDocumentHolder.NAME); if (holder == null) { holder = new LuceneDocumentHolder(indexingQueue, inMemoryDocsLimit); commitContext.set(LuceneDocumentHolder.NAME, holder); } return holder; }
public void addTo(CommitContext commitContext){ for (Map.Entry<String,JournalPropertyBuilder<JournalProperty>> e : builders.entrySet()){ JournalPropertyBuilder<JournalProperty> builder = e.getValue(); commitContext.set(e.getKey(), builder.build()); } }
public void addTo(CommitContext commitContext){ for (Map.Entry<String,JournalPropertyBuilder<JournalProperty>> e : builders.entrySet()){ JournalPropertyBuilder<JournalProperty> builder = e.getValue(); commitContext.set(e.getKey(), builder.build()); } }
private static JournalProperty getEntry(CommitContext cc, String name){ Object o = cc.get(name); if (o == null){ return null; } checkArgument(o instanceof JournalProperty, "CommitContext entry for name [%s] " + "having value [%s] is not of type JournalEntry", name, o); return (JournalProperty) o; }
private LuceneDocumentHolder getDocumentHolder(CommitContext commitContext){ LuceneDocumentHolder holder = (LuceneDocumentHolder) commitContext.get(LuceneDocumentHolder.NAME); if (holder == null) { holder = new LuceneDocumentHolder(indexingQueue, inMemoryDocsLimit); commitContext.set(LuceneDocumentHolder.NAME, holder); } return holder; }
private static CommitInfo newCommitInfo(@NotNull ChangeSet changeSet, JournalPropertyHandler journalPropertyHandler) { CommitContext commitContext = new SimpleCommitContext(); commitContext.set(COMMIT_CONTEXT_OBSERVATION_CHANGESET, changeSet); journalPropertyHandler.addTo(commitContext); Map<String, Object> info = ImmutableMap.<String, Object>of(CommitContext.NAME, commitContext); return new CommitInfo(CommitInfo.OAK_UNKNOWN, CommitInfo.OAK_UNKNOWN, info, true); }
private static ChangeSet getChangeSet(CommitInfo info) { CommitContext commitContext = (CommitContext) info.getInfo().get(CommitContext.NAME); if (commitContext == null){ return null; } return (ChangeSet) commitContext.get(COMMIT_CONTEXT_OBSERVATION_CHANGESET); }
@Test public void docsAddedToQueue() throws Exception{ CommitInfo info = newCommitInfo(); CommitContext cc = (CommitContext) info.getInfo().get(CommitContext.NAME); LuceneDocumentHolder holder = new LuceneDocumentHolder(collectingQueue, 500); holder.add(false, LuceneDoc.forDelete("foo", "bar")); cc.set(LuceneDocumentHolder.NAME, holder); observer.contentChanged(EMPTY_NODE, info); assertEquals(1, collectingQueue.getQueuedDocs().size()); assertNull(cc.get(LuceneDocumentHolder.NAME)); }
private static CommitInfo newCommitInfo(@NotNull ChangeSet changeSet, JournalPropertyHandler journalPropertyHandler) { CommitContext commitContext = new SimpleCommitContext(); commitContext.set(COMMIT_CONTEXT_OBSERVATION_CHANGESET, changeSet); journalPropertyHandler.addTo(commitContext); Map<String, Object> info = ImmutableMap.<String, Object>of(CommitContext.NAME, commitContext); return new CommitInfo(CommitInfo.OAK_UNKNOWN, CommitInfo.OAK_UNKNOWN, info, true); }
private static ChangeSet getChangeSet(CommitInfo info) { CommitContext commitContext = (CommitContext) info.getInfo().get(CommitContext.NAME); if (commitContext == null){ return null; } return (ChangeSet) commitContext.get(COMMIT_CONTEXT_OBSERVATION_CHANGESET); }
b1.child("a"); CommitContext cc = new SimpleCommitContext(); cc.set(TestProperty.NAME, new TestProperty("foo")); ns1.merge(b1, newCollectingHook(), newCommitInfo(cc)); b2.child("b"); cc = new SimpleCommitContext(); cc.set(TestProperty.NAME, new TestProperty("bar")); ns1.merge(b2, newCollectingHook(), newCommitInfo(cc)); cc = (CommitContext) ci.getInfo().get(CommitContext.NAME); CumulativeTestProperty ct = (CumulativeTestProperty) cc.get(TestProperty.NAME); assertNotNull(ct);
@NotNull @Override public NodeState processCommit(NodeState before, NodeState after, CommitInfo info) throws CommitFailedException { CommitContext attrs = (CommitContext) info.getInfo().get(CommitContext.NAME); assertNotNull(attrs); attrs.set("foo", "bar"); return after; } })
/** * Utility method that extracts the ChangeSet from a CommitInfo if possible. * @param info * @return */ public static ChangeSet getChangeSet(CommitInfo info) { if (info == null) { return null; } CommitContext context = (CommitContext) info.getInfo().get(CommitContext.NAME); if (context == null) { return null; } return (ChangeSet) context.get(COMMIT_CONTEXT_OBSERVATION_CHANGESET); }
@Override public void leave(NodeState before, NodeState after) throws CommitFailedException { // first check if we have to add anything to paths and/or nodeNames if (changed && level <= support.maxPathDepth) { support.changeSetBuilder.addParentPath(path); } if (changed && childName != null) { support.changeSetBuilder.addParentNodeName(childName); } if (changed){ addParentNodeType(beforeParentNodeOrNull); addParentNodeType(afterParentNodeOrNull); } // then if we're not at the root, we're done if (!isRoot) { return; } // but if we're at the root, then we add the ChangeSet to the // CommitContext of the CommitInfo CommitContext commitContext = (CommitContext) support.info.getInfo().get(CommitContext.NAME); ChangeSet changeSet = support.changeSetBuilder.build(); commitContext.set(ChangeSet.COMMIT_CONTEXT_OBSERVATION_CHANGESET, changeSet); LOG.debug("Collected changeSet for commit {} is {}", support.info, changeSet); }
/** * Utility method that extracts the ChangeSet from a CommitInfo if possible. * @param info * @return */ public static ChangeSet getChangeSet(CommitInfo info) { if (info == null) { return null; } CommitContext context = (CommitContext) info.getInfo().get(CommitContext.NAME); if (context == null) { return null; } return (ChangeSet) context.get(COMMIT_CONTEXT_OBSERVATION_CHANGESET); }