keith-turner commented on code in PR #5807:
URL: https://github.com/apache/accumulo/pull/5807#discussion_r2286015113


##########
server/base/src/main/java/org/apache/accumulo/server/util/UpgradeUtil.java:
##########
@@ -304,4 +329,92 @@ public void execute(String[] args) throws Exception {
 
   }
 
+  private void validateCompactionServiceConfiguration(ServerContext ctx)
+      throws KeeperException, InterruptedException {
+
+    boolean configurationError = false;
+
+    final CompactionServicesConfig servicesConfig =
+        new CompactionServicesConfig(ctx.getConfiguration());
+    final Set<CompactionServiceId> definedServiceIds = 
servicesConfig.getPlanners().keySet()
+        
.stream().map(CompactionServiceId::of).collect(Collectors.toUnmodifiableSet());
+
+    LOG.info("Defined compaction service ids: {}", definedServiceIds);
+
+    final ZooReader zr = ctx.getZooSession().asReader();
+    List<String> zooTableIds = zr.getChildren(ZTABLES);
+
+    for (String tableId : zooTableIds) {
+
+      final String tableName =
+          new String(zr.getData(Constants.ZTABLES + "/" + tableId + 
ZTABLE_NAME), UTF_8);
+      final String namespaceId = new String(
+          zr.getData(Constants.ZTABLES + "/" + tableId + 
Constants.ZTABLE_NAMESPACE), UTF_8);
+
+      final NamespaceId nsid = NamespaceId.of(namespaceId);
+      final TableId tid = TableId.of(tableId);
+
+      final NamespaceConfiguration nsConf =
+          new NamespaceConfiguration(ctx, nsid, ctx.getConfiguration());
+      final TableConfiguration tconf = new TableConfiguration(ctx, tid, 
nsConf);
+
+      final CompactionDispatcher dispatcher = tconf.getCompactionDispatcher();
+
+      for (CompactionKind kind : CompactionKind.values()) {
+        final CompactionDispatcher.DispatchParameters dispatchParams =
+            new CompactionDispatcher.DispatchParameters() {
+              @Override
+              public CompactionServices getCompactionServices() {
+                return () -> definedServiceIds;
+              }
+
+              @Override
+              public ServiceEnvironment getServiceEnv() {
+                return (ServiceEnvironment) ctx;
+              }
+
+              @Override
+              public CompactionKind getCompactionKind() {
+                return kind;
+              }
+
+              @Override
+              public Map<String,String> getExecutionHints() {
+                return Map.of();
+              }
+            };
+        final CompactionServiceId expectedCompactionService =
+            dispatcher.dispatch(dispatchParams).getService();
+        LOG.info("Table {} is configured to use service \"{}\" for compaction 
kind {}", tableName,
+            expectedCompactionService, kind);
+        if 
(!servicesConfig.getPlanners().containsKey(expectedCompactionService.canonical()))
 {
+          if (tid.equals(SystemTables.ROOT.tableId())
+              || tid.equals(SystemTables.METADATA.tableId())) {

Review Comment:
   Could make this more specific looking for the default values set by the 2.1 
init/upgrade code and mirror the check done in the 4.0 upgrade code.    Then it 
will fail if these tables happen to have changed from the 2.1 defaults.
   
   ```suggestion
             if (( tid.equals(SystemTables.ROOT.tableId()) && 
xpectedCompactionService.canonical().equals("root"))
                 || (tid.equals(SystemTables.METADATA.tableId()) && 
xpectedCompactionService.canonical().equals("meta"))) {
   ```



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