Skip to content
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

Merged
merged 6 commits into from
Sep 28, 2023

Conversation

Marcosrico
Copy link
Contributor

@Marcosrico Marcosrico commented Sep 19, 2023

Issues

  • My PR addresses the following Helix issues and references them in the PR description:

#2237

Description

  • Here are some details about my PR, including screenshots of any UI changes:

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

  • The following tests are written for this issue:

testLazyDataCacheAndFetch and testCacheDataUpdates

Commits

  • My commits all reference appropriate Apache Helix GitHub issues in their subject lines. In addition, my commits follow the guidelines from "How to write a good git commit message":
    1. Subject is separated from body by a blank line
    2. Subject is limited to 50 characters (not including Jira issue reference)
    3. Subject does not end with a period
    4. Subject uses the imperative mood ("add", not "adding")
    5. Body wraps at 72 characters
    6. Body explains "what" and "why", not "how"

Code Quality

  • My diff has been formatted using helix-style.xml
    (helix-style-intellij.xml if IntelliJ IDE is used)

@Marcosrico Marcosrico marked this pull request as ready for review September 19, 2023 05:06
@Override
public T get(final String key) {
if (_cacheData) {
getDataCacheMap().computeIfAbsent(key, k -> _cacheClient.readData(k, true));
return getDataCacheMap().get(key);
Copy link
Contributor

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?

Copy link
Contributor Author

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));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above.

private final String path;
private final ChildChangeListener.ChangeType changeType;

public CacheUpdateRunnable(String path, ChildChangeListener.ChangeType changeType) {
Copy link
Contributor

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.

Copy link
Contributor Author

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();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why count down here?

Copy link
Contributor Author

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)

Copy link
Contributor

@xyuanlu xyuanlu left a 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

@Marcosrico
Copy link
Contributor Author

PR approved by @xyuanlu
Commit message: Lattice cache - caching just data implementation

@xyuanlu xyuanlu merged commit c147eb4 into apache:metaclient Sep 28, 2023
asfgit pushed a commit that referenced this pull request Oct 5, 2023
Lattice cache - caching just data implementation
---------

Co-authored-by: mapeng <[email protected]>
xyuanlu added a commit that referenced this pull request Oct 16, 2023
* 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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants