Search in sources :

Example 1 with IndexDirectoryStructure

use of org.neo4j.kernel.api.index.IndexDirectoryStructure in project neo4j by neo4j.

the class NativeIndexRestartAction method run.

@Override
public void run(FileSystemAbstraction fs, DatabaseLayout databaseLayout) throws IOException {
    IndexDirectoryStructure indexDirectoryStructure = nativeIndexDirectoryStructure(databaseLayout, providerDescriptor);
    runOnDirectoryStructure(fs, indexDirectoryStructure);
}
Also used : IndexDirectoryStructure(org.neo4j.kernel.api.index.IndexDirectoryStructure)

Example 2 with IndexDirectoryStructure

use of org.neo4j.kernel.api.index.IndexDirectoryStructure in project neo4j by neo4j.

the class GenericBlockBasedIndexPopulatorTest method setup.

@BeforeEach
void setup() {
    IndexProviderDescriptor providerDescriptor = new IndexProviderDescriptor("test", "v1");
    IndexDirectoryStructure directoryStructure = directoriesByProvider(directory.homePath()).forProvider(providerDescriptor);
    indexFiles = new IndexFiles.Directory(fs, directoryStructure, INDEX_DESCRIPTOR.getId());
    databaseIndexContext = DatabaseIndexContext.builder(pageCache, fs, DEFAULT_DATABASE_NAME).build();
    jobScheduler = JobSchedulerFactory.createInitialisedScheduler();
    populationWorkScheduler = new IndexPopulator.PopulationWorkScheduler() {

        @Override
        public <T> JobHandle<T> schedule(IndexPopulator.JobDescriptionSupplier descriptionSupplier, Callable<T> job) {
            return jobScheduler.schedule(Group.INDEX_POPULATION_WORK, new JobMonitoringParams(null, null, null), job);
        }
    };
}
Also used : IndexPopulator(org.neo4j.kernel.api.index.IndexPopulator) JobHandle(org.neo4j.scheduler.JobHandle) IndexDirectoryStructure(org.neo4j.kernel.api.index.IndexDirectoryStructure) NULL_CONTEXT(org.neo4j.internal.kernel.api.QueryContext.NULL_CONTEXT) IndexProviderDescriptor(org.neo4j.internal.schema.IndexProviderDescriptor) JobMonitoringParams(org.neo4j.scheduler.JobMonitoringParams) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 3 with IndexDirectoryStructure

use of org.neo4j.kernel.api.index.IndexDirectoryStructure in project neo4j by neo4j.

the class AccessUniqueDatabaseIndexTest method getIndexStorage.

private PartitionedIndexStorage getIndexStorage() {
    IndexProviderDescriptor descriptor = new IndexProviderDescriptor(NATIVE30.providerKey(), NATIVE30.providerVersion());
    IndexDirectoryStructure parent = directoriesByProvider(databaseLayout.databaseDirectory()).forProvider(descriptor);
    IndexStorageFactory storageFactory = new IndexStorageFactory(directoryFactory, fileSystem, directoriesBySubProvider(parent).forProvider(LuceneIndexProvider.DESCRIPTOR));
    return storageFactory.indexStorageOf(1);
}
Also used : IndexStorageFactory(org.neo4j.kernel.api.impl.index.storage.IndexStorageFactory) IndexDirectoryStructure(org.neo4j.kernel.api.index.IndexDirectoryStructure) IndexProviderDescriptor(org.neo4j.internal.schema.IndexProviderDescriptor)

Example 4 with IndexDirectoryStructure

use of org.neo4j.kernel.api.index.IndexDirectoryStructure in project neo4j by neo4j.

the class SchemaIndexMigratorTest method schemaAndLabelIndexesRemovedAfterSuccessfulMigration.

@Test
void schemaAndLabelIndexesRemovedAfterSuccessfulMigration() throws IOException {
    StorageEngineFactory storageEngineFactory = mock(StorageEngineFactory.class);
    StoreVersion version = mock(StoreVersion.class);
    when(version.hasCompatibleCapabilities(any(), eq(CapabilityType.INDEX))).thenReturn(false);
    when(storageEngineFactory.versionInformation(anyString())).thenReturn(version);
    IndexImporterFactory indexImporterFactory = mock(IndexImporterFactory.class);
    IndexDirectoryStructure directoryStructure = mock(IndexDirectoryStructure.class);
    Path indexProviderRootDirectory = databaseLayout.file("just-some-directory");
    when(directoryStructure.rootDirectory()).thenReturn(indexProviderRootDirectory);
    SchemaIndexMigrator migrator = new SchemaIndexMigrator("Test migrator", fs, pageCache, directoryStructure, storageEngineFactory, true);
    when(indexProvider.getProviderDescriptor()).thenReturn(new IndexProviderDescriptor("key", "version"));
    migrator.migrate(databaseLayout, migrationLayout, progressReporter, "from", "to", indexImporterFactory);
    migrator.moveMigratedFiles(migrationLayout, databaseLayout, "from", "to");
    verify(fs).deleteRecursively(indexProviderRootDirectory);
}
Also used : Path(java.nio.file.Path) IndexDirectoryStructure(org.neo4j.kernel.api.index.IndexDirectoryStructure) StorageEngineFactory(org.neo4j.storageengine.api.StorageEngineFactory) StoreVersion(org.neo4j.storageengine.api.StoreVersion) IndexProviderDescriptor(org.neo4j.internal.schema.IndexProviderDescriptor) IndexImporterFactory(org.neo4j.internal.batchimport.IndexImporterFactory) SchemaIndexMigrator(org.neo4j.storageengine.migration.SchemaIndexMigrator) Test(org.junit.jupiter.api.Test)

Example 5 with IndexDirectoryStructure

use of org.neo4j.kernel.api.index.IndexDirectoryStructure in project neo4j by neo4j.

the class SchemaIndexMigratorTest method shouldDeleteRelationshipIndexesAfterCrossFormatFamilyMigration.

@Test
void shouldDeleteRelationshipIndexesAfterCrossFormatFamilyMigration() throws IOException {
    // given
    IndexProviderDescriptor provider = new IndexProviderDescriptor("k", "v");
    IndexDirectoryStructure directoryStructure = directoriesByProvider(databaseLayout.databaseDirectory()).forProvider(provider);
    StorageEngineFactory storageEngineFactory = mock(StorageEngineFactory.class);
    StoreVersion fromVersion = mock(StoreVersion.class);
    StoreVersion toVersion = mock(StoreVersion.class);
    when(fromVersion.hasCompatibleCapabilities(toVersion, CapabilityType.FORMAT)).thenReturn(false);
    when(storageEngineFactory.versionInformation("from")).thenReturn(fromVersion);
    when(storageEngineFactory.versionInformation("to")).thenReturn(toVersion);
    List<SchemaRule> schemaRules = new ArrayList<>();
    schemaRules.add(forSchema(SchemaDescriptor.forLabel(1, 2, 3)).withName("n1").materialise(1L));
    schemaRules.add(forSchema(SchemaDescriptor.forRelType(5, 3)).withName("r1").materialise(2L));
    schemaRules.add(forSchema(SchemaDescriptor.fulltext(RELATIONSHIP, new int[] { 1, 2, 3 }, new int[] { 4, 5, 6 })).withName("r2").materialise(3L));
    schemaRules.add(forSchema(SchemaDescriptor.fulltext(NODE, new int[] { 1, 2, 3 }, new int[] { 4, 5, 6 })).withName("n2").materialise(4L));
    when(storageEngineFactory.loadSchemaRules(any(), any(), any(), any(), any())).thenReturn(schemaRules);
    SchemaIndexMigrator migrator = new SchemaIndexMigrator("Test migrator", fs, pageCache, directoryStructure, storageEngineFactory, false);
    // when
    migrator.migrate(databaseLayout, migrationLayout, progressReporter, "from", "to", IndexImporterFactory.EMPTY);
    migrator.moveMigratedFiles(databaseLayout, migrationLayout, "from", "to");
    // then
    verify(fs, never()).deleteRecursively(directoryStructure.directoryForIndex(1L));
    verify(fs).deleteRecursively(directoryStructure.directoryForIndex(2L));
    verify(fs).deleteRecursively(directoryStructure.directoryForIndex(3L));
    verify(fs, never()).deleteRecursively(directoryStructure.directoryForIndex(4L));
}
Also used : IndexDirectoryStructure(org.neo4j.kernel.api.index.IndexDirectoryStructure) StorageEngineFactory(org.neo4j.storageengine.api.StorageEngineFactory) IndexProviderDescriptor(org.neo4j.internal.schema.IndexProviderDescriptor) StoreVersion(org.neo4j.storageengine.api.StoreVersion) ArrayList(java.util.ArrayList) SchemaRule(org.neo4j.internal.schema.SchemaRule) SchemaIndexMigrator(org.neo4j.storageengine.migration.SchemaIndexMigrator) Test(org.junit.jupiter.api.Test)

Aggregations

IndexDirectoryStructure (org.neo4j.kernel.api.index.IndexDirectoryStructure)8 IndexProviderDescriptor (org.neo4j.internal.schema.IndexProviderDescriptor)5 BeforeEach (org.junit.jupiter.api.BeforeEach)3 Test (org.junit.jupiter.api.Test)3 Path (java.nio.file.Path)2 StorageEngineFactory (org.neo4j.storageengine.api.StorageEngineFactory)2 StoreVersion (org.neo4j.storageengine.api.StoreVersion)2 SchemaIndexMigrator (org.neo4j.storageengine.migration.SchemaIndexMigrator)2 TestDirectory (org.neo4j.test.rule.TestDirectory)2 ArrayList (java.util.ArrayList)1 SpaceFillingCurveConfiguration (org.neo4j.gis.spatial.index.curves.SpaceFillingCurveConfiguration)1 StandardConfiguration (org.neo4j.gis.spatial.index.curves.StandardConfiguration)1 RecoveryCleanupWorkCollector (org.neo4j.index.internal.gbptree.RecoveryCleanupWorkCollector)1 IndexImporterFactory (org.neo4j.internal.batchimport.IndexImporterFactory)1 NULL_CONTEXT (org.neo4j.internal.kernel.api.QueryContext.NULL_CONTEXT)1 IndexDescriptor (org.neo4j.internal.schema.IndexDescriptor)1 SchemaRule (org.neo4j.internal.schema.SchemaRule)1 IndexStorageFactory (org.neo4j.kernel.api.impl.index.storage.IndexStorageFactory)1 IndexPopulator (org.neo4j.kernel.api.index.IndexPopulator)1 IndexSpecificSpaceFillingCurveSettings (org.neo4j.kernel.impl.index.schema.config.IndexSpecificSpaceFillingCurveSettings)1