@Test public void createDatabase_asV5Database() throws Exception { final DatabaseFactory dbFactory = new VersionedDatabaseFactory( new StubMetricsSystem(), dataDir.toString(), DATA_STORAGE_MODE, "5", 1L, eth1Address); try (final Database db = dbFactory.createDatabase()) { assertThat(db).isNotNull(); assertDbVersionSaved(dataDir, DatabaseVersion.V5); } final File dbDirectory = new File(dataDir.toFile(), VersionedDatabaseFactory.DB_PATH); final File archiveDirectory = new File(dataDir.toFile(), VersionedDatabaseFactory.ARCHIVE_PATH); final File metadataFile = new File(dataDir.toFile(), VersionedDatabaseFactory.METADATA_FILENAME); assertThat(dbDirectory).exists(); assertThat(archiveDirectory).exists(); assertThat(metadataFile).exists(); }
@Override public Database createDatabase() { LOG.info("Data directory set to: {}", dataDirectory.getAbsolutePath()); validateDataPaths(); final DatabaseVersion dbVersion = getDatabaseVersion(); createDirectories(); saveDatabaseVersion(dbVersion); Database database; switch (dbVersion) { case NOOP: database = new NoOpDatabase(); LOG.trace("Created no-op database"); break; case V3: database = createV3Database(); LOG.trace( "Created V3 database ({}) at {}", dbVersion.getValue(), dbDirectory.getAbsolutePath()); break; case V4: database = createV4Database(); LOG.trace( "Created V4 Hot database ({}) at {}", dbVersion.getValue(), dbDirectory.getAbsolutePath()); LOG.trace( "Created V4 Finalized database ({}) at {}", dbVersion.getValue(), archiveDirectory.getAbsolutePath()); break; case V5: database = createV5Database(); LOG.trace( "Created V5 Hot database ({}) at {}", dbVersion.getValue(), dbDirectory.getAbsolutePath()); LOG.trace( "Created V5 Finalized database ({}) at {}", dbVersion.getValue(), archiveDirectory.getAbsolutePath()); break; default: throw new UnsupportedOperationException("Unhandled database version " + dbVersion); } return database; }
VersionedDatabaseFactory implements DatabaseFactory { @Override public Database createDatabase() { LOG.info("Data directory set to: {}", dataDirectory.getAbsolutePath()); validateDataPaths(); final DatabaseVersion dbVersion = getDatabaseVersion(); createDirectories(); saveDatabaseVersion(dbVersion); Database database; switch (dbVersion) { case NOOP: database = new NoOpDatabase(); LOG.trace("Created no-op database"); break; case V3: database = createV3Database(); LOG.trace( "Created V3 database ({}) at {}", dbVersion.getValue(), dbDirectory.getAbsolutePath()); break; case V4: database = createV4Database(); LOG.trace( "Created V4 Hot database ({}) at {}", dbVersion.getValue(), dbDirectory.getAbsolutePath()); LOG.trace( "Created V4 Finalized database ({}) at {}", dbVersion.getValue(), archiveDirectory.getAbsolutePath()); break; case V5: database = createV5Database(); LOG.trace( "Created V5 Hot database ({}) at {}", dbVersion.getValue(), dbDirectory.getAbsolutePath()); LOG.trace( "Created V5 Finalized database ({}) at {}", dbVersion.getValue(), archiveDirectory.getAbsolutePath()); break; default: throw new UnsupportedOperationException("Unhandled database version " + dbVersion); } return database; } }
VersionedDatabaseFactory implements DatabaseFactory { @Override public Database createDatabase() { LOG.info("Data directory set to: {}", dataDirectory.getAbsolutePath()); validateDataPaths(); final DatabaseVersion dbVersion = getDatabaseVersion(); createDirectories(); saveDatabaseVersion(dbVersion); Database database; switch (dbVersion) { case NOOP: database = new NoOpDatabase(); LOG.trace("Created no-op database"); break; case V3: database = createV3Database(); LOG.trace( "Created V3 database ({}) at {}", dbVersion.getValue(), dbDirectory.getAbsolutePath()); break; case V4: database = createV4Database(); LOG.trace( "Created V4 Hot database ({}) at {}", dbVersion.getValue(), dbDirectory.getAbsolutePath()); LOG.trace( "Created V4 Finalized database ({}) at {}", dbVersion.getValue(), archiveDirectory.getAbsolutePath()); break; case V5: database = createV5Database(); LOG.trace( "Created V5 Hot database ({}) at {}", dbVersion.getValue(), dbDirectory.getAbsolutePath()); LOG.trace( "Created V5 Finalized database ({}) at {}", dbVersion.getValue(), archiveDirectory.getAbsolutePath()); break; default: throw new UnsupportedOperationException("Unhandled database version " + dbVersion); } return database; } VersionedDatabaseFactory(
      final MetricsSystem metricsSystem,
      final String dataPath,
      final StateStorageMode dataStorageMode,
      final Eth1Address depositContractAddress);  VersionedDatabaseFactory(
      final MetricsSystem metricsSystem,
      final String dataPath,
      final StateStorageMode dataStorageMode,
      final String createDatabaseVersion,
      final long stateStorageFrequency,
      final Eth1Address eth1Address); }
VersionedDatabaseFactory implements DatabaseFactory { @Override public Database createDatabase() { LOG.info("Data directory set to: {}", dataDirectory.getAbsolutePath()); validateDataPaths(); final DatabaseVersion dbVersion = getDatabaseVersion(); createDirectories(); saveDatabaseVersion(dbVersion); Database database; switch (dbVersion) { case NOOP: database = new NoOpDatabase(); LOG.trace("Created no-op database"); break; case V3: database = createV3Database(); LOG.trace( "Created V3 database ({}) at {}", dbVersion.getValue(), dbDirectory.getAbsolutePath()); break; case V4: database = createV4Database(); LOG.trace( "Created V4 Hot database ({}) at {}", dbVersion.getValue(), dbDirectory.getAbsolutePath()); LOG.trace( "Created V4 Finalized database ({}) at {}", dbVersion.getValue(), archiveDirectory.getAbsolutePath()); break; case V5: database = createV5Database(); LOG.trace( "Created V5 Hot database ({}) at {}", dbVersion.getValue(), dbDirectory.getAbsolutePath()); LOG.trace( "Created V5 Finalized database ({}) at {}", dbVersion.getValue(), archiveDirectory.getAbsolutePath()); break; default: throw new UnsupportedOperationException("Unhandled database version " + dbVersion); } return database; } VersionedDatabaseFactory(
      final MetricsSystem metricsSystem,
      final String dataPath,
      final StateStorageMode dataStorageMode,
      final Eth1Address depositContractAddress);  VersionedDatabaseFactory(
      final MetricsSystem metricsSystem,
      final String dataPath,
      final StateStorageMode dataStorageMode,
      final String createDatabaseVersion,
      final long stateStorageFrequency,
      final Eth1Address eth1Address); @Override Database createDatabase(); }
VersionedDatabaseFactory implements DatabaseFactory { @Override public Database createDatabase() { LOG.info("Data directory set to: {}", dataDirectory.getAbsolutePath()); validateDataPaths(); final DatabaseVersion dbVersion = getDatabaseVersion(); createDirectories(); saveDatabaseVersion(dbVersion); Database database; switch (dbVersion) { case NOOP: database = new NoOpDatabase(); LOG.trace("Created no-op database"); break; case V3: database = createV3Database(); LOG.trace( "Created V3 database ({}) at {}", dbVersion.getValue(), dbDirectory.getAbsolutePath()); break; case V4: database = createV4Database(); LOG.trace( "Created V4 Hot database ({}) at {}", dbVersion.getValue(), dbDirectory.getAbsolutePath()); LOG.trace( "Created V4 Finalized database ({}) at {}", dbVersion.getValue(), archiveDirectory.getAbsolutePath()); break; case V5: database = createV5Database(); LOG.trace( "Created V5 Hot database ({}) at {}", dbVersion.getValue(), dbDirectory.getAbsolutePath()); LOG.trace( "Created V5 Finalized database ({}) at {}", dbVersion.getValue(), archiveDirectory.getAbsolutePath()); break; default: throw new UnsupportedOperationException("Unhandled database version " + dbVersion); } return database; } VersionedDatabaseFactory(
      final MetricsSystem metricsSystem,
      final String dataPath,
      final StateStorageMode dataStorageMode,
      final Eth1Address depositContractAddress);  VersionedDatabaseFactory(
      final MetricsSystem metricsSystem,
      final String dataPath,
      final StateStorageMode dataStorageMode,
      final String createDatabaseVersion,
      final long stateStorageFrequency,
      final Eth1Address eth1Address); @Override Database createDatabase(); static final long DEFAULT_STORAGE_FREQUENCY; }