use of org.apache.jackrabbit.oak.plugins.segment.file.FileStore in project jackrabbit by apache.
the class RepositoryStartupServlet method initRepository.
/**
* Creates a new Repository based on the configuration and initializes the
* {@link #repository} field if successful.
*
* @throws ServletException if an error occurs
*/
private void initRepository() throws ServletException {
// get repository config
File repHome;
try {
repHome = new File(config.getRepositoryHome()).getCanonicalFile();
} catch (IOException e) {
throw new ServletExceptionWithCause("Repository configuration failure: " + config.getRepositoryHome(), e);
}
String repConfig = config.getRepositoryConfig();
if (repConfig != null) {
// Jackrabbit Classic
InputStream in = getServletContext().getResourceAsStream(repConfig);
if (in == null) {
try {
in = new FileInputStream(new File(repConfig));
} catch (FileNotFoundException e) {
// fallback to old config
try {
in = new FileInputStream(new File(repHome, repConfig));
} catch (FileNotFoundException e1) {
throw new ServletExceptionWithCause("Repository configuration not found: " + repConfig, e);
}
}
}
try {
repository = createRepository(new InputSource(in), repHome);
} catch (RepositoryException e) {
throw new ServletExceptionWithCause("Error while creating repository", e);
}
} else {
// Jackrabbit Oak
try {
String model = System.getProperty("sun.arch.data.model", "32");
store = new FileStore(repHome, 256, "64".equals(model));
repository = new Jcr(new SegmentNodeStore(store)).createRepository();
} catch (IOException e) {
throw new ServletExceptionWithCause("Error while creating repository", e);
}
}
}
use of org.apache.jackrabbit.oak.plugins.segment.file.FileStore in project jackrabbit-oak by apache.
the class SegmentFactory method hasExternalBlobReferences.
@Override
public boolean hasExternalBlobReferences() throws IOException {
Builder builder = FileStore.builder(new File(dir, "segmentstore"));
builder.withMaxFileSize(256);
builder.withMemoryMapping(false);
FileStore fs;
try {
fs = builder.buildReadOnly();
} catch (InvalidFileStoreVersionException e) {
throw new IOException(e);
}
try {
fs.getTracker().collectBlobReferences(new ReferenceCollector() {
@Override
public void addReference(String reference, @Nullable String nodeId) {
// see java.nio.file.FileVisitor
throw new ExternalBlobFound();
}
});
return false;
} catch (ExternalBlobFound e) {
return true;
} finally {
fs.close();
}
}
use of org.apache.jackrabbit.oak.plugins.segment.file.FileStore in project jackrabbit-oak by apache.
the class SegmentFactory method create.
@Override
public NodeStore create(BlobStore blobStore, Closer closer) throws IOException {
Builder builder = FileStore.builder(new File(dir, "segmentstore"));
if (blobStore != null) {
builder.withBlobStore(blobStore);
}
builder.withMaxFileSize(256);
if (disableMmap) {
builder.withMemoryMapping(false);
} else {
builder.withDefaultMemoryMapping();
}
final FileStore fs;
try {
if (readOnly) {
fs = builder.buildReadOnly();
} else {
fs = builder.build();
}
} catch (InvalidFileStoreVersionException e) {
throw new IllegalStateException(e);
}
closer.register(asCloseable(fs));
return new TarNodeStore(SegmentNodeStore.builder(fs).build(), new TarNodeStore.SuperRootProvider() {
@Override
public NodeState getSuperRoot() {
return fs.getHead();
}
});
}
Aggregations