Search in sources :

Example 1 with SegmentNodeStore

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

the class CompactionEstimatorTest method testGainEstimator.

@Test
public void testGainEstimator() throws Exception {
    final int MB = 1024 * 1024;
    final int blobSize = 2 * MB;
    FileStore fileStore = fileStoreBuilder(getFileStoreFolder()).withMaxFileSize(2).withMemoryMapping(false).build();
    SegmentNodeStore nodeStore = SegmentNodeStoreBuilders.builder(fileStore).build();
    // 1. Create some blob properties
    NodeBuilder builder = nodeStore.getRoot().builder();
    NodeBuilder c1 = builder.child("c1");
    c1.setProperty("a", createBlob(nodeStore, blobSize));
    c1.setProperty("b", "foo");
    NodeBuilder c2 = builder.child("c2");
    c2.setProperty("a", createBlob(nodeStore, blobSize));
    c2.setProperty("b", "foo");
    NodeBuilder c3 = builder.child("c3");
    c3.setProperty("a", createBlob(nodeStore, blobSize));
    c3.setProperty("b", "foo");
    nodeStore.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
    // 2. Now remove the property
    builder = nodeStore.getRoot().builder();
    builder.child("c1").remove();
    builder.child("c2").remove();
    nodeStore.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
    fileStore.flush();
    try {
        GCEstimation est = fileStore.estimateCompactionGain();
        assertTrue(est.gcNeeded());
    } finally {
        fileStore.close();
    }
}
Also used : SegmentNodeStore(org.apache.jackrabbit.oak.segment.SegmentNodeStore) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) Test(org.junit.Test)

Example 2 with SegmentNodeStore

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

the class JournalEntryTest method timestampInJournalEntry.

@Test
public void timestampInJournalEntry() throws Exception {
    FileStore fileStore = fileStoreBuilder(tempFolder.getRoot()).withMaxFileSize(5).withSegmentCacheSize(0).withStringCacheSize(0).withTemplateCacheSize(0).withMemoryMapping(true).build();
    SegmentNodeStore nodeStore = SegmentNodeStoreBuilders.builder(fileStore).build();
    long startTime = System.currentTimeMillis();
    for (int i = 0; i < 5; i++) {
        NodeBuilder root = nodeStore.getRoot().builder();
        root.child("c" + i);
        nodeStore.merge(root, EmptyHook.INSTANCE, CommitInfo.EMPTY);
        fileStore.flush();
    }
    fileStore.close();
    File journal = new File(tempFolder.getRoot(), "journal.log");
    List<String> lines = Files.readLines(journal, Charset.defaultCharset());
    assertFalse(lines.isEmpty());
    String line = lines.get(0);
    List<String> parts = journalParts(line);
    assertEquals(3, parts.size());
    long entryTime = Long.valueOf(parts.get(2));
    assertTrue(entryTime >= startTime);
    JournalReader jr = new JournalReader(journal);
    JournalEntry journalEntry = jr.next();
    assertEquals(journalParts(lines.get(lines.size() - 1)).get(0), journalEntry.getRevision());
    assertEquals(journalParts(lines.get(lines.size() - 1)).get(2), String.valueOf(journalEntry.getTimestamp()));
    jr.close();
}
Also used : SegmentNodeStore(org.apache.jackrabbit.oak.segment.SegmentNodeStore) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) File(java.io.File) Test(org.junit.Test)

Example 3 with SegmentNodeStore

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

the class LargeNumberOfPropertiesTestIT method corruption.

@Test
public void corruption() throws Exception {
    FileStore fileStore = fileStoreBuilder(getFileStoreFolder()).withMaxFileSize(5).withSegmentCacheSize(0).withStringCacheSize(0).withTemplateCacheSize(0).withMemoryMapping(true).build();
    SegmentNodeStore nodeStore = SegmentNodeStoreBuilders.builder(fileStore).build();
    NodeBuilder root = nodeStore.getRoot().builder();
    try {
        NodeBuilder c = root.child("c" + System.currentTimeMillis());
        // have (262144)
        for (int i = 0; i < 25; i++) {
            LOG.debug("run {}/24", i);
            for (int j = 0; j < 10000; j++) {
                c.setProperty("int-" + i + "-" + j, i);
            }
        }
        nodeStore.merge(root, EmptyHook.INSTANCE, CommitInfo.EMPTY);
    } finally {
        fileStore.close();
    }
}
Also used : SegmentNodeStore(org.apache.jackrabbit.oak.segment.SegmentNodeStore) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) Test(org.junit.Test)

Example 4 with SegmentNodeStore

use of org.apache.jackrabbit.oak.segment.SegmentNodeStore 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 5 with SegmentNodeStore

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

the class RepeatedRepositorySidegradeTest method upgradeRepository.

@Before
public synchronized void upgradeRepository() throws Exception {
    if (!upgradeComplete) {
        final File sourceDir = new File(getTestDirectory(), "jackrabbit2");
        sourceDir.mkdirs();
        FileStore fileStore = fileStoreBuilder(sourceDir).build();
        SegmentNodeStore segmentNodeStore = SegmentNodeStoreBuilders.builder(fileStore).build();
        RepositoryImpl repository = (RepositoryImpl) new Jcr(new Oak(segmentNodeStore)).createRepository();
        Session session = repository.login(CREDENTIALS);
        try {
            createSourceContent(session);
        } finally {
            session.save();
            session.logout();
            repository.shutdown();
            fileStore.close();
        }
        final NodeStore target = getTargetNodeStore();
        doUpgradeRepository(sourceDir, target, false);
        fileStore.flush();
        fileStore = fileStoreBuilder(sourceDir).build();
        segmentNodeStore = SegmentNodeStoreBuilders.builder(fileStore).build();
        repository = (RepositoryImpl) new Jcr(new Oak(segmentNodeStore)).createRepository();
        session = repository.login(CREDENTIALS);
        try {
            modifySourceContent(session);
        } finally {
            session.save();
            session.logout();
            repository.shutdown();
            fileStore.close();
        }
        doUpgradeRepository(sourceDir, target, true);
        fileStore.flush();
        upgradeComplete = true;
    }
}
Also used : FileStore(org.apache.jackrabbit.oak.segment.file.FileStore) NodeStore(org.apache.jackrabbit.oak.spi.state.NodeStore) SegmentNodeStore(org.apache.jackrabbit.oak.segment.SegmentNodeStore) RepositoryImpl(org.apache.jackrabbit.oak.jcr.repository.RepositoryImpl) Jcr(org.apache.jackrabbit.oak.jcr.Jcr) Oak(org.apache.jackrabbit.oak.Oak) SegmentNodeStore(org.apache.jackrabbit.oak.segment.SegmentNodeStore) File(java.io.File) Session(javax.jcr.Session) Before(org.junit.Before)

Aggregations

SegmentNodeStore (org.apache.jackrabbit.oak.segment.SegmentNodeStore)19 FileStore (org.apache.jackrabbit.oak.segment.file.FileStore)11 NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)10 Test (org.junit.Test)10 File (java.io.File)4 Session (javax.jcr.Session)3 Oak (org.apache.jackrabbit.oak.Oak)3 Jcr (org.apache.jackrabbit.oak.jcr.Jcr)3 RepositoryImpl (org.apache.jackrabbit.oak.jcr.repository.RepositoryImpl)3 MemoryStore (org.apache.jackrabbit.oak.segment.memory.MemoryStore)3 ArrayList (java.util.ArrayList)2 FileStoreBackupImpl (org.apache.jackrabbit.oak.backup.impl.FileStoreBackupImpl)2 InvalidFileStoreVersionException (org.apache.jackrabbit.oak.segment.file.InvalidFileStoreVersionException)2 NodeState (org.apache.jackrabbit.oak.spi.state.NodeState)2 NodeStore (org.apache.jackrabbit.oak.spi.state.NodeStore)2 Directory (org.apache.lucene.store.Directory)2 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)2 Before (org.junit.Before)2 IOException (java.io.IOException)1 StringReader (java.io.StringReader)1