@Test public void checkingIfRecordIsInUseMustHappenAfterConsistentRead() { AtomicBoolean nextReadIsInconsistent = new AtomicBoolean( false ); PageCache pageCache = pageCacheRule.getPageCache( fs, config().withInconsistentReads( nextReadIsInconsistent ) ); StoreFactory factory = factory( null, pageCache ); try ( NeoStores neoStores = factory.openAllNeoStores( true ) ) { RecordStore<RelationshipGroupRecord> relationshipGroupStore = neoStores.getRelationshipGroupStore(); RelationshipGroupRecord record = new RelationshipGroupRecord( 1 ).initialize( true, 2, 3, 4, 5, 6, Record.NO_NEXT_RELATIONSHIP.intValue() ); relationshipGroupStore.updateRecord( record ); nextReadIsInconsistent.set( true ); // Now the following should not throw any RecordNotInUse exceptions RelationshipGroupRecord readBack = relationshipGroupStore.getRecord( 1, relationshipGroupStore.newRecord(), NORMAL ); assertThat( readBack.toString(), equalTo( record.toString() ) ); } }
private PageCache createPageCache( int pageSize ) { return pageCacheRule.getPageCache( fs.get(), config().withPageSize( pageSize ) ); }
private NeoStores storeFixture() { PageCache pageCache = pageCacheRule.getPageCache( fs, config().withInconsistentReads( nextReadIsInconsistent ) ); StoreFactory factory = new StoreFactory( testDirectory.databaseLayout(), Config.defaults(), new DefaultIdGeneratorFactory( fs ), pageCache, fs, NullLogProvider.getInstance(), EmptyVersionContextSupplier.EMPTY ); NeoStores neoStores = factory.openAllNeoStores( true ); S store = initialiseStore( neoStores ); CommonAbstractStore commonAbstractStore = (CommonAbstractStore) store; commonAbstractStore.rebuildIdGenerator(); return neoStores; }
/** * @return new {@link PageCacheConfig} instance. */ public static PageCacheConfig config() { return new PageCacheConfig(); }
@Before public void setupPagedFile() throws IOException { PageCache pageCache = pageCacheRule .getPageCache( fileSystemRule.get(), config().withPageSize( PAGE_SIZE ).withAccessChecks( true ) ); pagedFile = pageCache .map( testDirectory.file( FILE_NAME ), PAGE_SIZE, CREATE, DELETE_ON_CLOSE ); }
private GBPTree<KEY,VALUE> createIndex() throws IOException { // some random padding layout = getLayout( random ); PageCache pageCache = pageCacheRule.getPageCache( fs.get(), config().withPageSize( 512 ).withAccessChecks( true ) ); return index = new GBPTreeBuilder<>( pageCache, directory.file( "index" ), layout ).build(); }
private GBPTree<RawBytes,RawBytes> createIndex( Layout<RawBytes,RawBytes> layout ) throws IOException { // some random padding PageCache pageCache = storage.pageCacheRule().getPageCache( storage.fileSystem(), config().withAccessChecks( true ) ); return new GBPTreeBuilder<>( pageCache, storage.directory().file( "index" ), layout ).build(); } }
private GBPTree<KEY,VALUE> createIndex() throws IOException { int pageSize = 512; layout = getLayout( random ); PageCache pageCache = pageCacheRule.getPageCache( fs.get(), config().withPageSize( pageSize ).withAccessChecks( true ) ); return index = new GBPTreeBuilder<>( pageCache, directory.file( "index" ), layout ).build(); }