use of org.apache.jackrabbit.oak.stats.StatisticsProvider in project jackrabbit-oak by apache.
the class OutOfBandIndexer method configureEstimators.
private void configureEstimators(IndexUpdate indexUpdate) {
StatisticsProvider statsProvider = indexHelper.getStatisticsProvider();
if (statsProvider instanceof MetricStatisticsProvider) {
MetricRegistry registry = ((MetricStatisticsProvider) statsProvider).getRegistry();
indexUpdate.setTraversalRateEstimator(new MetricRateEstimator(REINDEX_LANE, registry));
}
NodeCounterMBeanEstimator estimator = new NodeCounterMBeanEstimator(indexHelper.getNodeStore());
indexUpdate.setNodeCountEstimator(estimator);
}
use of org.apache.jackrabbit.oak.stats.StatisticsProvider in project jackrabbit-oak by apache.
the class CompactionAndCleanupIT method concurrentWritesCleanupNoNewGen.
/**
* Test asserting OAK-4669: No new generation of tar should be created when the segments are the same
* and when various indices are created.
*/
@Test
public void concurrentWritesCleanupNoNewGen() throws Exception {
ScheduledExecutorService scheduler = newSingleThreadScheduledExecutor();
StatisticsProvider statsProvider = new DefaultStatisticsProvider(scheduler);
final FileStoreGCMonitor fileStoreGCMonitor = new FileStoreGCMonitor(Clock.SIMPLE);
File fileStoreFolder = getFileStoreFolder();
final FileStore fileStore = fileStoreBuilder(fileStoreFolder).withGCOptions(defaultGCOptions().setRetainedGenerations(2)).withGCMonitor(fileStoreGCMonitor).withStatisticsProvider(statsProvider).withMaxFileSize(1).withMemoryMapping(false).build();
final SegmentNodeStore nodeStore = SegmentNodeStoreBuilders.builder(fileStore).build();
ExecutorService executorService = newFixedThreadPool(5);
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, 512 * 512));
nodeStore.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
fileStore.flush();
return null;
}
};
List<Future<?>> results = newArrayList();
for (int i = 0; i < 5; i++) {
results.add(executorService.submit(concurrentWriteTask));
}
for (Future<?> result : results) {
assertNull(result.get());
}
fileStore.cleanup();
for (String fileName : fileStoreFolder.list()) {
if (fileName.endsWith(".tar")) {
int pos = fileName.length() - "a.tar".length();
char generation = fileName.charAt(pos);
assertTrue("Expected generation is 'a', but instead was: '" + generation + "' for file " + fileName, generation == 'a');
}
}
} finally {
new ExecutorCloser(executorService).close();
fileStore.close();
new ExecutorCloser(scheduler).close();
}
}
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 FileStoreStatsTest method tarWriterIntegration.
@Test
public void tarWriterIntegration() throws Exception {
StatisticsProvider statsProvider = new DefaultStatisticsProvider(executor);
File directory = segmentFolder.newFolder();
FileStore store = fileStoreBuilder(directory).withStatisticsProvider(statsProvider).build();
FileStoreStats stats = new FileStoreStats(statsProvider, store, 0);
try {
long initialSize = stats.getApproximateSize();
UUID id = UUID.randomUUID();
long msb = id.getMostSignificantBits();
// OAK-1672
long lsb = id.getLeastSignificantBits() & (-1 >>> 4);
byte[] data = "Hello, World!".getBytes(UTF_8);
try (TarWriter writer = new TarWriter(directory, stats, 0, new IOMonitorAdapter())) {
writer.writeEntry(msb, lsb, data, 0, data.length, 0);
assertEquals(stats.getApproximateSize() - initialSize, writer.fileLength());
}
} finally {
store.close();
}
assertEquals(1, stats.getJournalWriteStatsAsCount());
}
use of org.apache.jackrabbit.oak.stats.StatisticsProvider in project jackrabbit-oak by apache.
the class FileStoreStatsTest method initCall.
@Test
public void initCall() throws Exception {
FileStore store = mock(FileStore.class);
StatisticsProvider statsProvider = new DefaultStatisticsProvider(executor);
FileStoreStats stats = new FileStoreStats(statsProvider, store, 1000);
assertEquals(1000, stats.getApproximateSize());
stats.written(500);
assertEquals(1500, stats.getApproximateSize());
stats.reclaimed(250);
assertEquals(1250, stats.getApproximateSize());
assertEquals(1, stats.getTarFileCount());
}
Aggregations