public PageCacheRule() { this( config() ); }
public PageCache getPageCache( FileSystemAbstraction fs ) { return getPageCache( fs, config() ); }
private PageCache createPageCache( int pageSize ) { return pageCacheRule.getPageCache( fs.get(), config().withPageSize( pageSize ) ); }
@Test public void writingOfHeaderRecordDuringInitialiseNewStoreFileMustThrowOnPageOverflow() throws Exception { // 16-byte header will overflow an 8-byte page size PageCacheRule.PageCacheConfig pageCacheConfig = PageCacheRule.config(); PageCache pageCache = pageCacheRule.getPageCache( fs.get(), pageCacheConfig, config ); MyStore store = new MyStore( config, pageCache, PAGE_SIZE + 1 ); assertThrowsUnderlyingStorageException( () -> store.initialise( true ) ); }
KeyValueStoreFile create( Map<String,String> config, Map<String,byte[]> headers, DataProvider data ) throws IOException { PageCacheRule.PageCacheConfig pageCacheConfig = PageCacheRule.config(); PageCache pageCache = pages.getPageCache( fs.get(), pageCacheConfig, Config.defaults( config ) ); return createStore( fs.get(), pageCache, getStoreFile(), 16, 16, headers( headers ), data ); }
@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<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(); }
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(); }
@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() ) ); } }
@Test public void extractHeaderRecordDuringLoadStorageMustThrowOnPageOverflow() throws Exception { MyStore first = new MyStore( config, pageCacheRule.getPageCache( fs.get(), config ), 8 ); first.initialise( true ); first.close(); PageCacheRule.PageCacheConfig pageCacheConfig = PageCacheRule.config(); PageCache pageCache = pageCacheRule.getPageCache( fs.get(), pageCacheConfig, config ); MyStore second = new MyStore( config, pageCache, PAGE_SIZE + 1 ); assertThrowsUnderlyingStorageException( () -> second.initialise( false ) ); }
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; }