use of org.neo4j.kernel.impl.api.index.IndexProxy in project neo4j by neo4j.
the class MultiIndexPopulationConcurrentUpdatesIT method checkIndexIsOnline.
private void checkIndexIsOnline(int labelId) throws IndexNotFoundKernelException {
LabelSchemaDescriptor schema = SchemaDescriptor.forLabel(labelId, propertyId);
IndexDescriptor index = single(schemaCache.indexesForSchema(schema));
IndexProxy indexProxy = indexService.getIndexProxy(index);
assertSame(InternalIndexState.ONLINE, indexProxy.getState());
}
use of org.neo4j.kernel.impl.api.index.IndexProxy in project neo4j by neo4j.
the class MultiIndexPopulationConcurrentUpdatesIT method waitIndexOnline.
private void waitIndexOnline(IndexingService indexService, int propertyId, int labelId) throws IndexNotFoundKernelException, IndexPopulationFailedKernelException, InterruptedException, IndexActivationFailedKernelException {
LabelSchemaDescriptor schema = SchemaDescriptor.forLabel(labelId, propertyId);
IndexDescriptor index = single(schemaCache.indexesForSchema(schema));
IndexProxy indexProxy = indexService.getIndexProxy(index);
indexProxy.awaitStoreScanCompleted(0, TimeUnit.MILLISECONDS);
while (indexProxy.getState() != InternalIndexState.ONLINE) {
Thread.sleep(10);
}
indexProxy.activate();
}
use of org.neo4j.kernel.impl.api.index.IndexProxy in project neo4j by neo4j.
the class PlainOperationsTest method indexedBackedConstraintCreateMustThrowOnIndexTypeFullText.
@Test
void indexedBackedConstraintCreateMustThrowOnIndexTypeFullText() throws Exception {
// given
IndexPrototype prototype = IndexPrototype.uniqueForSchema(schema).withName("constraint name").withIndexProvider(GenericNativeIndexProvider.DESCRIPTOR).withIndexType(IndexType.FULLTEXT);
IndexDescriptor constraintIndex = prototype.materialise(42);
when(constraintIndexCreator.createUniquenessConstraintIndex(any(), any(), eq(prototype))).thenReturn(constraintIndex);
IndexProxy indexProxy = mock(IndexProxy.class);
when(indexProxy.getDescriptor()).thenReturn(constraintIndex);
when(indexingService.getIndexProxy(constraintIndex)).thenReturn(indexProxy);
when(storageReader.constraintsGetForSchema(schema)).thenReturn(Collections.emptyIterator());
when(storageReader.indexGetForSchema(schema)).thenReturn(Collections.emptyIterator());
// when
var e = assertThrows(KernelException.class, () -> operations.uniquePropertyConstraintCreate(prototype));
assertThat(e.getUserMessage(new InMemoryTokens())).contains("FULLTEXT");
}
use of org.neo4j.kernel.impl.api.index.IndexProxy in project neo4j by neo4j.
the class PlainOperationsTest method indexedBackedConstraintCreateMustThrowOnRelationshipSchemas.
@Test
void indexedBackedConstraintCreateMustThrowOnRelationshipSchemas() throws Exception {
// given
when(tokenHolders.relationshipTypeTokens().getTokenById(anyInt())).thenReturn(new NamedToken("RelType", 123));
when(tokenHolders.propertyKeyTokens().getTokenById(anyInt())).thenReturn(new NamedToken("prop", 456));
SchemaDescriptor schema = SchemaDescriptor.forRelType(this.schema.getEntityTokenIds()[0], this.schema.getPropertyIds());
IndexPrototype prototype = IndexPrototype.uniqueForSchema(schema).withName("constraint name").withIndexProvider(GenericNativeIndexProvider.DESCRIPTOR);
IndexDescriptor constraintIndex = prototype.materialise(42);
when(constraintIndexCreator.createUniquenessConstraintIndex(any(), any(), eq(prototype))).thenReturn(constraintIndex);
IndexProxy indexProxy = mock(IndexProxy.class);
when(indexProxy.getDescriptor()).thenReturn(constraintIndex);
when(indexingService.getIndexProxy(constraintIndex)).thenReturn(indexProxy);
when(storageReader.constraintsGetForSchema(schema)).thenReturn(Collections.emptyIterator());
when(storageReader.indexGetForSchema(schema)).thenReturn(Collections.emptyIterator());
// when
var e = assertThrows(KernelException.class, () -> operations.uniquePropertyConstraintCreate(prototype));
assertThat(e.getUserMessage(tokenHolders)).contains("relationship type schema");
}
use of org.neo4j.kernel.impl.api.index.IndexProxy in project neo4j by neo4j.
the class PlainOperationsTest method shouldAcquireSchemaWriteLockBeforeRemovingIndexRuleBySchema.
@Test
void shouldAcquireSchemaWriteLockBeforeRemovingIndexRuleBySchema() throws Exception {
// given
IndexDescriptor index = IndexPrototype.forSchema(SchemaDescriptor.forLabel(0, 0)).withName("index").materialise(0);
IndexProxy indexProxy = mock(IndexProxy.class);
when(indexProxy.getDescriptor()).thenReturn(index);
when(indexingService.getIndexProxy(index)).thenReturn(indexProxy);
when(storageReader.indexGetForSchema(index.schema())).thenReturn(Iterators.iterator(index));
when(storageReader.indexExists(index)).thenReturn(true);
// when
operations.indexDrop(index.schema());
// then
order.verify(locks).acquireExclusive(LockTracer.NONE, ResourceTypes.LABEL, 0);
order.verify(txState).indexDoDrop(index);
}
Aggregations