rich7420 commented on code in PR #11650:
URL: https://github.com/apache/ozone/pull/11650#discussion_r4557795158
##########
hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/ReconSqlDbConfig.java:
##########
@@ -30,17 +30,23 @@
@ConfigGroup(prefix = "ozone.recon.sql.db")
public class ReconSqlDbConfig {
+ public static final String DEFAULT_DRIVER_CLASS = "org.sqlite.JDBC";
+ public static final String DEFAULT_JDBC_URL =
"jdbc:sqlite:${ozone.recon.db.dir}/ozone_recon_sqlite.db";
+ public static final String DEFAULT_SQL_DB_DIALECT = "SQLITE";
Review Comment:
nit: now that the fallback only resets the URL, `DEFAULT_DRIVER_CLASS` and
`DEFAULT_SQL_DB_DIALECT` are only used by the `@Config` defaults (plus one test
assert). Maybe just inline them like before, so those lines stay a plain value
change?
##########
hadoop-ozone/recon/src/test/java/org/apache/hadoop/ozone/recon/TestReconUtils.java:
##########
@@ -94,6 +94,21 @@ public void testSqlDbJdbcUrlResolvesReconDbDirPlaceholder() {
assertEquals("SQLITE", dataSourceConfiguration.getSqlDialect());
}
+ @Test
+ public void testSqlDbDerbyConfigFallsBackToSqlite() {
+ OzoneConfiguration configuration = new OzoneConfiguration();
+ configuration.set(OZONE_METADATA_DIRS, temporaryFolder.toString());
+ configuration.set("ozone.recon.sql.db.driver",
"org.apache.derby.jdbc.EmbeddedDriver");
+ configuration.set("ozone.recon.sql.db.jdbc.url",
"jdbc:derby:/old/ozone_recon_derby.db");
+ configuration.set("ozone.recon.sql.db.jooq.dialect", "DERBY");
+
+ DataSourceConfiguration dataSourceConfiguration =
+ new
ReconControllerModule(null).getDataSourceConfiguration(configuration);
+
+ assertEquals("jdbc:sqlite:" + temporaryFolder + "/ozone_recon_sqlite.db",
dataSourceConfiguration.getJdbcUrl());
+ assertEquals(ReconSqlDbConfig.DEFAULT_SQL_DB_DIALECT,
dataSourceConfiguration.getSqlDialect());
Review Comment:
nit: could just be `"SQLITE"` like the test above. Also, the comment at L93
still says the default is DERBY. It's SQLITE now, so that test doesn't really
hit the override anymore (this new one does), and the comment can go.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]