Search in sources :

Example 6 with IndexPopulationFailedKernelException

use of org.neo4j.kernel.api.exceptions.index.IndexPopulationFailedKernelException in project neo4j by neo4j.

the class MultipleIndexPopulatorUpdatesTest method updateForHigherNodeIgnoredWhenUsingFullNodeStoreScan.

@Test
public void updateForHigherNodeIgnoredWhenUsingFullNodeStoreScan() throws IndexPopulationFailedKernelException, IOException, IndexEntryConflictException {
    NeoStores neoStores = Mockito.mock(NeoStores.class);
    CountsTracker countsTracker = mock(CountsTracker.class);
    NodeStore nodeStore = mock(NodeStore.class);
    PropertyStore propertyStore = mock(PropertyStore.class);
    NodeRecord nodeRecord = getNodeRecord();
    PropertyRecord propertyRecord = getPropertyRecord();
    when(neoStores.getCounts()).thenReturn(countsTracker);
    when(neoStores.getNodeStore()).thenReturn(nodeStore);
    when(neoStores.getPropertyStore()).thenReturn(propertyStore);
    when(propertyStore.getPropertyRecordChain(anyInt())).thenReturn(Collections.singletonList(propertyRecord));
    when(countsTracker.nodeCount(anyInt(), any(Register.DoubleLongRegister.class))).thenReturn(Registers.newDoubleLongRegister(3, 3));
    when(nodeStore.getHighestPossibleIdInUse()).thenReturn(20L);
    when(nodeStore.newRecord()).thenReturn(nodeRecord);
    when(nodeStore.getRecord(anyInt(), eq(nodeRecord), any(RecordLoad.class))).thenAnswer(new SetNodeIdRecordAnswer(nodeRecord, 1));
    when(nodeStore.getRecord(eq(7L), eq(nodeRecord), any(RecordLoad.class))).thenAnswer(new SetNodeIdRecordAnswer(nodeRecord, 7));
    ProcessListenableNeoStoreIndexView storeView = new ProcessListenableNeoStoreIndexView(LockService.NO_LOCK_SERVICE, neoStores);
    MultipleIndexPopulator indexPopulator = new MultipleIndexPopulator(storeView, logProvider);
    storeView.setProcessListener(new NodeUpdateProcessListener(indexPopulator));
    IndexPopulator populator = createIndexPopulator();
    IndexUpdater indexUpdater = mock(IndexUpdater.class);
    when(populator.newPopulatingUpdater(storeView)).thenReturn(indexUpdater);
    addPopulator(indexPopulator, populator, 1, NewIndexDescriptorFactory.forLabel(1, 1));
    indexPopulator.create();
    StoreScan<IndexPopulationFailedKernelException> storeScan = indexPopulator.indexAllNodes();
    storeScan.run();
    Mockito.verify(indexUpdater, times(0)).process(any(IndexEntryUpdate.class));
}
Also used : IndexEntryUpdate(org.neo4j.kernel.api.index.IndexEntryUpdate) IndexPopulationFailedKernelException(org.neo4j.kernel.api.exceptions.index.IndexPopulationFailedKernelException) RecordLoad(org.neo4j.kernel.impl.store.record.RecordLoad) NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) IndexPopulator(org.neo4j.kernel.api.index.IndexPopulator) NodeStore(org.neo4j.kernel.impl.store.NodeStore) PropertyRecord(org.neo4j.kernel.impl.store.record.PropertyRecord) NeoStores(org.neo4j.kernel.impl.store.NeoStores) CountsTracker(org.neo4j.kernel.impl.store.counts.CountsTracker) IndexUpdater(org.neo4j.kernel.api.index.IndexUpdater) PropertyStore(org.neo4j.kernel.impl.store.PropertyStore) Test(org.junit.Test)

Example 7 with IndexPopulationFailedKernelException

use of org.neo4j.kernel.api.exceptions.index.IndexPopulationFailedKernelException in project neo4j by neo4j.

the class NeoStoreTransactionApplierTest method shouldApplyUpdateIndexRuleSchemaRuleCommandToTheStoreThrowingIndexProblem.

@Test
public void shouldApplyUpdateIndexRuleSchemaRuleCommandToTheStoreThrowingIndexProblem() throws IOException, IndexNotFoundKernelException, IndexPopulationFailedKernelException, IndexActivationFailedKernelException {
    // given
    final BatchTransactionApplier applier = newIndexApplier();
    doThrow(new IndexNotFoundKernelException("")).when(indexingService).activateIndex(anyLong());
    final DynamicRecord record = DynamicRecord.dynamicRecord(21, true);
    final Collection<DynamicRecord> recordsAfter = Arrays.asList(record);
    final IndexRule rule = constraintIndexRule(0, 1, 2, new SchemaIndexProvider.Descriptor("K", "X.Y"), 42L);
    final Command.SchemaRuleCommand command = new Command.SchemaRuleCommand(Collections.<DynamicRecord>emptyList(), recordsAfter, rule);
    // when
    try {
        apply(applier, command::handle, transactionToApply);
        fail("should have thrown");
    } catch (Exception e) {
        // then
        assertTrue(e.getCause() instanceof IndexNotFoundKernelException);
    }
}
Also used : DynamicRecord(org.neo4j.kernel.impl.store.record.DynamicRecord) IndexRule(org.neo4j.kernel.impl.store.record.IndexRule) SchemaIndexProvider(org.neo4j.kernel.api.index.SchemaIndexProvider) RelationshipTypeTokenCommand(org.neo4j.kernel.impl.transaction.command.Command.RelationshipTypeTokenCommand) LabelTokenCommand(org.neo4j.kernel.impl.transaction.command.Command.LabelTokenCommand) PropertyKeyTokenCommand(org.neo4j.kernel.impl.transaction.command.Command.PropertyKeyTokenCommand) IndexNotFoundKernelException(org.neo4j.kernel.api.exceptions.index.IndexNotFoundKernelException) BatchTransactionApplier(org.neo4j.kernel.impl.api.BatchTransactionApplier) IndexNotFoundKernelException(org.neo4j.kernel.api.exceptions.index.IndexNotFoundKernelException) IndexPopulationFailedKernelException(org.neo4j.kernel.api.exceptions.index.IndexPopulationFailedKernelException) IOException(java.io.IOException) IndexActivationFailedKernelException(org.neo4j.kernel.api.exceptions.index.IndexActivationFailedKernelException) Test(org.junit.Test)

Aggregations

IndexPopulationFailedKernelException (org.neo4j.kernel.api.exceptions.index.IndexPopulationFailedKernelException)7 Test (org.junit.Test)5 NodeUpdates (org.neo4j.kernel.api.index.NodeUpdates)3 IOException (java.io.IOException)2 ExecutorService (java.util.concurrent.ExecutorService)2 Visitor (org.neo4j.helpers.collection.Visitor)2 IndexEntryConflictException (org.neo4j.kernel.api.exceptions.index.IndexEntryConflictException)2 IndexEntryUpdate (org.neo4j.kernel.api.index.IndexEntryUpdate)2 IndexPopulator (org.neo4j.kernel.api.index.IndexPopulator)2 IndexUpdater (org.neo4j.kernel.api.index.IndexUpdater)2 PropertyAccessor (org.neo4j.kernel.api.index.PropertyAccessor)2 SchemaIndexProvider (org.neo4j.kernel.api.index.SchemaIndexProvider)2 NewIndexDescriptor (org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor)2 NeoStoreIndexStoreView (org.neo4j.kernel.impl.transaction.state.storeview.NeoStoreIndexStoreView)2 String.format (java.lang.String.format)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 List (java.util.List)1