-
Notifications
You must be signed in to change notification settings - Fork 55
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
[JBIDE-21590] Add project cache to handle connection refresh issues #950
[JBIDE-21590] Add project cache to handle connection refresh issues #950
Conversation
Unit tests? |
May singleton instance of OpenShiftProjectCache be needed for other clients than only content provider? Then OpenShiftProjectCacheSingleton might be of use as ConnectionsRegistrySingleton is for ConnectionsRegistry. |
When removing IProjectAdapter, it should be disposed by a dispose() method that would destroy deployment resource mapper and remove listener from connections registry. |
ServerSettingsViewModel gets from connection projects and builds new DeploymentResourceMapper, could it instead reuse this new cache singleton? |
dcffe0a
to
642937a
Compare
@fbricon I was already on it. Added unit tests for the cache. |
@scabanovich I have not fully thought through the places where one could utilize this cache other then the contentprovider, but one think to note is it is currently impl to only provide UI adapter classes. I would think we would want to keep this out of the ConnectionRegistry. @adietish and I have spoken of a complete resource cache but I think we are still in baby steps before we could fully provide such a solution. I think this is a start towards that goal. |
@scabanovich I'm not sure I fully grasp your 'dispose' suggestion but welcome examples are additional suggestions. |
synchronized (listeners) { | ||
try { | ||
for (IProjectAdapter a : adapters) { | ||
listeners.forEach(l->l.handleRemoveFromCache(this, a)); |
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.
@jcantrill Cache listeners are notified of removed IProjectAdapter and they are already removed from 'cache' map. That is fine. However, DeploymentResourceMapper is still a listener to ConnectionsRegistry, so that it cannot be handled by garbage collector together with all maps that it built. I suggest
public void IProjectAdapter.dispose() {
mapper.dispose();
}
public void DeploymentResourceMapper.dispose() {
ConnectionsRegistrySingleton.getInstance().removeListener(connectionListener);
cache.dispose();
//clean maps for faster memory cleaning.
}
public void ObservableResourceCache.dispose() {
//clean maps and collections for faster memory cleaning.
}
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.
@jcantrill , I forgot to add that I suggest to call a.dispose() at this point, after listeners are notified that adapter is removed.
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.
updated
642937a
to
29f7df9
Compare
@scabanovich @fbricon updated per comments |
@jcantrill , I have a comment that may be not quite related to this issue, but it may be not so a big deal to open a new one.
Maybe, there are more places that transform something to property name, I am not aware of them yet. But, imho, even if they are only 2 places and no other will appear, they are too much related to be hidden in the depth of implementation. I suggest a utility that will encapsulate all manipulations with resource property names, (being in an internal package it may have public methods without getting into API), and describe in Java docs in details how it works. Tests for this utility may help to find early if some modification breaks consistency of related names. |
One more comment, summarizing our discussion in XChat. I focused on method in ResourcesUIModel
asserting that it will not notify correctly (and other similar setters). That I believe is true. But now I see that actually changes go through methods ResourcesUIModel.add, ResourcesUIModel.remove, ResourcesUIModel.update that have correct notification.
and with use of private setResourcesForKind all other setters will remain one-liners. |
@scabanovich please open a separate issue regarding your observations. I will merge this PR as is unless there are objections from @fbricon or @adietish |
bd702f9
to
f46cb95
Compare
f46cb95
to
2da48ac
Compare
cc @fbricon @mlabuda @adietish