Search in sources :

Example 6 with IndexSamplingConfig

use of org.neo4j.kernel.impl.api.index.IndexSamplingConfig in project neo4j by neo4j.

the class LuceneIndexAccessorIT method setUp.

@BeforeEach
void setUp() {
    Path path = directory.directory("db");
    config = Config.defaults();
    readOnlyChecker = new DatabaseReadOnlyChecker.Default(config, DEFAULT_DATABASE_NAME);
    indexProvider = new LuceneIndexProvider(directory.getFileSystem(), PERSISTENT, directoriesByProvider(path), new Monitors(), config, readOnlyChecker);
    life.add(indexProvider);
    life.start();
    samplingConfig = new IndexSamplingConfig(config);
}
Also used : Path(java.nio.file.Path) IndexSamplingConfig(org.neo4j.kernel.impl.api.index.IndexSamplingConfig) DatabaseReadOnlyChecker(org.neo4j.configuration.helpers.DatabaseReadOnlyChecker) Monitors(org.neo4j.monitoring.Monitors) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 7 with IndexSamplingConfig

use of org.neo4j.kernel.impl.api.index.IndexSamplingConfig in project neo4j by neo4j.

the class LuceneSchemaIndexPopulatorTest method before.

@BeforeEach
void before() throws IOException {
    directory = new ByteBuffersDirectory();
    DirectoryFactory directoryFactory = new DirectoryFactory.Single(new DirectoryFactory.UncloseableDirectory(directory));
    provider = new LuceneIndexProvider(fs, directoryFactory, directoriesByProvider(testDir.directory("folder")), new Monitors(), Config.defaults(), writable());
    propertyAccessor = mock(NodePropertyAccessor.class);
    IndexSamplingConfig samplingConfig = new IndexSamplingConfig(Config.defaults());
    index = IndexPrototype.forSchema(forLabel(42, propertyKeyId), provider.getProviderDescriptor()).withName("index").materialise(0);
    indexPopulator = provider.getPopulator(index, samplingConfig, heapBufferFactory(1024), INSTANCE, SIMPLE_TOKEN_LOOKUP);
    indexPopulator.create();
}
Also used : IndexSamplingConfig(org.neo4j.kernel.impl.api.index.IndexSamplingConfig) ByteBuffersDirectory(org.apache.lucene.store.ByteBuffersDirectory) DirectoryFactory(org.neo4j.kernel.api.impl.index.storage.DirectoryFactory) Monitors(org.neo4j.monitoring.Monitors) NodePropertyAccessor(org.neo4j.storageengine.api.NodePropertyAccessor) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 8 with IndexSamplingConfig

use of org.neo4j.kernel.impl.api.index.IndexSamplingConfig in project neo4j by neo4j.

the class CheckerTestBase method context.

CheckerContext context(int numberOfThreads, ConsistencyFlags consistencyFlags, ConsistencySummaryStatistics inconsistenciesSummary) throws Exception {
    if (context != null) {
        return context;
    }
    // We do this as late as possible because of how it eagerly caches which indexes exist so if the test creates an index
    // this lazy instantiation allows the context to pick it up
    Config config = Config.defaults(neo4j_home, directory.homePath());
    DependencyResolver dependencies = db.getDependencyResolver();
    IndexProviderMap indexProviders = dependencies.resolveDependency(IndexProviderMap.class);
    IndexingService indexingService = dependencies.resolveDependency(IndexingService.class);
    IndexAccessors indexAccessors = new IndexAccessors(indexProviders, neoStores, new IndexSamplingConfig(config), new LookupAccessorsFromRunningDb(indexingService), PageCacheTracer.NULL, tokenHolders, neoStores.getMetaDataStore());
    InconsistencyReport report = new InconsistencyReport(new InconsistencyMessageLogger(NullLog.getInstance()), inconsistenciesSummary);
    monitor = mock(ConsistencyReporter.Monitor.class);
    reporter = new ConsistencyReporter(report, monitor);
    countsState = new CountsState(neoStores, cacheAccess, INSTANCE);
    NodeBasedMemoryLimiter limiter = new NodeBasedMemoryLimiter(pageCache.pageSize() * pageCache.maxCachedPages(), Runtime.getRuntime().maxMemory(), Long.MAX_VALUE, CacheSlots.CACHE_LINE_SIZE_BYTES, nodeStore.getHighId(), 1);
    ProgressMonitorFactory.MultiPartBuilder progress = ProgressMonitorFactory.NONE.multipleParts("Test");
    ParallelExecution execution = new ParallelExecution(numberOfThreads, NOOP_EXCEPTION_HANDLER, IDS_PER_CHUNK);
    context = new CheckerContext(neoStores, indexAccessors, execution, reporter, cacheAccess, tokenHolders, new RecordLoading(neoStores), countsState, limiter, progress, pageCache, PageCacheTracer.NULL, INSTANCE, DebugContext.NO_DEBUG, consistencyFlags);
    context.initialize();
    return context;
}
Also used : IndexSamplingConfig(org.neo4j.kernel.impl.api.index.IndexSamplingConfig) IndexAccessors(org.neo4j.consistency.checking.index.IndexAccessors) InconsistencyReport(org.neo4j.consistency.report.InconsistencyReport) ConsistencyReporter(org.neo4j.consistency.report.ConsistencyReporter) ProgressMonitorFactory(org.neo4j.internal.helpers.progress.ProgressMonitorFactory) Config(org.neo4j.configuration.Config) IndexSamplingConfig(org.neo4j.kernel.impl.api.index.IndexSamplingConfig) IndexProviderMap(org.neo4j.kernel.impl.api.index.IndexProviderMap) DependencyResolver(org.neo4j.common.DependencyResolver) LookupAccessorsFromRunningDb(org.neo4j.consistency.LookupAccessorsFromRunningDb) IndexingService(org.neo4j.kernel.impl.api.index.IndexingService) InconsistencyMessageLogger(org.neo4j.consistency.report.InconsistencyMessageLogger)

Example 9 with IndexSamplingConfig

use of org.neo4j.kernel.impl.api.index.IndexSamplingConfig in project neo4j by neo4j.

the class SimpleIndexPopulatorCompatibility method shouldBeAbleToDropAClosedIndexPopulator.

@Test
public void shouldBeAbleToDropAClosedIndexPopulator() {
    // GIVEN
    IndexSamplingConfig indexSamplingConfig = new IndexSamplingConfig(Config.defaults());
    final IndexPopulator p = indexProvider.getPopulator(descriptor, indexSamplingConfig, heapBufferFactory(1024), INSTANCE, tokenNameLookup);
    p.close(false, NULL);
    // WHEN
    p.drop();
// THEN - no exception should be thrown (it's been known to!)
}
Also used : IndexSamplingConfig(org.neo4j.kernel.impl.api.index.IndexSamplingConfig) Test(org.junit.Test)

Example 10 with IndexSamplingConfig

use of org.neo4j.kernel.impl.api.index.IndexSamplingConfig in project neo4j by neo4j.

the class SimpleIndexPopulatorCompatibility method shouldReportInitialStateAsFailedIfPopulationFailed.

@Test
public void shouldReportInitialStateAsFailedIfPopulationFailed() throws Exception {
    // GIVEN
    IndexSamplingConfig indexSamplingConfig = new IndexSamplingConfig(Config.defaults());
    withPopulator(indexProvider.getPopulator(descriptor, indexSamplingConfig, heapBufferFactory(1024), INSTANCE, tokenNameLookup), p -> {
        String failure = "The contrived failure";
        // WHEN
        p.markAsFailed(failure);
        p.close(false, NULL);
        // THEN
        assertEquals(FAILED, indexProvider.getInitialState(descriptor, NULL));
    }, false);
}
Also used : IndexSamplingConfig(org.neo4j.kernel.impl.api.index.IndexSamplingConfig) Test(org.junit.Test)

Aggregations

IndexSamplingConfig (org.neo4j.kernel.impl.api.index.IndexSamplingConfig)15 Test (org.junit.Test)7 BeforeEach (org.junit.jupiter.api.BeforeEach)3 IndexAccessors (org.neo4j.consistency.checking.index.IndexAccessors)3 ConsistencyReport (org.neo4j.consistency.report.ConsistencyReport)2 Monitors (org.neo4j.monitoring.Monitors)2 Path (java.nio.file.Path)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1 ByteBuffersDirectory (org.apache.lucene.store.ByteBuffersDirectory)1 Before (org.junit.Before)1 Test (org.junit.jupiter.api.Test)1 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1 DependencyResolver (org.neo4j.common.DependencyResolver)1 Config (org.neo4j.configuration.Config)1 DatabaseReadOnlyChecker (org.neo4j.configuration.helpers.DatabaseReadOnlyChecker)1 LookupAccessorsFromRunningDb (org.neo4j.consistency.LookupAccessorsFromRunningDb)1 ConsistencyReporter (org.neo4j.consistency.report.ConsistencyReporter)1 ConsistencySummaryStatistics (org.neo4j.consistency.report.ConsistencySummaryStatistics)1 InconsistencyMessageLogger (org.neo4j.consistency.report.InconsistencyMessageLogger)1 InconsistencyReport (org.neo4j.consistency.report.InconsistencyReport)1