use of org.neo4j.io.pagecache.PageCache in project neo4j by neo4j.
the class StreamToDiskTest method shouldLetPageCacheHandleRecordStoresAndNativeLabelScanStoreFiles.
@Test
public void shouldLetPageCacheHandleRecordStoresAndNativeLabelScanStoreFiles() throws Exception {
// GIVEN
PageCache pageCache = spy(pageCacheRule.getPageCache(fs));
Monitors monitors = new Monitors();
try (StreamToDisk writer = new StreamToDisk(directory.absolutePath(), fs, pageCache, monitors)) {
ByteBuffer tempBuffer = ByteBuffer.allocate(128);
// WHEN
for (StoreType type : StoreType.values()) {
if (type.isRecordStore()) {
String fileName = type.getStoreFile().fileName(STORE);
writeAndVerifyWrittenThroughPageCache(pageCache, writer, tempBuffer, fileName);
}
}
writeAndVerifyWrittenThroughPageCache(pageCache, writer, tempBuffer, NativeLabelScanStore.FILE_NAME);
}
}
use of org.neo4j.io.pagecache.PageCache in project neo4j by neo4j.
the class StoreFilesTest method deleteMustNotDeleteIgnoredFiles.
@Test
public void deleteMustNotDeleteIgnoredFiles() throws Exception {
File dir = getBaseDir();
File a = new File(dir, "a");
File b = new File(dir, "b");
File c = new File(dir, "c");
File d = new File(dir, "d");
createOnFileSystem(a);
createOnFileSystem(c);
createOnPageCache(b);
createOnPageCache(d);
FilenameFilter filter = (directory, name) -> !name.equals("c") && !name.equals("d");
storeFiles = new StoreFiles(fs, pageCache, filter);
storeFiles.delete(dir);
assertFalse(fs.fileExists(a));
assertFalse(pc.fileExists(b));
assertTrue(fs.fileExists(c));
assertTrue(pc.fileExists(d));
}
use of org.neo4j.io.pagecache.PageCache in project neo4j by neo4j.
the class DumpStore method main.
public static void main(String... args) throws Exception {
if (args == null || args.length == 0) {
System.err.println("SYNTAX: [file[:id[,id]*]]+");
return;
}
try (DefaultFileSystemAbstraction fs = new DefaultFileSystemAbstraction();
PageCache pageCache = createPageCache(fs)) {
final DefaultIdGeneratorFactory idGeneratorFactory = new DefaultIdGeneratorFactory(fs);
Function<File, StoreFactory> createStoreFactory = file -> new StoreFactory(file.getParentFile(), Config.defaults(), idGeneratorFactory, pageCache, fs, logProvider());
for (String arg : args) {
dumpFile(createStoreFactory, arg);
}
}
}
use of org.neo4j.io.pagecache.PageCache in project neo4j by neo4j.
the class ReadReplicaReplicationIT method changeStoreId.
private void changeStoreId(ReadReplica replica) throws IOException {
File neoStoreFile = new File(replica.storeDir(), MetaDataStore.DEFAULT_NAME);
PageCache pageCache = replica.database().getDependencyResolver().resolveDependency(PageCache.class);
MetaDataStore.setRecord(pageCache, neoStoreFile, TIME, System.currentTimeMillis());
}
use of org.neo4j.io.pagecache.PageCache in project neo4j by neo4j.
the class SwitchToSlaveBranchThenCopyTest method mockPageCache.
private PageCache mockPageCache() throws IOException {
PageCache pageCacheMock = mock(PageCache.class);
PagedFile pagedFileMock = mock(PagedFile.class);
when(pagedFileMock.getLastPageId()).thenReturn(1L);
when(pageCacheMock.map(any(File.class), anyInt())).thenThrow(new IOException()).thenThrow(new IOException()).thenReturn(pagedFileMock);
return pageCacheMock;
}
Aggregations