You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@knox.apache.org by GitBox <gi...@apache.org> on 2019/10/15 09:19:38 UTC

[GitHub] [knox] risdenk commented on a change in pull request #164: KNOX-2053 - New REST API to create/read/update/delete service definitions

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:
users@infra.apache.org


With regards,
Apache Git Services