use of org.apache.jackrabbit.oak.spi.blob.AbstractSharedBackend in project jackrabbit-oak by apache.
the class CachingDataStoreTest method init.
private void init(int i, int cacheSize, int uploadSplit) throws Exception {
LOG.info("Starting init");
// create executor
taskLatch = new CountDownLatch(1);
callbackLatch = new CountDownLatch(1);
afterExecuteLatch = new CountDownLatch(i);
TestExecutor listeningExecutor = new TestExecutor(1, taskLatch, callbackLatch, afterExecuteLatch);
// stats
ScheduledExecutorService statsExecutor = Executors.newSingleThreadScheduledExecutor();
closer.register(new ExecutorCloser(statsExecutor, 500, TimeUnit.MILLISECONDS));
StatisticsProvider statsProvider = new DefaultStatisticsProvider(statsExecutor);
scheduledExecutor = Executors.newSingleThreadScheduledExecutor();
closer.register(new ExecutorCloser(scheduledExecutor, 500, TimeUnit.MILLISECONDS));
final File datastoreRoot = folder.newFolder();
final TestMemoryBackend testBackend = new TestMemoryBackend(datastoreRoot);
this.backend = testBackend;
dataStore = new AbstractSharedCachingDataStore() {
@Override
protected AbstractSharedBackend createBackend() {
return testBackend;
}
@Override
public int getMinRecordLength() {
return 0;
}
};
dataStore.setStatisticsProvider(statsProvider);
dataStore.setCacheSize(cacheSize);
dataStore.setStagingSplitPercentage(uploadSplit);
dataStore.listeningExecutor = listeningExecutor;
dataStore.schedulerExecutor = scheduledExecutor;
dataStore.executor = sameThreadExecutor();
dataStore.init(root.getAbsolutePath());
LOG.info("Finished init");
}
use of org.apache.jackrabbit.oak.spi.blob.AbstractSharedBackend in project jackrabbit-oak by apache.
the class ConsolidatedDataStoreStatsTest method init.
private void init(int i) throws Exception {
testFile = folder.newFile();
copyInputStreamToFile(randomStream(0, 16384), testFile);
String testNodeId = getIdForInputStream(new FileInputStream(testFile));
mockBlob = mock(Blob.class);
when(mockBlob.getContentIdentity()).thenReturn(testNodeId);
nodeStore = initNodeStore(Optional.of(mockBlob), Optional.<Blob>absent(), Optional.<String>absent(), Optional.<Integer>absent(), Optional.<List<Blob>>absent());
// create executor
taskLatch = new CountDownLatch(1);
callbackLatch = new CountDownLatch(1);
afterExecuteLatch = new CountDownLatch(i);
executor = new TestExecutor(1, taskLatch, callbackLatch, afterExecuteLatch);
// stats
ScheduledExecutorService statsExecutor = Executors.newSingleThreadScheduledExecutor();
closer.register(new ExecutorCloser(statsExecutor, 500, TimeUnit.MILLISECONDS));
statsProvider = new DefaultStatisticsProvider(statsExecutor);
scheduledExecutor = Executors.newSingleThreadScheduledExecutor();
closer.register(new ExecutorCloser(scheduledExecutor, 500, TimeUnit.MILLISECONDS));
final File datastoreRoot = folder.newFolder();
dataStore = new AbstractSharedCachingDataStore() {
@Override
protected AbstractSharedBackend createBackend() {
return new TestMemoryBackend(datastoreRoot);
}
@Override
public int getMinRecordLength() {
return 0;
}
};
dataStore.setStatisticsProvider(statsProvider);
dataStore.listeningExecutor = executor;
dataStore.schedulerExecutor = scheduledExecutor;
dataStore.init(root.getAbsolutePath());
stats = new ConsolidatedDataStoreCacheStats();
stats.nodeStore = nodeStore;
stats.cachingDataStore = dataStore;
}
Aggregations