use of org.neo4j.kernel.api.index.IndexSample in project neo4j by neo4j.
the class MultipleIndexPopulatorTest method testStopPopulation.
@Test
void testStopPopulation() throws FlipFailedKernelException {
IndexPopulator indexPopulator1 = createIndexPopulator();
IndexPopulator indexPopulator2 = createIndexPopulator();
addPopulator(indexPopulator1, 1);
addPopulator(indexPopulator2, 2);
multipleIndexPopulator.stop(NULL);
verify(indexStatisticsStore, times(2)).replaceStats(anyLong(), eq(new IndexSample(0, 0, 0)));
verify(indexPopulator1).close(false, NULL);
verify(indexPopulator2).close(false, NULL);
}
use of org.neo4j.kernel.api.index.IndexSample in project neo4j by neo4j.
the class MultipleIndexPopulatorTest method createIndexPopulator.
private static IndexPopulator createIndexPopulator() {
IndexPopulator populator = mock(IndexPopulator.class);
when(populator.sample(any(CursorContext.class))).thenReturn(new IndexSample());
return populator;
}
use of org.neo4j.kernel.api.index.IndexSample in project neo4j by neo4j.
the class MultipleIndexPopulatorTest method shouldVerifyConstraintsBeforeFlippingIfToldTo.
@Test
void shouldVerifyConstraintsBeforeFlippingIfToldTo() throws IndexEntryConflictException {
// given
IndexProxyFactory indexProxyFactory = mock(IndexProxyFactory.class);
FailedIndexProxyFactory failedIndexProxyFactory = mock(FailedIndexProxyFactory.class);
FlippableIndexProxy flipper = new FlippableIndexProxy();
flipper.setFlipTarget(indexProxyFactory);
IndexPopulator indexPopulator = createIndexPopulator();
addPopulator(indexPopulator, 1, flipper, failedIndexProxyFactory);
when(indexPopulator.sample(any(CursorContext.class))).thenReturn(new IndexSample());
// when
multipleIndexPopulator.createStoreScan(PageCacheTracer.NULL);
multipleIndexPopulator.flipAfterStoreScan(true, NULL);
// then
verify(indexPopulator).verifyDeferredConstraints(any(NodePropertyAccessor.class));
verify(indexPopulator).close(true, NULL);
}
use of org.neo4j.kernel.api.index.IndexSample in project neo4j by neo4j.
the class IndexingServiceTest method shouldNotLoseIndexDescriptorDueToOtherSimilarIndexDuringRecovery.
/*
* See comments in IndexingService#createIndex
*/
@Test
void shouldNotLoseIndexDescriptorDueToOtherSimilarIndexDuringRecovery() throws Exception {
// GIVEN
long nodeId = 0;
long otherIndexId = 2;
Update update = addNodeUpdate(nodeId, "value");
when(indexStatisticsStore.indexSample(anyLong())).thenReturn(new IndexSample(100, 42, 42));
// For some reason the usual accessor returned null from newUpdater, even when told to return the updater
// so spying on a real object instead.
IndexAccessor accessor = spy(new TrackingIndexAccessor());
IndexingService indexing = newIndexingServiceWithMockedDependencies(populator, accessor, withData(update), index);
when(indexProvider.getInitialState(index, NULL)).thenReturn(ONLINE);
life.init();
// WHEN dropping another index, which happens to have the same label/property... while recovering
IndexDescriptor otherIndex = prototype.withName("index_" + otherIndexId).materialise(otherIndexId);
indexing.createIndexes(AUTH_DISABLED, otherIndex);
indexing.dropIndex(otherIndex);
// and WHEN finally creating our index again (at a later point in recovery)
indexing.createIndexes(AUTH_DISABLED, index);
reset(accessor);
indexing.applyUpdates(nodeIdsAsIndexUpdates(nodeId), NULL);
// and WHEN starting, i.e. completing recovery
life.start();
verify(accessor).newUpdater(eq(RECOVERY), any(CursorContext.class));
}
use of org.neo4j.kernel.api.index.IndexSample in project neo4j by neo4j.
the class IndexingServiceTest method shouldLogDeprecatedIndexesOnStart.
@Test
void shouldLogDeprecatedIndexesOnStart() throws Exception {
// given two indexes per available index provider
int id = 1;
List<IndexDescriptor> indexDescriptors = new ArrayList<>();
IndexProvider[] indexProviders = new IndexProvider[indexProviderDescriptors.length];
for (int i = 0; i < indexProviderDescriptors.length; i++) {
IndexProviderDescriptor indexProviderDescriptor = indexProviderDescriptors[i];
IndexProvider indexProvider = mockIndexProviderWithAccessor(indexProviderDescriptor);
indexProviders[i] = indexProvider;
// Two indexes per provider
for (int j = 0; j < 2; j++) {
IndexDescriptor index = storeIndex(id, 1, id, indexProviderDescriptor);
indexDescriptors.add(index);
when(indexProvider.getInitialState(eq(index), any())).thenReturn(ONLINE);
id++;
}
}
Config config = Config.defaults(default_schema_provider, nativeBtree10Descriptor.name());
DependencyResolver dependencies = buildIndexDependencies(indexProviders);
DefaultIndexProviderMap providerMap = new DefaultIndexProviderMap(dependencies, config);
providerMap.init();
when(indexStatisticsStore.indexSample(anyLong())).thenReturn(new IndexSample(1, 1, 1));
IndexingService indexingService = IndexingServiceFactory.createIndexingService(config, mock(JobScheduler.class), providerMap, storeViewFactory, nameLookup, indexDescriptors, internalLogProvider, userLogProvider, IndexingService.NO_MONITOR, schemaState, indexStatisticsStore, PageCacheTracer.NULL, INSTANCE, "", writable());
// when starting IndexingService
indexingService.init();
for (IndexProviderDescriptor indexProviderDescriptor : indexProviderDescriptors) {
onBothLogProviders(logProvider -> assertThat(logProvider).doesNotContainMessage(indexProviderDescriptor.name()));
}
userLogProvider.clear();
indexingService.start();
// then we should see log messages about deprecated providers if any
for (IndexProviderDescriptor indexProviderDescriptor : indexProviderDescriptors) {
if (isDeprecated(indexProviderDescriptor)) {
assertThat(userLogProvider).containsMessages("Deprecated index providers in use:", indexProviderDescriptor.name() + " (2 indexes)", "Use procedure 'db.indexes()' to see what indexes use which index provider.");
} else {
onBothLogProviders(logProvider -> assertThat(logProvider).doesNotContainMessage(indexProviderDescriptor.name()));
}
}
}
Aggregations