While looking in to application undeployment issue, I noticed that
*getApplications*() in ApplicationHolder is executed as a synchronized
block. Normally doing IO operations inside a synchronized block is not
recommended since other threads has to wait to take the lock. Assume that
one thread hang a long time due to a slowness in just one connection of
registry db call, then all other threads become BLOCKED. This may result in
performance degrade.
I guess since it is just a READ operation, it is not needed to synchronize.

 public static Applications getApplications () {

        if (applications == null) {
            synchronized (ApplicationHolder.class) {
                if (applications == null) {
                    // retrieve from registry
                    applications = AutoscalerUtil.getApplications();
                    if (log.isDebugEnabled()) {
                        log.debug("Trying to retrieve Applications from
registry");
                    }
                    if (applications == null) {
                        if (log.isDebugEnabled()) {
                            log.debug("No applications found in Registry");
                        }
                        // create a new Applications object
                        applications = new Applications();
                    }
                }
            }
        }

        return applications;
    }
-- 

Udara Liyanage
Software Engineer
WSO2, Inc.: http://wso2.com
lean. enterprise. middleware

web: http://udaraliyanage.wordpress.com
phone: +94 71 443 6897

Reply via email to