narendly commented on a change in pull request #362: The WAGED rebalancer 
cluster model implementation
URL: https://github.com/apache/helix/pull/362#discussion_r310162365
 
 

 ##########
 File path: 
helix-core/src/main/java/org/apache/helix/controller/rebalancer/waged/model/ClusterModel.java
 ##########
 @@ -19,9 +19,131 @@
  * under the License.
  */
 
+import org.apache.helix.HelixException;
+import org.apache.helix.model.IdealState;
+
+import java.util.Collections;
+import java.util.Map;
+import java.util.Set;
+import java.util.stream.Collectors;
+
 /**
- * A placeholder before we have the implementation.
- *
  * This class wraps the required input for the rebalance algorithm.
  */
-public class ClusterModel { }
+public class ClusterModel {
+  private final ClusterContext _clusterContext;
+  // Map to track all the assignable replications. <Resource Name, 
Set<Replicas>>
+  private final Map<String, Set<AssignableReplica>> _assignableReplicas;
+  // The index to find the replication information with a certain state. 
<Resource, <Replica Key (resource, partition, state), Replica>>
+  // Note that the identical replicas are dedupe in the index.
+  private final Map<String, Map<String, AssignableReplica>> 
_assignableReplicaIndex;
+  private final Map<String, AssignableNode> _assignableNodeMap;
+
+  // Records about the previous assignment
+  private final Map<String, IdealState> _baselineAssignment;
+  private final Map<String, IdealState> _bestPossibleAssignment;
+
+  /**
+   * @param clusterContext         The initialized cluster context.
+   * @param assignableReplicas     The replications to be assigned.
+   *                               Note that the replicas in this list shall 
not be included while initializing the context and assignable nodes.
+   * @param assignableNodes        The active instances.
+   * @param baselineAssignment     The recorded baseline assignment.
+   * @param bestPossibleAssignment The current best possible assignment.
+   */
+  ClusterModel(ClusterContext clusterContext, Set<AssignableReplica> 
assignableReplicas,
+      Set<AssignableNode> assignableNodes, Map<String, IdealState> 
baselineAssignment,
+      Map<String, IdealState> bestPossibleAssignment) {
+    _clusterContext = clusterContext;
+
+    // Save all the to be assigned replication
+    _assignableReplicas = assignableReplicas.stream()
 
 Review comment:
   Nit: just to avoid confusion, what do you think about renaming 
assignableReplicas to assignableReplicaMap? That's what you seem to be doing 
assignableNodeMap/assignableNodes.

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


With regards,
Apache Git Services

Reply via email to