Github user rfarivar commented on a diff in the pull request:
https://github.com/apache/storm/pull/921#discussion_r47698615
--- Diff:
storm-core/src/jvm/backtype/storm/validation/ConfigValidation.java ---
@@ -489,17 +489,62 @@ public void validateField(String name, Object o) {
public static class PacemakerAuthTypeValidator extends Validator {
@Override
public void validateField(String name, Object o) {
- if(o == null) {
- throw new IllegalArgumentException( "Field " + name + "
must be set.");
+ if (o == null) {
+ throw new IllegalArgumentException("Field " + name + "
must be set.");
+ }
+
+ if (o instanceof String &&
+ (((String) o).equals("NONE") ||
+ ((String) o).equals("DIGEST") ||
+ ((String) o).equals("KERBEROS"))) {
+ return;
+ }
+ throw new IllegalArgumentException("Field " + name + " must be
one of \"NONE\", \"DIGEST\", or \"KERBEROS\"");
+ }
+ }
+
+ public static class UserResourcePoolEntryValidator extends Validator {
+
+ @Override
+ public void validateField(String name, Object o) {
+ if (o == null) {
+ return;
+ }
+ SimpleTypeValidator.validateField(name, Map.class, o);
+ if (!((Map) o).containsKey("cpu")) {
+ throw new IllegalArgumentException("Field " + name + "
must have map entry with key: cpu");
}
+ if (!((Map) o).containsKey("memory")) {
+ throw new IllegalArgumentException("Field " + name + "
must have map entry with key: memory");
+ }
+
+ SimpleTypeValidator.validateField(name, Number.class, ((Map)
o).get("cpu"));
+ SimpleTypeValidator.validateField(name, Number.class, ((Map)
o).get("memory"));
+ }
+ }
+
+ public static class ImplementsClassValidator extends Validator {
+
+ Class classImplements;
+
+ public ImplementsClassValidator(Map<String, Object> params) {
+ this.classImplements = (Class)
params.get(ConfigValidationAnnotations.ValidatorParams.IMPLEMENTS_CLASS);
+ }
- if(o instanceof String &&
- (((String)o).equals("NONE") ||
- ((String)o).equals("DIGEST") ||
- ((String)o).equals("KERBEROS"))) {
+ @Override
+ public void validateField(String name, Object o) {
+ if (o == null) {
return;
}
- throw new IllegalArgumentException( "Field " + name + " must
be one of \"NONE\", \"DIGEST\", or \"KERBEROS\"");
+ SimpleTypeValidator.validateField(name, String.class, o);
+ try {
+ Class objectClass = Class.forName((String) o);
+ if (!this.classImplements.isAssignableFrom(objectClass)) {
+ throw new IllegalArgumentException("Field " + name + "
with value " + o + " does not implement " + this.classImplements.getName());
--- End diff --
long line
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---