use of org.neo4j.kernel.api.index.IndexUpdater 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));
}
use of org.neo4j.kernel.api.index.IndexUpdater in project neo4j by neo4j.
the class MultipleIndexPopulator method newPopulatingUpdater.
@VisibleForTesting
MultipleIndexUpdater newPopulatingUpdater(NodePropertyAccessor accessor, CursorContext cursorContext) {
Map<SchemaDescriptor, Pair<IndexPopulation, IndexUpdater>> updaters = new HashMap<>();
forEachPopulation(population -> {
IndexUpdater updater = population.populator.newPopulatingUpdater(accessor, cursorContext);
updaters.put(population.schema(), Pair.of(population, updater));
}, cursorContext);
return new MultipleIndexUpdater(this, updaters, logProvider, cursorContext);
}
use of org.neo4j.kernel.api.index.IndexUpdater in project neo4j by neo4j.
the class IndexUpdaterMap method close.
@Override
public void close() throws UnderlyingStorageException {
Set<Pair<IndexDescriptor, UnderlyingStorageException>> exceptions = null;
for (Map.Entry<IndexDescriptor, IndexUpdater> updaterEntry : updaterMap.entrySet()) {
IndexUpdater updater = updaterEntry.getValue();
try {
updater.close();
} catch (UncheckedIOException | IndexEntryConflictException e) {
if (null == exceptions) {
exceptions = new HashSet<>();
}
exceptions.add(Pair.of(updaterEntry.getKey(), new UnderlyingStorageException(e)));
}
}
clear();
if (null != exceptions) {
throw new MultipleUnderlyingStorageExceptions(exceptions);
}
}
use of org.neo4j.kernel.api.index.IndexUpdater in project neo4j by neo4j.
the class IndexingServiceTest method shouldBringIndexOnlineAndFlipOverToIndexAccessor.
@Test
void shouldBringIndexOnlineAndFlipOverToIndexAccessor() throws Exception {
// given
when(accessor.newUpdater(any(IndexUpdateMode.class), any(CursorContext.class))).thenReturn(updater);
IndexingService indexingService = newIndexingServiceWithMockedDependencies(populator, accessor, withData());
life.start();
// when
indexingService.createIndexes(AUTH_DISABLED, index);
IndexProxy proxy = indexingService.getIndexProxy(index);
waitForIndexesToComeOnline(indexingService, index);
verify(populator, timeout(10000)).close(eq(true), any());
try (IndexUpdater updater = proxy.newUpdater(IndexUpdateMode.ONLINE, NULL)) {
updater.process(add(10, "foo"));
}
// then
assertEquals(ONLINE, proxy.getState());
InOrder order = inOrder(populator, accessor, updater);
order.verify(populator).create();
order.verify(populator).close(eq(true), any());
order.verify(accessor).newUpdater(eq(IndexUpdateMode.ONLINE_IDEMPOTENT), any());
order.verify(updater).process(add(10, "foo"));
order.verify(updater).close();
}
use of org.neo4j.kernel.api.index.IndexUpdater in project neo4j by neo4j.
the class IndexingServiceTest method shouldRefreshIndexesOnStart.
@Test
void shouldRefreshIndexesOnStart() throws Exception {
// given
newIndexingServiceWithMockedDependencies(populator, accessor, withData(), index);
IndexAccessor accessor = mock(IndexAccessor.class);
IndexUpdater updater = mock(IndexUpdater.class);
when(accessor.newValueReader()).thenReturn(ValueIndexReader.EMPTY);
when(accessor.newUpdater(any(IndexUpdateMode.class), any(CursorContext.class))).thenReturn(updater);
when(indexProvider.getOnlineAccessor(any(IndexDescriptor.class), any(IndexSamplingConfig.class), any(TokenNameLookup.class))).thenReturn(accessor);
life.init();
verify(accessor, never()).refresh();
life.start();
// Then
verify(accessor).refresh();
}
Aggregations