Github user cestella commented on a diff in the pull request:
https://github.com/apache/incubator-metron/pull/210#discussion_r75534840
--- Diff:
metron-analytics/metron-maas-common/src/main/java/org/apache/metron/maas/discovery/ServiceDiscoverer.java
---
@@ -76,12 +92,19 @@ public void resetState() {
private void updateState() {
Map<Model, List<ModelEndpoint>> state = new HashMap<>();
+ Map<String, String> modelToVersion = new HashMap<>();
Map<String, ServiceInstance<ModelEndpoint>> containerToEndpoint = new
HashMap<>();
try {
for(String name : serviceDiscovery.queryForNames()) {
for(ServiceInstance<ModelEndpoint> endpoint:
serviceDiscovery.queryForInstances(name)) {
ModelEndpoint ep = endpoint.getPayload();
LOG.info("Found model endpoint " + ep);
+ String currentVersion =
modelToVersion.getOrDefault(ep.getName(), ep.getVersion());
+ modelToVersion.put( ep.getName()
+ , currentVersion.compareTo(ep.getVersion()) < 0
+ ? ep.getVersion()
+ : currentVersion
+ );
--- End diff --
It's hard for the author to make code easier to read that he did not
intentionally make hard to read..after all, I don't find my own code hard to
read. :)
That being said, that particular block of code is intended to update a map
with the current version of the model which has been discovered. If you
request a model without a version, an instance of the most recent version will
be returned. I can, perhaps, use another variable and put a comment.
---
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.
---