Search in sources :

Example 1 with DefaultIdGeneratorFactory

use of org.neo4j.kernel.impl.store.id.DefaultIdGeneratorFactory in project neo4j by neo4j.

the class AbstractDynamicStoreTest method newTestableDynamicStore.

private AbstractDynamicStore newTestableDynamicStore() {
    DefaultIdGeneratorFactory idGeneratorFactory = new DefaultIdGeneratorFactory(fs);
    AbstractDynamicStore store = new AbstractDynamicStore(fileName, Config.empty(), IdType.ARRAY_BLOCK, idGeneratorFactory, pageCache, NullLogProvider.getInstance(), "test", BLOCK_SIZE, formats.dynamic(), formats.storeVersion()) {

        @Override
        public void accept(Processor processor, DynamicRecord record) {
        // Ignore
        }

        @Override
        public String getTypeDescriptor() {
            return "TestDynamicStore";
        }
    };
    store.initialise(true);
    return store;
}
Also used : DynamicRecord(org.neo4j.kernel.impl.store.record.DynamicRecord) DefaultIdGeneratorFactory(org.neo4j.kernel.impl.store.id.DefaultIdGeneratorFactory)

Example 2 with DefaultIdGeneratorFactory

use of org.neo4j.kernel.impl.store.id.DefaultIdGeneratorFactory in project neo4j by neo4j.

the class NeoStoreDataSourceRule method getDataSource.

public NeoStoreDataSource getDataSource(File storeDir, FileSystemAbstraction fs, PageCache pageCache, Map<String, String> additionalConfig, DatabaseHealth databaseHealth) {
    CommunityIdTypeConfigurationProvider idTypeConfigurationProvider = new CommunityIdTypeConfigurationProvider();
    DefaultIdGeneratorFactory idGeneratorFactory = new DefaultIdGeneratorFactory(fs);
    NullLogService logService = NullLogService.getInstance();
    return getDataSource(storeDir, fs, idGeneratorFactory, idTypeConfigurationProvider, pageCache, additionalConfig, databaseHealth, logService);
}
Also used : CommunityIdTypeConfigurationProvider(org.neo4j.kernel.impl.store.id.configuration.CommunityIdTypeConfigurationProvider) DefaultIdGeneratorFactory(org.neo4j.kernel.impl.store.id.DefaultIdGeneratorFactory) NullLogService(org.neo4j.kernel.impl.logging.NullLogService)

Example 3 with DefaultIdGeneratorFactory

use of org.neo4j.kernel.impl.store.id.DefaultIdGeneratorFactory in project neo4j by neo4j.

the class NeoStoresRule method open.

public NeoStores open(FileSystemAbstraction fs, PageCache pageCache, RecordFormats format, String... config) throws IOException {
    assert neoStores == null : "Already opened";
    TestDirectory testDirectory = TestDirectory.testDirectory(testClass, fs);
    File storeDir = testDirectory.makeGraphDbDir();
    Config configuration = Config.embeddedDefaults(stringMap(config));
    StoreFactory storeFactory = new StoreFactory(storeDir, configuration, new DefaultIdGeneratorFactory(fs), pageCache, fs, format, NullLogProvider.getInstance());
    return neoStores = stores.length == 0 ? storeFactory.openAllNeoStores(true) : storeFactory.openNeoStores(true, stores);
}
Also used : Config(org.neo4j.kernel.configuration.Config) DefaultIdGeneratorFactory(org.neo4j.kernel.impl.store.id.DefaultIdGeneratorFactory) StoreFactory(org.neo4j.kernel.impl.store.StoreFactory) File(java.io.File)

Example 4 with DefaultIdGeneratorFactory

use of org.neo4j.kernel.impl.store.id.DefaultIdGeneratorFactory in project neo4j by neo4j.

the class DirectRecordStoreMigrator method migrate.

public void migrate(File fromStoreDir, RecordFormats fromFormat, File toStoreDir, RecordFormats toFormat, MigrationProgressMonitor.Section progressMonitor, StoreType[] types, StoreType... additionalTypesToOpen) {
    StoreType[] storesToOpen = ArrayUtil.concat(types, additionalTypesToOpen);
    progressMonitor.start(storesToOpen.length);
    try (NeoStores fromStores = new StoreFactory(fromStoreDir, config, new DefaultIdGeneratorFactory(fs), pageCache, fs, fromFormat, NullLogProvider.getInstance()).openNeoStores(true, storesToOpen);
        NeoStores toStores = new StoreFactory(toStoreDir, withPersistedStoreHeadersAsConfigFrom(fromStores, storesToOpen), new DefaultIdGeneratorFactory(fs), pageCache, fs, toFormat, NullLogProvider.getInstance()).openNeoStores(true, storesToOpen)) {
        for (StoreType type : types) {
            // This condition will exclude counts store first and foremost.
            if (type.isRecordStore()) {
                migrate(fromStores.getRecordStore(type), toStores.getRecordStore(type));
                progressMonitor.progress(1);
            }
        }
    }
}
Also used : StoreType(org.neo4j.kernel.impl.store.StoreType) NeoStores(org.neo4j.kernel.impl.store.NeoStores) DefaultIdGeneratorFactory(org.neo4j.kernel.impl.store.id.DefaultIdGeneratorFactory) StoreFactory(org.neo4j.kernel.impl.store.StoreFactory)

Example 5 with DefaultIdGeneratorFactory

use of org.neo4j.kernel.impl.store.id.DefaultIdGeneratorFactory in project neo4j by neo4j.

the class TestGrowingFileMemoryMapping method shouldGrowAFileWhileContinuingToMemoryMapNewRegions.

@Test
public void shouldGrowAFileWhileContinuingToMemoryMapNewRegions() throws Exception {
    // don't run on windows because memory mapping doesn't work properly there
    assumeTrue(!SystemUtils.IS_OS_WINDOWS);
    // given
    int NUMBER_OF_RECORDS = 1000000;
    File storeDir = testDirectory.graphDbDir();
    Config config = Config.embeddedDefaults(stringMap(pagecache_memory.name(), mmapSize(NUMBER_OF_RECORDS, NodeRecordFormat.RECORD_SIZE)));
    FileSystemAbstraction fileSystemAbstraction = fileSystemRule.get();
    DefaultIdGeneratorFactory idGeneratorFactory = new DefaultIdGeneratorFactory(fileSystemAbstraction);
    PageCache pageCache = pageCacheRule.getPageCache(fileSystemAbstraction, config);
    StoreFactory storeFactory = new StoreFactory(storeDir, config, idGeneratorFactory, pageCache, fileSystemAbstraction, NullLogProvider.getInstance());
    NeoStores neoStores = storeFactory.openAllNeoStores(true);
    NodeStore nodeStore = neoStores.getNodeStore();
    // when
    int iterations = 2 * NUMBER_OF_RECORDS;
    long startingId = nodeStore.nextId();
    long nodeId = startingId;
    for (int i = 0; i < iterations; i++) {
        NodeRecord record = new NodeRecord(nodeId, false, i, 0);
        record.setInUse(true);
        nodeStore.updateRecord(record);
        nodeId = nodeStore.nextId();
    }
    // then
    NodeRecord record = new NodeRecord(0, false, 0, 0);
    for (int i = 0; i < iterations; i++) {
        record.setId(startingId + i);
        nodeStore.getRecord(i, record, NORMAL);
        assertTrue("record[" + i + "] should be in use", record.inUse());
        assertThat("record[" + i + "] should have nextRelId of " + i, record.getNextRel(), is((long) i));
    }
    neoStores.close();
}
Also used : NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) FileSystemAbstraction(org.neo4j.io.fs.FileSystemAbstraction) Config(org.neo4j.kernel.configuration.Config) DefaultIdGeneratorFactory(org.neo4j.kernel.impl.store.id.DefaultIdGeneratorFactory) File(java.io.File) PageCache(org.neo4j.io.pagecache.PageCache) Test(org.junit.Test)

Aggregations

DefaultIdGeneratorFactory (org.neo4j.kernel.impl.store.id.DefaultIdGeneratorFactory)34 File (java.io.File)18 Config (org.neo4j.kernel.configuration.Config)17 Test (org.junit.Test)13 StoreFactory (org.neo4j.kernel.impl.store.StoreFactory)11 Before (org.junit.Before)10 FileSystemAbstraction (org.neo4j.io.fs.FileSystemAbstraction)8 PageCache (org.neo4j.io.pagecache.PageCache)6 NeoStores (org.neo4j.kernel.impl.store.NeoStores)5 NodeRecord (org.neo4j.kernel.impl.store.record.NodeRecord)4 ArrayList (java.util.ArrayList)3 UncloseableDelegatingFileSystemAbstraction (org.neo4j.graphdb.mockfs.UncloseableDelegatingFileSystemAbstraction)2 DefaultFileSystemAbstraction (org.neo4j.io.fs.DefaultFileSystemAbstraction)2 PagedFile (org.neo4j.io.pagecache.PagedFile)2 StandalonePageCacheFactory.createPageCache (org.neo4j.io.pagecache.impl.muninn.StandalonePageCacheFactory.createPageCache)2 DynamicRecord (org.neo4j.kernel.impl.store.record.DynamicRecord)2 NullLogProvider (org.neo4j.logging.NullLogProvider)2 IOException (java.io.IOException)1 InterruptedIOException (java.io.InterruptedIOException)1 PrintStream (java.io.PrintStream)1