Search in sources :

Example 21 with StorageEngineFactory

use of org.neo4j.storageengine.api.StorageEngineFactory in project neo4j by neo4j.

the class LogFilesBuilder method readOnlyTransactionIdStore.

private TransactionIdStore readOnlyTransactionIdStore() throws IOException {
    StorageEngineFactory storageEngineFactory = StorageEngineFactory.defaultStorageEngine();
    var pageCacheTracer = databaseTracers.getPageCacheTracer();
    try (var cursorContext = new CursorContext(pageCacheTracer.createPageCursorTracer(READ_ONLY_TRANSACTION_STORE_READER_TAG))) {
        return storageEngineFactory.readOnlyTransactionIdStore(fileSystem, databaseLayout, pageCache, cursorContext);
    }
}
Also used : StorageEngineFactory(org.neo4j.storageengine.api.StorageEngineFactory) CursorContext(org.neo4j.io.pagecache.context.CursorContext)

Example 22 with StorageEngineFactory

use of org.neo4j.storageengine.api.StorageEngineFactory in project neo4j by neo4j.

the class TransactionLogsInSeparateLocationIT method databaseWithTransactionLogsInSeparateAbsoluteLocation.

@Test
void databaseWithTransactionLogsInSeparateAbsoluteLocation() throws IOException {
    Path txDirectory = testDirectory.directory("transaction-logs");
    Config config = Config.newBuilder().set(neo4j_home, testDirectory.homePath()).set(transaction_logs_root_path, txDirectory.toAbsolutePath()).build();
    DatabaseLayout layout = DatabaseLayout.of(config);
    StorageEngineFactory storageEngineFactory = performTransactions(txDirectory.toAbsolutePath(), layout.databaseDirectory());
    verifyTransactionLogs(layout.getTransactionLogsDirectory(), layout.databaseDirectory(), storageEngineFactory);
}
Also used : Path(java.nio.file.Path) Config(org.neo4j.configuration.Config) StorageEngineFactory(org.neo4j.storageengine.api.StorageEngineFactory) DatabaseLayout(org.neo4j.io.layout.DatabaseLayout) Test(org.junit.jupiter.api.Test)

Example 23 with StorageEngineFactory

use of org.neo4j.storageengine.api.StorageEngineFactory in project neo4j by neo4j.

the class TransactionLogsInSeparateLocationIT method performTransactions.

private static StorageEngineFactory performTransactions(Path txPath, Path storeDir) {
    DatabaseManagementService managementService = new TestDatabaseManagementServiceBuilder(storeDir).setConfig(transaction_logs_root_path, txPath).build();
    GraphDatabaseService database = managementService.database(DEFAULT_DATABASE_NAME);
    for (int i = 0; i < 10; i++) {
        try (Transaction transaction = database.beginTx()) {
            Node node = transaction.createNode();
            node.setProperty("a", "b");
            node.setProperty("c", "d");
            transaction.commit();
        }
    }
    StorageEngineFactory storageEngineFactory = ((GraphDatabaseAPI) database).getDependencyResolver().resolveDependency(StorageEngineFactory.class);
    managementService.shutdown();
    return storageEngineFactory;
}
Also used : TestDatabaseManagementServiceBuilder(org.neo4j.test.TestDatabaseManagementServiceBuilder) StorageEngineFactory(org.neo4j.storageengine.api.StorageEngineFactory) DatabaseManagementService(org.neo4j.dbms.api.DatabaseManagementService)

Example 24 with StorageEngineFactory

use of org.neo4j.storageengine.api.StorageEngineFactory in project neo4j by neo4j.

the class StoreInfoCommand method execute.

@Override
public void execute() {
    var storageEngineFactory = StorageEngineFactory.defaultStorageEngine();
    var config = CommandHelpers.buildConfig(ctx, allowCommandExpansion);
    var neo4jLayout = Neo4jLayout.of(config);
    try (var fs = ctx.fs();
        var jobScheduler = createInitialisedScheduler();
        var pageCache = StandalonePageCacheFactory.createPageCache(fs, jobScheduler, PageCacheTracer.NULL)) {
        validatePath(fs, all, path, neo4jLayout);
        if (all) {
            var collector = structured ? Collectors.joining(",", "[", "]") : Collectors.joining(System.lineSeparator() + System.lineSeparator());
            var result = Arrays.stream(fs.listFiles(path)).sorted(comparing(Path::getFileName)).map(dbPath -> neo4jLayout.databaseLayout(dbPath.getFileName().toString())).filter(dbLayout -> Validators.isExistingDatabase(fs, dbLayout)).map(dbLayout -> printInfo(fs, dbLayout, pageCache, storageEngineFactory, config, structured, true)).collect(collector);
            ctx.out().println(result);
        } else {
            var databaseLayout = neo4jLayout.databaseLayout(path.getFileName().toString());
            ctx.out().println(printInfo(fs, databaseLayout, pageCache, storageEngineFactory, config, structured, false));
        }
    } catch (CommandFailedException e) {
        throw e;
    } catch (Exception e) {
        throw new CommandFailedException(format("Failed to execute command: '%s'.", e.getMessage()), e);
    }
}
Also used : Arrays(java.util.Arrays) Parameters(picocli.CommandLine.Parameters) NullLogService(org.neo4j.logging.internal.NullLogService) CursorContext(org.neo4j.io.pagecache.context.CursorContext) Config(org.neo4j.configuration.Config) EmptyMemoryTracker(org.neo4j.memory.EmptyMemoryTracker) JobSchedulerFactory.createInitialisedScheduler(org.neo4j.kernel.impl.scheduler.JobSchedulerFactory.createInitialisedScheduler) DatabaseLayout(org.neo4j.io.layout.DatabaseLayout) PageCacheTracer(org.neo4j.io.pagecache.tracing.PageCacheTracer) Recovery.isRecoveryRequired(org.neo4j.kernel.recovery.Recovery.isRecoveryRequired) AbstractCommand(org.neo4j.cli.AbstractCommand) Comparator.comparing(java.util.Comparator.comparing) Command(picocli.CommandLine.Command) Path(java.nio.file.Path) MemoryTracker(org.neo4j.memory.MemoryTracker) PageCache(org.neo4j.io.pagecache.PageCache) Validators(org.neo4j.kernel.impl.util.Validators) StandalonePageCacheFactory(org.neo4j.io.pagecache.impl.muninn.StandalonePageCacheFactory) Collectors(java.util.stream.Collectors) Neo4jLayout(org.neo4j.io.layout.Neo4jLayout) String.format(java.lang.String.format) ExecutionContext(org.neo4j.cli.ExecutionContext) Objects(java.util.Objects) StorageEngineFactory(org.neo4j.storageengine.api.StorageEngineFactory) Option(picocli.CommandLine.Option) List(java.util.List) FileLockException(org.neo4j.kernel.internal.locker.FileLockException) CommandFailedException(org.neo4j.cli.CommandFailedException) Pair(org.neo4j.internal.helpers.collection.Pair) StoreVersion(org.neo4j.storageengine.api.StoreVersion) FileSystemAbstraction(org.neo4j.io.fs.FileSystemAbstraction) CommandFailedException(org.neo4j.cli.CommandFailedException) FileLockException(org.neo4j.kernel.internal.locker.FileLockException) CommandFailedException(org.neo4j.cli.CommandFailedException)

Aggregations

StorageEngineFactory (org.neo4j.storageengine.api.StorageEngineFactory)24 Test (org.junit.jupiter.api.Test)9 Path (java.nio.file.Path)7 DatabaseLayout (org.neo4j.io.layout.DatabaseLayout)7 DatabaseManagementService (org.neo4j.dbms.api.DatabaseManagementService)5 AssertableLogProvider (org.neo4j.logging.AssertableLogProvider)5 TestDatabaseManagementServiceBuilder (org.neo4j.test.TestDatabaseManagementServiceBuilder)4 Dependencies (org.neo4j.collection.Dependencies)3 Config (org.neo4j.configuration.Config)3 FileSystemAbstraction (org.neo4j.io.fs.FileSystemAbstraction)3 CursorContext (org.neo4j.io.pagecache.context.CursorContext)3 GraphDatabaseAPI (org.neo4j.kernel.internal.GraphDatabaseAPI)3 StoreVersion (org.neo4j.storageengine.api.StoreVersion)3 SchemaIndexMigrator (org.neo4j.storageengine.migration.SchemaIndexMigrator)3 ArrayList (java.util.ArrayList)2 Transaction (org.neo4j.graphdb.Transaction)2 IndexProviderDescriptor (org.neo4j.internal.schema.IndexProviderDescriptor)2 Neo4jLayout (org.neo4j.io.layout.Neo4jLayout)2 PageCache (org.neo4j.io.pagecache.PageCache)2 IndexDirectoryStructure (org.neo4j.kernel.api.index.IndexDirectoryStructure)2