risdenk commented on a change in pull request #205: KNOX-2134 - Add caching to 
ZookeeperRemoteAliasService
URL: https://github.com/apache/knox/pull/205#discussion_r349761377
 
 

 ##########
 File path: 
gateway-server/src/main/java/org/apache/knox/gateway/services/security/impl/ZookeeperRemoteAliasService.java
 ##########
 @@ -169,19 +171,23 @@ private static void checkPathsExist(
   public List<String> getAliasesForCluster(final String clusterName) throws 
AliasServiceException {
     List<String> remoteAliases = new ArrayList<>();
 
-    /* If we have remote registry configured, query it */
-    if (remoteClient != null) {
-      remoteAliases = remoteClient
-          .listChildEntries(buildClusterEntryName(clusterName));
+    // First, check the alias cache
+    if (aliasCache.containsKey(clusterName)) {
+      remoteAliases.addAll(aliasCache.get(clusterName).keySet());
+    } else { // If it's not available locally, then check ZK
+      /* If we have remote registry configured, query it */
+      if (remoteClient != null) {
+        remoteAliases = 
remoteClient.listChildEntries(buildClusterEntryName(clusterName));
+      }
 
 Review comment:
   I don't think I follow this logic. In my head, the cache should be up to 
date. We should never just straight return remove data without updating the 
cache. 

----------------------------------------------------------------
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