use of org.apache.jackrabbit.oak.segment.SegmentNodeStore in project jackrabbit-oak by apache.
the class BrokenVersionableTest method createSourceContent.
private NodeStore createSourceContent() throws Exception {
SegmentNodeStore source = SegmentNodeStoreBuilders.builder(new MemoryStore()).build();
RepositoryImpl repository = (RepositoryImpl) new Jcr(new Oak(source)).createRepository();
Session session = repository.login(CREDENTIALS);
List<String> versionHistoryPaths = new ArrayList<String>();
try {
CndImporter.registerNodeTypes(new StringReader("<test = 'http://jackrabbit.apache.org/ns/test'>\n" + "[test:Versionable] > nt:unstructured, mix:versionable"), session);
Node root = session.getRootNode();
Node versionable1 = root.addNode("versionable1", NT_UNSTRUCTURED);
versionable1.addMixin(MIX_VERSIONABLE);
versionable1.addNode("child", NT_UNSTRUCTURED);
Node versionable2 = root.addNode("versionable2", "test:Versionable");
versionable2.addNode("child", NT_UNSTRUCTURED);
session.save();
VersionManager vMgr = session.getWorkspace().getVersionManager();
vMgr.checkin("/versionable1");
vMgr.checkin("/versionable2");
versionHistoryPaths.add(vMgr.getVersionHistory("/versionable1").getPath());
versionHistoryPaths.add(vMgr.getVersionHistory("/versionable2").getPath());
} finally {
session.logout();
repository.shutdown();
}
// remove version history to corrupt the JCR repository structure
NodeBuilder rootBuilder = source.getRoot().builder();
for (String versionHistoryPath : versionHistoryPaths) {
NodeStateTestUtils.createOrGetBuilder(rootBuilder, versionHistoryPath).remove();
}
source.merge(rootBuilder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
return source;
}
use of org.apache.jackrabbit.oak.segment.SegmentNodeStore in project jackrabbit-oak by apache.
the class SegmentReferenceLimitTestIT method corruption.
@Test
public void corruption() throws Exception {
FileStore fileStore = fileStoreBuilder(getFileStoreFolder()).withMaxFileSize(1).withSegmentCacheSize(0).withStringCacheSize(0).withTemplateCacheSize(0).withNodeDeduplicationCacheSize(1).withStringDeduplicationCacheSize(0).withTemplateDeduplicationCacheSize(0).withMemoryMapping(true).build();
SegmentNodeStore nodeStore = SegmentNodeStoreBuilders.builder(fileStore).build();
NodeBuilder root = nodeStore.getRoot().builder();
root.setChildNode("test");
nodeStore.merge(root, EmptyHook.INSTANCE, CommitInfo.EMPTY);
List<FutureTask<Void>> l = new ArrayList<FutureTask<Void>>();
for (int i = 0; i < 10; i++) {
l.add(run(new Worker(nodeStore, "w" + i)));
}
try {
for (FutureTask<Void> w : l) {
w.get();
}
} finally {
fileStore.close();
}
}
use of org.apache.jackrabbit.oak.segment.SegmentNodeStore in project jackrabbit-oak by apache.
the class FileStoreStatsTest method testJournalWriteStats.
@Test
public void testJournalWriteStats() throws Exception {
StatisticsProvider statsProvider = new DefaultStatisticsProvider(executor);
FileStore fileStore = fileStoreBuilder(segmentFolder.newFolder()).withStatisticsProvider(statsProvider).build();
FileStoreStats stats = new FileStoreStats(statsProvider, fileStore, 0);
SegmentNodeStore nodeStore = SegmentNodeStoreBuilders.builder(fileStore).build();
for (int i = 0; i < 10; i++) {
NodeBuilder root = nodeStore.getRoot().builder();
root.setProperty("count", i);
nodeStore.merge(root, EmptyHook.INSTANCE, CommitInfo.EMPTY);
fileStore.flush();
}
assertEquals(10, stats.getJournalWriteStatsAsCount());
}
use of org.apache.jackrabbit.oak.segment.SegmentNodeStore in project jackrabbit-oak by apache.
the class CheckRepositoryTestBase method addValidRevision.
protected void addValidRevision() throws InvalidFileStoreVersionException, IOException, CommitFailedException {
FileStore fileStore = FileStoreBuilder.fileStoreBuilder(temporaryFolder.getRoot()).withMaxFileSize(256).withSegmentCacheSize(64).build();
SegmentNodeStore nodeStore = SegmentNodeStoreBuilders.builder(fileStore).build();
NodeBuilder builder = nodeStore.getRoot().builder();
addChildWithBlobProperties(nodeStore, builder, "a", 1);
addChildWithBlobProperties(nodeStore, builder, "b", 2);
addChildWithBlobProperties(nodeStore, builder, "c", 3);
addChildWithProperties(nodeStore, builder, "d", 4);
addChildWithProperties(nodeStore, builder, "e", 5);
addChildWithProperties(nodeStore, builder, "f", 6);
nodeStore.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
fileStore.close();
}
use of org.apache.jackrabbit.oak.segment.SegmentNodeStore in project jackrabbit-oak by apache.
the class CheckRepositoryTestBase method addInvalidRevision.
protected void addInvalidRevision() throws InvalidFileStoreVersionException, IOException, CommitFailedException {
FileStore fileStore = FileStoreBuilder.fileStoreBuilder(temporaryFolder.getRoot()).withMaxFileSize(256).withSegmentCacheSize(64).build();
SegmentNodeStore nodeStore = SegmentNodeStoreBuilders.builder(fileStore).build();
NodeBuilder builder = nodeStore.getRoot().builder();
// add a new child "z"
addChildWithBlobProperties(nodeStore, builder, "z", 5);
// add a new property value to existing child "a"
addChildWithBlobProperties(nodeStore, builder, "a", 1);
NodeState after = nodeStore.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
// get record number to corrupt (NODE record for "z")
SegmentNodeState child = (SegmentNodeState) after.getChildNode("z");
int zRecordNumber = child.getRecordId().getRecordNumber();
// get record number to corrupt (NODE record for "a")
child = (SegmentNodeState) after.getChildNode("a");
int aRecordNumber = child.getRecordId().getRecordNumber();
fileStore.close();
corruptRecord(zRecordNumber);
corruptRecord(aRecordNumber);
}
Aggregations