dlmarion commented on code in PR #4733:
URL: https://github.com/apache/accumulo/pull/4733#discussion_r1672086324


##########
server/manager/src/main/java/org/apache/accumulo/manager/Manager.java:
##########
@@ -960,39 +957,85 @@ private void 
checkForHeldServer(SortedMap<TServerInstance,TabletServerStatus> ts
       }
     }
 
-    private long balanceTablets() {
-
-      Map<DataLevel,Set<KeyExtent>> partitionedMigrations =
+    /**
+     * balanceTablets() balances tables by DataLevel. Return the current set 
of migrations
+     * partitioned by DataLevel
+     */
+    private Map<DataLevel,Set<KeyExtent>> partitionMigrations(final 
Set<KeyExtent> migrations) {
+      final Map<DataLevel,Set<KeyExtent>> partitionedMigrations =
           new HashMap<>(DataLevel.values().length);
-      migrationsSnapshot().forEach(ke -> {
-        partitionedMigrations.computeIfAbsent(DataLevel.of(ke.tableId()), f -> 
new HashSet<>())
-            .add(ke);
+      // populate to prevent NPE
+      for (DataLevel dl : DataLevel.values()) {
+        partitionedMigrations.put(dl, new HashSet<>());
+      }
+      migrations.forEach(ke -> {
+        partitionedMigrations.get(DataLevel.of(ke.tableId())).add(ke);
       });
+      return partitionedMigrations;
+    }
+
+    /**
+     * Given the current tserverStatus map and a DataLevel, return a view of 
the tserverStatus map
+     * that only contains entries for tables in the DataLevel
+     */
+    private SortedMap<TServerInstance,TabletServerStatus> 
createTServerStatusView(
+        final DataLevel dl, final 
SortedMap<TServerInstance,TabletServerStatus> status) {
+      final SortedMap<TServerInstance,TabletServerStatus> 
tserverStatusForLevel = new TreeMap<>();
+      status.forEach((k, v) -> {
+        TabletServerStatus copy = v.deepCopy();

Review Comment:
   I looked further at this method and it doesn't do a deep copy. It just 
creates a new object and sets the internal references for the new object to 
point to the old object internal objects. Modifications to the copy's internal 
objects are likely going to modify the original object which may have 
unintended consequences. I think I need to find a different way.



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