use of org.apache.jackrabbit.oak.plugins.observation.ChangeSet 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.plugins.observation.ChangeSet 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());
}
use of org.apache.jackrabbit.oak.plugins.observation.ChangeSet in project jackrabbit-oak by apache.
the class JournalEntry method addTo.
private void addTo(ChangeSetBuilder changeSetBuilder) {
String cs = (String) get(CHANGE_SET);
ChangeSet set = null;
if (cs == null && getChanges().keySet().isEmpty()) {
//Purely a branch commit. So ChangeSet can be empty
return;
}
if (cs != null) {
set = ChangeSet.fromString(cs);
} else {
LOG.debug("Null changeSet found for JournalEntry {}. ChangeSetBuilder would be set to overflow mode", getId());
}
changeSetBuilder.add(set);
}
use of org.apache.jackrabbit.oak.plugins.observation.ChangeSet in project jackrabbit-oak by apache.
the class ExternalChangesTest method changeSetForExternalChanges.
@Test
public void changeSetForExternalChanges() 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");
ns1.merge(b2, 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);
assertFalse(cs.anyOverflow());
assertThat(cs.getPropertyNames(), containsInAnyOrder("foo1", "foo2"));
}
use of org.apache.jackrabbit.oak.plugins.observation.ChangeSet in project jackrabbit-oak by apache.
the class AsyncIndexerServiceTest method changeCollectionEnabled.
@Test
public void changeCollectionEnabled() throws Exception {
injectDefaultServices();
Map<String, Object> config = ImmutableMap.<String, Object>of("asyncConfigs", new String[] { "async:5" });
context.registerService(IndexEditorProvider.class, new PropertyIndexEditorProvider());
MockOsgi.activate(service, context.bundleContext(), config);
NodeBuilder builder = nodeStore.getRoot().builder();
createIndexDefinition(builder.child(INDEX_DEFINITIONS_NAME), "rootIndex", true, false, ImmutableSet.of("foo"), null).setProperty(ASYNC_PROPERTY_NAME, "async");
builder.child("testRoot").setProperty("foo", "abc");
// merge it back in
nodeStore.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
CommitInfoCollector infoCollector = new CommitInfoCollector();
nodeStore.addObserver(infoCollector);
AsyncIndexUpdate indexUpdate = getIndexUpdate("async");
indexUpdate.run();
CommitContext commitContext = (CommitContext) infoCollector.infos.get(0).getInfo().get(CommitContext.NAME);
assertNotNull(commitContext);
ChangeSet changeSet = (ChangeSet) commitContext.get(ChangeCollectorProvider.COMMIT_CONTEXT_OBSERVATION_CHANGESET);
assertNotNull(changeSet);
}
Aggregations