adoroszlai commented on code in PR #4798:
URL: https://github.com/apache/ozone/pull/4798#discussion_r1271809994
##########
hadoop-hdds/config/src/main/java/org/apache/hadoop/hdds/conf/ConfigurationSource.java:
##########
@@ -183,6 +183,20 @@ default <T> T getObject(Class<T> configurationClass) {
}
+ /**
+ * Returns a singleton instance of the given configuration class.
+ * If an instance of the class has already been created,
+ * it will be returned; otherwise, a new instance will be created,
+ * stored in a map for future retrieval.
+ *
+ * @param configurationClass The class for which a singleton
+ * instance is required
+ * @return a singleton instance of the given class
+ */
+ default <T> T getSingletonObject(Class<T> configurationClass) {
+ return getObject(configurationClass);
+ }
+
Review Comment:
Thanks @xichen01 for making the change. On second thought, instead of
adding a new method `getSingletonObject`, we should override `getObject` from
`ConfigurationSource` with the singleton-based implementation. This way we can
keep passing `ConfigurationSource`.
In the long run, we should move towards passing the type-safe config objects
(`DatanodeConfiguration`, `ScmConfig`, etc.)
--
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]