[
https://issues.apache.org/jira/browse/STORM-1084?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14950681#comment-14950681
]
ASF GitHub Bot commented on STORM-1084:
---------------------------------------
Github user revans2 commented on the pull request:
https://github.com/apache/storm/pull/785#issuecomment-146926754
@jerrypeng Perhaps we can do a hybrid approach, where we have validation
for complex types made up of something that is a bit ugly, but expressive. And
a set of simple annotations for common types. for example
```
@Validate(type=Map.class, nullAllowed=false,
key=@Validate(type=String.class),
value=@Validate(type=Number.class, min=0, max=500))
public static final String MY_MAP_CONF="my.map.conf";
@Validate(type=List.class, value=@Validate(type=String.class))
public static final String MY_LIST_OF_STRINGS="my.list.of.strings";
@IntValidator(min=0, nullAllowed=false)
public static final String MY_INT_CONF="my.int.conf";
//And for the really strange types
@Validate(type=List.class, value=@Validate(type=Map.class,
validator=RegistryValidator.class))
public static final String TOPOLOGY_METRICS_CONSUMER_REGISTER =
"topology.metrics.consumer.register";
```
> Improve Storm config validation process to use java annotations instead of
> *_SCHEMA format
> ------------------------------------------------------------------------------------------
>
> Key: STORM-1084
> URL: https://issues.apache.org/jira/browse/STORM-1084
> Project: Apache Storm
> Issue Type: Improvement
> Components: storm-core
> Reporter: Boyang Jerry Peng
> Assignee: Boyang Jerry Peng
>
> So currently we specify validators:
> public static final String STORM_MESSAGING_NETTY_MIN_SLEEP_MS =
> "storm.messaging.netty.min_wait_ms";
> public static final Object STORM_MESSAGING_NETTY_MIN_SLEEP_MS_SCHEMA =
> ConfigValidation.IntegerValidator;
> A better way to do this is using annotations. Something like:
> @IntegerValidator
> public static final String STORM_MESSAGING_NETTY_MIN_SLEEP_MS =
> "storm.messaging.netty.min_wait_ms";
> Do this has many advantages. For one you can stack multiple annotations:
> @IntegerValidator
> @NotNull
> public static final String STORM_MESSAGING_NETTY_MIN_SLEEP_MS =
> "storm.messaging.netty.min_wait_ms";
> And we don't have to write another validator for strings that cannot be null
> And we can pass parameters into the annotations:
> @PositiveIntegerValidator(notNull=true)
> public static final String DRPC_REQUEST_TIMEOUT_SECS =
> "drpc.request.timeout.secs";
> instead of having to write another validator:
> ConfigValidation.NotNullPosIntegerValidator for checking for not null
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)