You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@helix.apache.org by "xyuanlu (via GitHub)" <gi...@apache.org> on 2023/09/20 20:11:29 UTC

[GitHub] [helix] xyuanlu commented on a diff in pull request #2619: Lattice Cache - Caching Just Data Implementation

xyuanlu commented on code in PR #2619:
URL: https://github.com/apache/helix/pull/2619#discussion_r1332122781


##########
meta-client/src/main/java/org/apache/helix/metaclient/impl/zk/ZkMetaClientCache.java:
##########
@@ -81,14 +114,45 @@ public int countDirectChildren(final String key) {
         throw new MetaClientException("Not implemented yet.");
     }
 
-    @Override
-    public List<T> get(List<String> keys) {
-        throw new MetaClientException("Not implemented yet.");
+    private void handleCacheUpdate(String path, ChildChangeListener.ChangeType changeType) {
+        switch (changeType) {
+            case ENTRY_CREATED:
+                // Not implemented yet.
+                break;
+            case ENTRY_DELETED:
+                // Not implemented yet.
+                break;
+            case ENTRY_DATA_CHANGE:
+                modifyDataInCache(path);
+                break;
+            default:
+                LOG.error("Unknown change type: " + changeType);
+        }
     }
 
+    private void modifyDataInCache(String path) {
+        if (_cacheData) {
+            T dataRecord = _cacheClient.readData(path, true);
+            getDataCacheMap().put(path, dataRecord);
+        }
+    }
+
+    public ConcurrentHashMap<String, T> getDataCacheMap() {
+        return _dataCacheMap;
+    }
+
+    public TrieNode getChildrenCacheTree() {
+        return _childrenCacheTree;
+    }
+
+    /**
+     * Connect to the underlying ZkClient.
+     */
     @Override
-    public List<Stat> exists(List<String> keys) {
-        throw new MetaClientException("Not implemented yet.");
+    public void connect() {
+        super.connect();
+        _eventListener = this::handleCacheUpdate;

Review Comment:
   Do you think we need a separate thread to handle change events? So that it wont block user requests when we have massive events coming.



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

To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org