Use memoized suppliers to lazy load resources#2658
Merged
ctubbsii merged 1 commit intoapache:mainfrom Apr 28, 2022
Merged
Conversation
* Remove the need to synchronize on reads for lazily initialized singleton resources, particularly in the configuration and context utilities, using Suppliers.memoize * Apply to DefaultConfiguration.getInstance() to avoid unnecessary object creation whenever that is called * Make all ServerContext fields final, and use memoize to lazily load anything that was previously checking if it was set in a synchronized getter method * Use computeIfAbsent in ServerConfigurationFactory, and make its caches of configuration objects non-static, so they only live as long as the ServerContext that created it lives; this, along with using ConcurrentHashMaps, dramatically simplifies this code * Reduce ServerContext reliance on ServerConfigurationFactory when it already has the information (notably, it has the instance of SiteConfiguration it used to construct the ServerConfigurationFactory) * Add a builder option for SiteConfiguration.empty() for use with tests * Update related tests, and make ServerContextTest.testCanRun more robust
EdColeman
approved these changes
Apr 28, 2022
Contributor
|
Were these changes pulled from the ZK single node prop store refactor? |
Contributor
|
Yes - the goal is to submit changes that are adjacent to the single node changes and have them submitted separately to reduce the number of absolute changes in the single node PR. It also contains changes that @ctubbsii identified during his review that were not originally in the single node PR, but are general code improvements and were in areas touched by the single node PR If these changes are merged, the the single prop node PR can be overlaid on top of them with work that is being done as part of his review. |
This file contains hidden or 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
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.
singleton resources, particularly in the configuration and context
utilities, using Suppliers.memoize
object creation whenever that is called
anything that was previously checking if it was set in a synchronized
getter method
of configuration objects non-static, so they only live as long as the
ServerContext that created it lives; this, along with using
ConcurrentHashMaps, dramatically simplifies this code
already has the information (notably, it has the instance of
SiteConfiguration it used to construct the ServerConfigurationFactory)
robust