use of org.apache.jackrabbit.oak.jcr.Jcr in project jackrabbit-oak by apache.
the class PersistentCacheTest method createRepository.
@Override
protected Repository[] createRepository(RepositoryFixture fixture) throws Exception {
System.setProperty("PersistentCacheStats.rejectedPut", "true");
if (fixture instanceof OakRepositoryFixture) {
OakFixture oakFixture = ((OakRepositoryFixture) fixture).getOakFixture();
if (oakFixture instanceof OakFixture.MongoFixture) {
OakFixture.MongoFixture mongoFixture = (OakFixture.MongoFixture) oakFixture;
DocumentMK.Builder builder = mongoFixture.getBuilder(1);
builder.setStatisticsProvider(statsProvider);
builder.setPersistentCache("target/persistentCache,time," + CACHE_OPTIONS);
dns = builder.getNodeStore();
nodesCache = DocumentNodeStoreHelper.getNodesCache(dns);
Oak[] cluster = mongoFixture.setUpCluster(new DocumentMK.Builder[] { builder }, statsProvider);
return new Repository[] { new Jcr(cluster[0]).createRepository() };
}
}
throw new IllegalArgumentException("Fixture " + fixture + " not supported for this benchmark.");
}
use of org.apache.jackrabbit.oak.jcr.Jcr in project jackrabbit-oak by apache.
the class ObservationTest method run.
@Override
public void run(Iterable<RepositoryFixture> fixtures) {
for (RepositoryFixture fixture : fixtures) {
if (fixture.isAvailable(1)) {
System.out.format("%s: Observation throughput benchmark%n", fixture);
try {
final AtomicReference<Whiteboard> whiteboardRef = new AtomicReference<Whiteboard>();
Repository[] cluster;
if (fixture instanceof OakRepositoryFixture) {
cluster = ((OakRepositoryFixture) fixture).setUpCluster(1, new JcrCreator() {
@Override
public Jcr customize(Oak oak) {
whiteboardRef.set(oak.getWhiteboard());
return new Jcr(oak);
}
});
} else {
cluster = fixture.setUpCluster(1);
}
try {
run(cluster[0], whiteboardRef.get());
} finally {
fixture.tearDownCluster();
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
use of org.apache.jackrabbit.oak.jcr.Jcr 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.jcr.Jcr in project jackrabbit-oak by apache.
the class RevisionGCTest method run.
@Override
public void run(Iterable<RepositoryFixture> fixtures) {
for (RepositoryFixture fixture : fixtures) {
if (fixture.isAvailable(1)) {
System.out.format("%s: RevisionGC benchmark%n", fixture);
try {
final AtomicReference<Oak> whiteboardRef = new AtomicReference<Oak>();
Repository[] cluster;
if (fixture instanceof OakRepositoryFixture) {
cluster = ((OakRepositoryFixture) fixture).setUpCluster(1, new JcrCreator() {
@Override
public Jcr customize(Oak oak) {
whiteboardRef.set(oak);
return new Jcr(oak);
}
});
} else {
System.err.format("%s: RevisionGC benchmark only runs on Oak%n", fixture);
return;
}
try {
run(cluster[0], getNodeStore(whiteboardRef.get()));
} finally {
fixture.tearDownCluster();
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
use of org.apache.jackrabbit.oak.jcr.Jcr in project jackrabbit-oak by apache.
the class JsonIndexCommand method openSession.
public static Session openSession(NodeStore nodeStore) throws RepositoryException {
if (nodeStore == null) {
return null;
}
StatisticsProvider statisticsProvider = StatisticsProvider.NOOP;
Oak oak = new Oak(nodeStore).with(ManagementFactory.getPlatformMBeanServer());
oak.getWhiteboard().register(StatisticsProvider.class, statisticsProvider, Collections.emptyMap());
LuceneIndexProvider provider = createLuceneIndexProvider();
oak.with((QueryIndexProvider) provider).with((Observer) provider).with(createLuceneIndexEditorProvider());
Jcr jcr = new Jcr(oak);
Repository repository = jcr.createRepository();
return repository.login(new SimpleCredentials("admin", "admin".toCharArray()));
}
Aggregations