Tejaskriya commented on code in PR #7652:
URL: https://github.com/apache/ozone/pull/7652#discussion_r1906555829
##########
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/DBDefinitionFactory.java:
##########
@@ -98,6 +99,36 @@ public static DBDefinition getDefinition(Path dbPath,
return getDefinition(dbName);
}
+ public static DBDefinition getDefinition(Path dbPath, ConfigurationSource
config, String overrideDBDef) {
+ if (overrideDBDef == null) {
+ return getDefinition(dbPath, config);
+ }
+ try {
+ Class<?> clazz = Class.forName(overrideDBDef);
+ if (DBDefinition.class.isAssignableFrom(clazz)) {
+ DBDefinition instance;
+ try {
+ Constructor<?> noParamConstructor = clazz.getDeclaredConstructor();
+ noParamConstructor.setAccessible(true);
+ instance = (DBDefinition) noParamConstructor.newInstance();
+ } catch (NoSuchMethodException e) {
+ Constructor<?> stringParamConstructor =
clazz.getDeclaredConstructor(String.class);
+ stringParamConstructor.setAccessible(true);
+ instance = (DBDefinition)
stringParamConstructor.newInstance(dbPath.toAbsolutePath().toString());
+ }
+ return instance;
Review Comment:
Thanks for the suggestion, this seems to be a better approach! I have
implemented the same and updated the test.
--
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]