use of org.neo4j.io.pagecache.DelegatingPageCache in project neo4j by neo4j.
the class RecordStorageEngineTest method mustFlushStoresWithGivenIOLimiter.
@Test
public void mustFlushStoresWithGivenIOLimiter() throws Exception {
IOLimiter limiter = (stamp, completedIOs, swapper) -> 0;
FileSystemAbstraction fs = fsRule.get();
AtomicReference<IOLimiter> observedLimiter = new AtomicReference<>();
PageCache pageCache = new DelegatingPageCache(pageCacheRule.getPageCache(fs)) {
@Override
public void flushAndForce(IOLimiter limiter) throws IOException {
super.flushAndForce(limiter);
observedLimiter.set(limiter);
}
};
RecordStorageEngine engine = storageEngineRule.getWith(fs, pageCache).build();
engine.flushAndForce(limiter);
assertThat(observedLimiter.get(), sameInstance(limiter));
}
use of org.neo4j.io.pagecache.DelegatingPageCache in project neo4j by neo4j.
the class NodeStoreTest method shouldCloseStoreFileOnFailureToOpen.
@Test
void shouldCloseStoreFileOnFailureToOpen() {
// GIVEN
final MutableBoolean fired = new MutableBoolean();
// WHEN
Exception exception = assertThrows(Exception.class, () -> {
try (PageCache pageCache = pageCacheExtension.getPageCache(fs)) {
PageCache customPageCache = new DelegatingPageCache(pageCache) {
@Override
public PagedFile map(Path path, int pageSize, String databaseName, ImmutableSet<OpenOption> openOptions, IOController ioController) throws IOException {
if (path.getFileName().toString().toLowerCase().endsWith(".id")) {
fired.setTrue();
throw new IOException("Proving a point here");
}
return super.map(path, pageSize, databaseName, openOptions, ioController);
}
};
newNodeStore(fs, customPageCache);
}
});
assertTrue(indexOfThrowable(exception, IOException.class) != -1);
assertTrue(fired.booleanValue());
}
use of org.neo4j.io.pagecache.DelegatingPageCache in project neo4j by neo4j.
the class MetaDataStoreTest method setUp.
@BeforeEach
void setUp() {
pageCache = pageCacheExtension.getPageCache(fs);
fakePageCursorOverflow = false;
pageCacheWithFakeOverflow = new DelegatingPageCache(pageCache) {
@Override
public PagedFile map(Path path, int pageSize, String databaseName, ImmutableSet<OpenOption> openOptions, IOController ioController) throws IOException {
return new DelegatingPagedFile(super.map(path, pageSize, databaseName, openOptions, ioController)) {
@Override
public PageCursor io(long pageId, int pf_flags, CursorContext context) throws IOException {
return new DelegatingPageCursor(super.io(pageId, pf_flags, context)) {
@Override
public boolean checkAndClearBoundsFlag() {
return fakePageCursorOverflow | super.checkAndClearBoundsFlag();
}
};
}
};
}
};
}
Aggregations