-
Notifications
You must be signed in to change notification settings - Fork 234
Improve setInstanceOperation performance #3017
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
Improve setInstanceOperation performance #3017
Conversation
…ssarily finding instances with matching logicalIds as well as individually getting all instance configs in the cluster. This change will switch to parallel get on all instance configs and avoid calling findInstancesWithMatchingLogicalId for instance operation transitions where this check is not required.
This will close: #2928 |
if (baseDataAccessor != null) { | ||
return findInstancesWithMatchingLogicalId(baseDataAccessor, clusterName, instanceConfig); | ||
} else if (configAccessor != null) { | ||
return findInstancesWithMatchingLogicalId(configAccessor, clusterName, instanceConfig); | ||
} else { | ||
throw new HelixException( | ||
"Both BaseDataAccessor and ConfigAccessor cannot be null at the same time"); | ||
} |
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.
A better way to make the code more clear is:
if (baseDataAccessor == null && configAccessor == null) {
throw new HelixException(
"Both BaseDataAccessor and ConfigAccessor cannot be null at the same time");
}
return findInstancesWithMatchingLogicalId(baseDataAccessor != null ? baseDataAccessor : configAccessor, clusterName, instanceConfig);
This simplify the branch of coding and also return the fail over logic at first beginning with out further checks. Especially when you have function with a lot of arguments repeatedly shows up, readability can be reduced.
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.
Thanks for the review, I have incorporated the suggestion.
Had an offline discussion about wether we want to use multistream with configAccessor or using dataAccessor. if we use multistream with configAccessor, we need to follow the pattern for all current usage of configAccessor - call If we change to using dataAccessor, we need to deprecate the prev API and create a new one. Considering we need to get all instances config in the cluster, I think we could favor performance to code style. And also do code clean in follow up changes. |
This PR is ready to be merged. Commit Message:
|
This change will switch to parallel/async get on all instance configs, using HelixDataAccessor, and avoid calling findInstancesWithMatchingLogicalId for instance operation transitions where this check is not required.
This change will switch to parallel/async get on all instance configs, using HelixDataAccessor, and avoid calling findInstancesWithMatchingLogicalId for instance operation transitions where this check is not required.
This change will switch to parallel/async get on all instance configs, using HelixDataAccessor, and avoid calling findInstancesWithMatchingLogicalId for instance operation transitions where this check is not required.
Issues
(#200 - Link your issue number here: You can write "Fixes #XXX". Please use the proper keyword so that the issue gets closed automatically. See https://docs.github.com/en/github/managing-your-work-on-github/linking-a-pull-request-to-an-issue
Any of the following keywords can be used: close, closes, closed, fix, fixes, fixed, resolve, resolves, resolved)
Description
This change will switch to parallel get on all instance configs and avoid calling findInstancesWithMatchingLogicalId for instance operation transitions where this check is not required.
Tests
Current tests cover this change, as the result/response of these APIs will not change.
Changes that Break Backward Compatibility (Optional)
(Consider including all behavior changes for public methods or API. Also include these changes in merge description so that other developers are aware of these changes. This allows them to make relevant code changes in feature branches accounting for the new method/API behavior.)
Documentation (Optional)
(Link the GitHub wiki you added)
Commits
Code Quality
(helix-style-intellij.xml if IntelliJ IDE is used)