Search in sources :

Example 16 with InternalIndexState

use of org.neo4j.internal.kernel.api.InternalIndexState in project neo4j by neo4j.

the class SchemaStatementProcedureTest method schemaStatementsMustIncludeOnlineIndexes.

@Test
void schemaStatementsMustIncludeOnlineIndexes() throws IndexNotFoundKernelException, ProcedureException {
    IndexDescriptor index = someIndex();
    InternalIndexState indexState = InternalIndexState.ONLINE;
    SchemaReadCore schemaReadCore = getSchemaReadCore(index, indexState);
    TokenRead tokenRead = mock(TokenRead.class);
    Collection<BuiltInProcedures.SchemaStatementResult> result = createSchemaStatementResults(schemaReadCore, tokenRead);
    assertEquals(1, result.size());
}
Also used : InternalIndexState(org.neo4j.internal.kernel.api.InternalIndexState) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor) SchemaReadCore(org.neo4j.internal.kernel.api.SchemaReadCore) TokenRead(org.neo4j.internal.kernel.api.TokenRead) Test(org.junit.jupiter.api.Test)

Example 17 with InternalIndexState

use of org.neo4j.internal.kernel.api.InternalIndexState in project neo4j by neo4j.

the class SchemaStatementProcedureTest method schemaStatementsMustNotIncludePopulatingIndexes.

@Test
void schemaStatementsMustNotIncludePopulatingIndexes() throws ProcedureException, IndexNotFoundKernelException {
    IndexDescriptor index = someIndex();
    InternalIndexState indexState = InternalIndexState.POPULATING;
    SchemaReadCore schemaReadCore = getSchemaReadCore(index, indexState);
    TokenRead tokenRead = mock(TokenRead.class);
    Collection<BuiltInProcedures.SchemaStatementResult> result = createSchemaStatementResults(schemaReadCore, tokenRead);
    assertEquals(0, result.size());
}
Also used : InternalIndexState(org.neo4j.internal.kernel.api.InternalIndexState) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor) SchemaReadCore(org.neo4j.internal.kernel.api.SchemaReadCore) TokenRead(org.neo4j.internal.kernel.api.TokenRead) Test(org.junit.jupiter.api.Test)

Example 18 with InternalIndexState

use of org.neo4j.internal.kernel.api.InternalIndexState in project neo4j by neo4j.

the class SchemaStatementProcedureTest method schemaStatementsMustOnlyIncludeIndexBackedConstraintNotActualIndex.

@Test
void schemaStatementsMustOnlyIncludeIndexBackedConstraintNotActualIndex() throws IndexNotFoundKernelException, ProcedureException {
    IndexDescriptor index = someOrphanedIndex();
    ConstraintDescriptor constraint = indexBackedConstraint(index);
    index = indexBoundToConstraint(index, constraint);
    InternalIndexState internalIndexState = InternalIndexState.ONLINE;
    SchemaReadCore schemaReadCore = getSchemaReadCore(constraint, index, internalIndexState);
    TokenRead tokenRead = mock(TokenRead.class);
    Collection<BuiltInProcedures.SchemaStatementResult> result = createSchemaStatementResults(schemaReadCore, tokenRead);
    Iterator<BuiltInProcedures.SchemaStatementResult> iter = result.iterator();
    assertTrue(iter.hasNext());
    BuiltInProcedures.SchemaStatementResult next = iter.next();
    assertEquals(SchemaStatementProcedure.SchemaRuleType.CONSTRAINT.name(), next.type);
    assertEquals(CONSTRAINT_NAME, next.name);
    assertFalse(iter.hasNext());
}
Also used : InternalIndexState(org.neo4j.internal.kernel.api.InternalIndexState) ConstraintDescriptor(org.neo4j.internal.schema.ConstraintDescriptor) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor) SchemaReadCore(org.neo4j.internal.kernel.api.SchemaReadCore) TokenRead(org.neo4j.internal.kernel.api.TokenRead) Test(org.junit.jupiter.api.Test)

Example 19 with InternalIndexState

use of org.neo4j.internal.kernel.api.InternalIndexState in project neo4j by neo4j.

the class IndexProviderTests method shouldReportInitialStateAsFailedIfMarkedAsFailed.

@Test
void shouldReportInitialStateAsFailedIfMarkedAsFailed() throws IOException {
    // given
    provider = newProvider();
    IndexPopulator populator = provider.getPopulator(descriptor(), samplingConfig(), heapBufferFactory(1024), INSTANCE, tokenNameLookup);
    populator.create();
    populator.markAsFailed("Just some failure");
    populator.close(false, NULL);
    // when
    InternalIndexState state = provider.getInitialState(descriptor(), NULL);
    // then
    assertEquals(InternalIndexState.FAILED, state);
}
Also used : IndexPopulator(org.neo4j.kernel.api.index.IndexPopulator) InternalIndexState(org.neo4j.internal.kernel.api.InternalIndexState) Test(org.junit.jupiter.api.Test)

Example 20 with InternalIndexState

use of org.neo4j.internal.kernel.api.InternalIndexState in project neo4j by neo4j.

the class BuiltInProcedures method getIndexStatus.

private static IndexStatus getIndexStatus(SchemaReadCore schemaRead, IndexDescriptor index) {
    IndexStatus status = new IndexStatus();
    try {
        InternalIndexState internalIndexState = schemaRead.indexGetState(index);
        status.state = internalIndexState.toString();
        PopulationProgress progress = schemaRead.indexGetPopulationProgress(index);
        status.populationProgress = progress.toIndexPopulationProgress().getCompletedPercentage();
        status.failureMessage = internalIndexState == InternalIndexState.FAILED ? schemaRead.indexGetFailure(index) : "";
    } catch (IndexNotFoundKernelException e) {
        status.state = "NOT FOUND";
        status.populationProgress = 0D;
        status.failureMessage = "Index not found. It might have been concurrently dropped.";
    }
    return status;
}
Also used : InternalIndexState(org.neo4j.internal.kernel.api.InternalIndexState) PopulationProgress(org.neo4j.internal.kernel.api.PopulationProgress) IndexNotFoundKernelException(org.neo4j.internal.kernel.api.exceptions.schema.IndexNotFoundKernelException)

Aggregations

InternalIndexState (org.neo4j.internal.kernel.api.InternalIndexState)25 Test (org.junit.jupiter.api.Test)17 IndexDescriptor (org.neo4j.internal.schema.IndexDescriptor)16 SchemaReadCore (org.neo4j.internal.kernel.api.SchemaReadCore)7 TokenRead (org.neo4j.internal.kernel.api.TokenRead)7 IndexNotFoundKernelException (org.neo4j.internal.kernel.api.exceptions.schema.IndexNotFoundKernelException)7 IndexPopulator (org.neo4j.kernel.api.index.IndexPopulator)5 ArrayList (java.util.ArrayList)3 EnumMap (java.util.EnumMap)3 HashMap (java.util.HashMap)3 List (java.util.List)3 Map (java.util.Map)3 MutableLongObjectMap (org.eclipse.collections.api.map.primitive.MutableLongObjectMap)3 LongObjectHashMap (org.eclipse.collections.impl.map.mutable.primitive.LongObjectHashMap)3 IndexProvider (org.neo4j.kernel.api.index.IndexProvider)3 IOException (java.io.IOException)2 UncheckedIOException (java.io.UncheckedIOException)2 String.format (java.lang.String.format)2 Path (java.nio.file.Path)2 Arrays (java.util.Arrays)2