szetszwo commented on code in PR #11878:
URL: https://github.com/apache/ozone/pull/11878#discussion_r4459589213
##########
hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/client/ReplicationConfigValidator.java:
##########
@@ -43,6 +50,23 @@ public class ReplicationConfigValidator {
private Pattern compiledValidationPattern;
+ /**
+ * Returns a validator for the pattern configured in {@code conf}. {@code
conf.getObject(...)} creates a validator
+ * by reflection and compiles its pattern on every call; this reuses the one
built for the same pattern, and still
+ * reads the pattern from {@code conf} each time, so a changed configuration
takes effect at once.
+ * The returned validator is shared, so it is not exposed outside this
package.
+ */
+ static ReplicationConfigValidator get(ConfigurationSource conf) {
+ final String pattern = conf.get(ALLOWED_CONFIGS_KEY,
ALLOWED_CONFIGS_DEFAULT);
+ ReplicationConfigValidator validator = cached;
+ if (validator == null || !Objects.equals(validator.validationPattern,
pattern)) {
+ validator = new ReplicationConfigValidator();
+ validator.setValidationPattern(pattern);
Review Comment:
Why it needs to creates a new object? Could we make
ReplicationConfigValidator thread-safe and call setValidationPattern Just using
the old object?
--
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]