hani-fouladgar commented on code in PR #11218:
URL: https://github.com/apache/ozone/pull/11218#discussion_r4074289144
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OzoneManager.java:
##########
@@ -6092,6 +6098,94 @@ public ListSnapshotDiffJobResponse listSnapshotDiffJobs(
}
}
+ /**
+ * Validate and publish a reconfigured SCM node list
+ * ({@code ozone.scm.nodes.<serviceId>}) and reload the block and container
SCM
+ * failover proxies so the OM can reach a newly added SCM without a restart.
+ *
+ * The reload reads the node list and the per-node address keys
+ * ({@code ozone.scm.address.<serviceId>.<nodeId>}) from the same live
+ * configuration. If the new list references an SCM whose address is not set
+ * yet, the reload fails: the previous node list is restored and the
exception
+ * is rethrown so the reconfiguration is reported FAILED and can be retried.
+ * This keeps the live configuration from holding an SCM node without a
+ * resolvable address (which would break {@code getServiceList()}). To add an
+ * SCM in a single {@code reconfig start}, set its address key together with
+ * the node list; the reconfiguration-complete callback
+ * ({@link #reloadScmProxiesOnReconfig}) applies the final membership once
both
+ * are stored.
+ *
+ * Scope: only the block and container proxies are reloaded. The secure-mode
+ * SCM security and secret-key proxy providers are not reloaded and continue
to
+ * use the node list captured at startup.
+ */
+ private String reconfScmNodes(String value) {
+ if (StringUtils.isBlank(value)) {
+ throw new IllegalArgumentException("Reconfiguration failed since setting
an empty SCM nodes "
+ + "configuration is not allowed");
+ }
+ // ReconfigurableBase stores the new value into the configuration only
after
+ // this callback returns, but reloadScmNodes() rebuilds the SCM proxies
from
+ // that same live configuration. Publish the new node list first so the
+ // reload sees the intended membership.
+ String scmNodesKey = ConfUtils.addKeySuffixes(OZONE_SCM_NODES_KEY,
+ HddsUtils.getScmServiceId(configuration));
+ String previous = configuration.get(scmNodesKey);
+ configuration.set(scmNodesKey, value);
+ try {
+ scmClient.reloadScmNodes();
+ LOG.info("Reloaded SCM proxy configuration for {} : {}", scmNodesKey,
value);
+ } catch (ConfigurationException e) {
+ // A referenced SCM address is not set, so the new membership cannot be
+ // resolved. Restore the previous node list so the live configuration
never
+ // keeps a node without an address, and rethrow so the reconfiguration is
+ // reported FAILED and can be retried once the address key is set.
+ if (previous == null) {
+ configuration.unset(scmNodesKey);
+ } else {
+ configuration.set(scmNodesKey, previous);
+ }
+ throw e;
+ }
+ return value;
+ }
+
+ /**
+ * Reconfiguration-complete callback that reloads the block and container SCM
+ * failover proxies once a batch that touched the SCM node list or any
per-node
+ * SCM address has been fully applied. Because it runs after every property
in
+ * the batch is stored, an address-only change takes effect (the per-property
+ * path only fires for the node list), and a node added with its address key
+ * listed before or after the node list is picked up in a single
reconfiguration.
+ */
+ @VisibleForTesting
+ public void reloadScmProxiesOnReconfig(Map<String, Boolean>
changedProperties,
+ Configuration newConf) {
+ String scmServiceId = HddsUtils.getScmServiceId(configuration);
+ if (scmServiceId == null || scmClient == null) {
+ return;
+ }
+ String scmNodesKey = ConfUtils.addKeySuffixes(OZONE_SCM_NODES_KEY,
scmServiceId);
+ String scmAddressPrefix =
+ ConfUtils.addKeySuffixes(OZONE_SCM_ADDRESS_KEY, scmServiceId) + ".";
+ boolean scmProxyKeyChanged = changedProperties.keySet().stream()
+ .anyMatch(key -> key.equals(scmNodesKey) ||
key.startsWith(scmAddressPrefix));
+ if (scmProxyKeyChanged) {
+ try {
+ scmClient.reloadScmNodes();
+ LOG.info("Reloaded SCM failover proxies after reconfiguration of {} /
{}*",
+ scmNodesKey, scmAddressPrefix);
+ } catch (ConfigurationException e) {
Review Comment:
Done!
--
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]