You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by dl...@apache.org on 2025/06/12 20:19:23 UTC

(accumulo) branch main updated (3cb7bf134e -> b2de885ba9)

This is an automated email from the ASF dual-hosted git repository.

dlmarion pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/accumulo.git


    from 3cb7bf134e Merge branch '2.1'
     add 022225a4b2 Don't balance user tables when tserver count below threshold (#5638)
     new b2de885ba9 Merge branch '2.1'

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../org/apache/accumulo/core/conf/Property.java    |  5 ++++
 .../java/org/apache/accumulo/manager/Manager.java  | 32 ++++++++++++++++++++++
 2 files changed, 37 insertions(+)


(accumulo) 01/01: Merge branch '2.1'

Posted by dl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

dlmarion pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/accumulo.git

commit b2de885ba9a42262f3983281d5cde1c59917f97d
Merge: 3cb7bf134e 022225a4b2
Author: Dave Marion <dl...@apache.org>
AuthorDate: Thu Jun 12 20:19:08 2025 +0000

    Merge branch '2.1'

 .../org/apache/accumulo/core/conf/Property.java    |  5 ++++
 .../java/org/apache/accumulo/manager/Manager.java  | 32 ++++++++++++++++++++++
 2 files changed, 37 insertions(+)

diff --cc server/manager/src/main/java/org/apache/accumulo/manager/Manager.java
index 68a564495c,909955da39..452ae0ecea
--- a/server/manager/src/main/java/org/apache/accumulo/manager/Manager.java
+++ b/server/manager/src/main/java/org/apache/accumulo/manager/Manager.java
@@@ -915,8 -1039,13 +916,13 @@@ public class Manager extends AbstractSe
            continue;
          }
  
+         if (dl == DataLevel.USER && !canAssignAndBalance()) {
+           log.debug("not balancing user tablets because not enough tablet servers");
+           continue;
+         }
+ 
          if ((dl == DataLevel.METADATA || dl == DataLevel.USER)
 -            && !migrations.isEmpty(DataLevel.ROOT)) {
 +            && !partitionedMigrations.get(DataLevel.ROOT).isEmpty()) {
            log.debug("Not balancing {} because {} has migrations", dl, DataLevel.ROOT);
            continue;
          }
@@@ -1845,59 -1950,42 +1851,85 @@@
    }
  
    void getAssignments(SortedMap<TServerInstance,TabletServerStatus> currentStatus,
 +      Map<String,Set<TServerInstance>> currentTServerGroups,
        Map<KeyExtent,UnassignedTablet> unassigned, Map<KeyExtent,TServerInstance> assignedOut) {
 -    AssignmentParamsImpl params = AssignmentParamsImpl.fromThrift(currentStatus,
 -        unassigned.entrySet().stream().collect(HashMap::new,
 -            (m, e) -> m.put(e.getKey(), e.getValue().getServerInstance()), Map::putAll),
 -        assignedOut);
 +    AssignmentParamsImpl params =
 +        AssignmentParamsImpl.fromThrift(currentStatus, currentTServerGroups,
 +            unassigned.entrySet().stream().collect(HashMap::new,
 +                (m, e) -> m.put(e.getKey(),
 +                    e.getValue().getLastLocation() == null ? null
 +                        : e.getValue().getLastLocation().getServerInstance()),
 +                Map::putAll),
 +            assignedOut);
      tabletBalancer.getAssignments(params);
+     if (!canAssignAndBalance()) {
+       // remove assignment for user tables
+       Iterator<KeyExtent> iter = assignedOut.keySet().iterator();
+       while (iter.hasNext()) {
+         KeyExtent ke = iter.next();
+         if (!ke.isMeta()) {
+           iter.remove();
+           log.trace("Removed assignment for {} as assignments for user tables is disabled.", ke);
+         }
+       }
+     }
    }
  
 +  public TabletStateStore getTabletStateStore(DataLevel level) {
 +    switch (level) {
 +      case METADATA:
 +        return this.metadataTabletStore;
 +      case ROOT:
 +        return this.rootTabletStore;
 +      case USER:
 +        return this.userTabletStore;
 +      default:
 +        throw new IllegalStateException("Unhandled DataLevel value: " + level);
 +    }
 +  }
 +
 +  @Override
 +  public void registerMetrics(MeterRegistry registry) {
 +    super.registerMetrics(registry);
 +    compactionCoordinator.registerMetrics(registry);
 +  }
 +
 +  private Map<FateInstanceType,Fate<Manager>> getFateRefs() {
 +    var fateRefs = this.fateRefs.get();
 +    Preconditions.checkState(fateRefs != null, "Unexpected null fate references map");
 +    return fateRefs;
 +  }
 +
    @Override
    public ServiceLock getLock() {
      return managerLock;
    }
  
 +  private long numMigrations() {
 +    long count = 0;
 +    for (DataLevel dl : DataLevel.values()) {
 +      // prev row needed for the extent
 +      try (var tabletsMetadata = getContext().getAmple().readTablets().forLevel(dl)
 +          .fetch(TabletMetadata.ColumnType.PREV_ROW, TabletMetadata.ColumnType.MIGRATION).build()) {
 +        count += tabletsMetadata.stream()
 +            .filter(tabletMetadata -> tabletMetadata.getMigration() != null).count();
 +      }
 +    }
 +    return count;
 +  }
++
+   private boolean canAssignAndBalance() {
+     final int threshold =
+         getConfiguration().getCount(Property.MANAGER_TABLET_BALANCER_TSERVER_THRESHOLD);
+     if (threshold == 0) {
+       return true;
+     }
+     final int numTServers = tserverSet.size();
+     final boolean result = numTServers >= threshold;
+     if (!result) {
+       log.warn("Not assigning or balancing as number of tservers ({}) is below threshold ({})",
+           numTServers, threshold);
+     }
+     return result;
+   }
  }