kevinrr888 commented on code in PR #5301:
URL: https://github.com/apache/accumulo/pull/5301#discussion_r1949913027
##########
core/src/main/java/org/apache/accumulo/core/conf/PropertyType.java:
##########
@@ -393,4 +414,86 @@ public static IntStream parse(String portRange) {
}
+ private static class ValidFateConfig implements Predicate<String> {
+ private static final Logger log =
LoggerFactory.getLogger(ValidFateConfig.class);
+ private final Set<Fate.FateOperation> allFateOps;
+ private final String name;
+
+ private ValidFateConfig(Set<Fate.FateOperation> allFateOps, String name) {
+ this.allFateOps = allFateOps;
+ this.name = name;
+ }
+
+ @Override
+ public boolean test(String s) {
+ final Set<Fate.FateOperation> seenFateOps;
+
+ try {
+ final var json = JsonParser.parseString(s).getAsJsonObject();
+ seenFateOps = new HashSet<>();
+
+ for (var entry : json.entrySet()) {
+ var key = entry.getKey();
+ var val = entry.getValue().getAsInt();
+ if (val <= 0) {
+ log.warn(
+ "Invalid entry {} in {}. Must be a valid thread pool size.
Property was unchanged.",
+ entry, name);
+ return false;
+ }
+ var fateOpsStrArr = key.split(",");
+ for (String fateOpStr : fateOpsStrArr) {
+ Fate.FateOperation fateOp = Fate.FateOperation.valueOf(fateOpStr);
+ if (seenFateOps.contains(fateOp)) {
+ log.warn("Duplicate fate operation {} seen in {}. Property was
unchanged.", fateOp,
+ name);
+ return false;
+ }
+ seenFateOps.add(fateOp);
+ }
+ }
+ } catch (Exception e) {
+ log.warn("Exception from attempting to set {}. Property was
unchanged.", name, e);
+ return false;
+ }
+
+ var allFateOpsSeen = allFateOps.equals(seenFateOps);
+ if (!allFateOpsSeen) {
+ log.warn(
+ "Not all fate operations found in {}. Expected to see {} but saw
{}. Property was unchanged.",
+ name, allFateOps, seenFateOps);
+ }
+ return allFateOpsSeen;
+ }
+ }
+
+ private static class ValidUserFateConfig extends ValidFateConfig {
+ private static final String NAME = "fate user config";
+
+ private ValidUserFateConfig() {
+ super(Fate.FateOperation.getAllUserFateOps(), NAME);
+ }
+ }
+
+ private static class ValidMetaFateConfig extends ValidFateConfig {
+ private static final String NAME = "fate meta config";
+
+ private ValidMetaFateConfig() {
+ super(Fate.FateOperation.getAllMetaFateOps(), NAME);
+ }
+ }
+
+ private static class FateThreadPoolSize implements Predicate<String> {
+ private static final Logger log =
LoggerFactory.getLogger(FateThreadPoolSize.class);
+
+ @Override
+ public boolean test(String s) {
+ log.warn(
+ "The manager fate thread pool size property is no longer used. See
the {} and {} for "
+ + "the replacements to this property.",
+ ValidUserFateConfig.NAME, ValidMetaFateConfig.NAME);
+ return true;
Review Comment:
Would be nice to print the actual property but I don't think it's possible
since Property uses PropertyType to construct each Property. Accessing Property
here may introduce circular dependencies. This is safe and probably good enough.
--
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]