smolnar82 opened a new pull request #213: KNOX-2136 - Caching credentials in DefaultKeystoreService when an alias is being added (instead of the first time someone fetches) and using a different cache implementation URL: https://github.com/apache/knox/pull/213 ## What changes were proposed in this pull request? The following changes we made in `DefaultKeystoreService`: - make sure we cache a credential of a given alias right after we saved it in the keystore (until my change it was cached after the first time the credential was fetched from the keystore) - changing cache implementation from a simple `ConcurrentHashMap` to [Caffeine Cache](https://github.com/ben-manes/caffeine/wiki). This change allows us to configure appropriate eviction policy (as of now, policy attributes are hard-coded) ## How was this patch tested? Added a new JUnit test and r=executed a full build: ``` $ mvn clean -Dshellcheck=true -T1C verify -Prelease,package ... [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 18:41 min (Wall Clock) [INFO] Finished at: 2019-12-12T12:51:54+01:00 [INFO] Final Memory: 414M/2402M [INFO] ------------------------------------------------------------------------ ``` In addition to unit testing, I've executed a performance test to check how much do we gain when adding/fetching 200/500 credentials (repeated 5 times) after my changes were in place: | Num of credentials | Before change (ms) | After Change (ms) | |--|--|--| | 200 | 44686<br>51197<br>50423<br>50734<br>50207 | 23011<br>28117<br>27075<br>26996<br>27070 | |500| 139908<br>188967<br>184465<br>175496<br>182561 | 77049<br>105465<br>105407<br>105488<br>105559 |
---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
