use of org.apache.jackrabbit.oak.spi.commit.CommitInfo in project jackrabbit-oak by apache.
the class IndexUpdateTest method contextAwareCallback.
@Test
public void contextAwareCallback() throws Exception {
NodeState before = builder.getNodeState();
createIndexDefinition(builder.child(INDEX_DEFINITIONS_NAME), "rootIndex", true, false, ImmutableSet.of("foo"), null);
NodeState after = builder.getNodeState();
CallbackCapturingProvider provider = new CallbackCapturingProvider();
EditorHook hook = new EditorHook(new IndexUpdateProvider(provider));
CommitInfo info = new CommitInfo("foo", "bar");
NodeState indexed = hook.processCommit(before, after, info);
assertNotNull(provider.callback);
assertThat(provider.callback, instanceOf(ContextAwareCallback.class));
ContextAwareCallback contextualCallback = (ContextAwareCallback) provider.callback;
IndexingContext context = contextualCallback.getIndexingContext();
assertNotNull(context);
assertEquals("/oak:index/rootIndex", context.getIndexPath());
assertTrue(context.isReindexing());
assertFalse(context.isAsync());
assertSame(info, context.getCommitInfo());
before = indexed;
builder = indexed.builder();
builder.child("a").setProperty("foo", "bar");
after = builder.getNodeState();
hook.processCommit(before, after, info);
assertFalse(((ContextAwareCallback) provider.callback).getIndexingContext().isReindexing());
}
use of org.apache.jackrabbit.oak.spi.commit.CommitInfo in project jackrabbit-oak by apache.
the class MutableRoot method commit.
@Override
public void commit(@Nonnull Map<String, Object> info) throws CommitFailedException {
checkLive();
ContentSession session = getContentSession();
CommitInfo commitInfo = new CommitInfo(session.toString(), session.getAuthInfo().getUserID(), newInfoWithCommitContext(info));
store.merge(builder, getCommitHook(), commitInfo);
secureBuilder.baseChanged();
modCount = 0;
if (permissionProvider.hasValue()) {
permissionProvider.get().refresh();
}
moveTracker.clear();
}
use of org.apache.jackrabbit.oak.spi.commit.CommitInfo in project jackrabbit-oak by apache.
the class ExternalChangesTest method journalService.
@Test
public void journalService() throws Exception {
wb.register(JournalPropertyService.class, new TestJournalService(), null);
//Do a dummy write so that journal property handler gets refreshed
//and picks our newly registered service
NodeBuilder b0 = ns1.getRoot().builder();
b0.child("0");
ns1.merge(b0, newCollectingHook(), newCommitInfo());
ns1.runBackgroundUpdateOperations();
NodeBuilder b1 = ns1.getRoot().builder();
b1.child("a");
CommitContext cc = new SimpleCommitContext();
cc.set(TestProperty.NAME, new TestProperty("foo"));
ns1.merge(b1, newCollectingHook(), newCommitInfo(cc));
NodeBuilder b2 = ns1.getRoot().builder();
b2.child("b");
cc = new SimpleCommitContext();
cc.set(TestProperty.NAME, new TestProperty("bar"));
ns1.merge(b2, newCollectingHook(), newCommitInfo(cc));
//null entry
NodeBuilder b3 = ns1.getRoot().builder();
b3.child("c");
ns1.merge(b3, newCollectingHook(), newCommitInfo());
ns1.runBackgroundUpdateOperations();
c2.reset();
ns2.runBackgroundReadOperations();
CommitInfo ci = c2.getExternalChange();
cc = (CommitContext) ci.getInfo().get(CommitContext.NAME);
CumulativeTestProperty ct = (CumulativeTestProperty) cc.get(TestProperty.NAME);
assertNotNull(ct);
assertThat(ct.values, containsInAnyOrder("foo", "bar", "NULL"));
}
use of org.apache.jackrabbit.oak.spi.commit.CommitInfo in project jackrabbit-oak by apache.
the class ExternalChangesTest method changeSetForBranchCommit.
@Test
public void changeSetForBranchCommit() throws Exception {
final int NUM_NODES = DocumentMK.UPDATE_LIMIT / 2;
final int NUM_PROPS = 10;
Set<String> propNames = Sets.newHashSet();
NodeBuilder b1 = ns1.getRoot().builder();
for (int i = 0; i < NUM_NODES; i++) {
NodeBuilder c = b1.child("n" + i);
for (int j = 0; j < NUM_PROPS; j++) {
c.setProperty("q" + j, "value");
c.setProperty("p" + j, "value");
propNames.add("q" + j);
propNames.add("p" + j);
}
}
ns1.merge(b1, newCollectingHook(), newCommitInfo());
ns1.runBackgroundUpdateOperations();
c2.reset();
ns2.runBackgroundReadOperations();
CommitInfo ci = c2.getExternalChange();
CommitContext cc = (CommitContext) ci.getInfo().get(CommitContext.NAME);
assertNotNull(cc);
ChangeSet cs = (ChangeSet) cc.get(ChangeCollectorProvider.COMMIT_CONTEXT_OBSERVATION_CHANGESET);
assertNotNull(cs);
assertTrue(cs.getPropertyNames().containsAll(propNames));
}
use of org.apache.jackrabbit.oak.spi.commit.CommitInfo in project jackrabbit-oak by apache.
the class ExternalChangesTest method missingChangeSetResultsInOverflow.
@Test
public void missingChangeSetResultsInOverflow() throws Exception {
NodeBuilder b1 = ns1.getRoot().builder();
b1.child("a");
b1.setProperty("foo1", "bar");
ns1.merge(b1, newCollectingHook(), newCommitInfo());
NodeBuilder b2 = ns1.getRoot().builder();
b2.child("b");
b2.setProperty("foo2", "bar");
//Commit without ChangeSet
ns1.merge(b2, EmptyHook.INSTANCE, CommitInfo.EMPTY);
ns1.runBackgroundUpdateOperations();
c2.reset();
ns2.runBackgroundReadOperations();
CommitInfo ci = c2.getExternalChange();
CommitContext cc = (CommitContext) ci.getInfo().get(CommitContext.NAME);
assertNotNull(cc);
ChangeSet cs = (ChangeSet) cc.get(ChangeCollectorProvider.COMMIT_CONTEXT_OBSERVATION_CHANGESET);
assertNotNull(cs);
//ChangeSet should result in overflow
assertTrue(cs.anyOverflow());
}
Aggregations