use of org.neo4j.io.pagecache.IOController 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.IOController 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