use of org.neo4j.kernel.api.index.IndexProvider in project neo4j by neo4j.
the class ConstraintCreationIT method shouldNotLeaveLuceneIndexFilesHangingAroundIfConstraintCreationFails.
@Test
@DbmsExtension(configurationCallback = "configureLuceneSubProvider")
void shouldNotLeaveLuceneIndexFilesHangingAroundIfConstraintCreationFails() {
// given
attemptAndFailConstraintCreation();
// then
IndexProvider indexProvider = indexProviderMap.getDefaultProvider();
Path indexDir = indexProvider.directoryStructure().directoryForIndex(indexId);
assertFalse(Files.exists(indexDir));
}
use of org.neo4j.kernel.api.index.IndexProvider in project neo4j by neo4j.
the class ConstraintCreationIT method shouldNotLeaveNativeIndexFilesHangingAroundIfConstraintCreationFails.
@Test
void shouldNotLeaveNativeIndexFilesHangingAroundIfConstraintCreationFails() {
// given
attemptAndFailConstraintCreation();
// then
IndexProvider indexProvider = indexProviderMap.getDefaultProvider();
Path indexDir = indexProvider.directoryStructure().directoryForIndex(indexId);
assertFalse(Files.exists(indexDir));
}
use of org.neo4j.kernel.api.index.IndexProvider in project neo4j by neo4j.
the class IndexingService method init.
/**
* Called while the database starts up, before recovery.
*/
@Override
public void init() throws IOException {
validateDefaultProviderExisting();
try (var cursorContext = new CursorContext(pageCacheTracer.createPageCursorTracer(INIT_TAG))) {
indexMapRef.modify(indexMap -> {
Map<InternalIndexState, List<IndexLogRecord>> indexStates = new EnumMap<>(InternalIndexState.class);
for (IndexDescriptor descriptor : indexDescriptors) {
// No index (except NLI) is allowed to have the name generated for NLI.
if (descriptor.getName().equals(IndexDescriptor.NLI_GENERATED_NAME) && !(descriptor.schema().isAnyTokenSchemaDescriptor() && descriptor.schema().entityType() == NODE)) {
throw new IllegalStateException("Index '" + descriptor.userDescription(tokenNameLookup) + "' is using a reserved name: '" + IndexDescriptor.NLI_GENERATED_NAME + "'. This index must be removed on an earlier version " + "to be able to use binaries for version 4.3 or newer.");
}
IndexProxy indexProxy;
IndexProviderDescriptor providerDescriptor = descriptor.getIndexProvider();
IndexProvider provider = providerMap.lookup(providerDescriptor);
InternalIndexState initialState = provider.getInitialState(descriptor, cursorContext);
indexStates.computeIfAbsent(initialState, internalIndexState -> new ArrayList<>()).add(new IndexLogRecord(descriptor));
internalLog.debug(indexStateInfo("init", initialState, descriptor));
switch(initialState) {
case ONLINE:
monitor.initialState(databaseName, descriptor, ONLINE);
indexProxy = indexProxyCreator.createOnlineIndexProxy(descriptor);
break;
case POPULATING:
// The database was shut down during population, or a crash has occurred, or some other sad thing.
monitor.initialState(databaseName, descriptor, POPULATING);
indexProxy = indexProxyCreator.createRecoveringIndexProxy(descriptor);
break;
case FAILED:
monitor.initialState(databaseName, descriptor, FAILED);
IndexPopulationFailure failure = failure(provider.getPopulationFailure(descriptor, cursorContext));
indexProxy = indexProxyCreator.createFailedIndexProxy(descriptor, failure);
break;
default:
throw new IllegalArgumentException("" + initialState);
}
indexMap.putIndexProxy(indexProxy);
}
logIndexStateSummary("init", indexStates);
return indexMap;
});
}
indexStatisticsStore.init();
}
use of org.neo4j.kernel.api.index.IndexProvider in project neo4j by neo4j.
the class FusionIndexProviderTest method setupMocks.
private void setupMocks() {
IndexSlot[] aliveSlots = fusionVersion.aliveSlots();
aliveProviders = new IndexProvider[aliveSlots.length];
providers = new EnumMap<>(IndexSlot.class);
fill(providers, IndexProvider.EMPTY);
for (int i = 0; i < aliveSlots.length; i++) {
switch(aliveSlots[i]) {
case GENERIC:
IndexProvider generic = mockProvider(GenericNativeIndexProvider.class, "generic");
providers.put(GENERIC, generic);
aliveProviders[i] = generic;
break;
case LUCENE:
IndexProvider lucene = mockProvider(IndexProvider.class, "lucene");
providers.put(LUCENE, lucene);
aliveProviders[i] = lucene;
break;
default:
throw new RuntimeException();
}
}
fusionIndexProvider = new FusionIndexProvider(providers.get(GENERIC), providers.get(LUCENE), fusionVersion.slotSelector(), DESCRIPTOR, NONE, mock(FileSystemAbstraction.class), false, writable());
instanceSelector = new InstanceSelector<>(providers);
}
use of org.neo4j.kernel.api.index.IndexProvider in project neo4j by neo4j.
the class FusionIndexProviderTest method mockProvider.
private static IndexProvider mockProvider(Class<? extends IndexProvider> providerClass, String name) {
IndexProvider mock = mock(providerClass);
when(mock.getProviderDescriptor()).thenReturn(new IndexProviderDescriptor(name, "1"));
return mock;
}
Aggregations