use of org.neo4j.kernel.api.index.IndexSample in project neo4j by neo4j.
the class IndexingServiceTest method shouldLogIndexStateOutliersOnStart.
@Test
void shouldLogIndexStateOutliersOnStart() throws Throwable {
// given
IndexProvider provider = mockIndexProviderWithAccessor(PROVIDER_DESCRIPTOR);
Config config = Config.defaults(default_schema_provider, PROVIDER_DESCRIPTOR.name());
DefaultIndexProviderMap providerMap = new DefaultIndexProviderMap(buildIndexDependencies(provider, fulltextProvider()), config);
providerMap.init();
List<IndexDescriptor> indexes = new ArrayList<>();
int nextIndexId = 1;
IndexDescriptor populatingIndex = storeIndex(nextIndexId, nextIndexId++, 1, PROVIDER_DESCRIPTOR);
when(provider.getInitialState(eq(populatingIndex), any())).thenReturn(POPULATING);
indexes.add(populatingIndex);
IndexDescriptor failedIndex = storeIndex(nextIndexId, nextIndexId++, 1, PROVIDER_DESCRIPTOR);
when(provider.getInitialState(eq(failedIndex), any())).thenReturn(FAILED);
indexes.add(failedIndex);
for (int i = 0; i < 10; i++) {
IndexDescriptor indexRule = storeIndex(nextIndexId, nextIndexId++, 1, PROVIDER_DESCRIPTOR);
when(provider.getInitialState(eq(indexRule), any())).thenReturn(ONLINE);
indexes.add(indexRule);
}
for (int i = 0; i < nextIndexId; i++) {
nameLookup.label(i, "Label" + i);
}
IndexingService indexingService = IndexingServiceFactory.createIndexingService(config, mock(JobScheduler.class), providerMap, storeViewFactory, nameLookup, indexes, internalLogProvider, userLogProvider, IndexingService.NO_MONITOR, schemaState, indexStatisticsStore, PageCacheTracer.NULL, INSTANCE, "", writable());
when(indexStatisticsStore.indexSample(anyLong())).thenReturn(new IndexSample(100, 32, 32));
nameLookup.propertyKey(1, "prop");
// when
indexingService.init();
internalLogProvider.clear();
indexingService.start();
// then
assertThat(internalLogProvider).forLevel(INFO).containsMessages("IndexingService.start: index 1 on (:Label1 {prop}) is POPULATING", "IndexingService.start: index 2 on (:Label2 {prop}) is FAILED", "IndexingService.start: indexes not specifically mentioned above are ONLINE").doesNotContainMessage("IndexingService.start: index 3 on :Label3(prop) is ONLINE");
}
use of org.neo4j.kernel.api.index.IndexSample in project neo4j by neo4j.
the class IndexStatisticsStoreTest method shouldStoreDataOnCheckpoint.
@Test
void shouldStoreDataOnCheckpoint() throws IOException {
// given
long indexId1 = 1;
long indexId2 = 2;
IndexSample sample1 = new IndexSample(500, 100, 200, 25);
IndexSample sample2 = new IndexSample(501, 101, 201, 26);
store.replaceStats(indexId1, sample1);
store.replaceStats(indexId2, sample2);
// when
restartStore();
// then
assertEquals(sample1, store.indexSample(indexId1));
assertEquals(sample2, store.indexSample(indexId2));
}
use of org.neo4j.kernel.api.index.IndexSample in project neo4j by neo4j.
the class IndexStatisticsStoreTest method shouldAllowMultipleThreadsIncrementIndexUpdates.
@Test
void shouldAllowMultipleThreadsIncrementIndexUpdates() throws Throwable {
// given
long indexId = 5;
Race race = new Race();
int contestants = 20;
int delta = 3;
store.replaceStats(indexId, new IndexSample(0, 0, 0));
race.addContestants(contestants, () -> store.incrementIndexUpdates(indexId, delta), 1);
// when
race.go();
// then
assertEquals(new IndexSample(0, 0, 0, contestants * delta), store.indexSample(indexId));
}
use of org.neo4j.kernel.api.index.IndexSample in project neo4j by neo4j.
the class IndexStatisticsStoreTest method shouldReplaceIndexSample.
@Test
void shouldReplaceIndexSample() {
// given
long indexId = 4;
// when/then
replaceAndVerifySample(indexId, new IndexSample(456, 123, 456, 3));
replaceAndVerifySample(indexId, new IndexSample(555, 444, 550, 0));
}
use of org.neo4j.kernel.api.index.IndexSample in project neo4j by neo4j.
the class IndexStatisticsStoreTest method shouldIncrementIndexUpdates.
@Test
void shouldIncrementIndexUpdates() {
// given
long indexId = 4;
IndexSample initialSample = new IndexSample(456, 5, 200, 123);
store.replaceStats(indexId, initialSample);
// when
int addedUpdates = 5;
store.incrementIndexUpdates(indexId, addedUpdates);
// then
assertEquals(new IndexSample(initialSample.indexSize(), initialSample.uniqueValues(), initialSample.sampleSize(), initialSample.updates() + addedUpdates), store.indexSample(indexId));
}
Aggregations