Search in sources :

Example 66 with NewIndexDescriptor

use of org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor in project neo4j by neo4j.

the class LuceneSchemaIndexCorruptionTest method shouldRequestIndexPopulationIfTheIndexIsCorrupt.

@Test
public void shouldRequestIndexPopulationIfTheIndexIsCorrupt() throws Exception {
    // Given
    long faultyIndexId = 1;
    CorruptIndexException error = new CorruptIndexException("It's broken.", "");
    LuceneSchemaIndexProvider provider = newFaultySchemaIndexProvider(faultyIndexId, error);
    // When
    NewIndexDescriptor descriptor = NewIndexDescriptorFactory.forLabel(1, 1);
    InternalIndexState initialState = provider.getInitialState(faultyIndexId, descriptor);
    // Then
    assertThat(initialState, equalTo(InternalIndexState.POPULATING));
    logProvider.assertAtLeastOnce(loggedException(error));
}
Also used : InternalIndexState(org.neo4j.kernel.api.index.InternalIndexState) NewIndexDescriptor(org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor) CorruptIndexException(org.apache.lucene.index.CorruptIndexException) Test(org.junit.Test)

Example 67 with NewIndexDescriptor

use of org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor in project neo4j by neo4j.

the class ResampleIndexProcedureTest method shouldTriggerResampling.

@Test
public void shouldTriggerResampling() throws SchemaRuleNotFoundException, ProcedureException, IndexNotFoundKernelException {
    NewIndexDescriptor index = NewIndexDescriptorFactory.forLabel(123, 456);
    when(operations.indexGetForLabelAndPropertyKey(anyObject())).thenReturn(index);
    procedure.resampleIndex(":Person(name)");
    verify(indexingService).triggerIndexSampling(index.schema(), IndexSamplingMode.TRIGGER_REBUILD_ALL);
}
Also used : NewIndexDescriptor(org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor) Test(org.junit.Test)

Example 68 with NewIndexDescriptor

use of org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor in project neo4j by neo4j.

the class ResampleIndexProcedureTest method shouldLookUpTheIndexByLabelIdAndPropertyKeyId.

@Test
public void shouldLookUpTheIndexByLabelIdAndPropertyKeyId() throws ProcedureException, SchemaRuleNotFoundException, IndexNotFoundKernelException {
    NewIndexDescriptor index = NewIndexDescriptorFactory.forLabel(0, 0);
    when(operations.labelGetForName(anyString())).thenReturn(123);
    when(operations.propertyKeyGetForName(anyString())).thenReturn(456);
    when(operations.indexGetForLabelAndPropertyKey(anyObject())).thenReturn(index);
    procedure.resampleIndex(":Person(name)");
    verify(operations).indexGetForLabelAndPropertyKey(new NodePropertyDescriptor(123, 456));
}
Also used : NewIndexDescriptor(org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor) NodePropertyDescriptor(org.neo4j.kernel.api.schema.NodePropertyDescriptor) Test(org.junit.Test)

Example 69 with NewIndexDescriptor

use of org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor in project neo4j by neo4j.

the class KernelSchemaStateFlushingTest method createIndex.

private NewIndexDescriptor createIndex() throws KernelException {
    try (KernelTransaction transaction = kernel.newTransaction(KernelTransaction.Type.implicit, AUTH_DISABLED);
        Statement statement = transaction.acquireStatement()) {
        NewIndexDescriptor descriptor = statement.schemaWriteOperations().indexCreate(SchemaDescriptorFactory.forLabel(1, 1));
        transaction.success();
        return descriptor;
    }
}
Also used : KernelTransaction(org.neo4j.kernel.api.KernelTransaction) NewIndexDescriptor(org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor) Statement(org.neo4j.kernel.api.Statement)

Example 70 with NewIndexDescriptor

use of org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor in project neo4j by neo4j.

the class KernelSchemaStateFlushingTest method shouldInvalidateSchemaStateOnDropIndex.

@Test
public void shouldInvalidateSchemaStateOnDropIndex() throws Exception {
    NewIndexDescriptor descriptor = createIndex();
    awaitIndexOnline(descriptor, "test");
    commitToSchemaState("test", "before");
    dropIndex(descriptor);
    // when
    String after = commitToSchemaState("test", "after");
    // then
    assertEquals("after", after);
}
Also used : NewIndexDescriptor(org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor) Test(org.junit.Test)

Aggregations

NewIndexDescriptor (org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor)99 Test (org.junit.Test)55 Statement (org.neo4j.kernel.api.Statement)24 ReadOperations (org.neo4j.kernel.api.ReadOperations)17 IndexNotFoundKernelException (org.neo4j.kernel.api.exceptions.index.IndexNotFoundKernelException)10 KernelTransaction (org.neo4j.kernel.api.KernelTransaction)9 SchemaIndexProvider (org.neo4j.kernel.api.index.SchemaIndexProvider)9 InternalIndexState (org.neo4j.kernel.api.index.InternalIndexState)7 Transaction (org.neo4j.graphdb.Transaction)6 IndexDefinition (org.neo4j.graphdb.schema.IndexDefinition)5 IndexEntryConflictException (org.neo4j.kernel.api.exceptions.index.IndexEntryConflictException)5 SchemaRuleNotFoundException (org.neo4j.kernel.api.exceptions.schema.SchemaRuleNotFoundException)5 LabelSchemaDescriptor (org.neo4j.kernel.api.schema_new.LabelSchemaDescriptor)5 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)4 PrimitiveLongSet (org.neo4j.collection.primitive.PrimitiveLongSet)4 Label (org.neo4j.graphdb.Label)4 NotFoundException (org.neo4j.graphdb.NotFoundException)4 KernelException (org.neo4j.kernel.api.exceptions.KernelException)4 NodePropertyDescriptor (org.neo4j.kernel.api.schema.NodePropertyDescriptor)4