Search in sources :

Example 91 with Config

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());
}
Also used : IndexWriter(org.apache.lucene.index.IndexWriter) Config(org.neo4j.kernel.configuration.Config) Test(org.junit.Test)

Example 92 with Config

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));
}
Also used : Config(org.neo4j.kernel.configuration.Config) Test(org.junit.Test)

Example 93 with Config

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();
}
Also used : Config(org.neo4j.kernel.configuration.Config) Test(org.junit.Test)

Example 94 with Config

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();
}
Also used : Config(org.neo4j.kernel.configuration.Config) Test(org.junit.Test)

Example 95 with Config

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());
}
Also used : Neo4jJobScheduler(org.neo4j.kernel.impl.util.Neo4jJobScheduler) LogProvider(org.neo4j.logging.LogProvider) NullLogProvider(org.neo4j.logging.NullLogProvider) Config(org.neo4j.kernel.configuration.Config) IndexSamplingConfig(org.neo4j.kernel.impl.api.index.sampling.IndexSamplingConfig) GraphDatabaseFactoryState(org.neo4j.graphdb.factory.GraphDatabaseFactoryState) GraphDatabaseFacadeFactory(org.neo4j.kernel.impl.factory.GraphDatabaseFacadeFactory) GraphDatabaseFacade(org.neo4j.kernel.impl.factory.GraphDatabaseFacade) PlatformModule(org.neo4j.kernel.impl.factory.PlatformModule) File(java.io.File) LogService(org.neo4j.kernel.impl.logging.LogService) NullLogService(org.neo4j.kernel.impl.logging.NullLogService)

Aggregations

Config (org.neo4j.kernel.configuration.Config)264 Test (org.junit.Test)184 File (java.io.File)54 PageCache (org.neo4j.io.pagecache.PageCache)35 InstanceId (org.neo4j.cluster.InstanceId)26 MultiPaxosContext (org.neo4j.cluster.protocol.atomicbroadcast.multipaxos.context.MultiPaxosContext)25 FileSystemAbstraction (org.neo4j.io.fs.FileSystemAbstraction)25 LogProvider (org.neo4j.logging.LogProvider)20 Executor (java.util.concurrent.Executor)19 ClusterConfiguration (org.neo4j.cluster.protocol.cluster.ClusterConfiguration)19 Timeouts (org.neo4j.cluster.timeout.Timeouts)19 HashMap (java.util.HashMap)18 URI (java.net.URI)17 ObjectInputStreamFactory (org.neo4j.cluster.protocol.atomicbroadcast.ObjectInputStreamFactory)17 ObjectOutputStreamFactory (org.neo4j.cluster.protocol.atomicbroadcast.ObjectOutputStreamFactory)17 AcceptorInstanceStore (org.neo4j.cluster.protocol.atomicbroadcast.multipaxos.AcceptorInstanceStore)17 IOException (java.io.IOException)16 ListenSocketAddress (org.neo4j.helpers.ListenSocketAddress)15 BoltConnector (org.neo4j.kernel.configuration.BoltConnector)15 GraphDatabaseAPI (org.neo4j.kernel.internal.GraphDatabaseAPI)15