aries-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Guillaume Nodet (JIRA)" <j...@apache.org>
Subject [jira] [Comment Edited] (ARIES-1068) JNDI lookup performance bad when security enabled
Date Mon, 19 Feb 2018 10:13:00 GMT

    [ https://issues.apache.org/jira/browse/ARIES-1068?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13782973#comment-13782973
] 

Guillaume Nodet edited comment on ARIES-1068 at 2/19/18 10:12 AM:
------------------------------------------------------------------

Found some probable issues with the fix patch linked -

org.apache.aries.jndi.startup.Activator - Need to make the BundleTracker bt a field, and if
it is not null, bt.close() it at the end of the stop method.

org.apache.aries.jndi.tracker.ServiceTrackerCustomizers -

BaseCachingServiceTracker.clearCache(Bundle b) should be:

{code}

private void clearCache(Bundle b) {
    for (BundleContext bCtx : ctxServiceRefServiceCache.keySet()) {
        Bundle cacheB = null;
        try { 
            cacheB = bCtx.getBundle(); 
        } catch (IllegalStateException ise) { 
            if (LOGGER.isLoggable(Level.FINE))   
                LOGGER.fine("BaseCachingServiceTracker.clearCache IllegalStateException caught
getting bundle on " + bCtx); 
        }
        if (cacheB == null || cacheB.equals(b)) { 
            Object removedObj = ctxServiceRefServiceCache.remove(bCtx); 
            if (LOGGER.isLoggable(Level.FINE)) 
                LOGGER.fine("BaseCachingServiceTracker.clearCache Removed " + removedObj);

        }
     }
 }
 {code}
 
 
 CacheBundleTrackerCustomizer.removedBundle should start with :
 
 {code}

public void removedBundle(Bundle arg0, BundleEvent arg1, Object arg2) {
    //Work through srCache to find the bundle by matching to the context
    if (LOGGER.isLoggable(Level.FINE)) 
        LOGGER.fine("removedBundle: Bundle " + arg0);
    for (BundleContext bCtx : srCache.keySet()) {
        Bundle cacheB = null;
        try { 
            cacheB = bCtx.getBundle(); 
        } catch (IllegalStateException ise) { 
            if (LOGGER.isLoggable(Level.FINE)) 
                LOGGER.fine("CacheBundleTrackerCustomizer.removedBundle IllegalStateException
caught getting bundle on " + bCtx); 
        }
        if (cacheB == null || cacheB.equals(arg0)) {
            if (LOGGER.isLoggable(Level.FINE)) 
                LOGGER.fine("Found matching bundleContext " + bCtx);
            //Removing the bundle in the cache, so clear it out.
             ...
{code}


was (Author: sgormley):
Found some probable issues with the fix patch linked -

org.apache.aries.jndi.startup.Activator - Need to make the BundleTracker bt a field, and if
it is not null, bt.close() it at the end of the stop method.

org.apache.aries.jndi.tracker.ServiceTrackerCustomizers -

BaseCachingServiceTracker.clearCache(Bundle b) should be:

{code}

private void clearCache(Bundle b) {
 for (BundleContext bCtx : ctxServiceRefServiceCache.keySet()) {
 Bundle cacheB = null;
 try

{ cacheB = bCtx.getBundle(); } catch (IllegalStateException ise) \{ if (LOGGER.isLoggable(Level.FINE))
LOGGER.fine("BaseCachingServiceTracker.clearCache IllegalStateException caught getting bundle
on " + bCtx); }
 if (cacheB == null || cacheB.equals(b)) \{ Object removedObj = ctxServiceRefServiceCache.remove(bCtx);
if (LOGGER.isLoggable(Level.FINE)) LOGGER.fine("BaseCachingServiceTracker.clearCache Removed
" + removedObj); }
 }
 }
 \{code}
 
 
 CacheBundleTrackerCustomizer.removedBundle should start with :
 
 \{code}

public void removedBundle(Bundle arg0, BundleEvent arg1, Object arg2) {
 //Work through srCache to find the bundle by matching to the context
 if (LOGGER.isLoggable(Level.FINE)) LOGGER.fine("removedBundle: Bundle " + arg0);
 for (BundleContext bCtx : srCache.keySet()) {
 Bundle cacheB = null;
 try \{ cacheB = bCtx.getBundle(); }

catch (IllegalStateException ise)

{ if (LOGGER.isLoggable(Level.FINE)) LOGGER.fine("CacheBundleTrackerCustomizer.removedBundle
IllegalStateException caught getting bundle on " + bCtx); }

if (cacheB == null || cacheB.equals(arg0)) {
 if (LOGGER.isLoggable(Level.FINE)) LOGGER.fine("Found matching bundleContext " + bCtx);
 //Removing the bundle in the cache, so clear it out.
 ...

{code}

> JNDI lookup performance bad when security enabled
> -------------------------------------------------
>
>                 Key: ARIES-1068
>                 URL: https://issues.apache.org/jira/browse/ARIES-1068
>             Project: Aries
>          Issue Type: Bug
>          Components: JNDI
>            Reporter: Simon Gormley
>            Assignee: Jeremy Hughes
>            Priority: Critical
>         Attachments: servicelookupperf.patch
>
>
> JNDI lookups can be slow if Java security is enabled, specifically the getService methods
take time.
> If the services are cached then the lookup only has to be performed once, but care has
to be taken that the context performing the service lookup has the required permissions to
do so, and so cache buckets for each context will be necessary. 
> Also to prevent a leak, when contexts drop from scope, the associated caches need to
be cleared out.
> The ServiceTrackerCustomizer for JNDI already had some caching ability, and the provided
patch extends this to avoid looking up Services where possible.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message