prashantpogde commented on a change in pull request #1611:
URL: https://github.com/apache/ozone/pull/1611#discussion_r530107012
##########
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() {
+ boolean containersFound = true;
+ while (containersFound) {
+ containersFound = false;
+ for (DatanodeDetails datanodeDetails : scmNodeManager.getAllNodes()) {
+ try {
+ for (ContainerID id : scmNodeManager.getContainers(datanodeDetails))
{
+ try {
+ final ContainerInfo container =
containerManager.getContainer(id);
+ if (container.getState() == HddsProtos.LifeCycleState.OPEN ||
+ container.getState() == HddsProtos.LifeCycleState.CLOSING) {
+ containersFound = true;
+ if (container.getState() == HddsProtos.LifeCycleState.OPEN) {
+ eventQueue.fireEvent(SCMEvents.CLOSE_CONTAINER, id);
+ }
+ }
+ } catch (ContainerNotFoundException cnfe) {
+ LOG.warn("Container {} is not managed by ContainerManager.",
+ id, cnfe);
+ continue;
+ }
+ }
+ } catch (NodeNotFoundException e) {
+ continue;
+ }
+ }
+ try {
+ if (containersFound) {
+ LOG.info("Waiting for all containers to close.");
+ Thread.sleep(5000);
+ }
+ } catch (InterruptedException e) {
+ continue;
+ }
+ }
+ }
+
+ private void waitForAllPipelinesToDestroy() throws IOException {
+ boolean pipelineFound = true;
+ while (pipelineFound) {
+ pipelineFound = false;
+ for (Pipeline pipeline : pipelineManager.getPipelines()) {
+ if (pipeline.getPipelineState() != CLOSED) {
+ pipelineFound = true;
+ pipelineManager.finalizeAndDestroyPipeline(pipeline, false);
+ }
+ }
+ try {
+ if (pipelineFound) {
+ LOG.info("Waiting for all pipelines to close.");
+ Thread.sleep(5000);
+ }
+ } catch (InterruptedException e) {
+ continue;
+ }
+ }
+ }
+
+ // This should be called in the context of a separate finalize upgrade
thread.
+ // This function can block indefinitely till the conditions are met to safely
+ // finalize Upgrade.
+
+ public void preFinalizeUpgrade() throws IOException {
+ /**
+ * Ask pipeline manager to not create any new pipelines. Pipeline
+ * creation will remain frozen until postFinalizeUpgrade().
+ */
+ pipelineManager.freezePipelineCreation();
+
Review comment:
That is another route but we will need stop SCM from coming out of safe
mode until upgrade is complete. Also safe mode is good to enter when the SCM is
starts. Here the SCM was already running and I just needed a way to pause
pipeline creation for an upgrade window.
----------------------------------------------------------------
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]