use of org.apache.jackrabbit.oak.plugins.blob.datastore.CachingFileDataStore in project jackrabbit-oak by apache.
the class LuceneIndexEditorTest method setup.
@Before
public void setup() throws Exception {
if (useBlobStore) {
LuceneIndexEditorProvider provider = new LuceneIndexEditorProvider();
CachingFileDataStore ds = DataStoreUtils.createCachingFDS(temporaryFolder.newFolder().getAbsolutePath(), temporaryFolder.newFolder().getAbsolutePath());
provider.setBlobStore(new DataStoreBlobStore(ds));
HOOK = new EditorHook(new IndexUpdateProvider(provider));
} else {
HOOK = new EditorHook(new IndexUpdateProvider(new LuceneIndexEditorProvider()));
}
}
use of org.apache.jackrabbit.oak.plugins.blob.datastore.CachingFileDataStore in project jackrabbit-oak by apache.
the class MultiplexingIndexWriterTest method writesInDefaultMountBlobStore.
@Test
public void writesInDefaultMountBlobStore() throws Exception {
CachingFileDataStore ds = DataStoreUtils.createCachingFDS(folder.newFolder().getAbsolutePath(), folder.newFolder().getAbsolutePath());
LuceneIndexWriterFactory factory = new DefaultIndexWriterFactory(mip, null, new DataStoreBlobStore(ds));
LuceneIndexWriter writer = factory.newInstance(defn, builder, true);
//1. Add entry in foo mount
writer.updateDocument("/libs/config", newDoc("/libs/config"));
writer.close(0);
List<String> names = getIndexDirNodes();
//Only dirNode for mount foo should be present
assertThat(names, contains(indexDirName(fooMount)));
//2. Add entry in default mount
writer = factory.newInstance(defn, builder, true);
writer.updateDocument("/content", newDoc("/content"));
writer.close(0);
names = getIndexDirNodes();
//Dir names for both mounts should be present
assertThat(names, containsInAnyOrder(indexDirName(fooMount), indexDirName(defaultMount)));
}
use of org.apache.jackrabbit.oak.plugins.blob.datastore.CachingFileDataStore in project jackrabbit-oak by apache.
the class LuceneIndexProviderServiceTest method blobStoreRegistered.
@Test
public void blobStoreRegistered() throws Exception {
MockOsgi.activate(service, context.bundleContext(), getDefaultConfig());
LuceneIndexEditorProvider editorProvider = (LuceneIndexEditorProvider) context.getService(IndexEditorProvider.class);
assertNull(editorProvider.getBlobStore());
/* Register a blob store */
CachingFileDataStore ds = DataStoreUtils.createCachingFDS(folder.newFolder().getAbsolutePath(), folder.newFolder().getAbsolutePath());
service.bindBlobStore(new DataStoreBlobStore(ds));
assertNotNull(editorProvider.getBlobStore());
}
use of org.apache.jackrabbit.oak.plugins.blob.datastore.CachingFileDataStore in project jackrabbit-oak by apache.
the class DefaultIndexReaderFactoryTest method indexDirWithBlobStore.
@Test
public void indexDirWithBlobStore() throws Exception {
/* Register a blob store */
CachingFileDataStore ds = DataStoreUtils.createCachingFDS(folder.newFolder().getAbsolutePath(), folder.newFolder().getAbsolutePath());
LuceneIndexWriterFactory factory = new DefaultIndexWriterFactory(mip, null, new DataStoreBlobStore(ds));
LuceneIndexWriter writer = factory.newInstance(defn, builder, true);
writer.updateDocument("/content/en", newDoc("/content/en"));
writer.close(0);
LuceneIndexReaderFactory readerFactory = new DefaultIndexReaderFactory(mip, null);
List<LuceneIndexReader> readers = readerFactory.createReaders(defn, builder.getNodeState(), "/foo");
assertEquals(1, readers.size());
LuceneIndexReader reader = readers.get(0);
assertNotNull(reader.getReader());
assertNull(reader.getSuggestDirectory());
assertNull(reader.getLookup());
assertEquals(1, reader.getReader().numDocs());
final AtomicBoolean closed = new AtomicBoolean();
reader.getReader().addReaderClosedListener(new IndexReader.ReaderClosedListener() {
@Override
public void onClose(IndexReader reader) {
closed.set(true);
}
});
reader.close();
assertTrue(closed.get());
}
Aggregations