Search in sources :

Example 6 with StorageEngineFactory

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

the class GlobalModule method checkLegacyDefaultDatabase.

private void checkLegacyDefaultDatabase() {
    if (!globalConfig.isExplicitlySet(default_database)) {
        StorageEngineFactory storageEngineFactory = StorageEngineFactory.defaultStorageEngine();
        DatabaseLayout defaultDatabaseLayout = neo4jLayout.databaseLayout(globalConfig.get(default_database));
        if (storageEngineFactory.storageExists(fileSystem, defaultDatabaseLayout, pageCache)) {
            return;
        }
        final String legacyDatabaseName = "graph.db";
        DatabaseLayout legacyDatabaseLayout = neo4jLayout.databaseLayout(legacyDatabaseName);
        if (storageEngineFactory.storageExists(fileSystem, legacyDatabaseLayout, pageCache)) {
            Log internalLog = logService.getInternalLog(getClass());
            globalConfig.set(default_database, legacyDatabaseName);
            internalLog.warn("Legacy `%s` database was found and default database was set to point to into it. Please consider setting default database explicitly.", legacyDatabaseName);
        }
    }
}
Also used : Log(org.neo4j.logging.Log) StorageEngineFactory(org.neo4j.storageengine.api.StorageEngineFactory) DatabaseLayout(org.neo4j.io.layout.DatabaseLayout)

Example 7 with StorageEngineFactory

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

the class KernelDiagnosticsTest method shouldPrintDiskUsage.

@Test
void shouldPrintDiskUsage() throws IOException {
    DatabaseLayout layout = DatabaseLayout.ofFlat(testDirectory.homePath());
    StorageEngineFactory storageEngineFactory = mock(StorageEngineFactory.class);
    when(storageEngineFactory.listStorageFiles(any(), any())).thenReturn(Collections.emptyList());
    AssertableLogProvider logProvider = new AssertableLogProvider();
    StoreFilesDiagnostics storeFiles = new StoreFilesDiagnostics(storageEngineFactory, fs, layout);
    storeFiles.dump(logProvider.getLog(getClass())::debug);
    assertThat(logProvider).containsMessages("Disk space on partition");
}
Also used : StorageEngineFactory(org.neo4j.storageengine.api.StorageEngineFactory) DatabaseLayout(org.neo4j.io.layout.DatabaseLayout) AssertableLogProvider(org.neo4j.logging.AssertableLogProvider) Test(org.junit.jupiter.api.Test)

Example 8 with StorageEngineFactory

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

the class RecoveryCorruptedTransactionLogIT method startStopDatabaseAndGetTxOffset.

private long startStopDatabaseAndGetTxOffset() {
    DatabaseManagementService managementService = databaseFactory.build();
    final GraphDatabaseAPI database = (GraphDatabaseAPI) managementService.database(DEFAULT_DATABASE_NAME);
    storageEngineFactory = database.getDependencyResolver().resolveDependency(StorageEngineFactory.class);
    long offset = getLastClosedTransactionOffset(database);
    managementService.shutdown();
    return offset;
}
Also used : GraphDatabaseAPI(org.neo4j.kernel.internal.GraphDatabaseAPI) StorageEngineFactory(org.neo4j.storageengine.api.StorageEngineFactory) DatabaseManagementService(org.neo4j.dbms.api.DatabaseManagementService)

Example 9 with StorageEngineFactory

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

the class MemoryRecommendationsCommand method sumStoreFiles.

private long sumStoreFiles(DatabaseLayout databaseLayout) {
    StorageEngineFactory storageEngineFactory = StorageEngineFactory.defaultStorageEngine();
    FileSystemAbstraction fileSystem = ctx.fs();
    try {
        long total = 0L;
        for (Path path : storageEngineFactory.listStorageFiles(fileSystem, databaseLayout)) {
            total += fileSystem.getFileSize(path);
        }
        // Include label index
        total += sizeOfFileIfExists(databaseLayout.labelScanStore());
        return total;
    } catch (IOException e) {
        return 0;
    }
}
Also used : Path(java.nio.file.Path) FileSystemAbstraction(org.neo4j.io.fs.FileSystemAbstraction) StorageEngineFactory(org.neo4j.storageengine.api.StorageEngineFactory) IOException(java.io.IOException)

Example 10 with StorageEngineFactory

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

the class StoreVersionLoader method loadStoreVersion.

/**
 * Reads store version from the store files
 * @param layout The la
 * @return the {@link Result} of the store version if the format can not be read.
 */
public Result loadStoreVersion(DatabaseLayout layout) {
    StorageEngineFactory sef = StorageEngineFactory.selectStorageEngine(fs, layout, pageCache).orElseGet(StorageEngineFactory::defaultStorageEngine);
    StoreVersionCheck versionCheck = sef.versionCheck(fs, layout, config, pageCache, NullLogService.getInstance(), PageCacheTracer.NULL);
    String storeVersion = versionCheck.storeVersion(CursorContext.NULL).orElseThrow(() -> new IllegalStateException("Can not read store version of database " + layout.getDatabaseName()));
    return new Result(storeVersion, versionCheck.versionInformation(storeVersion).latest().storeVersion());
}
Also used : StoreVersionCheck(org.neo4j.storageengine.api.StoreVersionCheck) StorageEngineFactory(org.neo4j.storageengine.api.StorageEngineFactory)

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