use of org.neo4j.kernel.impl.store.counts.CountsTracker in project neo4j by neo4j.
the class FullCheck method execute.
ConsistencySummaryStatistics execute(DirectStoreAccess stores, Log log, Monitor reportMonitor) throws ConsistencyCheckIncompleteException {
ConsistencySummaryStatistics summary = new ConsistencySummaryStatistics();
InconsistencyReport report = new InconsistencyReport(new InconsistencyMessageLogger(log), summary);
OwnerCheck ownerCheck = new OwnerCheck(checkPropertyOwners);
CountsBuilderDecorator countsBuilder = new CountsBuilderDecorator(stores.nativeStores());
CheckDecorator decorator = new CheckDecorator.ChainCheckDecorator(ownerCheck, countsBuilder);
CacheAccess cacheAccess = new DefaultCacheAccess(statistics.getCounts(), threads);
RecordAccess records = recordAccess(stores.nativeStores(), cacheAccess);
execute(stores, decorator, records, report, cacheAccess, reportMonitor);
ownerCheck.scanForOrphanChains(progressFactory);
if (checkGraph) {
CountsAccessor countsAccessor = stores.nativeStores().getCounts();
if (countsAccessor instanceof CountsTracker) {
CountsTracker tracker = (CountsTracker) countsAccessor;
try {
tracker.start();
} catch (Exception e) {
// let's hope it was already started :)
}
}
countsBuilder.checkCounts(countsAccessor, new ConsistencyReporter(records, report), progressFactory);
}
if (!summary.isConsistent()) {
log.warn("Inconsistencies found: " + summary);
}
return summary;
}
use of org.neo4j.kernel.impl.store.counts.CountsTracker in project neo4j by neo4j.
the class CountsStoreTransactionApplierTest method shouldNotifyCacheAccessOnHowManyUpdatesOnCountsWeHadSoFar.
@Test
public void shouldNotifyCacheAccessOnHowManyUpdatesOnCountsWeHadSoFar() throws Exception {
// GIVEN
final CountsTracker tracker = mock(CountsTracker.class);
final CountsAccessor.Updater updater = mock(CountsAccessor.Updater.class);
when(tracker.apply(anyLong())).thenReturn(Optional.of(updater));
final CountsStoreBatchTransactionApplier applier = new CountsStoreBatchTransactionApplier(tracker, TransactionApplicationMode.INTERNAL);
// WHEN
try (TransactionApplier txApplier = applier.startTx(new TransactionToApply(null, 2L))) {
txApplier.visitNodeCountsCommand(new Command.NodeCountsCommand(ReadOperations.ANY_LABEL, 1));
}
// THEN
verify(updater, times(1)).incrementNodeCount(ReadOperations.ANY_LABEL, 1);
}
use of org.neo4j.kernel.impl.store.counts.CountsTracker in project neo4j by neo4j.
the class HACountsPropagationTest method shouldPropagateRelationshipCountsInHA.
@Test
public void shouldPropagateRelationshipCountsInHA() throws Throwable {
ManagedCluster cluster = clusterRule.startCluster();
HighlyAvailableGraphDatabase master = cluster.getMaster();
try (Transaction tx = master.beginTx()) {
Node left = master.createNode();
Node right = master.createNode(Label.label("A"));
left.createRelationshipTo(right, RelationshipType.withName("Type"));
tx.success();
}
cluster.sync();
for (HighlyAvailableGraphDatabase db : cluster.getAllMembers()) {
CountsTracker counts = counts(db);
assertEquals(1, counts.relationshipCount(-1, -1, -1, newDoubleLongRegister()).readSecond());
assertEquals(1, counts.relationshipCount(-1, -1, 0, newDoubleLongRegister()).readSecond());
assertEquals(1, counts.relationshipCount(-1, 0, -1, newDoubleLongRegister()).readSecond());
assertEquals(1, counts.relationshipCount(-1, 0, 0, newDoubleLongRegister()).readSecond());
}
}
use of org.neo4j.kernel.impl.store.counts.CountsTracker in project neo4j by neo4j.
the class HACountsPropagationTest method shouldPropagateNodeCountsInHA.
@Test
public void shouldPropagateNodeCountsInHA() throws Throwable {
ManagedCluster cluster = clusterRule.startCluster();
HighlyAvailableGraphDatabase master = cluster.getMaster();
try (Transaction tx = master.beginTx()) {
master.createNode();
master.createNode(Label.label("A"));
tx.success();
}
cluster.sync();
for (HighlyAvailableGraphDatabase db : cluster.getAllMembers()) {
CountsTracker counts = counts(db);
assertEquals(2, counts.nodeCount(-1, newDoubleLongRegister()).readSecond());
assertEquals(1, counts.nodeCount(0, /* A */
newDoubleLongRegister()).readSecond());
}
}
use of org.neo4j.kernel.impl.store.counts.CountsTracker in project neo4j by neo4j.
the class IndexSamplingIntegrationTest method fetchIndexSamplingValues.
private DoubleLongRegister fetchIndexSamplingValues(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();
IndexSampleKey key = CountsKeyFactory.indexSampleKey(indexId(api));
return countsTracker.get(key, Registers.newDoubleLongRegister());
} finally {
if (db != null) {
db.shutdown();
}
}
}
Aggregations