Search in sources :

Example 6 with ConstraintIndexCreator

use of org.neo4j.kernel.impl.api.state.ConstraintIndexCreator in project neo4j by neo4j.

the class ConstraintIndexCreatorTest method shouldReleaseSchemaLockWhileAwaitingIndexPopulation.

@Test
public void shouldReleaseSchemaLockWhileAwaitingIndexPopulation() throws Exception {
    // given
    StubKernel kernel = new StubKernel();
    IndexingService indexingService = mock(IndexingService.class);
    StatementOperationParts constraintCreationContext = mockedParts();
    PropertyAccessor propertyAccessor = mock(PropertyAccessor.class);
    KernelStatement state = mockedState();
    when(constraintCreationContext.schemaReadOperations().indexGetCommittedId(state, index)).thenReturn(2468L);
    IndexProxy indexProxy = mock(IndexProxy.class);
    when(indexingService.getIndexProxy(anyLong())).thenReturn(indexProxy);
    ConstraintIndexCreator creator = new ConstraintIndexCreator(() -> kernel, indexingService, propertyAccessor, true);
    // when
    creator.createUniquenessConstraintIndex(state, constraintCreationContext.schemaReadOperations(), index.schema());
    // then
    verify(state.locks().pessimistic()).releaseExclusive(ResourceTypes.SCHEMA, ResourceTypes.schemaResource());
    verify(state.locks().pessimistic()).acquireExclusive(state.lockTracer(), ResourceTypes.SCHEMA, ResourceTypes.schemaResource());
}
Also used : ConstraintIndexCreator(org.neo4j.kernel.impl.api.state.ConstraintIndexCreator) PropertyAccessor(org.neo4j.kernel.api.index.PropertyAccessor) StatementOperationParts(org.neo4j.kernel.impl.api.StatementOperationParts) KernelStatement(org.neo4j.kernel.impl.api.KernelStatement) IndexingService(org.neo4j.kernel.impl.api.index.IndexingService) IndexProxy(org.neo4j.kernel.impl.api.index.IndexProxy) Test(org.junit.Test)

Aggregations

ConstraintIndexCreator (org.neo4j.kernel.impl.api.state.ConstraintIndexCreator)6 Test (org.junit.Test)5 PropertyAccessor (org.neo4j.kernel.api.index.PropertyAccessor)5 IndexingService (org.neo4j.kernel.impl.api.index.IndexingService)4 NewIndexDescriptor (org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor)3 KernelStatement (org.neo4j.kernel.impl.api.KernelStatement)3 StatementOperationParts (org.neo4j.kernel.impl.api.StatementOperationParts)3 IndexProxy (org.neo4j.kernel.impl.api.index.IndexProxy)3 KernelAPI (org.neo4j.kernel.api.KernelAPI)1 ReadOperations (org.neo4j.kernel.api.ReadOperations)1 IndexEntryConflictException (org.neo4j.kernel.api.exceptions.index.IndexEntryConflictException)1 IndexPopulationFailedKernelException (org.neo4j.kernel.api.exceptions.index.IndexPopulationFailedKernelException)1 UniquePropertyValueValidationException (org.neo4j.kernel.api.exceptions.schema.UniquePropertyValueValidationException)1 TransactionState (org.neo4j.kernel.api.txstate.TransactionState)1 Kernel (org.neo4j.kernel.impl.api.Kernel)1 KernelTransactions (org.neo4j.kernel.impl.api.KernelTransactions)1 StatementOperationContainer (org.neo4j.kernel.impl.api.StatementOperationContainer)1 TransactionCommitProcess (org.neo4j.kernel.impl.api.TransactionCommitProcess)1 TransactionHooks (org.neo4j.kernel.impl.api.TransactionHooks)1 KernelIntegrationTest (org.neo4j.kernel.impl.api.integrationtest.KernelIntegrationTest)1