use of org.neo4j.kernel.api.index.IndexPopulator in project neo4j by neo4j.
the class FullCheckIntegrationTest method shouldNotReportIndexInconsistenciesIfIndexIsFailed.
@Test
public void shouldNotReportIndexInconsistenciesIfIndexIsFailed() throws Exception {
// this test fails all indexes, and then destroys a record and makes sure we only get a failure for
// the label scan store but not for any index
// given
DirectStoreAccess storeAccess = fixture.directStoreAccess();
// fail all indexes
Iterator<IndexRule> rules = new SchemaStorage(storeAccess.nativeStores().getSchemaStore()).indexesGetAll();
while (rules.hasNext()) {
IndexRule rule = rules.next();
IndexSamplingConfig samplingConfig = new IndexSamplingConfig(Config.empty());
IndexPopulator populator = storeAccess.indexes().getPopulator(rule.getId(), rule.getIndexDescriptor(), samplingConfig);
populator.markAsFailed("Oh noes! I was a shiny index and then I was failed");
populator.close(false);
}
for (Long indexedNodeId : indexedNodes) {
storeAccess.nativeStores().getNodeStore().updateRecord(notInUse(new NodeRecord(indexedNodeId, false, -1, -1)));
}
// when
ConsistencySummaryStatistics stats = check();
// then
on(stats).verify(RecordType.LABEL_SCAN_DOCUMENT, 1).verify(RecordType.COUNTS, 3).andThatsAllFolks();
}
use of org.neo4j.kernel.api.index.IndexPopulator in project neo4j by neo4j.
the class BatchInsertTest method dbWithIndexAndSingleIndexedNode.
private long dbWithIndexAndSingleIndexedNode() throws Exception {
IndexPopulator populator = mock(IndexPopulator.class);
SchemaIndexProvider provider = mock(SchemaIndexProvider.class);
when(provider.getProviderDescriptor()).thenReturn(InMemoryIndexProviderFactory.PROVIDER_DESCRIPTOR);
when(provider.getPopulator(anyLong(), any(NewIndexDescriptor.class), any(IndexSamplingConfig.class))).thenReturn(populator);
BatchInserter inserter = newBatchInserterWithSchemaIndexProvider(singleInstanceSchemaIndexProviderFactory(InMemoryIndexProviderFactory.KEY, provider));
inserter.createDeferredSchemaIndex(label("Hacker")).on("handle").create();
long nodeId = inserter.createNode(map("handle", "Jakewins"), label("Hacker"));
inserter.shutdown();
return nodeId;
}
use of org.neo4j.kernel.api.index.IndexPopulator in project neo4j by neo4j.
the class BatchInsertTest method shouldRunConstraintPopulationJobAtShutdown.
@Test
public void shouldRunConstraintPopulationJobAtShutdown() throws Throwable {
// GIVEN
IndexPopulator populator = mock(IndexPopulator.class);
SchemaIndexProvider provider = mock(SchemaIndexProvider.class);
when(provider.getProviderDescriptor()).thenReturn(InMemoryIndexProviderFactory.PROVIDER_DESCRIPTOR);
when(provider.getPopulator(anyLong(), any(NewIndexDescriptor.class), any(IndexSamplingConfig.class))).thenReturn(populator);
BatchInserter inserter = newBatchInserterWithSchemaIndexProvider(singleInstanceSchemaIndexProviderFactory(InMemoryIndexProviderFactory.KEY, provider));
inserter.createDeferredConstraint(label("Hacker")).assertPropertyIsUnique("handle").create();
long nodeId = inserter.createNode(map("handle", "Jakewins"), label("Hacker"));
// WHEN
inserter.shutdown();
// THEN
verify(provider).init();
verify(provider).start();
verify(provider).getPopulator(anyLong(), any(NewIndexDescriptor.class), any(IndexSamplingConfig.class));
verify(populator).create();
verify(populator).add(singletonList(IndexEntryUpdate.add(nodeId, internalUniqueIndex.schema(), "Jakewins")));
verify(populator).verifyDeferredConstraints(any(PropertyAccessor.class));
verify(populator).close(true);
verify(provider).stop();
verify(provider).shutdown();
verifyNoMoreInteractions(populator);
}
use of org.neo4j.kernel.api.index.IndexPopulator in project neo4j by neo4j.
the class BatchingMultipleIndexPopulatorTest method populateFromQueueDoesNothingIfThresholdNotReached.
@Test
public void populateFromQueueDoesNothingIfThresholdNotReached() throws Exception {
setProperty(QUEUE_THRESHOLD_NAME, 5);
BatchingMultipleIndexPopulator batchingPopulator = new BatchingMultipleIndexPopulator(mock(IndexStoreView.class), mock(ExecutorService.class), NullLogProvider.getInstance());
IndexPopulator populator = addPopulator(batchingPopulator, index1);
IndexUpdater updater = mock(IndexUpdater.class);
when(populator.newPopulatingUpdater(any())).thenReturn(updater);
IndexEntryUpdate update1 = IndexEntryUpdate.add(1, index1.schema(), "foo");
IndexEntryUpdate update2 = IndexEntryUpdate.add(2, index1.schema(), "bar");
batchingPopulator.queue(update1);
batchingPopulator.queue(update2);
batchingPopulator.populateFromQueueBatched(42);
verify(updater, never()).process(any());
verify(populator, never()).newPopulatingUpdater(any());
}
use of org.neo4j.kernel.api.index.IndexPopulator in project neo4j by neo4j.
the class BatchingMultipleIndexPopulatorTest method populatorMarkedAsFailedAndUpdatesNotAdded.
@Test
public void populatorMarkedAsFailedAndUpdatesNotAdded() throws Exception {
setProperty(BATCH_SIZE_NAME, 2);
NodeUpdates update1 = nodeUpdates(1, propertyId, "aaa", labelId);
NodeUpdates update2 = nodeUpdates(1, propertyId, "bbb", labelId);
NodeUpdates update3 = nodeUpdates(1, propertyId, "ccc", labelId);
NodeUpdates update4 = nodeUpdates(1, propertyId, "ddd", labelId);
NodeUpdates update5 = nodeUpdates(1, propertyId, "eee", labelId);
IndexStoreView storeView = newStoreView(update1, update2, update3, update4, update5);
RuntimeException batchFlushError = new RuntimeException("Batch failed");
BatchingMultipleIndexPopulator batchingPopulator = new BatchingMultipleIndexPopulator(storeView, sameThreadExecutor(), NullLogProvider.getInstance());
IndexPopulator populator = addPopulator(batchingPopulator, index1);
doThrow(batchFlushError).when(populator).add(Arrays.asList(forIndex(update3, index1), forIndex(update4, index1)));
batchingPopulator.indexAllNodes().run();
verify(populator).add(Arrays.asList(forIndex(update1, index1), forIndex(update2, index1)));
verify(populator).add(Arrays.asList(forIndex(update3, index1), forIndex(update4, index1)));
verify(populator).markAsFailed(failure(batchFlushError).asString());
verify(populator, never()).add(singletonList(forIndex(update5, index1)));
}
Aggregations