use of org.neo4j.kernel.impl.store.counts.CountsTracker in project neo4j by neo4j.
the class TestRecoveryScenarios method shouldRecoverCounts.
@Test
public void shouldRecoverCounts() throws Exception {
// GIVEN
Node node = createNode(label);
checkPoint();
deleteNode(node);
// WHEN
crashAndRestart(indexProvider);
// -- really the problem was that recovery threw exception, so mostly assert that.
try (Transaction tx = db.beginTx()) {
CountsTracker tracker = db.getDependencyResolver().resolveDependency(RecordStorageEngine.class).testAccessNeoStores().getCounts();
assertEquals(0, tracker.nodeCount(-1, newDoubleLongRegister()).readSecond());
final LabelTokenHolder holder = db.getDependencyResolver().resolveDependency(LabelTokenHolder.class);
int labelId = holder.getIdByName(label.name());
assertEquals(0, tracker.nodeCount(labelId, newDoubleLongRegister()).readSecond());
tx.success();
}
}
use of org.neo4j.kernel.impl.store.counts.CountsTracker in project neo4j by neo4j.
the class IndexSamplingIntegrationTest method fetchIndexSizeValues.
private DoubleLongRegister fetchIndexSizeValues(GraphDatabaseService db) throws IndexNotFoundKernelException {
try {
// Then
db = new TestGraphDatabaseFactory().newEmbeddedDatabase(testDirectory.graphDbDir());
@SuppressWarnings("deprecation") GraphDatabaseAPI api = (GraphDatabaseAPI) db;
CountsTracker countsTracker = api.getDependencyResolver().resolveDependency(RecordStorageEngine.class).testAccessNeoStores().getCounts();
IndexStatisticsKey key = CountsKeyFactory.indexStatisticsKey(indexId(api));
return countsTracker.get(key, Registers.newDoubleLongRegister());
} finally {
if (db != null) {
db.shutdown();
}
}
}
use of org.neo4j.kernel.impl.store.counts.CountsTracker 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.impl.store.counts.CountsTracker in project neo4j by neo4j.
the class RecordStorageEngineTest method obtainCountsStoreResetterAfterFailedTransaction.
@Test(timeout = 30_000)
public void obtainCountsStoreResetterAfterFailedTransaction() throws Throwable {
RecordStorageEngine engine = buildRecordStorageEngine();
Exception applicationError = executeFailingTransaction(engine);
assertNotNull(applicationError);
CountsTracker countsStore = engine.testAccessNeoStores().getCounts();
// possible to obtain a resetting updater that internally has a write lock on the counts store
try (CountsAccessor.Updater updater = countsStore.reset(0)) {
assertNotNull(updater);
}
}
Aggregations