Search in sources :

Example 1 with MemoryStore

use of org.apache.jackrabbit.oak.segment.memory.MemoryStore in project jackrabbit-oak by apache.

the class LockBasedSchedulerCheckpointTest method testShortWait.

/**
     * OAK-3587 test simulates a timeout while trying to create a checkpoint,
     * then releases the lock and tries again
     */
@Test
public void testShortWait() throws Exception {
    MemoryStore ms = new MemoryStore();
    System.setProperty("oak.checkpoints.lockWaitTime", "1");
    final LockBasedScheduler scheduler = LockBasedScheduler.builder(ms.getRevisions(), ms.getReader()).build();
    final Semaphore semaphore = new Semaphore(0);
    final AtomicBoolean blocking = new AtomicBoolean(true);
    final Callable<Boolean> block = new Callable<Boolean>() {

        @Override
        public Boolean call() {
            while (blocking.get()) {
                if (semaphore.availablePermits() == 0) {
                    semaphore.release();
                }
            }
            return true;
        }
    };
    Thread background = new Thread() {

        @Override
        public void run() {
            try {
                Commit commit = createBlockingCommit(scheduler, "foo", "bar", block);
                scheduler.schedule(commit);
            } catch (Exception e) {
            //
            }
        }
    };
    background.start();
    semaphore.acquire();
    String cp0 = scheduler.checkpoint(10, Collections.<String, String>emptyMap());
    assertNull(retrieveCheckpoint(scheduler, cp0));
    blocking.set(false);
    String cp1 = scheduler.checkpoint(10, Collections.<String, String>emptyMap());
    assertNotNull(retrieveCheckpoint(scheduler, cp1));
}
Also used : MemoryStore(org.apache.jackrabbit.oak.segment.memory.MemoryStore) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Semaphore(java.util.concurrent.Semaphore) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Callable(java.util.concurrent.Callable) Test(org.junit.Test)

Example 2 with MemoryStore

use of org.apache.jackrabbit.oak.segment.memory.MemoryStore in project jackrabbit-oak by apache.

the class LongNameTest method longNameOnSegmentStoreWorksFine.

@Test
public void longNameOnSegmentStoreWorksFine() throws RepositoryException, IOException {
    SegmentNodeStore nodeStore = SegmentNodeStoreBuilders.builder(new MemoryStore()).build();
    upgrade(nodeStore, false, false);
    NodeState parent = getParent(nodeStore.getRoot());
    Assert.assertTrue(parent.hasChildNode(NOT_TOO_LONG_NAME));
    Assert.assertTrue(parent.hasChildNode(TOO_LONG_NAME));
}
Also used : MemoryStore(org.apache.jackrabbit.oak.segment.memory.MemoryStore) NodeState(org.apache.jackrabbit.oak.spi.state.NodeState) SegmentNodeStore(org.apache.jackrabbit.oak.segment.SegmentNodeStore) Test(org.junit.Test)

Example 3 with MemoryStore

use of org.apache.jackrabbit.oak.segment.memory.MemoryStore in project jackrabbit-oak by apache.

the class RepositorySidegradeTest method upgradeRepository.

@Before
public synchronized void upgradeRepository() throws Exception {
    targetNodeStore = SegmentNodeStoreBuilders.builder(new MemoryStore()).build();
    targetRepository = new Jcr(new Oak(targetNodeStore)).createRepository();
    NodeStore source = createSourceContent();
    RepositorySidegrade sidegrade = new RepositorySidegrade(source, targetNodeStore);
    sidegrade.copy();
}
Also used : MemoryStore(org.apache.jackrabbit.oak.segment.memory.MemoryStore) NodeStore(org.apache.jackrabbit.oak.spi.state.NodeStore) Jcr(org.apache.jackrabbit.oak.jcr.Jcr) Oak(org.apache.jackrabbit.oak.Oak) Before(org.junit.Before)

Example 4 with MemoryStore

use of org.apache.jackrabbit.oak.segment.memory.MemoryStore in project jackrabbit-oak by apache.

the class HiddenNodeTest method before.

@Before
public void before() throws Exception {
    store = SegmentNodeStoreBuilders.builder(new MemoryStore()).build();
    repo = new Jcr(store).createRepository();
    session = repo.login(new SimpleCredentials("admin", "admin".toCharArray()));
    vMgr = session.getWorkspace().getVersionManager();
}
Also used : MemoryStore(org.apache.jackrabbit.oak.segment.memory.MemoryStore) SimpleCredentials(javax.jcr.SimpleCredentials) Jcr(org.apache.jackrabbit.oak.jcr.Jcr) Before(org.junit.Before)

Example 5 with MemoryStore

use of org.apache.jackrabbit.oak.segment.memory.MemoryStore in project jackrabbit-oak by apache.

the class MergeTest method testSequentialMerge.

@Test
public void testSequentialMerge() throws CommitFailedException, IOException {
    NodeStore store = SegmentNodeStoreBuilders.builder(new MemoryStore()).build();
    assertFalse(store.getRoot().hasProperty("foo"));
    assertFalse(store.getRoot().hasProperty("bar"));
    NodeBuilder a = store.getRoot().builder();
    a.setProperty("foo", "abc");
    store.merge(a, EmptyHook.INSTANCE, CommitInfo.EMPTY);
    assertTrue(store.getRoot().hasProperty("foo"));
    assertFalse(store.getRoot().hasProperty("bar"));
    NodeBuilder b = store.getRoot().builder();
    b.setProperty("bar", "xyz");
    store.merge(b, EmptyHook.INSTANCE, CommitInfo.EMPTY);
    assertTrue(store.getRoot().hasProperty("foo"));
    assertTrue(store.getRoot().hasProperty("bar"));
}
Also used : MemoryStore(org.apache.jackrabbit.oak.segment.memory.MemoryStore) NodeStore(org.apache.jackrabbit.oak.spi.state.NodeStore) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) Test(org.junit.Test)

Aggregations

MemoryStore (org.apache.jackrabbit.oak.segment.memory.MemoryStore)28 Test (org.junit.Test)15 NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)9 NodeStore (org.apache.jackrabbit.oak.spi.state.NodeStore)9 Before (org.junit.Before)7 Oak (org.apache.jackrabbit.oak.Oak)6 Jcr (org.apache.jackrabbit.oak.jcr.Jcr)6 SegmentNodeStore (org.apache.jackrabbit.oak.segment.SegmentNodeStore)4 Session (javax.jcr.Session)3 NodeState (org.apache.jackrabbit.oak.spi.state.NodeState)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2 InputStream (java.io.InputStream)2 Callable (java.util.concurrent.Callable)2 Semaphore (java.util.concurrent.Semaphore)2 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)2 Node (javax.jcr.Node)2 JackrabbitSession (org.apache.jackrabbit.api.JackrabbitSession)2 InitialContent (org.apache.jackrabbit.oak.InitialContent)2 IOException (java.io.IOException)1 StringReader (java.io.StringReader)1