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);
}
}
}
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");
}
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;
}
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;
}
}
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());
}
Aggregations