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();
}
}
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();
}
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();
}
}
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));
}
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;
}
}
Aggregations