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


##########
core/src/main/java/org/apache/accumulo/core/conf/cluster/ClusterConfigParser.java:
##########
@@ -125,46 +124,68 @@ public static void 
outputShellVariables(Map<String,String> config, PrintStream o
     }
 
     List<String> compactorGroups =
-        config.keySet().stream().filter(k -> k.startsWith(COMPACTOR_PREFIX))
-            .map(k -> 
k.substring(COMPACTOR_PREFIX.length())).sorted().collect(Collectors.toList());
+        config.keySet().stream().filter(k -> 
k.startsWith(COMPACTOR_PREFIX)).map(k -> {
+          if (k.contains(HOSTS_SUFFIX)) {
+            return k.substring(COMPACTOR_PREFIX.length(), 
k.indexOf(HOSTS_SUFFIX));
+          } else if (k.contains(SERVERS_PER_HOST_SUFFIX)) {
+            return k.substring(COMPACTOR_PREFIX.length(), 
k.indexOf(SERVERS_PER_HOST_SUFFIX));
+          } else {
+            return k.substring(COMPACTOR_PREFIX.length());
+          }
+        }).sorted().distinct().collect(Collectors.toList());
 
     if (!compactorGroups.isEmpty()) {
       out.printf(PROPERTY_FORMAT, "COMPACTOR_GROUPS",
           compactorGroups.stream().collect(Collectors.joining(" ")));
       for (String group : compactorGroups) {
         out.printf(PROPERTY_FORMAT, "COMPACTOR_HOSTS_" + group,
-            config.get(COMPACTOR_PREFIX + group));
-        String numCompactors = config.getOrDefault("compactors_per_host." + 
group, "1");
-        out.printf(PROPERTY_FORMAT, "NUM_COMPACTORS_" + group, numCompactors);
+            config.get(COMPACTOR_PREFIX + group + HOSTS_SUFFIX));
+        String numCompactors =
+            config.getOrDefault(COMPACTOR_PREFIX + group + 
SERVERS_PER_HOST_SUFFIX, "1");
+        out.printf(PROPERTY_FORMAT, "COMPACTORS_PER_HOST_" + group, 
numCompactors);
       }
     }
 
-    List<String> sserverGroups = config.keySet().stream().filter(k -> 
k.startsWith(SSERVER_PREFIX))
-        .map(k -> 
k.substring(SSERVER_PREFIX.length())).sorted().collect(Collectors.toList());
+    List<String> sserverGroups =
+        config.keySet().stream().filter(k -> 
k.startsWith(SSERVER_PREFIX)).map(k -> {
+          if (k.contains(HOSTS_SUFFIX)) {
+            return k.substring(SSERVER_PREFIX.length(), 
k.indexOf(HOSTS_SUFFIX));
+          } else if (k.contains(SERVERS_PER_HOST_SUFFIX)) {
+            return k.substring(SSERVER_PREFIX.length(), 
k.indexOf(SERVERS_PER_HOST_SUFFIX));
+          } else {
+            return k.substring(SSERVER_PREFIX.length());
+          }
+        }).sorted().distinct().collect(Collectors.toList());
 
     if (!sserverGroups.isEmpty()) {
       out.printf(PROPERTY_FORMAT, "SSERVER_GROUPS",
           sserverGroups.stream().collect(Collectors.joining(" ")));
       sserverGroups.forEach(ssg -> out.printf(PROPERTY_FORMAT, 
"SSERVER_HOSTS_" + ssg,
-          config.get(SSERVER_PREFIX + ssg)));
-      sserverGroups.forEach(ssg -> out.printf(PROPERTY_FORMAT, "NUM_SSERVERS_" 
+ ssg,
-          config.getOrDefault("sservers_per_host." + ssg, "1")));
-
+          config.get(SSERVER_PREFIX + ssg + HOSTS_SUFFIX)));
+      sserverGroups.forEach(ssg -> out.printf(PROPERTY_FORMAT, 
"SSERVERS_PER_HOST_" + ssg,
+          config.getOrDefault(SSERVER_PREFIX + ssg + SERVERS_PER_HOST_SUFFIX, 
"1")));
     }
 
-    List<String> tserverGroups = config.keySet().stream().filter(k -> 
k.startsWith(TSERVER_PREFIX))
-        .map(k -> 
k.substring(TSERVER_PREFIX.length())).sorted().collect(Collectors.toList());
+    List<String> tserverGroups =
+        config.keySet().stream().filter(k -> 
k.startsWith(TSERVER_PREFIX)).map(k -> {

Review Comment:
   It would be nice to make the parser more strict for unexpected data like the 
following.  This may be a good place to do those more strict checks,  ensuring 
only `.hosts` or  `.servers_per_host` follows the group and that the depth is 3.
   
   
   ```yaml
   tserver:
     default:
       junk: 
          abc: 7
          xyz: 13
       servers_per_hostes: 2
       ghosts:
         - localhost1
         - localhost2
         - localhost3
         - localhost4
   ```
   



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