-
Notifications
You must be signed in to change notification settings - Fork 5
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
[ALS-6235] Investigate: BDC Auth login issue: Explore delays creating the user roles #173
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Move AccessRule creation out to a separate method. Centralizing this will make it is to optimize more in the near future.
The code changes refactor the FENCEAuthenticationService class to enhance code readability and performance. This includes introducing a new `_authZMap` for faster lookups and reorganizing methods for better code reusability.
We need to call this at least once in order to load the maps.
A new utility class (FenceMappingUtility) has been introduced to handle FENCE mapping operations. The FenceMappingUtility is now used for FENCE mapping in FENCEAuthenticationService and StudyAccessService instead of these classes handling it directly. This change makes the applications more modular, distributes responsibilities better among classes, and improves code readability.
In the FenceMappingUtility class, the data structures have been updated to improve the thread safety of the application. The non-thread-safe HashMap was replaced with ConcurrentHashMap to handle potential concurrency issues. To further strengthen thread safety, the 'volatile' keyword was added to provide the most recent value whenever a variable is called, directly addressing potential issues with thread caching. The method 'initializeFENCEMappings' was also modified to use a parallel stream for efficient data processing.
Refactor upsertTopmedPrivilege to improve readability and make future improvements easier. Refactor getAllowedQueryTypeRules to cache fence_allowed_query_types.
A null-check has been added before using the standardAccessRules variable to safeguard against potential NullPointerException. The logic has also been reconsidered, and now it only attempts to populate the standardAccessRules set from the database if it is found to be empty or null. This should enhance efficiency by avoiding unnecessary database calls.
The role creation and assignment process has been optimized in the FENCEAuthenticationService. Rather than processing roles one-by-one, the revised code collects all the role names, prepares a list of roles, and commits them all at once to the repository. This is achieved by leveraging Java's parallel streams and the 'persistAll' method added to RoleRepository.
A check has been added in the createRole method to handle the situation when the role name is empty. It prevents the creation of roles with empty names, logging an error message
The persistAll method in the RoleRepository has been updated. This change ensures that if a role already has a UUID, it is merged instead of persisted, preventing any duplicate entries. New roles, which do not yet have a UUID, are persisted as before.
FENCEAuthenticationService.java has been refactored to improve role handling. The logic is now more precise and efficient in checking the existence of roles, adding new ones, and removing obsolete ones. It ensures correct persistence of roles while providing better error handling and logging.
The previous code used to find roles that aren't present in a user's existing roles, but the following logic left it unused. Thus, this redundancy has been removed, streamlining the process of handling roles in the FENCEAuthenticationService class.
Gcolon021
force-pushed
the
ALS-6235-Rewrite
branch
from
May 28, 2024 12:09
ce7580e
to
b6334c4
Compare
ramari16
reviewed
May 28, 2024
} | ||
} | ||
|
||
private synchronized void initializeFENCEMappings() { |
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.
As discussed, remove synchronized here
Performance timing for user login within the FENCEAuthenticationService was removed to clean up the code. This logging was unnecessary and did not contribute in any significant manner to the overall functionality.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
[ALS-6235] Investigate: BDC Auth login issue: Explore delays creating the user roles