use of org.neo4j.io.pagecache.PageCache in project neo4j by neo4j.
the class ManyPropertyKeysIT method databaseWithManyPropertyKeys.
private GraphDatabaseAPI databaseWithManyPropertyKeys(int propertyKeyCount) throws IOException {
PageCache pageCache = pageCacheRule.getPageCache(fileSystemRule.get());
StoreFactory storeFactory = new StoreFactory(storeDir, pageCache, fileSystemRule.get(), NullLogProvider.getInstance());
NeoStores neoStores = storeFactory.openAllNeoStores(true);
PropertyKeyTokenStore store = neoStores.getPropertyKeyTokenStore();
for (int i = 0; i < propertyKeyCount; i++) {
PropertyKeyTokenRecord record = new PropertyKeyTokenRecord((int) store.nextId());
record.setInUse(true);
Collection<DynamicRecord> nameRecords = store.allocateNameRecords(PropertyStore.encodeString(key(i)));
record.addNameRecords(nameRecords);
record.setNameId((int) Iterables.first(nameRecords).getId());
store.updateRecord(record);
}
neoStores.close();
return database();
}
use of org.neo4j.io.pagecache.PageCache in project neo4j by neo4j.
the class StoreFilesTest method deleteMustNotDeleteFilesInIgnoredDirectories.
@Test
public void deleteMustNotDeleteFilesInIgnoredDirectories() throws Exception {
File dir = getBaseDir();
File ignore = new File(dir, "ignore");
File a = new File(dir, "a");
File b = new File(dir, "b");
File c = new File(ignore, "c");
File d = new File(ignore, "d");
createOnFileSystem(a);
createOnFileSystem(c);
createOnPageCache(b);
createOnPageCache(d);
FilenameFilter filter = (directory, name) -> !name.startsWith("ignore");
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 StoreFilesTest method moveMustIgnoreFilesFilteredOut.
@Test
public void moveMustIgnoreFilesFilteredOut() throws Exception {
File base = getBaseDir();
File src = new File(base, "src");
File a = new File(src, "a");
File b = new File(src, "b");
File ignore = new File(src, "ignore");
File c = new File(ignore, "c");
File d = new File(ignore, "d");
File tgt = new File(base, "tgt");
createOnFileSystem(a);
createOnPageCache(b);
createOnFileSystem(c);
createOnPageCache(d);
// Ensure the 'tgt' directory exists
createOnFileSystem(new File(tgt, ".fs-ignore"));
createOnPageCache(new File(tgt, ".pc-ignore"));
FilenameFilter filter = (directory, name) -> !name.startsWith("ignore");
storeFiles = new StoreFiles(fs, pageCache, filter);
storeFiles.moveTo(src, tgt);
assertFalse(fs.fileExists(a));
assertFalse(pc.fileExists(b));
assertTrue(fs.fileExists(c));
assertTrue(pc.fileExists(d));
assertTrue(fs.fileExists(new File(tgt, "a")));
assertTrue(pc.fileExists(new File(tgt, "b")));
}
use of org.neo4j.io.pagecache.PageCache in project neo4j by neo4j.
the class StoreFilesTest method isEmptyMustFindFilesBothOnFileSystemAndPageCache.
@Test
public void isEmptyMustFindFilesBothOnFileSystemAndPageCache() throws Exception {
File dir = getBaseDir();
File ignore = new File(dir, "ignore");
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);
createOnFileSystem(ignore);
createOnPageCache(b);
createOnPageCache(d);
createOnPageCache(ignore);
FilenameFilter filter = (directory, name) -> !name.startsWith("ignore");
storeFiles = new StoreFiles(fs, pageCache, filter);
List<File> filesOnFilesystem = Arrays.asList(new File[] { a, c });
List<File> fileOnFilesystem = Arrays.asList(new File[] { a });
List<File> filesOnPageCache = Arrays.asList(new File[] { b, d });
List<File> fileOnPageCache = Arrays.asList(new File[] { b });
List<File> ingore = Arrays.asList(new File[] { ignore });
assertFalse(storeFiles.isEmpty(dir, filesOnFilesystem));
assertFalse(storeFiles.isEmpty(dir, fileOnFilesystem));
assertFalse(storeFiles.isEmpty(dir, filesOnPageCache));
assertFalse(storeFiles.isEmpty(dir, fileOnPageCache));
assertTrue(storeFiles.isEmpty(dir, Collections.emptyList()));
assertTrue(storeFiles.isEmpty(dir, ingore));
}
use of org.neo4j.io.pagecache.PageCache in project neo4j by neo4j.
the class TestStoreId method assertAllStoresHaveTheSameStoreId.
public static void assertAllStoresHaveTheSameStoreId(List<File> coreStoreDirs, FileSystemAbstraction fs) throws IOException {
Set<StoreId> storeIds = new HashSet<>();
try (PageCache pageCache = StandalonePageCacheFactory.createPageCache(fs)) {
for (File coreStoreDir : coreStoreDirs) {
storeIds.add(doReadStoreId(coreStoreDir, pageCache));
}
}
assertEquals("Store Ids " + storeIds, 1, storeIds.size());
}
Aggregations