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 CacheAccessTrackerTest method setup.
@Before
public void setup() {
ScheduledExecutorService scheduler = newScheduledThreadPool(1);
StatisticsProvider statistics = new DefaultStatisticsProvider(scheduler);
cache = new CacheAccessTracker<String, RecordId>("foo", statistics, newRecordCache(100));
closer = new ExecutorCloser(scheduler);
accessStats = statistics.getMeter("foo.access-count", StatsOptions.DEFAULT);
missStats = statistics.getMeter("foo.miss-count", StatsOptions.DEFAULT);
}
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();
}
}
use of org.apache.jackrabbit.oak.stats.StatisticsProvider in project jackrabbit-oak by apache.
the class LockBasedSchedulerCheckpointTest method testLongWait.
/**
* OAK-3587 test simulates a wait less than configured
* {@code SegmentNodeStore#setCheckpointsLockWaitTime(int)} value so the
* checkpoint call must return a valid value
*/
@Test
public void testLongWait() throws Exception {
final int blockTime = 1;
MemoryStore ms = new MemoryStore();
System.setProperty("oak.checkpoints.lockWaitTime", "2");
StatisticsProvider statsProvider = StatisticsProvider.NOOP;
SegmentNodeStoreStats stats = new SegmentNodeStoreStats(statsProvider);
final LockBasedScheduler scheduler = LockBasedScheduler.builder(ms.getRevisions(), ms.getReader(), stats).build();
final Semaphore semaphore = new Semaphore(0);
final Callable<Boolean> block = new Callable<Boolean>() {
@Override
public Boolean call() {
try {
semaphore.release();
SECONDS.sleep(blockTime);
} catch (InterruptedException e) {
//
}
return true;
}
};
Thread background = new Thread() {
@Override
public void run() {
try {
Commit commit = createBlockingCommit(scheduler, "foo", "bar", block);
scheduler.schedule(commit);
} catch (Exception e) {
//
}
}
};
background.start();
semaphore.acquire();
String cp0 = scheduler.checkpoint(10, Collections.<String, String>emptyMap());
assertNotNull(retrieveCheckpoint(scheduler, cp0));
}
use of org.apache.jackrabbit.oak.stats.StatisticsProvider in project jackrabbit-oak by apache.
the class S3DataStoreFactory method create.
@Override
public BlobStore create(Closer closer) throws IOException {
S3DataStore delegate = createDS(directory, props);
// Initialize a default stats provider
final ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor();
StatisticsProvider statsProvider = new DefaultStatisticsProvider(executor);
delegate.setStatisticsProvider(statsProvider);
// Reduce staging purge interval to 60 seconds
delegate.setStagingPurgeInterval(60);
try {
delegate.init(tempHomeDir.getPath());
} catch (RepositoryException e) {
throw new IOException(e);
}
closer.register(asCloseable(delegate));
closer.register(new Closeable() {
@Override
public void close() throws IOException {
executor.shutdown();
try {
if (!executor.awaitTermination(30, TimeUnit.SECONDS)) {
throw new IOException("Can't shut down the executor");
}
} catch (InterruptedException e) {
throw new IOException(e);
}
}
});
if (ignoreMissingBlobs) {
return new SafeDataStoreBlobStore(delegate);
} else {
return new DataStoreBlobStore(delegate);
}
}
Aggregations