Search in sources :

Example 11 with DefaultIdGeneratorFactory

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

the class IdGeneratorRebuildFailureEmulationTest method initialize.

@Before
public void initialize() {
    fs = new FileSystem();
    GraphDatabaseService graphdb = new Database(storeDir);
    createInitialData(graphdb);
    graphdb.shutdown();
    Map<String, String> params = new HashMap<>();
    params.put(GraphDatabaseSettings.rebuild_idgenerators_fast.name(), Settings.FALSE);
    Config config = Config.embeddedDefaults(params);
    factory = new StoreFactory(storeDir, config, new DefaultIdGeneratorFactory(fs), pageCacheRule.getPageCache(fs), fs, NullLogProvider.getInstance());
}
Also used : GraphDatabaseService(org.neo4j.graphdb.GraphDatabaseService) HashMap(java.util.HashMap) Config(org.neo4j.kernel.configuration.Config) ImpermanentGraphDatabase(org.neo4j.test.ImpermanentGraphDatabase) DefaultIdGeneratorFactory(org.neo4j.kernel.impl.store.id.DefaultIdGeneratorFactory) Before(org.junit.Before)

Example 12 with DefaultIdGeneratorFactory

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

the class TestArrayStore method before.

@Before
public void before() throws Exception {
    File dir = testDirectory.graphDbDir();
    FileSystemAbstraction fs = fileSystemRule.get();
    DefaultIdGeneratorFactory idGeneratorFactory = new DefaultIdGeneratorFactory(fs);
    PageCache pageCache = pageCacheRule.getPageCache(fs);
    StoreFactory factory = new StoreFactory(dir, Config.empty(), idGeneratorFactory, pageCache, fs, NullLogProvider.getInstance());
    neoStores = factory.openAllNeoStores(true);
    arrayStore = neoStores.getPropertyStore().getArrayStore();
}
Also used : FileSystemAbstraction(org.neo4j.io.fs.FileSystemAbstraction) DefaultIdGeneratorFactory(org.neo4j.kernel.impl.store.id.DefaultIdGeneratorFactory) File(java.io.File) PageCache(org.neo4j.io.pagecache.PageCache) Before(org.junit.Before)

Example 13 with DefaultIdGeneratorFactory

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

the class ConsistencyCheckService method runFullConsistencyCheck.

public Result runFullConsistencyCheck(final File storeDir, Config config, ProgressMonitorFactory progressFactory, final LogProvider logProvider, final FileSystemAbstraction fileSystem, final PageCache pageCache, final boolean verbose, File reportDir, CheckConsistencyConfig checkConsistencyConfig) throws ConsistencyCheckIncompleteException {
    Log log = logProvider.getLog(getClass());
    config = config.with(stringMap(GraphDatabaseSettings.read_only.name(), TRUE, GraphDatabaseSettings.label_index.name(), LabelIndex.AUTO.name()));
    StoreFactory factory = new StoreFactory(storeDir, config, new DefaultIdGeneratorFactory(fileSystem), pageCache, fileSystem, logProvider);
    ConsistencySummaryStatistics summary;
    final File reportFile = chooseReportPath(reportDir);
    Log reportLog = new ConsistencyReportLog(Suppliers.lazySingleton(() -> {
        try {
            return new PrintWriter(createOrOpenAsOuputStream(fileSystem, reportFile, true));
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }));
    // Bootstrap kernel extensions
    LifeSupport life = new LifeSupport();
    try (NeoStores neoStores = factory.openAllNeoStores()) {
        IndexStoreView indexStoreView = new NeoStoreIndexStoreView(LockService.NO_LOCK_SERVICE, neoStores);
        Dependencies dependencies = new Dependencies();
        dependencies.satisfyDependencies(config, fileSystem, new SimpleLogService(logProvider, logProvider), indexStoreView, pageCache);
        KernelContext kernelContext = new SimpleKernelContext(storeDir, UNKNOWN, dependencies);
        KernelExtensions extensions = life.add(new KernelExtensions(kernelContext, (Iterable) load(KernelExtensionFactory.class), dependencies, ignore()));
        life.start();
        LabelScanStore labelScanStore = life.add(extensions.resolveDependency(LabelScanStoreProvider.class, new NamedLabelScanStoreSelectionStrategy(config)).getLabelScanStore());
        SchemaIndexProvider indexes = life.add(extensions.resolveDependency(SchemaIndexProvider.class, HighestSelectionStrategy.getInstance()));
        int numberOfThreads = defaultConsistencyCheckThreadsNumber();
        Statistics statistics;
        StoreAccess storeAccess;
        AccessStatistics stats = new AccessStatistics();
        if (verbose) {
            statistics = new VerboseStatistics(stats, new DefaultCounts(numberOfThreads), log);
            storeAccess = new AccessStatsKeepingStoreAccess(neoStores, stats);
        } else {
            statistics = Statistics.NONE;
            storeAccess = new StoreAccess(neoStores);
        }
        storeAccess.initialize();
        DirectStoreAccess stores = new DirectStoreAccess(storeAccess, labelScanStore, indexes);
        FullCheck check = new FullCheck(progressFactory, statistics, numberOfThreads, checkConsistencyConfig);
        summary = check.execute(stores, new DuplicatingLog(log, reportLog));
    } finally {
        life.shutdown();
    }
    if (!summary.isConsistent()) {
        log.warn("See '%s' for a detailed consistency report.", reportFile.getPath());
        return Result.failure(reportFile);
    }
    return Result.success(reportFile);
}
Also used : LabelScanStore(org.neo4j.kernel.api.labelscan.LabelScanStore) AccessStatsKeepingStoreAccess(org.neo4j.consistency.statistics.AccessStatsKeepingStoreAccess) DirectStoreAccess(org.neo4j.kernel.api.direct.DirectStoreAccess) StoreAccess(org.neo4j.kernel.impl.store.StoreAccess) SimpleLogService(org.neo4j.kernel.impl.logging.SimpleLogService) DirectStoreAccess(org.neo4j.kernel.api.direct.DirectStoreAccess) StoreFactory(org.neo4j.kernel.impl.store.StoreFactory) DefaultCounts(org.neo4j.consistency.statistics.DefaultCounts) AccessStatistics(org.neo4j.consistency.statistics.AccessStatistics) SimpleKernelContext(org.neo4j.kernel.impl.spi.SimpleKernelContext) LifeSupport(org.neo4j.kernel.lifecycle.LifeSupport) DuplicatingLog(org.neo4j.logging.DuplicatingLog) VerboseStatistics(org.neo4j.consistency.statistics.VerboseStatistics) Dependencies(org.neo4j.kernel.impl.util.Dependencies) NamedLabelScanStoreSelectionStrategy(org.neo4j.kernel.extension.dependency.NamedLabelScanStoreSelectionStrategy) ConsistencySummaryStatistics(org.neo4j.consistency.report.ConsistencySummaryStatistics) PrintWriter(java.io.PrintWriter) SimpleKernelContext(org.neo4j.kernel.impl.spi.SimpleKernelContext) KernelContext(org.neo4j.kernel.impl.spi.KernelContext) SchemaIndexProvider(org.neo4j.kernel.api.index.SchemaIndexProvider) Log(org.neo4j.logging.Log) DuplicatingLog(org.neo4j.logging.DuplicatingLog) DefaultIdGeneratorFactory(org.neo4j.kernel.impl.store.id.DefaultIdGeneratorFactory) AccessStatsKeepingStoreAccess(org.neo4j.consistency.statistics.AccessStatsKeepingStoreAccess) IOException(java.io.IOException) KernelExtensionFactory(org.neo4j.kernel.extension.KernelExtensionFactory) Statistics(org.neo4j.consistency.statistics.Statistics) VerboseStatistics(org.neo4j.consistency.statistics.VerboseStatistics) ConsistencySummaryStatistics(org.neo4j.consistency.report.ConsistencySummaryStatistics) AccessStatistics(org.neo4j.consistency.statistics.AccessStatistics) NeoStoreIndexStoreView(org.neo4j.kernel.impl.transaction.state.storeview.NeoStoreIndexStoreView) FullCheck(org.neo4j.consistency.checking.full.FullCheck) KernelExtensions(org.neo4j.kernel.extension.KernelExtensions) NeoStores(org.neo4j.kernel.impl.store.NeoStores) IndexStoreView(org.neo4j.kernel.impl.api.index.IndexStoreView) NeoStoreIndexStoreView(org.neo4j.kernel.impl.transaction.state.storeview.NeoStoreIndexStoreView) File(java.io.File)

Example 14 with DefaultIdGeneratorFactory

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

the class DumpStoreChain method dump.

void dump(File storeDir) throws IOException {
    try (DefaultFileSystemAbstraction fs = new DefaultFileSystemAbstraction();
        PageCache pageCache = createPageCache(fs)) {
        DefaultIdGeneratorFactory idGeneratorFactory = new DefaultIdGeneratorFactory(fs);
        Config config = Config.defaults();
        StoreFactory storeFactory = new StoreFactory(storeDir, config, idGeneratorFactory, pageCache, fs, logProvider());
        try (NeoStores neoStores = storeFactory.openNeoStores(getStoreTypes())) {
            RecordStore<RECORD> store = store(neoStores);
            RECORD record = store.newRecord();
            for (long next = first; next != -1; ) {
                store.getRecord(next, record, RecordLoad.FORCE);
                System.out.println(record);
                next = next(record);
            }
        }
    }
}
Also used : DefaultFileSystemAbstraction(org.neo4j.io.fs.DefaultFileSystemAbstraction) Config(org.neo4j.kernel.configuration.Config) NeoStores(org.neo4j.kernel.impl.store.NeoStores) DefaultIdGeneratorFactory(org.neo4j.kernel.impl.store.id.DefaultIdGeneratorFactory) StoreFactory(org.neo4j.kernel.impl.store.StoreFactory) StandalonePageCacheFactory.createPageCache(org.neo4j.io.pagecache.impl.muninn.StandalonePageCacheFactory.createPageCache) PageCache(org.neo4j.io.pagecache.PageCache)

Example 15 with DefaultIdGeneratorFactory

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

the class CoreBootstrapper method deriveIdAllocationState.

private IdAllocationState deriveIdAllocationState(File dbDir) throws IOException {
    DefaultIdGeneratorFactory factory = new DefaultIdGeneratorFactory(fs);
    long[] highIds = new long[] { getHighId(dbDir, factory, NODE, NODE_STORE_NAME), getHighId(dbDir, factory, RELATIONSHIP, RELATIONSHIP_STORE_NAME), getHighId(dbDir, factory, PROPERTY, PROPERTY_STORE_NAME), getHighId(dbDir, factory, STRING_BLOCK, PROPERTY_STRINGS_STORE_NAME), getHighId(dbDir, factory, ARRAY_BLOCK, PROPERTY_ARRAYS_STORE_NAME), getHighId(dbDir, factory, PROPERTY_KEY_TOKEN, PROPERTY_KEY_TOKEN_STORE_NAME), getHighId(dbDir, factory, PROPERTY_KEY_TOKEN_NAME, PROPERTY_KEY_TOKEN_NAMES_STORE_NAME), getHighId(dbDir, factory, RELATIONSHIP_TYPE_TOKEN, RELATIONSHIP_TYPE_TOKEN_STORE_NAME), getHighId(dbDir, factory, RELATIONSHIP_TYPE_TOKEN_NAME, RELATIONSHIP_TYPE_TOKEN_NAMES_STORE_NAME), getHighId(dbDir, factory, LABEL_TOKEN, LABEL_TOKEN_STORE_NAME), getHighId(dbDir, factory, LABEL_TOKEN_NAME, LABEL_TOKEN_NAMES_STORE_NAME), getHighId(dbDir, factory, NEOSTORE_BLOCK, ""), getHighId(dbDir, factory, SCHEMA, SCHEMA_STORE_NAME), getHighId(dbDir, factory, NODE_LABELS, NODE_LABELS_STORE_NAME), getHighId(dbDir, factory, RELATIONSHIP_GROUP, RELATIONSHIP_GROUP_STORE_NAME) };
    return new IdAllocationState(highIds, FIRST_INDEX);
}
Also used : IdAllocationState(org.neo4j.causalclustering.core.state.machines.id.IdAllocationState) DefaultIdGeneratorFactory(org.neo4j.kernel.impl.store.id.DefaultIdGeneratorFactory)

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