[ 
https://issues.apache.org/jira/browse/KNOX-2304?focusedWorklogId=418595&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-418595
 ]

ASF GitHub Bot logged work on KNOX-2304:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 08/Apr/20 15:01
            Start Date: 08/Apr/20 15:01
    Worklog Time Spent: 10m 
      Work Description: pzampino commented on pull request #307: KNOX-2304 - CM 
discovery cluster config monitor needs to be aware of …
URL: https://github.com/apache/knox/pull/307#discussion_r405592686
 
 

 ##########
 File path: 
gateway-discovery-cm/src/main/java/org/apache/knox/gateway/topology/discovery/cm/monitor/PollingConfigurationAnalyzer.java
 ##########
 @@ -365,12 +375,32 @@ private DiscoveryApiClient getApiClient(final 
ServiceDiscoveryConfig discoveryCo
                                                clusterName,
                                                lastTimestamp);
     for (ApiEvent event : events) {
-      restartEvents.add(new RestartEvent(event));
+      List<ApiEventAttribute> attributes = event.getAttributes();
+      Map<String,Object> map = getAttributeMap(attributes);
+      addIfRelevantEvent(restartEvents, event, map);
     }
 
     return restartEvents;
   }
 
+  @SuppressWarnings("unchecked")
+  private void addIfRelevantEvent(List<RestartEvent> restartEvents, ApiEvent 
event, Map<String, Object> map) {
+    String command = null;
+    String status = null;
+    command = (String) ((List<String>) map.get(COMMAND)).get(0);
+    status = (String) ((List<String>) map.get(COMMAND_STATUS)).get(0);
+    if (START_COMMAND.equals(command) || RESTART_COMMAND.equals(command) &&
+        SUCCEEDED_STATUS.equals(status) || STARTED_STATUS.equals(status)) {
+      restartEvents.add(new RestartEvent(event));
+    }
+  }
+
+  private Map<String, Object> getAttributeMap(List<ApiEventAttribute> 
attributes) {
+    Map<String,Object> map = new HashMap<>();
+    attributes.forEach(attr -> { map.put(attr.getName(), attr.getValues());});
 
 Review comment:
   The map is associated with a specific ApiEvent, so I'm not sure that the map 
is the concern. We may want to sort the ApiEvent collection by _timeOccurred_ 
to avoid issues associated with what you're describing.
 
----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
-------------------

    Worklog Id:     (was: 418595)
    Time Spent: 1h  (was: 50m)

> CM discovery - cluster config monitor needs to be aware of all relevant CM 
> event types
> --------------------------------------------------------------------------------------
>
>                 Key: KNOX-2304
>                 URL: https://issues.apache.org/jira/browse/KNOX-2304
>             Project: Apache Knox
>          Issue Type: Bug
>          Components: cm-discovery
>    Affects Versions: 1.4.0
>            Reporter: Philip Zampino
>            Assignee: Philip Zampino
>            Priority: Major
>             Fix For: 1.4.0
>
>          Time Spent: 1h
>  Remaining Estimate: 0h
>
> The CM cluster config monitor currently only polls for restart events. There 
> are other event types (e.g., start) that should trigger the configuration 
> analysis and subsequently trigger re-discovery.
> Need to determine the full set of event types that apply, and update the 
> polling query.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to