diff --git a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/balancer/ContainerBalancer.java b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/balancer/ContainerBalancer.java index 3dddd67bd8a..9809ee0df4d 100644 --- a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/balancer/ContainerBalancer.java +++ b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/balancer/ContainerBalancer.java @@ -183,17 +183,19 @@ public ContainerBalancerTask.Status getBalancerStatus() { * @return balancer status info if balancer started */ public ContainerBalancerStatusInfo getBalancerStatusInfo() throws IOException { - if (isBalancerRunning()) { - ContainerBalancerConfigurationProto configProto = readConfiguration(ContainerBalancerConfigurationProto.class); - return new ContainerBalancerStatusInfo( - this.startedAt, - configProto, - task.getCurrentIterationsStatistic() - ); - } else { + lock.lock(); + try { + if (isBalancerRunning()) { + return new ContainerBalancerStatusInfo( + this.startedAt, + config.toProtobufBuilder().build(), + task.getCurrentIterationsStatistic() + ); + } return null; + } finally { + lock.unlock(); } - } /** * Checks if ContainerBalancer is in valid state to call stop.