public StoreAccess( NeoStores store ) { this.neoStores = store; this.counts = store.getCounts(); }
public CountsTracker getCountsStore() { return neoStores.getCounts(); }
public void startCountStore() throws IOException { // TODO: move this to LifeCycle getCounts().start(); }
private void addCountStoreFiles( List<StoreFileMetadata> files ) { Iterable<File> countStoreFiles = neoStores.getCounts().allFiles(); for ( File countStoreFile : countStoreFiles ) { StoreFileMetadata countStoreFileMetadata = new StoreFileMetadata( countStoreFile, RecordFormat.NO_RECORD_SIZE ); files.add( countStoreFileMetadata ); } }
public NeoStoreIndexStoreView( LockService locks, NeoStores neoStores ) { this.locks = locks; this.neoStores = neoStores; this.propertyStore = neoStores.getPropertyStore(); this.nodeStore = neoStores.getNodeStore(); this.relationshipStore = neoStores.getRelationshipStore(); this.counts = neoStores.getCounts(); }
private void rebuildCounts() { CountsTracker counts = neoStores.getCounts(); try { counts.start(); } catch ( IOException e ) { throw new UnderlyingStorageException( e ); } CountsComputer.recomputeCounts( neoStores, pageCache, databaseLayout ); }
public static void recomputeCounts( NeoStores stores, PageCache pageCache, DatabaseLayout databaseLayout ) { MetaDataStore metaDataStore = stores.getMetaDataStore(); CountsTracker counts = stores.getCounts(); try ( CountsAccessor.Updater updater = counts.reset( metaDataStore.getLastCommittedTransactionId() ) ) { new CountsComputer( stores, pageCache, databaseLayout ).initialize( updater ); } }
RecordStorageReader( TokenHolders tokenHolders, SchemaStorage schemaStorage, NeoStores neoStores, IndexingService indexService, SchemaCache schemaCache, Supplier<IndexReaderFactory> indexReaderFactory, Supplier<LabelScanReader> labelScanReaderSupplier, RecordStorageCommandCreationContext commandCreationContext ) { this.tokenHolders = tokenHolders; this.neoStores = neoStores; this.schemaStorage = schemaStorage; this.indexService = indexService; this.nodeStore = neoStores.getNodeStore(); this.relationshipStore = neoStores.getRelationshipStore(); this.relationshipGroupStore = neoStores.getRelationshipGroupStore(); this.propertyStore = neoStores.getPropertyStore(); this.counts = neoStores.getCounts(); this.schemaCache = schemaCache; this.indexReaderFactorySupplier = indexReaderFactory; this.labelScanReaderSupplier = labelScanReaderSupplier; this.commandCreationContext = commandCreationContext; }
appliers.add( new CountsStoreBatchTransactionApplier( neoStores.getCounts(), mode ) );
@Before public void setUp() { NodeRecord nodeRecord = getNodeRecord(); when( labelScanStore.allNodeLabelRanges()).thenReturn( nodeLabelRanges ); when( neoStores.getCounts() ).thenReturn( countStore ); when( neoStores.getNodeStore() ).thenReturn( nodeStore ); when( nodeStore.newRecord() ).thenReturn( nodeRecord ); doAnswer( invocation -> { NodeRecord record = invocation.getArgument( 1 ); record.initialize( true, 1L, false, 1L, 0L ); record.setId( invocation.getArgument( 0 ) ); return null; } ).when( nodeStore ).getRecordByCursor( anyLong(), any( NodeRecord.class ), any( RecordLoad.class ), any( PageCursor.class ) ); doAnswer( invocation -> { NodeRecord record = invocation.getArgument( 0 ); record.initialize( true, 1L, false, 1L, 0L ); record.setId( record.getId() + 1 ); return null; } ).when( nodeStore ).nextRecordByCursor( any( NodeRecord.class ), any( RecordLoad.class ), any( PageCursor.class ) ); }
private CountsTracker getTracker() { return ((GraphDatabaseAPI) db).getDependencyResolver().resolveDependency( RecordStorageEngine.class ) .testAccessNeoStores().getCounts(); }
private void resetIndexCounts( long indexId ) { try ( CountsAccessor.IndexStatsUpdater updater = neoStores().getCounts().updateIndexCounts() ) { updater.replaceIndexSample( indexId, 0, 0 ); updater.replaceIndexUpdateAndSize( indexId, 0, 0 ); } }
CountsTracker counts = neoStore.getCounts(); counts.start(); long nextTxId = neoStore.getMetaDataStore().getLastCommittedTransactionId() + 1;
@Test public void rotationShouldNotCauseUnmappedFileProblem() throws IOException { // GIVEN GraphDatabaseAPI db = (GraphDatabaseAPI) dbBuilder.newGraphDatabase(); DependencyResolver resolver = db.getDependencyResolver(); RecordStorageEngine storageEngine = resolver.resolveDependency( RecordStorageEngine.class ); CountsTracker countStore = storageEngine.testAccessNeoStores().getCounts(); AtomicBoolean workerContinueFlag = new AtomicBoolean( true ); AtomicLong lookupsCounter = new AtomicLong(); int rotations = 100; for ( int i = 0; i < 5; i++ ) { threadingRule.execute( countStoreLookup( workerContinueFlag, lookupsCounter ), countStore ); } long startTxId = countStore.txId(); for ( int i = 1; (i < rotations) || (lookupsCounter.get() == 0); i++ ) { try ( Transaction tx = db.beginTx() ) { db.createNode( B ); tx.success(); } checkPoint( db ); } workerContinueFlag.set( false ); assertEquals( "Should perform at least 100 rotations.", rotations, Math.min( rotations, countStore.txId() - startTxId) ); assertTrue( "Should perform more then 0 lookups without exceptions.", lookupsCounter.get() > 0 ); db.shutdown(); }
@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 ); } }
@Test public void shouldHaveSpecificCountsTrackerForReadOnlyDatabase() throws IOException { // when StoreFactory readOnlyStoreFactory = storeFactory( Config.defaults( GraphDatabaseSettings.read_only, Settings.TRUE ) ); neoStores = readOnlyStoreFactory.openAllNeoStores( true ); long lastClosedTransactionId = neoStores.getMetaDataStore().getLastClosedTransactionId(); // then assertEquals( -1, neoStores.getCounts().rotate( lastClosedTransactionId ) ); }
assertThat( "Count store should be rotated once at least", neoStores.getCounts().txId(), greaterThan( 0L ) ); txIdStore.getLastClosedTransactionId(), lastRotationTx ); assertEquals( "Last closed transaction should be last rotated tx in count store", txIdStore.getLastClosedTransactionId(), neoStores.getCounts().txId() );
@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 IndexDescriptor index = TestIndexDescriptorFactory.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)" ); }
.testAccessNeoStores().getCounts(); assertEquals( 1 + 1, tracker.nodeCount( -1, newDoubleLongRegister() ).readSecond() );
neoStores.getCounts().start(); CountsComputer.recomputeCounts( neoStores, pageCache, databaseLayout ); nodeStore = neoStores.getNodeStore();