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());
}
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());
}
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());
}
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);
}
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;
}
Aggregations