GlenGeng commented on a change in pull request #2230:
URL: https://github.com/apache/ozone/pull/2230#discussion_r639542307



##########
File path: 
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/balancer/ContainerBalancer.java
##########
@@ -40,96 +44,347 @@
   private ContainerManagerV2 containerManager;
   private ReplicationManager replicationManager;
   private OzoneConfiguration ozoneConfiguration;
+  private final SCMContext scmContext;
   private double threshold;
   private int maxDatanodesToBalance;
   private long maxSizeToMove;
-  private boolean balancerRunning;
-  private List<DatanodeUsageInfo> sourceNodes;
-  private List<DatanodeUsageInfo> targetNodes;
+  private List<DatanodeUsageInfo> unBalancedNodes;
+  private List<DatanodeUsageInfo> overUtilizedNodes;
+  private List<DatanodeUsageInfo> underUtilizedNodes;
+  private List<DatanodeUsageInfo> withinThresholdUtilizedNodes;
   private ContainerBalancerConfiguration config;
+  private ContainerBalancerMetrics metrics;
+  private long clusterCapacity;
+  private long clusterUsed;
+  private long clusterRemaining;
+  private double clusterAvgUtilisation;
+  private final AtomicBoolean balancerRunning = new AtomicBoolean(false);
 
+  /**
+   * Constructs ContainerBalancer with the specified arguments. Initializes
+   * new ContainerBalancerConfiguration and ContainerBalancerMetrics.
+   * Container Balancer does not start on construction.
+   *
+   * @param nodeManager NodeManager
+   * @param containerManager ContainerManager
+   * @param replicationManager ReplicationManager
+   * @param ozoneConfiguration OzoneConfiguration
+   */
   public ContainerBalancer(
       NodeManager nodeManager,
       ContainerManagerV2 containerManager,
       ReplicationManager replicationManager,
-      OzoneConfiguration ozoneConfiguration) {
+      OzoneConfiguration ozoneConfiguration,
+      final SCMContext scmContext) {
     this.nodeManager = nodeManager;
     this.containerManager = containerManager;
     this.replicationManager = replicationManager;
     this.ozoneConfiguration = ozoneConfiguration;
-    this.balancerRunning = false;
     this.config = new ContainerBalancerConfiguration();
+    this.metrics = new ContainerBalancerMetrics();
+    this.scmContext = scmContext;
+
+    this.clusterCapacity = 0L;
+    this.clusterUsed = 0L;
+    this.clusterRemaining = 0L;
+
+    this.overUtilizedNodes = new ArrayList<>();
+    this.underUtilizedNodes = new ArrayList<>();
+    this.unBalancedNodes = new ArrayList<>();
+    this.withinThresholdUtilizedNodes = new ArrayList<>();
   }
 
   /**
-   * Start ContainerBalancer. Current implementation is incomplete.
+   * Starts ContainerBalancer. Current implementation is incomplete.
    *
    * @param balancerConfiguration Configuration values.
    */
-  public void start(ContainerBalancerConfiguration balancerConfiguration) {
-    this.balancerRunning = true;
+  public boolean start(ContainerBalancerConfiguration balancerConfiguration) {

Review comment:
       According to our design decision, params will be based from command 
line, which will be implemented by https://github.com/apache/ozone/pull/2278, 
thereby the conf related code will be removed in future.




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