Search in sources :

Example 51 with PageCache

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();
}
Also used : PropertyKeyTokenStore(org.neo4j.kernel.impl.store.PropertyKeyTokenStore) DynamicRecord(org.neo4j.kernel.impl.store.record.DynamicRecord) NeoStores(org.neo4j.kernel.impl.store.NeoStores) StoreFactory(org.neo4j.kernel.impl.store.StoreFactory) PageCache(org.neo4j.io.pagecache.PageCache) PropertyKeyTokenRecord(org.neo4j.kernel.impl.store.record.PropertyKeyTokenRecord)

Example 52 with PageCache

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));
}
Also used : FilenameFilter(java.io.FilenameFilter) Arrays(java.util.Arrays) EphemeralFileSystemRule(org.neo4j.test.rule.fs.EphemeralFileSystemRule) Supplier(java.util.function.Supplier) Assert.assertThat(org.junit.Assert.assertThat) PageCacheRule(org.neo4j.test.rule.PageCacheRule) ThreadLocalRandom(java.util.concurrent.ThreadLocalRandom) Before(org.junit.Before) PageCache(org.neo4j.io.pagecache.PageCache) Position(org.neo4j.kernel.impl.store.MetaDataStore.Position) TestDirectory(org.neo4j.test.rule.TestDirectory) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) IOException(java.io.IOException) File(java.io.File) StoreId(org.neo4j.causalclustering.identity.StoreId) RuleChain(org.junit.rules.RuleChain) EphemeralFileSystemAbstraction(org.neo4j.graphdb.mockfs.EphemeralFileSystemAbstraction) List(java.util.List) Rule(org.junit.Rule) MetaDataStore(org.neo4j.kernel.impl.store.MetaDataStore) Assert.assertFalse(org.junit.Assert.assertFalse) Matchers.is(org.hamcrest.Matchers.is) Collections(java.util.Collections) FileSystemAbstraction(org.neo4j.io.fs.FileSystemAbstraction) FilenameFilter(java.io.FilenameFilter) File(java.io.File) Test(org.junit.Test)

Example 53 with PageCache

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")));
}
Also used : FilenameFilter(java.io.FilenameFilter) Arrays(java.util.Arrays) EphemeralFileSystemRule(org.neo4j.test.rule.fs.EphemeralFileSystemRule) Supplier(java.util.function.Supplier) Assert.assertThat(org.junit.Assert.assertThat) PageCacheRule(org.neo4j.test.rule.PageCacheRule) ThreadLocalRandom(java.util.concurrent.ThreadLocalRandom) Before(org.junit.Before) PageCache(org.neo4j.io.pagecache.PageCache) Position(org.neo4j.kernel.impl.store.MetaDataStore.Position) TestDirectory(org.neo4j.test.rule.TestDirectory) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) IOException(java.io.IOException) File(java.io.File) StoreId(org.neo4j.causalclustering.identity.StoreId) RuleChain(org.junit.rules.RuleChain) EphemeralFileSystemAbstraction(org.neo4j.graphdb.mockfs.EphemeralFileSystemAbstraction) List(java.util.List) Rule(org.junit.Rule) MetaDataStore(org.neo4j.kernel.impl.store.MetaDataStore) Assert.assertFalse(org.junit.Assert.assertFalse) Matchers.is(org.hamcrest.Matchers.is) Collections(java.util.Collections) FileSystemAbstraction(org.neo4j.io.fs.FileSystemAbstraction) FilenameFilter(java.io.FilenameFilter) File(java.io.File) Test(org.junit.Test)

Example 54 with PageCache

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));
}
Also used : FilenameFilter(java.io.FilenameFilter) Arrays(java.util.Arrays) EphemeralFileSystemRule(org.neo4j.test.rule.fs.EphemeralFileSystemRule) Supplier(java.util.function.Supplier) Assert.assertThat(org.junit.Assert.assertThat) PageCacheRule(org.neo4j.test.rule.PageCacheRule) ThreadLocalRandom(java.util.concurrent.ThreadLocalRandom) Before(org.junit.Before) PageCache(org.neo4j.io.pagecache.PageCache) Position(org.neo4j.kernel.impl.store.MetaDataStore.Position) TestDirectory(org.neo4j.test.rule.TestDirectory) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) IOException(java.io.IOException) File(java.io.File) StoreId(org.neo4j.causalclustering.identity.StoreId) RuleChain(org.junit.rules.RuleChain) EphemeralFileSystemAbstraction(org.neo4j.graphdb.mockfs.EphemeralFileSystemAbstraction) List(java.util.List) Rule(org.junit.Rule) MetaDataStore(org.neo4j.kernel.impl.store.MetaDataStore) Assert.assertFalse(org.junit.Assert.assertFalse) Matchers.is(org.hamcrest.Matchers.is) Collections(java.util.Collections) FileSystemAbstraction(org.neo4j.io.fs.FileSystemAbstraction) FilenameFilter(java.io.FilenameFilter) File(java.io.File) Test(org.junit.Test)

Example 55 with PageCache

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());
}
Also used : StoreId(org.neo4j.causalclustering.identity.StoreId) File(java.io.File) PageCache(org.neo4j.io.pagecache.PageCache) HashSet(java.util.HashSet)

Aggregations

PageCache (org.neo4j.io.pagecache.PageCache)134 Test (org.junit.Test)90 File (java.io.File)74 Config (org.neo4j.kernel.configuration.Config)39 IOException (java.io.IOException)32 FileSystemAbstraction (org.neo4j.io.fs.FileSystemAbstraction)31 StoreVersionCheck (org.neo4j.kernel.impl.storemigration.StoreVersionCheck)19 LegacyStoreVersionCheck (org.neo4j.kernel.impl.storemigration.legacystore.LegacyStoreVersionCheck)17 UpgradableDatabase (org.neo4j.kernel.impl.storemigration.UpgradableDatabase)16 PagedFile (org.neo4j.io.pagecache.PagedFile)15 LogService (org.neo4j.kernel.impl.logging.LogService)13 DefaultFileSystemAbstraction (org.neo4j.io.fs.DefaultFileSystemAbstraction)12 NullLogService (org.neo4j.kernel.impl.logging.NullLogService)12 StoreFactory (org.neo4j.kernel.impl.store.StoreFactory)12 NeoStores (org.neo4j.kernel.impl.store.NeoStores)11 RecordFormatSelector.selectForConfig (org.neo4j.kernel.impl.store.format.RecordFormatSelector.selectForConfig)11 RecordFormatSelector.selectForStoreOrConfig (org.neo4j.kernel.impl.store.format.RecordFormatSelector.selectForStoreOrConfig)11 Before (org.junit.Before)10 TransactionId (org.neo4j.kernel.impl.store.TransactionId)10 StoreCopyClient (org.neo4j.com.storecopy.StoreCopyClient)9