-
Notifications
You must be signed in to change notification settings - Fork 228
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lattice Cache - Caching Just Data Implementation #2619
Conversation
meta-client/src/main/java/org/apache/helix/metaclient/impl/zk/ZkMetaClientCache.java
Outdated
Show resolved
Hide resolved
meta-client/src/main/java/org/apache/helix/metaclient/impl/zk/ZkMetaClientCache.java
Outdated
Show resolved
Hide resolved
meta-client/src/main/java/org/apache/helix/metaclient/impl/zk/ZkMetaClientCache.java
Outdated
Show resolved
Hide resolved
meta-client/src/main/java/org/apache/helix/metaclient/impl/zk/ZkMetaClientCache.java
Outdated
Show resolved
Hide resolved
@Override | ||
public T get(final String key) { | ||
if (_cacheData) { | ||
getDataCacheMap().computeIfAbsent(key, k -> _cacheClient.readData(k, true)); | ||
return getDataCacheMap().get(key); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shall we differentiate if key is not in ZK, or it is in ZK but not populated to cache yet?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not too sure how to do this without pinging zookeeper. If it's not populated yet how do we know if it doesn't actually exist in zookeeper or it's being populated without checking zk?
dataList.add(_cacheClient.readData(key, true)); | ||
} | ||
for (String key : keys) { | ||
dataList.add(get(key)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above.
meta-client/src/main/java/org/apache/helix/metaclient/impl/zk/ZkMetaClientCache.java
Outdated
Show resolved
Hide resolved
meta-client/src/main/java/org/apache/helix/metaclient/impl/zk/ZkMetaClientCache.java
Outdated
Show resolved
Hide resolved
meta-client/src/main/java/org/apache/helix/metaclient/impl/zk/ZkMetaClientCache.java
Outdated
Show resolved
Hide resolved
private final String path; | ||
private final ChildChangeListener.ChangeType changeType; | ||
|
||
public CacheUpdateRunnable(String path, ChildChangeListener.ChangeType changeType) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Add todo for dedup.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added todo a little lower :)
if (!_cacheClient.exists(_rootEntry)) { | ||
LOG.warn("Root entry: {} does not exist.", _rootEntry); | ||
// Let the other threads know that the cache is populated. | ||
_initializedCache.countDown(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why count down here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
otherwise populateAllCache will return without counting down the latch so the cacheEventChange handler thread will wait indefinitely. We can have it twice or have it in the connect method (from previous impl)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks for addressing comments
PR approved by @xyuanlu |
Lattice cache - caching just data implementation --------- Co-authored-by: mapeng <[email protected]>
* MetaClientCache Part 1 - API's, configs, and builders (#2612) MetaClientCache Part 1 - API's, configs, and builders --------- Co-authored-by: mapeng <[email protected]> * Skip one time listener re-register for exists for ZkClient - MetaClient usage. (#2637) * Lattice cache - caching just data implementation (#2619) Lattice cache - caching just data implementation --------- Co-authored-by: mapeng <[email protected]> * Add recursiveCreate functionality to metaclient (#2607) Co-authored-by: Grant Palau Spencer <[email protected]> * Lattice Children Cache Implementation(#2623) Co-authored-by: mapeng <[email protected]> --------- Co-authored-by: Marcos Rico Peng <[email protected]> Co-authored-by: mapeng <[email protected]> Co-authored-by: Grant Paláu Spencer <[email protected]> Co-authored-by: Grant Palau Spencer <[email protected]>
Issues
#2237
Description
This PR includes all the implementation of the dataCache Map for storing the data in cache as well as the implementation of data specific apis (get and batch get).
Also made some refactoring for config builder.
Tests
testLazyDataCacheAndFetch
andtestCacheDataUpdates
Commits
Code Quality
(helix-style-intellij.xml if IntelliJ IDE is used)