avijayanhwx commented on a change in pull request #1611:
URL: https://github.com/apache/ozone/pull/1611#discussion_r529944182



##########
File path: 
hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/scm/exceptions/SCMException.java
##########
@@ -124,6 +124,7 @@ public ResultCodes getResult() {
     FAILED_TO_ALLOCATE_ENOUGH_BLOCKS,
     INTERNAL_ERROR,
     FAILED_TO_INIT_PIPELINE_CHOOSE_POLICY,
-    FAILED_TO_INIT_LEADER_CHOOSE_POLICY
+    FAILED_TO_INIT_LEADER_CHOOSE_POLICY,
+    FAILED_TO_FINALIZE_UPGRADE

Review comment:
       I don't see any usages for this.

##########
File path: 
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/pipeline/SCMPipelineManager.java
##########
@@ -268,6 +275,12 @@ public Pipeline createPipeline(ReplicationType type,
     }
     lock.writeLock().lock();
     try {
+      if (freezePipelineCreation.get()) {
+        LOG.debug("Pipeline creation is frozen while an upgrade is in " +

Review comment:
       Do we want to throw an exception here? The background pipeline creator 
will keep trying to create pipelines, and the logs may be filled with 
exceptions. Is there a way to do this more cleaner? Maybe something like
   
   _Stop pipeline creator --> Add flag in pipeline manager to stop 
createPipeline (for manual pipeline creation) -> Destroy existing pipelines_

##########
File path: 
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/server/StorageContainerManager.java
##########
@@ -1166,4 +1172,107 @@ public String getClusterId() {
   public HDDSLayoutVersionManager getLayoutVersionManager() {
     return scmLayoutVersionManager;
   }
+
+  private void waitForAllContainersToClose() {

Review comment:
       This may become a costly operation during finalize. If we have destroyed 
all pipelines, the containers are automatically closed. So, we maybe able to 
skip this.

##########
File path: 
hadoop-hdds/common/src/main/java/org/apache/hadoop/ozone/upgrade/BasicUpgradeFinalizer.java
##########
@@ -0,0 +1,271 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.ozone.upgrade;
+
+import static 
org.apache.hadoop.ozone.upgrade.UpgradeException.ResultCodes.INVALID_REQUEST;
+import static 
org.apache.hadoop.ozone.upgrade.UpgradeException.ResultCodes.LAYOUT_FEATURE_FINALIZATION_FAILED;
+import static 
org.apache.hadoop.ozone.upgrade.UpgradeException.ResultCodes.PERSIST_UPGRADE_TO_LAYOUT_VERSION_FAILED;
+import static 
org.apache.hadoop.ozone.upgrade.UpgradeException.ResultCodes.REMOVE_UPGRADE_TO_LAYOUT_VERSION_FAILED;
+import static 
org.apache.hadoop.ozone.upgrade.UpgradeException.ResultCodes.UPDATE_LAYOUT_VERSION_FAILED;
+import static 
org.apache.hadoop.ozone.upgrade.UpgradeFinalizer.Status.FINALIZATION_DONE;
+import static 
org.apache.hadoop.ozone.upgrade.UpgradeFinalizer.Status.FINALIZATION_IN_PROGRESS;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Optional;
+import java.util.Queue;
+import java.util.concurrent.ConcurrentLinkedQueue;
+
+import org.apache.hadoop.ozone.common.Storage;
+import org.apache.hadoop.ozone.upgrade.LayoutFeature.UpgradeAction;
+import org.apache.hadoop.ozone.upgrade.UpgradeException.ResultCodes;
+
+/**
+ * UpgradeFinalizer implementation for the Storage Container Manager service.
+ */
+@SuppressWarnings("checkstyle:VisibilityModifier")
+public class BasicUpgradeFinalizer<T, V extends AbstractLayoutVersionManager>
+    implements UpgradeFinalizer<T> {
+
+  protected V versionManager;
+  protected String clientID;
+  protected T component;
+
+  private Queue<String> msgs = new ConcurrentLinkedQueue<>();
+  protected boolean isDone = false;
+
+  public BasicUpgradeFinalizer(V versionManager) {
+    this.versionManager = versionManager;
+  }
+
+  /*
+   * This method must be overriden by the component implementing the
+   * finalization logic.
+   */
+  public StatusAndMessages finalize(String upgradeClientID, T id)

Review comment:
       What happens it this is invoked while the SCM (or OM) is being 
finalized? If it restarts, we may be OK with losing state, but how about the 
case when SCM is running & currently finalizing, and that time someone invokes 
finalize again?




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

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