use of org.neo4j.kernel.impl.store.counts.CountsTracker in project neo4j by neo4j.
the class RebuildCountsTest method shouldRebuildMissingCountsStoreAfterRecovery.
@Test
public void shouldRebuildMissingCountsStoreAfterRecovery() throws IOException {
// given
createAliensAndHumans();
// when
rotateLog();
deleteHumans();
FileSystemAbstraction fs = crash();
deleteCounts(fs);
restart(fs);
// then
CountsTracker tracker = counts();
assertEquals(ALIENS, tracker.nodeCount(-1, newDoubleLongRegister()).readSecond());
assertEquals(ALIENS, tracker.nodeCount(labelId(ALIEN), newDoubleLongRegister()).readSecond());
assertEquals(0, tracker.nodeCount(labelId(HUMAN), newDoubleLongRegister()).readSecond());
// and also
internalLogProvider.assertAtLeastOnce(inLog(MetaDataStore.class).warn("Missing counts store, rebuilding it."));
}
use of org.neo4j.kernel.impl.store.counts.CountsTracker in project neo4j by neo4j.
the class IndexStatisticsIT method shouldRecoverIndexCountsBySamplingThemOnStartup.
@Test
public void shouldRecoverIndexCountsBySamplingThemOnStartup() {
// given some aliens in a database
createAliens();
// that have been indexed
awaitIndexOnline(indexAliensBySpecimen());
// where ALIEN and SPECIMEN are both the first ids of their kind
NewIndexDescriptor index = NewIndexDescriptorFactory.forLabel(labelId(ALIEN), pkId(SPECIMEN));
SchemaStorage storage = new SchemaStorage(neoStores().getSchemaStore());
long indexId = storage.indexGetForSchema(index).getId();
// for which we don't have index counts
resetIndexCounts(indexId);
// when we shutdown the database and restart it
restart();
// then we should have re-sampled the index
CountsTracker tracker = neoStores().getCounts();
assertEqualRegisters("Unexpected updates and size for the index", newDoubleLongRegister(0, 32), tracker.indexUpdatesAndSize(indexId, newDoubleLongRegister()));
assertEqualRegisters("Unexpected sampling result", newDoubleLongRegister(16, 32), tracker.indexSample(indexId, newDoubleLongRegister()));
// and also
assertLogExistsForRecoveryOn(":Alien(specimen)");
}
use of org.neo4j.kernel.impl.store.counts.CountsTracker in project neo4j by neo4j.
the class BatchInserterImpl method rebuildCounts.
private void rebuildCounts() {
CountsTracker counts = neoStores.getCounts();
try {
counts.start();
} catch (IOException e) {
throw new UnderlyingStorageException(e);
}
CountsComputer.recomputeCounts(neoStores);
}
use of org.neo4j.kernel.impl.store.counts.CountsTracker in project neo4j by neo4j.
the class NeoStores method flush.
public void flush(IOLimiter limiter) {
try {
CountsTracker counts = (CountsTracker) stores[StoreType.COUNTS.ordinal()];
if (counts != null) {
counts.rotate(getMetaDataStore().getLastCommittedTransactionId());
}
pageCache.flushAndForce(limiter);
} catch (IOException e) {
throw new UnderlyingStorageException("Failed to flush", e);
}
}
use of org.neo4j.kernel.impl.store.counts.CountsTracker in project neo4j by neo4j.
the class NeoStores method createCountStore.
CountsTracker createCountStore(String storeName) {
File storeFile = getStoreFile(storeName);
boolean readOnly = config.get(GraphDatabaseSettings.read_only);
CountsTracker counts = readOnly ? createReadOnlyCountsTracker(storeFile) : createWritableCountsTracker(storeFile);
NeoStores neoStores = this;
counts.setInitializer(new DataInitializer<CountsAccessor.Updater>() {
private final Log log = logProvider.getLog(MetaDataStore.class);
@Override
public void initialize(CountsAccessor.Updater updater) {
log.warn("Missing counts store, rebuilding it.");
new CountsComputer(neoStores).initialize(updater);
}
@Override
public long initialVersion() {
return ((MetaDataStore) getOrCreateStore(StoreType.META_DATA)).getLastCommittedTransactionId();
}
});
try {
// TODO: move this to LifeCycle
counts.init();
} catch (IOException e) {
throw new UnderlyingStorageException("Failed to initialize counts store", e);
}
return counts;
}
Aggregations