use of org.neo4j.internal.schema.IndexProviderDescriptor in project neo4j by neo4j.
the class IndexIT method shouldBeAbleToRemoveAConstraintIndexWithoutOwner.
@Test
void shouldBeAbleToRemoveAConstraintIndexWithoutOwner() throws Exception {
// given
AssertableLogProvider logProvider = new AssertableLogProvider();
ConstraintIndexCreator creator = new ConstraintIndexCreator(() -> kernel, indexingService, logProvider);
IndexProviderDescriptor provider = GenericNativeIndexProvider.DESCRIPTOR;
IndexPrototype prototype = uniqueForSchema(schema).withName("constraint name").withIndexProvider(provider);
IndexDescriptor constraintIndex = creator.createConstraintIndex(prototype);
// then
KernelTransaction transaction = newTransaction();
assertEquals(emptySet(), asSet(transaction.schemaRead().constraintsGetForLabel(labelId)));
commit();
// when
SchemaWrite schemaWrite = schemaWriteInNewTransaction();
schemaWrite.indexDrop(constraintIndex);
commit();
// then
transaction = newTransaction();
assertEquals(emptySet(), asSet(transaction.schemaRead().indexesGetForLabel(labelId)));
commit();
}
use of org.neo4j.internal.schema.IndexProviderDescriptor in project neo4j by neo4j.
the class StubStorageCursors method indexDescriptor.
private IndexDescriptor indexDescriptor(EntityType entityType, long id) {
IndexPrototype indexPrototype = IndexPrototype.forSchema(forAnyEntityTokens(entityType)).withIndexType(LOOKUP).withIndexProvider(new IndexProviderDescriptor("token-lookup", "1.0"));
indexPrototype = indexPrototype.withName(SchemaRule.generateName(indexPrototype, new String[] {}, new String[] {}));
return indexPrototype.materialise(id);
}
use of org.neo4j.internal.schema.IndexProviderDescriptor in project neo4j by neo4j.
the class IndexingServiceTest method shouldFailToStartIfMissingIndexProvider.
@Test
void shouldFailToStartIfMissingIndexProvider() throws Exception {
// GIVEN an indexing service that has a schema index provider X
String otherProviderKey = "something-completely-different";
IndexProviderDescriptor otherDescriptor = new IndexProviderDescriptor(otherProviderKey, "no-version");
IndexDescriptor rule = storeIndex(1, 2, 3, otherDescriptor);
newIndexingServiceWithMockedDependencies(mock(IndexPopulator.class), mock(IndexAccessor.class), new DataUpdates(), rule);
// WHEN trying to start up and initialize it with an index from provider Y
var e = assertThrows(LifecycleException.class, life::init);
assertThat(e.getCause().getMessage()).contains(PROVIDER_DESCRIPTOR.name());
assertThat(e.getCause().getMessage()).contains(otherProviderKey);
}
use of org.neo4j.internal.schema.IndexProviderDescriptor in project neo4j by neo4j.
the class IndexingServiceTest method shouldLogDeprecatedIndexesOnStart.
@Test
void shouldLogDeprecatedIndexesOnStart() throws Exception {
// given two indexes per available index provider
int id = 1;
List<IndexDescriptor> indexDescriptors = new ArrayList<>();
IndexProvider[] indexProviders = new IndexProvider[indexProviderDescriptors.length];
for (int i = 0; i < indexProviderDescriptors.length; i++) {
IndexProviderDescriptor indexProviderDescriptor = indexProviderDescriptors[i];
IndexProvider indexProvider = mockIndexProviderWithAccessor(indexProviderDescriptor);
indexProviders[i] = indexProvider;
// Two indexes per provider
for (int j = 0; j < 2; j++) {
IndexDescriptor index = storeIndex(id, 1, id, indexProviderDescriptor);
indexDescriptors.add(index);
when(indexProvider.getInitialState(eq(index), any())).thenReturn(ONLINE);
id++;
}
}
Config config = Config.defaults(default_schema_provider, nativeBtree10Descriptor.name());
DependencyResolver dependencies = buildIndexDependencies(indexProviders);
DefaultIndexProviderMap providerMap = new DefaultIndexProviderMap(dependencies, config);
providerMap.init();
when(indexStatisticsStore.indexSample(anyLong())).thenReturn(new IndexSample(1, 1, 1));
IndexingService indexingService = IndexingServiceFactory.createIndexingService(config, mock(JobScheduler.class), providerMap, storeViewFactory, nameLookup, indexDescriptors, internalLogProvider, userLogProvider, IndexingService.NO_MONITOR, schemaState, indexStatisticsStore, PageCacheTracer.NULL, INSTANCE, "", writable());
// when starting IndexingService
indexingService.init();
for (IndexProviderDescriptor indexProviderDescriptor : indexProviderDescriptors) {
onBothLogProviders(logProvider -> assertThat(logProvider).doesNotContainMessage(indexProviderDescriptor.name()));
}
userLogProvider.clear();
indexingService.start();
// then we should see log messages about deprecated providers if any
for (IndexProviderDescriptor indexProviderDescriptor : indexProviderDescriptors) {
if (isDeprecated(indexProviderDescriptor)) {
assertThat(userLogProvider).containsMessages("Deprecated index providers in use:", indexProviderDescriptor.name() + " (2 indexes)", "Use procedure 'db.indexes()' to see what indexes use which index provider.");
} else {
onBothLogProviders(logProvider -> assertThat(logProvider).doesNotContainMessage(indexProviderDescriptor.name()));
}
}
}
use of org.neo4j.internal.schema.IndexProviderDescriptor in project neo4j by neo4j.
the class IndexDirectoryStructureTest method shouldHandleWeirdCharactersInProviderKey.
@Test
void shouldHandleWeirdCharactersInProviderKey() {
IndexProviderDescriptor providerWithWeirdName = new IndexProviderDescriptor("native+lucene", "1.0");
assertCorrectDirectories(directoriesByProvider(databaseStoreDir).forProvider(providerWithWeirdName), baseIndexDirectory.resolve("native_lucene-1.0"), baseIndexDirectory.resolve("native_lucene-1.0").resolve(String.valueOf(indexId)));
}
Aggregations