risdenk commented on a change in pull request #164: KNOX-2053 - New REST API to 
create/read/update/delete service definitions
URL: https://github.com/apache/knox/pull/164#discussion_r334834425
 
 

 ##########
 File path: 
gateway-server/src/main/java/org/apache/knox/gateway/services/topology/impl/DefaultTopologyService.java
 ##########
 @@ -530,6 +533,19 @@ public void addTopologyChangeListener(TopologyListener 
listener) {
     listeners.add(listener);
   }
 
+  @Override
+  public void onServiceDefinitionChange(String name, String role, String 
version) {
+    getTopologies().stream().filter(topology -> 
topology.getServices().stream().anyMatch(service -> isRelevantService(service, 
role, name, version))).forEach(topology -> {
+      log.redeployingTopologyOnServiceDefinitionChange(topology.getName(), 
name, role, version);
+      redeployTopology(topology);
+    });
+  }
+
+  private boolean isRelevantService(Service service, String role, String name, 
String version) {
+    return service.getRole().equalsIgnoreCase(role)
+        && (service.getName() == null || 
service.getName().equalsIgnoreCase(name) && (service.getVersion() == null || 
service.getVersion().compareTo(new Version(version)) == 0));
 
 Review comment:
   Compare to == 0 vs equals for version comparison?

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to