Search in sources :

Example 6 with LabelScanStore

use of org.neo4j.kernel.api.labelscan.LabelScanStore in project neo4j by neo4j.

the class ReadReplicaReplicationIT method gatherLabelScanStoreFiles.

private void gatherLabelScanStoreFiles(GraphDatabaseAPI db, Set<Path> labelScanStoreFiles) {
    Path dbStoreDirectory = Paths.get(db.getStoreDir()).toAbsolutePath();
    LabelScanStore labelScanStore = db.getDependencyResolver().resolveDependency(LabelScanStore.class);
    try (ResourceIterator<File> files = labelScanStore.snapshotStoreFiles()) {
        Path relativePath = dbStoreDirectory.relativize(files.next().toPath().toAbsolutePath());
        labelScanStoreFiles.add(relativePath);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
Also used : Path(java.nio.file.Path) LabelScanStore(org.neo4j.kernel.api.labelscan.LabelScanStore) IOException(java.io.IOException) File(java.io.File)

Example 7 with LabelScanStore

use of org.neo4j.kernel.api.labelscan.LabelScanStore in project neo4j by neo4j.

the class FullCheckIntegrationTest method shouldReportLabelScanStoreInconsistencies.

@Test
public void shouldReportLabelScanStoreInconsistencies() throws Exception {
    // given
    GraphStoreFixture.IdGenerator idGenerator = fixture.idGenerator();
    long nodeId1 = idGenerator.node();
    long labelId = idGenerator.label() - 1;
    LabelScanStore labelScanStore = fixture.directStoreAccess().labelScanStore();
    Iterable<NodeLabelUpdate> nodeLabelUpdates = asIterable(labelChanges(nodeId1, new long[] {}, new long[] { labelId }));
    write(labelScanStore, nodeLabelUpdates);
    // when
    ConsistencySummaryStatistics stats = check();
    // then
    on(stats).verify(RecordType.LABEL_SCAN_DOCUMENT, 1).andThatsAllFolks();
}
Also used : LabelScanStore(org.neo4j.kernel.api.labelscan.LabelScanStore) IdGenerator(org.neo4j.consistency.checking.GraphStoreFixture.IdGenerator) NodeLabelUpdate(org.neo4j.kernel.api.labelscan.NodeLabelUpdate) GraphStoreFixture(org.neo4j.consistency.checking.GraphStoreFixture) ConsistencySummaryStatistics(org.neo4j.consistency.report.ConsistencySummaryStatistics) Test(org.junit.Test)

Example 8 with LabelScanStore

use of org.neo4j.kernel.api.labelscan.LabelScanStore in project neo4j by neo4j.

the class LabelScanStoreStartupIT method scanStoreRecreateCorruptedIndexOnStartup.

@Test
public void scanStoreRecreateCorruptedIndexOnStartup() throws IOException {
    LabelScanStore labelScanStore = getLabelScanStore();
    createTestNode();
    long[] labels = readNodesForLabel(labelScanStore);
    assertEquals("Label scan store see 1 label for node", 1, labels.length);
    labelScanStore.force(IOLimiter.unlimited());
    labelScanStore.shutdown();
    corruptLabelScanStoreFiles(dbRule.getStoreDirFile());
    labelScanStore.init();
    labelScanStore.start();
    long[] rebuildLabels = readNodesForLabel(labelScanStore);
    assertArrayEquals("Store should rebuild corrupted index", labels, rebuildLabels);
}
Also used : LabelScanStore(org.neo4j.kernel.api.labelscan.LabelScanStore) LabelScanStoreTest(org.neo4j.kernel.api.impl.labelscan.LabelScanStoreTest) Test(org.junit.Test)

Example 9 with LabelScanStore

use of org.neo4j.kernel.api.labelscan.LabelScanStore in project neo4j by neo4j.

the class LabelScanStoreStartupIT method scanStoreStartWithoutExistentIndex.

@Test
public void scanStoreStartWithoutExistentIndex() throws IOException {
    LabelScanStore labelScanStore = getLabelScanStore();
    labelScanStore.shutdown();
    deleteLabelScanStoreFiles(dbRule.getStoreDirFile());
    labelScanStore.init();
    labelScanStore.start();
    checkLabelScanStoreAccessible(labelScanStore);
}
Also used : LabelScanStore(org.neo4j.kernel.api.labelscan.LabelScanStore) LabelScanStoreTest(org.neo4j.kernel.api.impl.labelscan.LabelScanStoreTest) Test(org.junit.Test)

Example 10 with LabelScanStore

use of org.neo4j.kernel.api.labelscan.LabelScanStore in project neo4j by neo4j.

the class LuceneLabelScanStoreBuilder method build.

public LabelScanStore build() {
    if (null == labelScanStore) {
        // TODO: Replace with kernel extension based lookup
        LabelScanStore.Monitor monitor = new LoggingMonitor(logProvider.getLog(LuceneLabelScanStore.class));
        LuceneLabelScanIndexBuilder indexBuilder = LuceneLabelScanIndexBuilder.create().withFileSystem(fileSystem).withIndexRootFolder(getStoreDirectory(storeDir)).withConfig(config).withOperationalMode(operationalMode);
        labelScanStore = new LuceneLabelScanStore(indexBuilder, new FullLabelStream(storeViewSupplier), monitor);
        try {
            labelScanStore.init();
            labelScanStore.start();
        } catch (IOException e) {
            // Throw better exception
            throw new RuntimeException(e);
        }
    }
    return labelScanStore;
}
Also used : LuceneLabelScanStore(org.neo4j.kernel.api.impl.labelscan.LuceneLabelScanStore) LabelScanStore(org.neo4j.kernel.api.labelscan.LabelScanStore) LoggingMonitor(org.neo4j.kernel.api.labelscan.LoggingMonitor) LuceneLabelScanIndexBuilder(org.neo4j.kernel.api.impl.labelscan.LuceneLabelScanIndexBuilder) FullLabelStream(org.neo4j.kernel.impl.api.scan.FullLabelStream) LuceneLabelScanStore(org.neo4j.kernel.api.impl.labelscan.LuceneLabelScanStore) IOException(java.io.IOException)

Aggregations

LabelScanStore (org.neo4j.kernel.api.labelscan.LabelScanStore)10 IOException (java.io.IOException)4 Test (org.junit.Test)4 File (java.io.File)3 ConsistencySummaryStatistics (org.neo4j.consistency.report.ConsistencySummaryStatistics)2 AccessStatistics (org.neo4j.consistency.statistics.AccessStatistics)2 AccessStatsKeepingStoreAccess (org.neo4j.consistency.statistics.AccessStatsKeepingStoreAccess)2 DefaultCounts (org.neo4j.consistency.statistics.DefaultCounts)2 VerboseStatistics (org.neo4j.consistency.statistics.VerboseStatistics)2 DirectStoreAccess (org.neo4j.kernel.api.direct.DirectStoreAccess)2 LabelScanStoreTest (org.neo4j.kernel.api.impl.labelscan.LabelScanStoreTest)2 KernelExtensionFactory (org.neo4j.kernel.extension.KernelExtensionFactory)2 KernelExtensions (org.neo4j.kernel.extension.KernelExtensions)2 NamedLabelScanStoreSelectionStrategy (org.neo4j.kernel.extension.dependency.NamedLabelScanStoreSelectionStrategy)2 IndexStoreView (org.neo4j.kernel.impl.api.index.IndexStoreView)2 SimpleLogService (org.neo4j.kernel.impl.logging.SimpleLogService)2 KernelContext (org.neo4j.kernel.impl.spi.KernelContext)2 SimpleKernelContext (org.neo4j.kernel.impl.spi.SimpleKernelContext)2 NeoStores (org.neo4j.kernel.impl.store.NeoStores)2 StoreAccess (org.neo4j.kernel.impl.store.StoreAccess)2