use of org.neo4j.kernel.configuration.Config in project neo4j by neo4j.
the class LuceneDataSourceTest method testClosesOldestIndexWriterWhenCacheSizeIsExceeded.
@Test
public void testClosesOldestIndexWriterWhenCacheSizeIsExceeded() throws Throwable {
addIndex("bar");
addIndex("baz");
Config config = Config.embeddedDefaults(cacheSizeConfig());
dataSource = life.add(new LuceneDataSource(directory.graphDbDir(), config, indexStore, fileSystemRule.get()));
IndexIdentifier fooIdentifier = identifier("foo");
IndexIdentifier barIdentifier = identifier("bar");
IndexIdentifier bazIdentifier = identifier("baz");
IndexWriter fooIndexWriter = dataSource.getIndexSearcher(fooIdentifier).getWriter();
dataSource.getIndexSearcher(barIdentifier);
assertTrue(fooIndexWriter.isOpen());
dataSource.getIndexSearcher(bazIdentifier);
assertFalse(fooIndexWriter.isOpen());
}
use of org.neo4j.kernel.configuration.Config in project neo4j by neo4j.
the class LuceneDataSourceTest method useReadOnlyIndexSearcherInReadOnlyMode.
@Test
public void useReadOnlyIndexSearcherInReadOnlyMode() throws IOException {
IndexIdentifier indexIdentifier = identifier("foo");
prepareIndexesByIdentifiers(indexIdentifier);
stopDataSource();
Config readOnlyConfig = Config.embeddedDefaults(readOnlyConfig());
dataSource = life.add(new LuceneDataSource(directory.graphDbDir(), readOnlyConfig, indexStore, fileSystemRule.get()));
IndexReference indexSearcher = dataSource.getIndexSearcher(indexIdentifier);
assertTrue("Read only index reference should be used in read only mode.", ReadOnlyIndexReference.class.isInstance(indexSearcher));
}
use of org.neo4j.kernel.configuration.Config in project neo4j by neo4j.
the class LuceneDataSourceTest method testShouldReturnIndexSearcherFromLRUCache.
@Test
public void testShouldReturnIndexSearcherFromLRUCache() throws Throwable {
Config config = Config.embeddedDefaults();
dataSource = life.add(new LuceneDataSource(directory.graphDbDir(), config, indexStore, fileSystemRule.get()));
IndexIdentifier identifier = identifier("foo");
IndexReference searcher = dataSource.getIndexSearcher(identifier);
assertSame(searcher, dataSource.getIndexSearcher(identifier));
searcher.close();
}
use of org.neo4j.kernel.configuration.Config in project neo4j by neo4j.
the class LuceneDataSourceTest method doNotTryToCommitWritersOnForceInReadOnlyMode.
@Test
public void doNotTryToCommitWritersOnForceInReadOnlyMode() throws IOException {
IndexIdentifier indexIdentifier = identifier("foo");
prepareIndexesByIdentifiers(indexIdentifier);
stopDataSource();
Config readOnlyConfig = Config.embeddedDefaults(readOnlyConfig());
LuceneDataSource readOnlyDataSource = life.add(new LuceneDataSource(directory.graphDbDir(), readOnlyConfig, indexStore, fileSystemRule.get()));
assertNotNull(readOnlyDataSource.getIndexSearcher(indexIdentifier));
readOnlyDataSource.force();
}
use of org.neo4j.kernel.configuration.Config in project neo4j by neo4j.
the class NonUniqueIndexTests method newEmbeddedGraphDatabaseWithSlowJobScheduler.
private GraphDatabaseService newEmbeddedGraphDatabaseWithSlowJobScheduler() {
GraphDatabaseFactoryState graphDatabaseFactoryState = new GraphDatabaseFactoryState();
graphDatabaseFactoryState.setUserLogProvider(NullLogService.getInstance().getUserLogProvider());
return new GraphDatabaseFacadeFactory(DatabaseInfo.COMMUNITY, CommunityEditionModule::new) {
@Override
protected PlatformModule createPlatform(File storeDir, Config config, Dependencies dependencies, GraphDatabaseFacade graphDatabaseFacade) {
return new PlatformModule(storeDir, config, databaseInfo, dependencies, graphDatabaseFacade) {
@Override
protected Neo4jJobScheduler createJobScheduler() {
return newSlowJobScheduler();
}
@Override
protected LogService createLogService(LogProvider userLogProvider) {
return NullLogService.getInstance();
}
};
}
}.newFacade(directory.graphDbDir(), Config.embeddedDefaults(), graphDatabaseFactoryState.databaseDependencies());
}
Aggregations