Search in sources :

Example 66 with NodeState

use of org.apache.jackrabbit.oak.spi.state.NodeState in project jackrabbit-oak by apache.

the class SecureNodeBuilderTest method testGetNodeStateNonAccessible.

@Test
public void testGetNodeStateNonAccessible() {
    NodeState ns = secureNodeBuilder.getChildNode(NAME_NON_ACCESSIBLE).getNodeState();
    assertTrue(ns instanceof SecureNodeState);
}
Also used : NodeState(org.apache.jackrabbit.oak.spi.state.NodeState) Test(org.junit.Test)

Example 67 with NodeState

use of org.apache.jackrabbit.oak.spi.state.NodeState in project jackrabbit-oak by apache.

the class SecureNodeBuilderTest method testGetBaseStateNonAccessible.

@Test
public void testGetBaseStateNonAccessible() {
    NodeState ns = secureNodeBuilder.getChildNode(NAME_NON_ACCESSIBLE).getBaseState();
    assertTrue(ns instanceof SecureNodeState);
}
Also used : NodeState(org.apache.jackrabbit.oak.spi.state.NodeState) Test(org.junit.Test)

Example 68 with NodeState

use of org.apache.jackrabbit.oak.spi.state.NodeState in project jackrabbit-oak by apache.

the class SecureNodeBuilderTest method testGetBaseState.

@Test
public void testGetBaseState() {
    NodeState ns = secureNodeBuilder.getBaseState();
    assertTrue(ns instanceof SecureNodeState);
}
Also used : NodeState(org.apache.jackrabbit.oak.spi.state.NodeState) Test(org.junit.Test)

Example 69 with NodeState

use of org.apache.jackrabbit.oak.spi.state.NodeState in project jackrabbit-oak by apache.

the class CheckpointsTest method crossClusterNodeCheckpoint.

@Test
public void crossClusterNodeCheckpoint() throws Exception {
    // use an async delay to ensure DocumentNodeStore.suspendUntil() works
    // but set it to a high value and control background ops manually in
    // this test
    final int asyncDelay = (int) TimeUnit.MINUTES.toMillis(1);
    DocumentStore store = new MemoryDocumentStore();
    final DocumentNodeStore ns1 = builderProvider.newBuilder().setClusterId(1).setDocumentStore(store).setAsyncDelay(asyncDelay).getNodeStore();
    final DocumentNodeStore ns2 = builderProvider.newBuilder().setClusterId(2).setDocumentStore(store).setAsyncDelay(asyncDelay).getNodeStore();
    // create node on ns1
    NodeBuilder builder = ns1.getRoot().builder();
    builder.child("foo");
    ns1.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
    // make visible on ns2
    ns1.runBackgroundOperations();
    ns2.runBackgroundOperations();
    // create checkpoint on ns1
    String cp1 = ns1.checkpoint(Long.MAX_VALUE);
    // retrieve checkpoint on ns2
    NodeState root = ns2.retrieve(cp1);
    assertNotNull(root);
    assertTrue(root.hasChildNode("foo"));
    ns2.release(cp1);
    // create node on ns1
    builder = ns1.getRoot().builder();
    builder.child("bar");
    ns1.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
    // create checkpoint when 'bar' is not yet visible to ns2
    final String cp2 = ns1.checkpoint(Long.MAX_VALUE);
    // retrieve checkpoint on ns2
    final NodeState[] state = new NodeState[1];
    Thread t = new Thread(new Runnable() {

        @Override
        public void run() {
            state[0] = ns2.retrieve(cp2);
        }
    });
    t.start();
    ns1.runBackgroundOperations();
    ns2.runBackgroundOperations();
    t.join();
    assertNotNull(state[0]);
    assertTrue(state[0].hasChildNode("bar"));
}
Also used : MemoryDocumentStore(org.apache.jackrabbit.oak.plugins.document.memory.MemoryDocumentStore) NodeState(org.apache.jackrabbit.oak.spi.state.NodeState) MemoryDocumentStore(org.apache.jackrabbit.oak.plugins.document.memory.MemoryDocumentStore) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) Test(org.junit.Test)

Example 70 with NodeState

use of org.apache.jackrabbit.oak.spi.state.NodeState in project jackrabbit-oak by apache.

the class AtomicCounterEditorTest method notCluster.

@Test
public void notCluster() throws CommitFailedException {
    NodeBuilder builder;
    NodeState before, after;
    builder = EMPTY_NODE.builder();
    before = builder.getNodeState();
    builder = setMixin(builder);
    builder = incrementBy(builder, INCREMENT_BY_1);
    after = builder.getNodeState();
    builder = HOOK_NO_CLUSTER.processCommit(before, after, EMPTY).builder();
    assertCounterNodeState(builder, ImmutableSet.of(PREFIX_PROP_COUNTER, PREFIX_PROP_REVISION), 1);
    before = builder.getNodeState();
    builder = incrementBy(builder, INCREMENT_BY_2);
    after = builder.getNodeState();
    builder = HOOK_NO_CLUSTER.processCommit(before, after, EMPTY).builder();
    assertCounterNodeState(builder, ImmutableSet.of(PREFIX_PROP_COUNTER, PREFIX_PROP_REVISION), 3);
}
Also used : NodeState(org.apache.jackrabbit.oak.spi.state.NodeState) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) Test(org.junit.Test)

Aggregations

NodeState (org.apache.jackrabbit.oak.spi.state.NodeState)580 Test (org.junit.Test)375 NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)254 EmptyNodeState (org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState)69 CommitFailedException (org.apache.jackrabbit.oak.api.CommitFailedException)46 PropertyState (org.apache.jackrabbit.oak.api.PropertyState)45 ChildNodeEntry (org.apache.jackrabbit.oak.spi.state.ChildNodeEntry)43 FilterImpl (org.apache.jackrabbit.oak.query.index.FilterImpl)39 EditorHook (org.apache.jackrabbit.oak.spi.commit.EditorHook)36 MemoryNodeStore (org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore)33 AbstractNodeState (org.apache.jackrabbit.oak.spi.state.AbstractNodeState)32 NodeStore (org.apache.jackrabbit.oak.spi.state.NodeStore)29 Nonnull (javax.annotation.Nonnull)28 Tree (org.apache.jackrabbit.oak.api.Tree)23 NodeStateTestUtils.getNodeState (org.apache.jackrabbit.oak.upgrade.util.NodeStateTestUtils.getNodeState)23 MemoryDocumentStore (org.apache.jackrabbit.oak.plugins.document.memory.MemoryDocumentStore)19 DocumentNodeState (org.apache.jackrabbit.oak.plugins.document.DocumentNodeState)18 ArrayList (java.util.ArrayList)17 CommitInfo (org.apache.jackrabbit.oak.spi.commit.CommitInfo)16 AbstractSecurityTest (org.apache.jackrabbit.oak.AbstractSecurityTest)15