use of org.apache.jackrabbit.oak.stats.StatisticsProvider 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.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);
Whiteboard wb = options.getWhiteboard();
Closer closer = Closer.create();
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, Collections.emptyMap());
NodeStore store;
if (commonOpts.isMongo() || commonOpts.isRDB()) {
store = configureDocumentMk(options, blobStore, statisticsProvider, closer, wb, readOnly);
} else {
store = configureSegment(options, blobStore, statisticsProvider, closer, readOnly);
}
return new SimpleNodeStoreFixture(store, blobStore, wb, closer);
}
use of org.apache.jackrabbit.oak.stats.StatisticsProvider in project jackrabbit-oak by apache.
the class JsonIndexCommand method createLuceneIndexEditorProvider.
private static LuceneIndexEditorProvider createLuceneIndexEditorProvider() {
LuceneIndexEditorProvider ep = new LuceneIndexEditorProvider();
ScheduledExecutorService executorService = MoreExecutors.getExitingScheduledExecutorService((ScheduledThreadPoolExecutor) Executors.newScheduledThreadPool(5));
StatisticsProvider statsProvider = StatisticsProvider.NOOP;
int queueSize = Integer.getInteger("queueSize", 1000);
IndexTracker tracker = new IndexTracker();
DocumentQueue queue = new DocumentQueue(queueSize, tracker, executorService, statsProvider);
ep.setIndexingQueue(queue);
return ep;
}
use of org.apache.jackrabbit.oak.stats.StatisticsProvider in project jackrabbit-oak by apache.
the class CompactionAndCleanupIT method concurrentWritesCleanupZeroReclaimedSize.
@Test
public void concurrentWritesCleanupZeroReclaimedSize() throws Exception {
ScheduledExecutorService scheduler = newSingleThreadScheduledExecutor();
StatisticsProvider statsProvider = new DefaultStatisticsProvider(scheduler);
final FileStoreGCMonitor fileStoreGCMonitor = new FileStoreGCMonitor(Clock.SIMPLE);
final FileStore fileStore = fileStoreBuilder(getFileStoreFolder()).withGCOptions(defaultGCOptions().setRetainedGenerations(2)).withGCMonitor(fileStoreGCMonitor).withStatisticsProvider(statsProvider).withMaxFileSize(1).withMemoryMapping(false).build();
final SegmentNodeStore nodeStore = SegmentNodeStoreBuilders.builder(fileStore).build();
ExecutorService executorService = newFixedThreadPool(100);
final AtomicInteger counter = new AtomicInteger();
try {
Callable<Void> concurrentWriteTask = new Callable<Void>() {
@Override
public Void call() throws Exception {
NodeBuilder builder = nodeStore.getRoot().builder();
builder.setProperty("blob-" + counter.getAndIncrement(), createBlob(nodeStore, 25 * 25));
nodeStore.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
fileStore.flush();
return null;
}
};
List<Future<?>> results = newArrayList();
for (int i = 0; i < 100; i++) {
results.add(executorService.submit(concurrentWriteTask));
}
Thread.sleep(100);
fileStore.cleanup();
for (Future<?> result : results) {
assertNull(result.get());
}
long reclaimedSize = fileStoreGCMonitor.getLastReclaimedSize();
assertEquals("Reclaimed size expected is 0, but instead was: " + reclaimedSize, 0, reclaimedSize);
} finally {
new ExecutorCloser(executorService).close();
fileStore.close();
new ExecutorCloser(scheduler).close();
}
}
Aggregations