Search in sources :

Example 6 with SchemaRuleNotFoundException

use of org.neo4j.kernel.api.exceptions.schema.SchemaRuleNotFoundException in project neo4j by neo4j.

the class SchemaImpl method getIndexState.

@Override
public IndexState getIndexState(final IndexDefinition index) {
    actions.assertInOpenTransaction();
    try (Statement statement = statementContextSupplier.get()) {
        ReadOperations readOps = statement.readOperations();
        NewIndexDescriptor descriptor = getIndexDescriptor(readOps, index);
        InternalIndexState indexState = readOps.indexGetState(descriptor);
        switch(indexState) {
            case POPULATING:
                return POPULATING;
            case ONLINE:
                return ONLINE;
            case FAILED:
                return FAILED;
            default:
                throw new IllegalArgumentException(String.format("Illegal index state %s", indexState));
        }
    } catch (SchemaRuleNotFoundException | IndexNotFoundKernelException e) {
        throw new NotFoundException(format("No index for label %s on property %s", index.getLabel().name(), index.getPropertyKeys()));
    }
}
Also used : ReadOperations(org.neo4j.kernel.api.ReadOperations) KeyReadOperations(org.neo4j.kernel.impl.api.operations.KeyReadOperations) InternalIndexState(org.neo4j.kernel.api.index.InternalIndexState) NewIndexDescriptor(org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor) Statement(org.neo4j.kernel.api.Statement) NotFoundException(org.neo4j.graphdb.NotFoundException) SchemaRuleNotFoundException(org.neo4j.kernel.api.exceptions.schema.SchemaRuleNotFoundException) SchemaRuleNotFoundException(org.neo4j.kernel.api.exceptions.schema.SchemaRuleNotFoundException) IndexNotFoundKernelException(org.neo4j.kernel.api.exceptions.index.IndexNotFoundKernelException)

Example 7 with SchemaRuleNotFoundException

use of org.neo4j.kernel.api.exceptions.schema.SchemaRuleNotFoundException in project neo4j by neo4j.

the class SchemaImpl method getIndexFailure.

@Override
public String getIndexFailure(IndexDefinition index) {
    actions.assertInOpenTransaction();
    try (Statement statement = statementContextSupplier.get()) {
        ReadOperations readOps = statement.readOperations();
        NewIndexDescriptor descriptor = getIndexDescriptor(readOps, index);
        return readOps.indexGetFailure(descriptor);
    } catch (SchemaRuleNotFoundException | IndexNotFoundKernelException e) {
        throw new NotFoundException(format("No index for label %s on property %s", index.getLabel().name(), index.getPropertyKeys()));
    }
}
Also used : ReadOperations(org.neo4j.kernel.api.ReadOperations) KeyReadOperations(org.neo4j.kernel.impl.api.operations.KeyReadOperations) NewIndexDescriptor(org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor) Statement(org.neo4j.kernel.api.Statement) NotFoundException(org.neo4j.graphdb.NotFoundException) SchemaRuleNotFoundException(org.neo4j.kernel.api.exceptions.schema.SchemaRuleNotFoundException) SchemaRuleNotFoundException(org.neo4j.kernel.api.exceptions.schema.SchemaRuleNotFoundException) IndexNotFoundKernelException(org.neo4j.kernel.api.exceptions.index.IndexNotFoundKernelException)

Example 8 with SchemaRuleNotFoundException

use of org.neo4j.kernel.api.exceptions.schema.SchemaRuleNotFoundException in project neo4j by neo4j.

the class AwaitIndexProcedureTest method shouldThrowAnExceptionIfTheIndexDoesNotExist.

@Test
public void shouldThrowAnExceptionIfTheIndexDoesNotExist() throws SchemaRuleNotFoundException, IndexNotFoundKernelException {
    when(operations.propertyKeyGetForName(anyString())).thenReturn(0);
    when(operations.labelGetForName(anyString())).thenReturn(0);
    when(operations.indexGetForLabelAndPropertyKey(any())).thenThrow(new SchemaRuleNotFoundException(INDEX_RULE, SchemaDescriptorFactory.forLabel(0, 0)));
    try {
        procedure.awaitIndex(":Person(name)", timeout, timeoutUnits);
        fail("Expected an exception");
    } catch (ProcedureException e) {
        assertThat(e.status(), is(Status.Schema.IndexNotFound));
    }
}
Also used : SchemaRuleNotFoundException(org.neo4j.kernel.api.exceptions.schema.SchemaRuleNotFoundException) ProcedureException(org.neo4j.kernel.api.exceptions.ProcedureException) Test(org.junit.Test)

Example 9 with SchemaRuleNotFoundException

use of org.neo4j.kernel.api.exceptions.schema.SchemaRuleNotFoundException in project neo4j by neo4j.

the class ResampleIndexProcedureTest method shouldThrowAnExceptionIfTheIndexDoesNotExist.

@Test
public void shouldThrowAnExceptionIfTheIndexDoesNotExist() throws SchemaRuleNotFoundException, IndexNotFoundKernelException {
    when(operations.labelGetForName(anyString())).thenReturn(0);
    when(operations.propertyKeyGetForName(anyString())).thenReturn(0);
    when(operations.indexGetForLabelAndPropertyKey(any())).thenThrow(new SchemaRuleNotFoundException(INDEX_RULE, SchemaDescriptorFactory.forLabel(0, 0)));
    try {
        procedure.resampleIndex(":Person(name)");
        fail("Expected an exception");
    } catch (ProcedureException e) {
        assertThat(e.status(), is(Status.Schema.IndexNotFound));
    }
}
Also used : SchemaRuleNotFoundException(org.neo4j.kernel.api.exceptions.schema.SchemaRuleNotFoundException) ProcedureException(org.neo4j.kernel.api.exceptions.ProcedureException) Test(org.junit.Test)

Aggregations

SchemaRuleNotFoundException (org.neo4j.kernel.api.exceptions.schema.SchemaRuleNotFoundException)9 NewIndexDescriptor (org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor)6 IndexNotFoundKernelException (org.neo4j.kernel.api.exceptions.index.IndexNotFoundKernelException)4 NotFoundException (org.neo4j.graphdb.NotFoundException)3 ReadOperations (org.neo4j.kernel.api.ReadOperations)3 Statement (org.neo4j.kernel.api.Statement)3 KeyReadOperations (org.neo4j.kernel.impl.api.operations.KeyReadOperations)3 Test (org.junit.Test)2 ProcedureException (org.neo4j.kernel.api.exceptions.ProcedureException)2 DuplicateSchemaRuleException (org.neo4j.kernel.api.exceptions.schema.DuplicateSchemaRuleException)2 IOException (java.io.IOException)1 IndexPopulationProgress (org.neo4j.graphdb.index.IndexPopulationProgress)1 IndexEntryConflictException (org.neo4j.kernel.api.exceptions.index.IndexEntryConflictException)1 CreateConstraintFailureException (org.neo4j.kernel.api.exceptions.schema.CreateConstraintFailureException)1 UniquePropertyValueValidationException (org.neo4j.kernel.api.exceptions.schema.UniquePropertyValueValidationException)1 InternalIndexState (org.neo4j.kernel.api.index.InternalIndexState)1 UniquenessConstraintDescriptor (org.neo4j.kernel.api.schema_new.constaints.UniquenessConstraintDescriptor)1 Client (org.neo4j.kernel.impl.locking.Locks.Client)1 ConstraintRule (org.neo4j.kernel.impl.store.record.ConstraintRule)1 PopulationProgress (org.neo4j.storageengine.api.schema.PopulationProgress)1