henrybear327 commented on code in PR #10934:
URL: https://github.com/apache/ozone/pull/10934#discussion_r3897560556
##########
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/local/LocalOzoneCluster.java:
##########
@@ -381,6 +390,141 @@ private void configureLocalDefaults(OzoneConfiguration
conf) {
conf.setFromObject(scmClientConfig);
}
+ /**
+ * Applies a value the local runtime requires, rejecting a conflicting one
the user configured.
+ * These keys are set rather than {@code setIfUnset} because
ozone-default.xml would otherwise
+ * win; a user value is refused rather than replaced, so the cluster never
behaves differently
+ * from the configuration the user is reading. Rejecting here, at the point
of the override,
+ * keeps a later override from being added without the same check.
+ *
+ * <p>This overload compares text, for keys whose value carries no other
spelling. The typed
+ * overloads below compare through the accessor the services read the key
with, so a value that
+ * already means what the runtime requires is kept rather than rejected.</p>
+ *
+ * @throws IOException if the user configured {@code key} with a value other
than {@code value}
+ */
+ private void setLocalOverride(OzoneConfiguration conf, String key, String
value)
+ throws IOException {
+ // Configuration#unset() leaves the key in updatingResource, so a source
can outlive its
+ // value; there is nothing to reject when no value is configured.
+ if (conf.get(key) != null && !value.equals(conf.get(key))) {
+ rejectUserConfigured(conf, key, value);
+ }
+ conf.set(key, value);
+ }
+
+ private void setLocalOverride(OzoneConfiguration conf, String key, boolean
value)
+ throws IOException {
+ // Defaulting to the negation keeps a value getBoolean() cannot read from
matching by accident.
+ if (conf.get(key) != null && conf.getBoolean(key, !value) != value) {
+ rejectUserConfigured(conf, key, String.valueOf(value));
+ }
+ conf.setBoolean(key, value);
+ }
+
+ private void setLocalOverride(OzoneConfiguration conf, String key, int value)
+ throws IOException {
+ if (conf.get(key) != null && !matchesInt(conf, key, value)) {
+ rejectUserConfigured(conf, key, String.valueOf(value));
+ }
+ conf.setInt(key, value);
+ }
+
+ /**
+ * Applies a duration the local runtime requires. The configured value is
compared as a duration
+ * rather than as text, so the same length written in another unit is not
treated as a conflict.
+ *
+ * @throws IOException if the user configured {@code key} with a different
duration
+ */
+ private void setLocalOverrideDuration(OzoneConfiguration conf, String key,
String value)
+ throws IOException {
+ long requiredMillis = TimeDurationUtil.getTimeDurationHelper(key, value,
TimeUnit.MILLISECONDS);
+ if (conf.get(key) != null && !matchesDuration(conf, key, requiredMillis)) {
+ rejectUserConfigured(conf, key, value);
+ }
+ conf.set(key, value);
+ }
+
Review Comment:
After some thinking, I decided to reject time configuration input without
unit, so we can eliminate the problematic time handling parsing part of the
logic. WDYT?
--
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]