Search in sources :

Example 1 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 2 with PageCache

use of org.neo4j.io.pagecache.PageCache in project neo4j by neo4j.

the class ConfigurableStandalonePageCacheFactory method createPageCache.

/**
     * Create page cache
     * @param fileSystem file system that page cache will be based on
     * @param pageCacheTracer global page cache tracer
     * @param pageCursorTracerSupplier supplier of thread local (transaction local) page cursor tracer that will provide
     * thread local page cache statistics
     * @param config page cache configuration
     * @return created page cache instance
     */
public static PageCache createPageCache(FileSystemAbstraction fileSystem, PageCacheTracer pageCacheTracer, PageCursorTracerSupplier pageCursorTracerSupplier, Config config) {
    Config finalConfig = config.withDefaults(MapUtil.stringMap(GraphDatabaseSettings.pagecache_memory.name(), "8M"));
    FormattedLogProvider logProvider = FormattedLogProvider.toOutputStream(System.err);
    ConfiguringPageCacheFactory pageCacheFactory = new ConfiguringPageCacheFactory(fileSystem, finalConfig, pageCacheTracer, pageCursorTracerSupplier, logProvider.getLog(PageCache.class));
    return pageCacheFactory.getOrCreatePageCache();
}
Also used : Config(org.neo4j.kernel.configuration.Config) PageCache(org.neo4j.io.pagecache.PageCache) FormattedLogProvider(org.neo4j.logging.FormattedLogProvider)

Example 3 with PageCache

use of org.neo4j.io.pagecache.PageCache in project neo4j by neo4j.

the class PlatformModule method createPageCache.

protected PageCache createPageCache(FileSystemAbstraction fileSystem, Config config, LogService logging, Tracers tracers) {
    Log pageCacheLog = logging.getInternalLog(PageCache.class);
    ConfiguringPageCacheFactory pageCacheFactory = new ConfiguringPageCacheFactory(fileSystem, config, tracers.pageCacheTracer, tracers.pageCursorTracerSupplier, pageCacheLog);
    PageCache pageCache = pageCacheFactory.getOrCreatePageCache();
    if (config.get(GraphDatabaseSettings.dump_configuration)) {
        pageCacheFactory.dumpConfiguration();
    }
    return pageCache;
}
Also used : Log(org.neo4j.logging.Log) ConfiguringPageCacheFactory(org.neo4j.kernel.impl.pagecache.ConfiguringPageCacheFactory) PageCache(org.neo4j.io.pagecache.PageCache)

Example 4 with PageCache

use of org.neo4j.io.pagecache.PageCache in project neo4j by neo4j.

the class RecoveryRequiredCheckerTest method shouldWantToRecoverBrokenStore.

@Test
public void shouldWantToRecoverBrokenStore() throws Exception {
    try (FileSystemAbstraction fileSystemAbstraction = createSomeDataAndCrash(storeDir, fileSystem)) {
        PageCache pageCache = pageCacheRule.getPageCache(fileSystemAbstraction);
        RecoveryRequiredChecker recoverer = new RecoveryRequiredChecker(fileSystemAbstraction, pageCache);
        assertThat(recoverer.isRecoveryRequiredAt(storeDir), is(true));
    }
}
Also used : EphemeralFileSystemAbstraction(org.neo4j.graphdb.mockfs.EphemeralFileSystemAbstraction) FileSystemAbstraction(org.neo4j.io.fs.FileSystemAbstraction) PageCache(org.neo4j.io.pagecache.PageCache) Test(org.junit.Test)

Example 5 with PageCache

use of org.neo4j.io.pagecache.PageCache 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));
}
Also used : RecordFormat(org.neo4j.kernel.impl.store.format.RecordFormat) TransactionIdStore(org.neo4j.kernel.impl.transaction.log.TransactionIdStore) StoreFileMetadata(org.neo4j.storageengine.api.StoreFileMetadata) EphemeralFileSystemRule(org.neo4j.test.rule.fs.EphemeralFileSystemRule) Exceptions(org.neo4j.helpers.Exceptions) BatchTransactionApplierFacade(org.neo4j.kernel.impl.api.BatchTransactionApplierFacade) IOLimiter(org.neo4j.io.pagecache.IOLimiter) AtomicReference(java.util.concurrent.atomic.AtomicReference) TransactionToApply(org.neo4j.kernel.impl.api.TransactionToApply) DelegatingPageCache(org.neo4j.io.pagecache.DelegatingPageCache) RecordStorageEngineRule(org.neo4j.test.rule.RecordStorageEngineRule) Assert.assertSame(org.junit.Assert.assertSame) Assert.assertThat(org.junit.Assert.assertThat) Mockito.doThrow(org.mockito.Mockito.doThrow) PageCacheRule(org.neo4j.test.rule.PageCacheRule) ThreadLocalRandom(java.util.concurrent.ThreadLocalRandom) TransactionApplicationMode(org.neo4j.storageengine.api.TransactionApplicationMode) CountsTracker(org.neo4j.kernel.impl.store.counts.CountsTracker) Assert.fail(org.junit.Assert.fail) StoreFile(org.neo4j.kernel.impl.storemigration.StoreFile) PageCache(org.neo4j.io.pagecache.PageCache) UnderlyingStorageException(org.neo4j.kernel.impl.store.UnderlyingStorageException) BatchTransactionApplier(org.neo4j.kernel.impl.api.BatchTransactionApplier) TransactionRepresentation(org.neo4j.kernel.impl.transaction.TransactionRepresentation) Assert.assertNotNull(org.junit.Assert.assertNotNull) Collection(java.util.Collection) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) IOException(java.io.IOException) Mockito.when(org.mockito.Mockito.when) File(java.io.File) Mockito.verify(org.mockito.Mockito.verify) RuleChain(org.junit.rules.RuleChain) Matchers.any(org.mockito.Matchers.any) Rule(org.junit.Rule) CountsAccessor(org.neo4j.kernel.impl.api.CountsAccessor) StoreFileType(org.neo4j.kernel.impl.storemigration.StoreFileType) DatabaseHealth(org.neo4j.kernel.internal.DatabaseHealth) Matchers.sameInstance(org.hamcrest.Matchers.sameInstance) StoreType(org.neo4j.kernel.impl.store.StoreType) Matchers.equalTo(org.hamcrest.Matchers.equalTo) CommandsToApply(org.neo4j.storageengine.api.CommandsToApply) Optional(java.util.Optional) FakeCommitment(org.neo4j.kernel.impl.transaction.log.FakeCommitment) Matchers.anyOf(org.hamcrest.Matchers.anyOf) FileSystemAbstraction(org.neo4j.io.fs.FileSystemAbstraction) Mockito.mock(org.mockito.Mockito.mock) FileSystemAbstraction(org.neo4j.io.fs.FileSystemAbstraction) DelegatingPageCache(org.neo4j.io.pagecache.DelegatingPageCache) IOLimiter(org.neo4j.io.pagecache.IOLimiter) AtomicReference(java.util.concurrent.atomic.AtomicReference) DelegatingPageCache(org.neo4j.io.pagecache.DelegatingPageCache) PageCache(org.neo4j.io.pagecache.PageCache) Test(org.junit.Test)

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