use of org.apache.jackrabbit.oak.segment.file.InvalidFileStoreVersionException in project jackrabbit-oak by apache.
the class IOTracerTest method collectBreadthFirstTrace.
@Test
public void collectBreadthFirstTrace() throws IOException, InvalidFileStoreVersionException {
try (StringWriter out = new StringWriter()) {
Function<IOMonitor, FileStore> factory = this::createFileStore;
IOTracer ioTracer = newIOTracer(factory, out, BreadthFirstTrace.CONTEXT_SPEC);
ioTracer.collectTrace(new BreadthFirstTrace(2, "/", ioTracer::setContext));
try (BufferedReader reader = new BufferedReader(new StringReader(out.toString()))) {
Optional<String> header = reader.lines().findFirst();
List<String[]> entries = reader.lines().map(line -> line.split(",")).collect(toList());
assertTrue(header.isPresent());
assertEquals("timestamp,file,segmentId,length,elapsed,depth,count", header.get());
long now = currentTimeMillis();
assertTrue("The timestamps of all entries must be in the past", entries.stream().map(// ts
row -> parseLong(row[0])).allMatch(ts -> ts <= now));
assertEquals("Expected depths 0, 1 and 2", ImmutableSet.of(0, 1, 2), entries.stream().map(// depth
row -> parseInt(row[5])).distinct().collect(toSet()));
assertEquals("Expected max 10 nodes", Optional.of(true), entries.stream().map(// count
row -> parseInt(row[6])).max(Comparator.naturalOrder()).map(max -> max <= 10));
}
}
}
use of org.apache.jackrabbit.oak.segment.file.InvalidFileStoreVersionException in project jackrabbit-oak by apache.
the class IncludeExcludeSidegradeTest method doUpgradeRepository.
@Override
protected void doUpgradeRepository(File source, NodeStore target) throws RepositoryException, IOException {
FileStore fileStore;
try {
fileStore = fileStoreBuilder(source).build();
} catch (InvalidFileStoreVersionException e) {
throw new IllegalStateException(e);
}
SegmentNodeStore segmentNodeStore = SegmentNodeStoreBuilders.builder(fileStore).build();
try {
final RepositorySidegrade sidegrade = new RepositorySidegrade(segmentNodeStore, target);
sidegrade.setIncludes("/content/foo/en", "/content/assets/foo", "/content/other");
sidegrade.setExcludes("/content/assets/foo/2013", "/content/assets/foo/2012", "/content/assets/foo/2011", "/content/assets/foo/2010");
sidegrade.copy();
} finally {
fileStore.close();
}
}
use of org.apache.jackrabbit.oak.segment.file.InvalidFileStoreVersionException in project jackrabbit-oak by apache.
the class SegmentTarFactory method create.
@Override
public NodeStore create(BlobStore blobStore, Closer closer) throws IOException {
final FileStoreBuilder builder = fileStoreBuilder(new File(dir, "segmentstore"));
if (blobStore != null) {
builder.withBlobStore(blobStore);
}
builder.withMaxFileSize(256);
if (disableMmap) {
builder.withMemoryMapping(false);
} else {
builder.withDefaultMemoryMapping();
}
try {
if (readOnly) {
final ReadOnlyFileStore fs;
fs = builder.buildReadOnly();
closer.register(asCloseable(fs));
return SegmentNodeStoreBuilders.builder(fs).build();
} else {
final FileStore fs;
fs = builder.build();
closer.register(asCloseable(fs));
return new NodeStoreWithFileStore(SegmentNodeStoreBuilders.builder(fs).build(), fs);
}
} catch (InvalidFileStoreVersionException e) {
throw new IllegalStateException(e);
}
}
use of org.apache.jackrabbit.oak.segment.file.InvalidFileStoreVersionException in project jackrabbit-oak by apache.
the class NodeStoreFixtureProvider method create.
public static NodeStoreFixture create(Options options, boolean readOnly) throws Exception {
CommonOptions commonOpts = options.getOptionBean(CommonOptions.class);
Closer closer = Closer.create();
Whiteboard wb = new ClosingWhiteboard(options.getWhiteboard(), closer);
BlobStoreFixture blobFixture = BlobStoreFixtureProvider.create(options);
BlobStore blobStore = null;
if (blobFixture != null) {
blobStore = blobFixture.getBlobStore();
closer.register(blobFixture);
}
StatisticsProvider statisticsProvider = createStatsProvider(options, wb, closer);
wb.register(StatisticsProvider.class, statisticsProvider, emptyMap());
NodeStore store;
if (commonOpts.isMemory()) {
store = new MemoryNodeStore();
} else if (commonOpts.isMongo() || commonOpts.isRDB()) {
DocumentNodeStore dns = DocumentFixtureProvider.configureDocumentMk(options, blobStore, wb, closer, readOnly);
store = dns;
if (blobStore == null) {
blobStore = dns.getBlobStore();
}
} else if (commonOpts.isOldSegment()) {
store = SegmentFixtureProvider.create(options, blobStore, wb, closer, readOnly);
} else {
try {
store = SegmentTarFixtureProvider.configureSegment(options, blobStore, wb, closer, readOnly);
} catch (InvalidFileStoreVersionException e) {
if (oldSegmentStore(options)) {
store = SegmentFixtureProvider.create(options, blobStore, wb, closer, readOnly);
} else {
throw e;
}
}
}
return new SimpleNodeStoreFixture(store, blobStore, wb, closer);
}
Aggregations