use of org.apache.jackrabbit.oak.stats.StatisticsProvider in project jackrabbit-oak by apache.
the class OakFixture method getMemory.
public static OakFixture getMemory(String name, final long cacheSize) {
return new OakFixture(name) {
@Override
public Oak getOak(int clusterId) throws Exception {
Oak oak;
oak = newOak(new MemoryNodeStore());
return oak;
}
@Override
public Oak[] setUpCluster(int n, StatisticsProvider statsProvider) throws Exception {
Oak[] cluster = new Oak[n];
for (int i = 0; i < cluster.length; i++) {
Oak oak;
oak = newOak(new MemoryNodeStore());
cluster[i] = oak;
}
return cluster;
}
@Override
public void tearDownCluster() {
// nothing to do
}
};
}
use of org.apache.jackrabbit.oak.stats.StatisticsProvider 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);
}
use of org.apache.jackrabbit.oak.stats.StatisticsProvider in project jackrabbit-oak by apache.
the class SegmentFixtureProvider method create.
static NodeStore create(Options options, BlobStore blobStore, Whiteboard wb, Closer closer, boolean readOnly) throws IOException, InvalidFileStoreVersionException {
StatisticsProvider statisticsProvider = checkNotNull(getService(wb, StatisticsProvider.class));
String path = options.getOptionBean(CommonOptions.class).getStoreArg();
FileStore.Builder builder = FileStore.builder(new File(path)).withMaxFileSize(256).withDefaultMemoryMapping();
FileStoreBuilderCustomizer customizer = getService(wb, FileStoreBuilderCustomizer.class);
if (customizer != null) {
customizer.customize(builder);
}
if (blobStore != null) {
builder.withBlobStore(blobStore);
}
NodeStore nodeStore;
if (readOnly) {
FileStore.ReadOnlyStore fileStore = builder.withStatisticsProvider(statisticsProvider).buildReadOnly();
closer.register(fileStore);
nodeStore = SegmentNodeStore.builder(fileStore).build();
wb.register(FileStore.ReadOnlyStore.class, fileStore, emptyMap());
} else {
FileStore fileStore = builder.withStatisticsProvider(statisticsProvider).build();
closer.register(fileStore);
nodeStore = SegmentNodeStore.builder(fileStore).build();
wb.register(FileStore.class, fileStore, emptyMap());
}
return nodeStore;
}
use of org.apache.jackrabbit.oak.stats.StatisticsProvider in project jackrabbit-oak by apache.
the class SegmentTarFixtureProvider method configureSegment.
static NodeStore configureSegment(Options options, BlobStore blobStore, Whiteboard wb, Closer closer, boolean readOnly) throws IOException, InvalidFileStoreVersionException {
StatisticsProvider statisticsProvider = checkNotNull(getService(wb, StatisticsProvider.class));
String path = options.getOptionBean(CommonOptions.class).getStoreArg();
FileStoreBuilder builder = fileStoreBuilder(new File(path)).withMaxFileSize(256);
FileStoreTarBuilderCustomizer customizer = getService(wb, FileStoreTarBuilderCustomizer.class);
if (customizer != null) {
customizer.customize(builder);
}
if (blobStore != null) {
builder.withBlobStore(blobStore);
}
NodeStore nodeStore;
if (readOnly) {
ReadOnlyFileStore fileStore = builder.withStatisticsProvider(statisticsProvider).buildReadOnly();
closer.register(fileStore);
nodeStore = SegmentNodeStoreBuilders.builder(fileStore).build();
wb.register(ReadOnlyFileStore.class, fileStore, emptyMap());
} else {
FileStore fileStore = builder.withStrictVersionCheck(true).withStatisticsProvider(statisticsProvider).build();
closer.register(fileStore);
nodeStore = SegmentNodeStoreBuilders.builder(fileStore).build();
wb.register(FileStore.class, fileStore, emptyMap());
}
return nodeStore;
}
use of org.apache.jackrabbit.oak.stats.StatisticsProvider in project jackrabbit-oak by apache.
the class JsonIndexCommand method openSession.
public static Session openSession(NodeStore nodeStore, String user, String password) 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(user, password.toCharArray()));
}
Aggregations