Search in sources :

Example 1 with AbstractSharedBackend

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");
}
Also used : ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) DefaultStatisticsProvider(org.apache.jackrabbit.oak.stats.DefaultStatisticsProvider) CountDownLatch(java.util.concurrent.CountDownLatch) ExecutorCloser(org.apache.jackrabbit.oak.commons.concurrent.ExecutorCloser) DefaultStatisticsProvider(org.apache.jackrabbit.oak.stats.DefaultStatisticsProvider) StatisticsProvider(org.apache.jackrabbit.oak.stats.StatisticsProvider) File(java.io.File) AbstractSharedBackend(org.apache.jackrabbit.oak.spi.blob.AbstractSharedBackend)

Example 2 with AbstractSharedBackend

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;
}
Also used : Blob(org.apache.jackrabbit.oak.api.Blob) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) DefaultStatisticsProvider(org.apache.jackrabbit.oak.stats.DefaultStatisticsProvider) Hex.encodeHexString(org.apache.commons.codec.binary.Hex.encodeHexString) CountDownLatch(java.util.concurrent.CountDownLatch) FileInputStream(java.io.FileInputStream) List(java.util.List) ExecutorCloser(org.apache.jackrabbit.oak.commons.concurrent.ExecutorCloser) FileUtils.copyInputStreamToFile(org.apache.commons.io.FileUtils.copyInputStreamToFile) File(java.io.File) AbstractSharedBackend(org.apache.jackrabbit.oak.spi.blob.AbstractSharedBackend)

Aggregations

File (java.io.File)2 CountDownLatch (java.util.concurrent.CountDownLatch)2 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)2 ExecutorCloser (org.apache.jackrabbit.oak.commons.concurrent.ExecutorCloser)2 AbstractSharedBackend (org.apache.jackrabbit.oak.spi.blob.AbstractSharedBackend)2 DefaultStatisticsProvider (org.apache.jackrabbit.oak.stats.DefaultStatisticsProvider)2 FileInputStream (java.io.FileInputStream)1 List (java.util.List)1 Hex.encodeHexString (org.apache.commons.codec.binary.Hex.encodeHexString)1 FileUtils.copyInputStreamToFile (org.apache.commons.io.FileUtils.copyInputStreamToFile)1 Blob (org.apache.jackrabbit.oak.api.Blob)1 StatisticsProvider (org.apache.jackrabbit.oak.stats.StatisticsProvider)1