hanishakoneru commented on a change in pull request #2491:
URL: https://github.com/apache/ozone/pull/2491#discussion_r719212939



##########
File path: 
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OzoneManager.java
##########
@@ -1373,6 +1411,64 @@ public void restart() throws IOException {
     omState = State.RUNNING;
   }
 
+  private void checkConfigBeforeBootstrap() throws IOException {
+    List<OMNodeDetails> omsWihtoutNewConfig = new ArrayList<>();
+    for (Map.Entry<String, OMNodeDetails> entry : peerNodesMap.entrySet()) {
+      String remoteNodeId = entry.getKey();
+      OMNodeDetails remoteNodeDetails = entry.getValue();
+      try (OMMetadataProtocolClientSideImpl omMetadataProtocolClient =
+               new OMMetadataProtocolClientSideImpl(configuration,
+                   getRemoteUser(), remoteNodeId,
+                   remoteNodeDetails.getRpcAddress())) {
+
+        OMMetadata remoteOMMetadata = omMetadataProtocolClient.getOMMetadata();
+        boolean exists = checkOMexistsInRemoteOMConfig(remoteOMMetadata);
+        if (!exists) {
+          LOG.error("Remote OM " + remoteNodeId + ":" +
+              remoteNodeDetails.getHostAddress() + " does not have the " +
+              "bootstrapping OM(" + getOMNodeId() + ") information on " +
+              "reloading configs.");
+          omsWihtoutNewConfig.add(remoteNodeDetails);
+        }
+      } catch (IOException ioe) {
+        LOG.error("Remote OM config check before bootstrap failed on OM {}",
+            remoteNodeId, ioe);
+        omsWihtoutNewConfig.add(remoteNodeDetails);
+      }
+    }
+    if (!omsWihtoutNewConfig.isEmpty()) {
+      StringBuilder errorMsgBuilder = new StringBuilder();
+      errorMsgBuilder.append("OM(s) [")
+          .append(omsWihtoutNewConfig.get(0).getOMPrintInfo());
+      for (int i = 1; i < omsWihtoutNewConfig.size(); i++) {
+        errorMsgBuilder.append(",")
+            .append(omsWihtoutNewConfig.get(i).getOMPrintInfo());
+      }
+      errorMsgBuilder.append("] do not have the bootstrapping OM information." 
+
+          " Update their ozone-site.xml with new node details before " +
+          "proceeding.");
+      shutdown(errorMsgBuilder.toString());
+    }
+  }
+
+  /**
+   * Check whether current OM information exists in the remote OM's reloaded
+   * configs.
+   */
+  private boolean checkOMexistsInRemoteOMConfig(OMMetadata remoteOMMetadata) {
+    List<OMNodeDetails> omNodesInNewConf = remoteOMMetadata
+        .getOmNodesInNewConf();
+    for (OMNodeDetails omNodeInRemoteOM : omNodesInNewConf) {

Review comment:
       I tested on a cluster and verified that bootstrapping a node again would 
lead it to crash. And the exception comes from Ratis. Instead, we should keep 
this check here to avoid that.
   




-- 
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]

Reply via email to