alievmirza commented on code in PR #2070:
URL: https://github.com/apache/ignite-3/pull/2070#discussion_r1214224098


##########
modules/distribution-zones/src/main/java/org/apache/ignite/internal/distributionzones/rebalance/DistributionZoneRebalanceEngine.java:
##########
@@ -271,9 +279,11 @@ private CompletableFuture<?> 
onUpdateReplicas(ConfigurationNotificationEvent<Int
 
                     int newReplicas = replicasCtx.newValue();
 
-                    byte[] assignmentsBytes = ((ExtendedTableConfiguration) 
tblCfg).assignments().value();
+                    int tableId = tblCfg.id().value();
 
-                    List<Set<Assignment>> tableAssignments = 
ByteUtils.fromBytes(assignmentsBytes);
+                    CompletableFuture<List<Set<Assignment>>> 
tableAssignmentsFut = tableAssignments(

Review Comment:
   I would use formatting like this
   
   ```
                       CompletableFuture<List<Set<Assignment>>> 
tableAssignmentsFut = tableAssignments(
                               metaStorageManager,
                               tableId, 
                               partCnt
                       );
   ```



##########
modules/distribution-zones/src/main/java/org/apache/ignite/internal/distributionzones/rebalance/RebalanceUtil.java:
##########
@@ -376,4 +381,51 @@ public static <T> Set<T> union(Set<T> op1, Set<T> op2) {
     public static <T> Set<T> intersect(Set<T> op1, Set<T> op2) {
         return op1.stream().filter(op2::contains).collect(Collectors.toSet());
     }
+
+    /**
+     * Returns partition assignments from meta storage.
+     *
+     * @param metaStorageManager Meta storage manager.
+     * @param tableId Table id.
+     * @param partitionNumber Partition number.
+     * @return Future with partition assignments as a value.
+     */
+    public static CompletableFuture<Set<Assignment>> partitionAssignments(
+            MetaStorageManager metaStorageManager, int tableId, int 
partitionNumber) {
+        return metaStorageManager
+                .get(stablePartAssignmentsKey(new TablePartitionId(tableId, 
partitionNumber)))
+                .thenApply(e -> (e.value() == null) ? null : 
ByteUtils.fromBytes(e.value()));
+    }
+
+    /**
+     * Returns table assignments for all table partitions from meta storage.
+     *
+     * @param metaStorageManager Meta storage manager.
+     * @param tableId Table id.
+     * @param numberOfPartitions Number of partitions.
+     * @return Future with table assignments as a value.
+     */
+    public static CompletableFuture<List<Set<Assignment>>> tableAssignments(

Review Comment:
   Let's use formatting like this 
   ```
       public static CompletableFuture<List<Set<Assignment>>> tableAssignments(
               MetaStorageManager metaStorageManager, 
               int tableId, 
               int numberOfPartitions
       ) {
   ```
   
   Also, do we really need this method to be public?



##########
modules/distribution-zones/src/main/java/org/apache/ignite/internal/distributionzones/rebalance/DistributionZoneRebalanceEngine.java:
##########
@@ -187,39 +187,47 @@ public CompletableFuture<Void> onUpdate(WatchEvent evt) {
                         if (zoneId == tableZoneId) {
                             TableConfiguration tableCfg = 
tables.get(tableView.name());
 
-                            byte[] assignmentsBytes = 
((ExtendedTableConfiguration) tableCfg).assignments().value();
+                            int tableId = tableCfg.id().value();
 
-                            List<Set<Assignment>> tableAssignments = 
assignmentsBytes == null
-                                    ? Collections.emptyList()
-                                    : ByteUtils.fromBytes(assignmentsBytes);
+                            CompletableFuture<List<Set<Assignment>>> 
tableAssignmentsFut = tableAssignments(

Review Comment:
   I would use formatting like this 
   
   ```
                               CompletableFuture<List<Set<Assignment>>> 
tableAssignmentsFut = tableAssignments(
                                       metaStorageManager,
                                       tableId, 
                                       
distributionZoneConfiguration.partitions().value()
                               );
   ```



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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to