oleg-vlsk commented on PR #12760:
URL: https://github.com/apache/ignite/pull/12760#issuecomment-3955541046

   @alex-plekhanov Regarding you comment:
   
   "I'm talking about cacheByLdr, not cache. For cacheByLdr it looks like only 
one deployment is possible for one classloader."
   
   I agree, for the sole purpose of getting a certain deployment by its 
classloader we could simply use:
   
   ```
   private final Map<ClassLoader, GridDeployment> cacheByLdr = new 
IdentityHashMap<>();
   ```
   
   The reason I mapped classloader to all its deployments is because currently 
in `cache` we keep all deployments associated with the given classloader. Once 
we identify the target deployment, we need to add all associated deployments to 
`cache`:
   
   ```
   if (cachedDeps != null) {
       assert dep != null;
   
       cache.put(alias, cachedDeps);
   
       if (!cls.getName().equals(alias)) 
           cache.put(cls.getName(), cachedDeps);
       
       ...
   }
   ```
   
   Which means that apart from 
   
   ```
   private final Map<ClassLoader, GridDeployment> cacheByLdr = new 
IdentityHashMap<>();
   ```
   
   We would still need something like
   
   ```
   private final Map<ClassLoader, Deque<GridDeployment>> depsByLdr = new 
IdentityHashMap<>();
   ```
   
   to have quick access to all deployments with the given classloader so we can 
add all of them to `cache` in order to preserve the current contract.
   
   But keeping both of those fields seems unnecessary, since peekFirst() from 
the queue is still O(1).
   
   Unless there is another way of going about it, which I’m unaware of.


-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to